diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventChannelsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventChannelsOperations.cs new file mode 100644 index 000000000000..7e3c982312e8 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventChannelsOperations.cs @@ -0,0 +1,1098 @@ +// +// 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 Microsoft.Azure.Management.EventGrid +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// EventChannelsOperations operations. + /// + internal partial class EventChannelsOperations : IServiceOperations, IEventChannelsOperations + { + /// + /// Initializes a new instance of the EventChannelsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal EventChannelsOperations(EventGridManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the EventGridManagementClient + /// + public EventGridManagementClient Client { get; private set; } + + /// + /// Get an event channel. + /// + /// + /// Get properties of an event channel. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the event channel. + /// + /// + /// 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> GetWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, string eventChannelName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerNamespaceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerNamespaceName"); + } + if (eventChannelName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "eventChannelName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerNamespaceName", partnerNamespaceName); + tracingParameters.Add("eventChannelName", eventChannelName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/eventChannels/{eventChannelName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerNamespaceName}", System.Uri.EscapeDataString(partnerNamespaceName)); + _url = _url.Replace("{eventChannelName}", System.Uri.EscapeDataString(eventChannelName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create an event channel. + /// + /// + /// Asynchronously creates a new event channel with the specified parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the event channel. + /// + /// + /// EventChannel information. + /// + /// + /// 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> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, string eventChannelName, EventChannel eventChannelInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerNamespaceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerNamespaceName"); + } + if (eventChannelName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "eventChannelName"); + } + if (eventChannelInfo == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "eventChannelInfo"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerNamespaceName", partnerNamespaceName); + tracingParameters.Add("eventChannelName", eventChannelName); + tracingParameters.Add("eventChannelInfo", eventChannelInfo); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/eventChannels/{eventChannelName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerNamespaceName}", System.Uri.EscapeDataString(partnerNamespaceName)); + _url = _url.Replace("{eventChannelName}", System.Uri.EscapeDataString(eventChannelName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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(eventChannelInfo != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(eventChannelInfo, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete an event channel. + /// + /// + /// Delete existing event channel. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the event channel. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, string eventChannelName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, eventChannelName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// List event channels. + /// + /// + /// List all the event channels in a partner namespace. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + /// + /// 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>> ListByPartnerNamespaceWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerNamespaceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerNamespaceName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerNamespaceName", partnerNamespaceName); + tracingParameters.Add("filter", filter); + tracingParameters.Add("top", top); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByPartnerNamespace", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/eventChannels").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerNamespaceName}", System.Uri.EscapeDataString(partnerNamespaceName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete an event channel. + /// + /// + /// Delete existing event channel. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the event channel. + /// + /// + /// 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 BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, string eventChannelName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerNamespaceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerNamespaceName"); + } + if (eventChannelName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "eventChannelName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerNamespaceName", partnerNamespaceName); + tracingParameters.Add("eventChannelName", eventChannelName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/eventChannels/{eventChannelName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerNamespaceName}", System.Uri.EscapeDataString(partnerNamespaceName)); + _url = _url.Replace("{eventChannelName}", System.Uri.EscapeDataString(eventChannelName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List event channels. + /// + /// + /// List all the event channels in a partner namespace. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// 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>> ListByPartnerNamespaceNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByPartnerNamespaceNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventChannelsOperationsExtensions.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventChannelsOperationsExtensions.cs new file mode 100644 index 000000000000..69bb2a0d215e --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventChannelsOperationsExtensions.cs @@ -0,0 +1,347 @@ +// +// 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 Microsoft.Azure.Management.EventGrid +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for EventChannelsOperations. + /// + public static partial class EventChannelsOperationsExtensions + { + /// + /// Get an event channel. + /// + /// + /// Get properties of an event channel. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the event channel. + /// + public static EventChannel Get(this IEventChannelsOperations operations, string resourceGroupName, string partnerNamespaceName, string eventChannelName) + { + return operations.GetAsync(resourceGroupName, partnerNamespaceName, eventChannelName).GetAwaiter().GetResult(); + } + + /// + /// Get an event channel. + /// + /// + /// Get properties of an event channel. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the event channel. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IEventChannelsOperations operations, string resourceGroupName, string partnerNamespaceName, string eventChannelName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, eventChannelName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create an event channel. + /// + /// + /// Asynchronously creates a new event channel with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the event channel. + /// + /// + /// EventChannel information. + /// + public static EventChannel CreateOrUpdate(this IEventChannelsOperations operations, string resourceGroupName, string partnerNamespaceName, string eventChannelName, EventChannel eventChannelInfo) + { + return operations.CreateOrUpdateAsync(resourceGroupName, partnerNamespaceName, eventChannelName, eventChannelInfo).GetAwaiter().GetResult(); + } + + /// + /// Create an event channel. + /// + /// + /// Asynchronously creates a new event channel with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the event channel. + /// + /// + /// EventChannel information. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IEventChannelsOperations operations, string resourceGroupName, string partnerNamespaceName, string eventChannelName, EventChannel eventChannelInfo, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, eventChannelName, eventChannelInfo, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete an event channel. + /// + /// + /// Delete existing event channel. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the event channel. + /// + public static void Delete(this IEventChannelsOperations operations, string resourceGroupName, string partnerNamespaceName, string eventChannelName) + { + operations.DeleteAsync(resourceGroupName, partnerNamespaceName, eventChannelName).GetAwaiter().GetResult(); + } + + /// + /// Delete an event channel. + /// + /// + /// Delete existing event channel. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the event channel. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IEventChannelsOperations operations, string resourceGroupName, string partnerNamespaceName, string eventChannelName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, eventChannelName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// List event channels. + /// + /// + /// List all the event channels in a partner namespace. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + public static IPage ListByPartnerNamespace(this IEventChannelsOperations operations, string resourceGroupName, string partnerNamespaceName, string filter = default(string), int? top = default(int?)) + { + return operations.ListByPartnerNamespaceAsync(resourceGroupName, partnerNamespaceName, filter, top).GetAwaiter().GetResult(); + } + + /// + /// List event channels. + /// + /// + /// List all the event channels in a partner namespace. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByPartnerNamespaceAsync(this IEventChannelsOperations operations, string resourceGroupName, string partnerNamespaceName, string filter = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByPartnerNamespaceWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, filter, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete an event channel. + /// + /// + /// Delete existing event channel. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the event channel. + /// + public static void BeginDelete(this IEventChannelsOperations operations, string resourceGroupName, string partnerNamespaceName, string eventChannelName) + { + operations.BeginDeleteAsync(resourceGroupName, partnerNamespaceName, eventChannelName).GetAwaiter().GetResult(); + } + + /// + /// Delete an event channel. + /// + /// + /// Delete existing event channel. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the event channel. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IEventChannelsOperations operations, string resourceGroupName, string partnerNamespaceName, string eventChannelName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, eventChannelName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// List event channels. + /// + /// + /// List all the event channels in a partner namespace. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByPartnerNamespaceNext(this IEventChannelsOperations operations, string nextPageLink) + { + return operations.ListByPartnerNamespaceNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List event channels. + /// + /// + /// List all the event channels in a partner namespace. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByPartnerNamespaceNextAsync(this IEventChannelsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByPartnerNamespaceNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventGridManagementClient.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventGridManagementClient.cs index 50170cac8a45..7626214c6b86 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventGridManagementClient.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventGridManagementClient.cs @@ -86,20 +86,45 @@ public partial class EventGridManagementClient : ServiceClient public virtual IDomainTopicsOperations DomainTopics { get; private set; } + /// + /// Gets the IEventChannelsOperations. + /// + public virtual IEventChannelsOperations EventChannels { get; private set; } + /// /// Gets the IEventSubscriptionsOperations. /// public virtual IEventSubscriptionsOperations EventSubscriptions { get; private set; } + /// + /// Gets the ISystemTopicEventSubscriptionsOperations. + /// + public virtual ISystemTopicEventSubscriptionsOperations SystemTopicEventSubscriptions { get; private set; } + + /// + /// Gets the IPartnerTopicEventSubscriptionsOperations. + /// + public virtual IPartnerTopicEventSubscriptionsOperations PartnerTopicEventSubscriptions { get; private set; } + /// /// Gets the IOperations. /// public virtual IOperations Operations { get; private set; } /// - /// Gets the ITopicsOperations. + /// Gets the IPartnerNamespacesOperations. /// - public virtual ITopicsOperations Topics { get; private set; } + public virtual IPartnerNamespacesOperations PartnerNamespaces { get; private set; } + + /// + /// Gets the IPartnerRegistrationsOperations. + /// + public virtual IPartnerRegistrationsOperations PartnerRegistrations { get; private set; } + + /// + /// Gets the IPartnerTopicsOperations. + /// + public virtual IPartnerTopicsOperations PartnerTopics { get; private set; } /// /// Gets the IPrivateEndpointConnectionsOperations. @@ -111,6 +136,21 @@ public partial class EventGridManagementClient : ServiceClient public virtual IPrivateLinkResourcesOperations PrivateLinkResources { get; private set; } + /// + /// Gets the ISystemTopicsOperations. + /// + public virtual ISystemTopicsOperations SystemTopics { get; private set; } + + /// + /// Gets the ITopicsOperations. + /// + public virtual ITopicsOperations Topics { get; private set; } + + /// + /// Gets the IExtensionTopicsOperations. + /// + public virtual IExtensionTopicsOperations ExtensionTopics { get; private set; } + /// /// Gets the ITopicTypesOperations. /// @@ -359,14 +399,22 @@ private void Initialize() { Domains = new DomainsOperations(this); DomainTopics = new DomainTopicsOperations(this); + EventChannels = new EventChannelsOperations(this); EventSubscriptions = new EventSubscriptionsOperations(this); + SystemTopicEventSubscriptions = new SystemTopicEventSubscriptionsOperations(this); + PartnerTopicEventSubscriptions = new PartnerTopicEventSubscriptionsOperations(this); Operations = new Operations(this); - Topics = new TopicsOperations(this); + PartnerNamespaces = new PartnerNamespacesOperations(this); + PartnerRegistrations = new PartnerRegistrationsOperations(this); + PartnerTopics = new PartnerTopicsOperations(this); PrivateEndpointConnections = new PrivateEndpointConnectionsOperations(this); PrivateLinkResources = new PrivateLinkResourcesOperations(this); + SystemTopics = new SystemTopicsOperations(this); + Topics = new TopicsOperations(this); + ExtensionTopics = new ExtensionTopicsOperations(this); TopicTypes = new TopicTypesOperations(this); BaseUri = new System.Uri("https://management.azure.com"); - ApiVersion = "2020-06-01"; + ApiVersion = "2020-10-15-preview"; AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; @@ -398,12 +446,14 @@ private void Initialize() }; SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("inputSchemaMappingType")); DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("inputSchemaMappingType")); - SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("endpointType")); - DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("endpointType")); SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("operatorType")); DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("operatorType")); + SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("endpointType")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("endpointType")); SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("endpointType")); DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("endpointType")); + SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("type")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("type")); CustomInitialize(); DeserializationSettings.Converters.Add(new TransformationJsonConverter()); DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventSubscriptionsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventSubscriptionsOperations.cs index c61670e7cbf5..87b0edcf05ee 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventSubscriptionsOperations.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventSubscriptionsOperations.cs @@ -2804,6 +2804,209 @@ internal EventSubscriptionsOperations(EventGridManagementClient client) return _result; } + /// + /// Get delivery attributes for an event subscription. + /// + /// + /// Get all delivery attributes for an event subscription. + /// + /// + /// The scope of the event subscription. The scope can be a subscription, or a + /// resource group, or a top level resource belonging to a resource provider + /// namespace, or an EventGrid topic. For example, use + /// '/subscriptions/{subscriptionId}/' for a subscription, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a + /// resource group, and + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' + /// for a resource, and + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' + /// for an EventGrid topic. + /// + /// + /// Name of the event subscription. + /// + /// + /// 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> GetDeliveryAttributesWithHttpMessagesAsync(string scope, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (eventSubscriptionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "eventSubscriptionName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("eventSubscriptionName", eventSubscriptionName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetDeliveryAttributes", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes").ToString(); + _url = _url.Replace("{scope}", scope); + _url = _url.Replace("{eventSubscriptionName}", System.Uri.EscapeDataString(eventSubscriptionName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + /// /// Create or update an event subscription. /// diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventSubscriptionsOperationsExtensions.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventSubscriptionsOperationsExtensions.cs index cbb1bf86c4d0..502da598df1d 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventSubscriptionsOperationsExtensions.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventSubscriptionsOperationsExtensions.cs @@ -1122,6 +1122,70 @@ public static EventSubscriptionFullUrl GetFullUrl(this IEventSubscriptionsOperat } } + /// + /// Get delivery attributes for an event subscription. + /// + /// + /// Get all delivery attributes for an event subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of the event subscription. The scope can be a subscription, or a + /// resource group, or a top level resource belonging to a resource provider + /// namespace, or an EventGrid topic. For example, use + /// '/subscriptions/{subscriptionId}/' for a subscription, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a + /// resource group, and + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' + /// for a resource, and + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' + /// for an EventGrid topic. + /// + /// + /// Name of the event subscription. + /// + public static DeliveryAttributeListResult GetDeliveryAttributes(this IEventSubscriptionsOperations operations, string scope, string eventSubscriptionName) + { + return operations.GetDeliveryAttributesAsync(scope, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Get delivery attributes for an event subscription. + /// + /// + /// Get all delivery attributes for an event subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of the event subscription. The scope can be a subscription, or a + /// resource group, or a top level resource belonging to a resource provider + /// namespace, or an EventGrid topic. For example, use + /// '/subscriptions/{subscriptionId}/' for a subscription, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a + /// resource group, and + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' + /// for a resource, and + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' + /// for an EventGrid topic. + /// + /// + /// Name of the event subscription. + /// + /// + /// The cancellation token. + /// + public static async Task GetDeliveryAttributesAsync(this IEventSubscriptionsOperations operations, string scope, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetDeliveryAttributesWithHttpMessagesAsync(scope, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// /// Create or update an event subscription. /// diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ExtensionTopicsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ExtensionTopicsOperations.cs new file mode 100644 index 000000000000..30b0c63530ff --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ExtensionTopicsOperations.cs @@ -0,0 +1,246 @@ +// +// 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 Microsoft.Azure.Management.EventGrid +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ExtensionTopicsOperations operations. + /// + internal partial class ExtensionTopicsOperations : IServiceOperations, IExtensionTopicsOperations + { + /// + /// Initializes a new instance of the ExtensionTopicsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ExtensionTopicsOperations(EventGridManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the EventGridManagementClient + /// + public EventGridManagementClient Client { get; private set; } + + /// + /// Get properties of an extension topic. + /// + /// + /// Get the properties of an extension topic. + /// + /// + /// The identifier of the resource to which extension topic is queried. The + /// scope can be a subscription, or a resource group, or a top level resource + /// belonging to a resource provider namespace. For example, use + /// '/subscriptions/{subscriptionId}/' for a subscription, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a + /// resource group, and + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' + /// for Azure resource. + /// + /// + /// 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> GetWithHttpMessagesAsync(string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.EventGrid/extensionTopics/default").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ExtensionTopicsOperationsExtensions.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ExtensionTopicsOperationsExtensions.cs new file mode 100644 index 000000000000..16616d14a956 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ExtensionTopicsOperationsExtensions.cs @@ -0,0 +1,79 @@ +// +// 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 Microsoft.Azure.Management.EventGrid +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ExtensionTopicsOperations. + /// + public static partial class ExtensionTopicsOperationsExtensions + { + /// + /// Get properties of an extension topic. + /// + /// + /// Get the properties of an extension topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource to which extension topic is queried. The + /// scope can be a subscription, or a resource group, or a top level resource + /// belonging to a resource provider namespace. For example, use + /// '/subscriptions/{subscriptionId}/' for a subscription, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a + /// resource group, and + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' + /// for Azure resource. + /// + public static ExtensionTopic Get(this IExtensionTopicsOperations operations, string scope) + { + return operations.GetAsync(scope).GetAwaiter().GetResult(); + } + + /// + /// Get properties of an extension topic. + /// + /// + /// Get the properties of an extension topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The identifier of the resource to which extension topic is queried. The + /// scope can be a subscription, or a resource group, or a top level resource + /// belonging to a resource provider namespace. For example, use + /// '/subscriptions/{subscriptionId}/' for a subscription, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a + /// resource group, and + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' + /// for Azure resource. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IExtensionTopicsOperations operations, string scope, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(scope, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IEventChannelsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IEventChannelsOperations.cs new file mode 100644 index 000000000000..e15cbd6411c7 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IEventChannelsOperations.cs @@ -0,0 +1,218 @@ +// +// 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 Microsoft.Azure.Management.EventGrid +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// EventChannelsOperations operations. + /// + public partial interface IEventChannelsOperations + { + /// + /// Get an event channel. + /// + /// + /// Get properties of an event channel. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the event channel. + /// + /// + /// The 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 + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, string eventChannelName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create an event channel. + /// + /// + /// Asynchronously creates a new event channel with the specified + /// parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the event channel. + /// + /// + /// EventChannel information. + /// + /// + /// The 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 + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, string eventChannelName, EventChannel eventChannelInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete an event channel. + /// + /// + /// Delete existing event channel. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the event channel. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, string eventChannelName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List event channels. + /// + /// + /// List all the event channels in a partner namespace. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// The query used to filter the search results using OData syntax. + /// Filtering is permitted on the 'name' property only and with limited + /// number of OData operations. These operations are: the 'contains' + /// function as well as the following logical operations: not, and, or, + /// eq (for equal), and ne (for not equal). No arithmetic operations + /// are supported. The following is a valid filter example: + /// $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. The + /// following is not a valid filter example: $filter=location eq + /// 'westus'. + /// + /// + /// The number of results to return per page for the list operation. + /// Valid range for top parameter is 1 to 100. If not specified, the + /// default number of results to be returned is 20 items per page. + /// + /// + /// The 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 + /// + Task>> ListByPartnerNamespaceWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete an event channel. + /// + /// + /// Delete existing event channel. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the event channel. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, string eventChannelName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List event channels. + /// + /// + /// List all the event channels in a partner namespace. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The 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 + /// + Task>> ListByPartnerNamespaceNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IEventGridManagementClient.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IEventGridManagementClient.cs index b45a7ced954a..e36aca2611ad 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IEventGridManagementClient.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IEventGridManagementClient.cs @@ -81,20 +81,45 @@ public partial interface IEventGridManagementClient : System.IDisposable /// IDomainTopicsOperations DomainTopics { get; } + /// + /// Gets the IEventChannelsOperations. + /// + IEventChannelsOperations EventChannels { get; } + /// /// Gets the IEventSubscriptionsOperations. /// IEventSubscriptionsOperations EventSubscriptions { get; } + /// + /// Gets the ISystemTopicEventSubscriptionsOperations. + /// + ISystemTopicEventSubscriptionsOperations SystemTopicEventSubscriptions { get; } + + /// + /// Gets the IPartnerTopicEventSubscriptionsOperations. + /// + IPartnerTopicEventSubscriptionsOperations PartnerTopicEventSubscriptions { get; } + /// /// Gets the IOperations. /// IOperations Operations { get; } /// - /// Gets the ITopicsOperations. + /// Gets the IPartnerNamespacesOperations. /// - ITopicsOperations Topics { get; } + IPartnerNamespacesOperations PartnerNamespaces { get; } + + /// + /// Gets the IPartnerRegistrationsOperations. + /// + IPartnerRegistrationsOperations PartnerRegistrations { get; } + + /// + /// Gets the IPartnerTopicsOperations. + /// + IPartnerTopicsOperations PartnerTopics { get; } /// /// Gets the IPrivateEndpointConnectionsOperations. @@ -106,6 +131,21 @@ public partial interface IEventGridManagementClient : System.IDisposable /// IPrivateLinkResourcesOperations PrivateLinkResources { get; } + /// + /// Gets the ISystemTopicsOperations. + /// + ISystemTopicsOperations SystemTopics { get; } + + /// + /// Gets the ITopicsOperations. + /// + ITopicsOperations Topics { get; } + + /// + /// Gets the IExtensionTopicsOperations. + /// + IExtensionTopicsOperations ExtensionTopics { get; } + /// /// Gets the ITopicTypesOperations. /// diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IEventSubscriptionsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IEventSubscriptionsOperations.cs index 7aa35fafa57a..16d48daec43a 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IEventSubscriptionsOperations.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IEventSubscriptionsOperations.cs @@ -674,6 +674,44 @@ public partial interface IEventSubscriptionsOperations /// Task>> ListByDomainTopicWithHttpMessagesAsync(string resourceGroupName, string domainName, string topicName, string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// + /// Get delivery attributes for an event subscription. + /// + /// + /// Get all delivery attributes for an event subscription. + /// + /// + /// The scope of the event subscription. The scope can be a + /// subscription, or a resource group, or a top level resource + /// belonging to a resource provider namespace, or an EventGrid topic. + /// For example, use '/subscriptions/{subscriptionId}/' for a + /// subscription, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for a resource group, and + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' + /// for a resource, and + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' + /// for an EventGrid topic. + /// + /// + /// Name of the event subscription. + /// + /// + /// The 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 + /// + Task> GetDeliveryAttributesWithHttpMessagesAsync(string scope, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// /// Create or update an event subscription. /// /// diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IExtensionTopicsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IExtensionTopicsOperations.cs new file mode 100644 index 000000000000..c6791881310b --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IExtensionTopicsOperations.cs @@ -0,0 +1,59 @@ +// +// 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 Microsoft.Azure.Management.EventGrid +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ExtensionTopicsOperations operations. + /// + public partial interface IExtensionTopicsOperations + { + /// + /// Get properties of an extension topic. + /// + /// + /// Get the properties of an extension topic. + /// + /// + /// The identifier of the resource to which extension topic is queried. + /// The scope can be a subscription, or a resource group, or a top + /// level resource belonging to a resource provider namespace. For + /// example, use '/subscriptions/{subscriptionId}/' for a subscription, + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' + /// for a resource group, and + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' + /// for Azure resource. + /// + /// + /// The 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 + /// + Task> GetWithHttpMessagesAsync(string scope, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerNamespacesOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerNamespacesOperations.cs new file mode 100644 index 000000000000..eb9e3312cbb2 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerNamespacesOperations.cs @@ -0,0 +1,421 @@ +// +// 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 Microsoft.Azure.Management.EventGrid +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PartnerNamespacesOperations operations. + /// + public partial interface IPartnerNamespacesOperations + { + /// + /// Get a partner namespace. + /// + /// + /// Get properties of a partner namespace. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// The 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 + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create a partner namespace. + /// + /// + /// Asynchronously creates a new partner namespace with the specified + /// parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// PartnerNamespace information. + /// + /// + /// The 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 + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, PartnerNamespace partnerNamespaceInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete a partner namespace. + /// + /// + /// Delete existing partner namespace. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update a partner namespace. + /// + /// + /// Asynchronously updates a partner namespace with the specified + /// parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Tags of the partner namespace. + /// + /// + /// The 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 + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List partner namespaces under an Azure subscription. + /// + /// + /// List all the partner namespaces under an Azure subscription. + /// + /// + /// The query used to filter the search results using OData syntax. + /// Filtering is permitted on the 'name' property only and with limited + /// number of OData operations. These operations are: the 'contains' + /// function as well as the following logical operations: not, and, or, + /// eq (for equal), and ne (for not equal). No arithmetic operations + /// are supported. The following is a valid filter example: + /// $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. The + /// following is not a valid filter example: $filter=location eq + /// 'westus'. + /// + /// + /// The number of results to return per page for the list operation. + /// Valid range for top parameter is 1 to 100. If not specified, the + /// default number of results to be returned is 20 items per page. + /// + /// + /// The 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 + /// + Task>> ListBySubscriptionWithHttpMessagesAsync(string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List partner namespaces under a resource group. + /// + /// + /// List all the partner namespaces under a resource group. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The query used to filter the search results using OData syntax. + /// Filtering is permitted on the 'name' property only and with limited + /// number of OData operations. These operations are: the 'contains' + /// function as well as the following logical operations: not, and, or, + /// eq (for equal), and ne (for not equal). No arithmetic operations + /// are supported. The following is a valid filter example: + /// $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. The + /// following is not a valid filter example: $filter=location eq + /// 'westus'. + /// + /// + /// The number of results to return per page for the list operation. + /// Valid range for top parameter is 1 to 100. If not specified, the + /// default number of results to be returned is 20 items per page. + /// + /// + /// The 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 + /// + Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List keys for a partner namespace. + /// + /// + /// List the two keys used to publish to a partner namespace. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// The 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 + /// + Task> ListSharedAccessKeysWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Regenerate key for a partner namespace. + /// + /// + /// Regenerate a shared access key for a partner namespace. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Key name to regenerate (key1 or key2). + /// + /// + /// The 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 + /// + Task> RegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, string keyName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create a partner namespace. + /// + /// + /// Asynchronously creates a new partner namespace with the specified + /// parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// PartnerNamespace information. + /// + /// + /// The 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 + /// + Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, PartnerNamespace partnerNamespaceInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete a partner namespace. + /// + /// + /// Delete existing partner namespace. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update a partner namespace. + /// + /// + /// Asynchronously updates a partner namespace with the specified + /// parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Tags of the partner namespace. + /// + /// + /// The 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 + /// + Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List partner namespaces under an Azure subscription. + /// + /// + /// List all the partner namespaces under an Azure subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The 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 + /// + Task>> ListBySubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List partner namespaces under a resource group. + /// + /// + /// List all the partner namespaces under a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The 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 + /// + Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerRegistrationsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerRegistrationsOperations.cs new file mode 100644 index 000000000000..f813ded402d3 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerRegistrationsOperations.cs @@ -0,0 +1,293 @@ +// +// 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 Microsoft.Azure.Management.EventGrid +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PartnerRegistrationsOperations operations. + /// + public partial interface IPartnerRegistrationsOperations + { + /// + /// Get a partner registration. + /// + /// + /// Gets a partner registration with the specified parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner registration. + /// + /// + /// The 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 + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string partnerRegistrationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create a partner registration. + /// + /// + /// Creates a new partner registration with the specified parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner registration. + /// + /// + /// PartnerRegistration information. + /// + /// + /// The 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 + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string partnerRegistrationName, PartnerRegistration partnerRegistrationInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete a partner registration. + /// + /// + /// Deletes a partner registration with the specified parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner registration. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string partnerRegistrationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update a partner registration. + /// + /// + /// Updates a partner registration with the specified parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner registration. + /// + /// + /// Partner registration update information. + /// + /// + /// The 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 + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string partnerRegistrationName, PartnerRegistrationUpdateParameters partnerRegistrationUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List partner registrations under an Azure subscription. + /// + /// + /// List all the partner registrations under an Azure subscription. + /// + /// + /// The query used to filter the search results using OData syntax. + /// Filtering is permitted on the 'name' property only and with limited + /// number of OData operations. These operations are: the 'contains' + /// function as well as the following logical operations: not, and, or, + /// eq (for equal), and ne (for not equal). No arithmetic operations + /// are supported. The following is a valid filter example: + /// $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. The + /// following is not a valid filter example: $filter=location eq + /// 'westus'. + /// + /// + /// The number of results to return per page for the list operation. + /// Valid range for top parameter is 1 to 100. If not specified, the + /// default number of results to be returned is 20 items per page. + /// + /// + /// The 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 + /// + Task>> ListBySubscriptionWithHttpMessagesAsync(string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List partner registrations under a resource group. + /// + /// + /// List all the partner registrations under a resource group. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The query used to filter the search results using OData syntax. + /// Filtering is permitted on the 'name' property only and with limited + /// number of OData operations. These operations are: the 'contains' + /// function as well as the following logical operations: not, and, or, + /// eq (for equal), and ne (for not equal). No arithmetic operations + /// are supported. The following is a valid filter example: + /// $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. The + /// following is not a valid filter example: $filter=location eq + /// 'westus'. + /// + /// + /// The number of results to return per page for the list operation. + /// Valid range for top parameter is 1 to 100. If not specified, the + /// default number of results to be returned is 20 items per page. + /// + /// + /// The 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 + /// + Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all available partners registrations. + /// + /// + /// List all partners registrations. + /// + /// + /// The 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 + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List partner registrations under an Azure subscription. + /// + /// + /// List all the partner registrations under an Azure subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The 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 + /// + Task>> ListBySubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List partner registrations under a resource group. + /// + /// + /// List all the partner registrations under a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The 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 + /// + Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerTopicEventSubscriptionsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerTopicEventSubscriptionsOperations.cs new file mode 100644 index 000000000000..e5baba1ca7ea --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerTopicEventSubscriptionsOperations.cs @@ -0,0 +1,408 @@ +// +// 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 Microsoft.Azure.Management.EventGrid +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PartnerTopicEventSubscriptionsOperations operations. + /// + public partial interface IPartnerTopicEventSubscriptionsOperations + { + /// + /// Get an event subscription of a partner topic. + /// + /// + /// Get an event subscription of a partner topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be found. Event subscription + /// names must be between 3 and 100 characters in length and use + /// alphanumeric letters only. + /// + /// + /// The 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 + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an event subscription of a partner topic. + /// + /// + /// Asynchronously creates or updates an event subscription of a + /// partner topic with the specified parameters. Existing event + /// subscriptions will be updated with this API. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription + /// names must be between 3 and 100 characters in length and use + /// alphanumeric letters only. + /// + /// + /// Event subscription properties containing the destination and filter + /// information. + /// + /// + /// The 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 + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete an event subscription of a partner topic. + /// + /// + /// Delete an event subscription of a partner topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription + /// names must be between 3 and 100 characters in length and use + /// alphanumeric letters only. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update event subscription of a partner topic. + /// + /// + /// Update event subscription of a partner topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription + /// names must be between 3 and 100 characters in length and use + /// alphanumeric letters only. + /// + /// + /// Updated event subscription information. + /// + /// + /// The 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 + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get full URL of an event subscription of a partner topic. + /// + /// + /// Get the full endpoint URL for an event subscription of a partner + /// topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription + /// names must be between 3 and 100 characters in length and use + /// alphanumeric letters only. + /// + /// + /// The 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 + /// + Task> GetFullUrlWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List event subscriptions of a partner topic. + /// + /// + /// List event subscriptions that belong to a specific partner topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// The query used to filter the search results using OData syntax. + /// Filtering is permitted on the 'name' property only and with limited + /// number of OData operations. These operations are: the 'contains' + /// function as well as the following logical operations: not, and, or, + /// eq (for equal), and ne (for not equal). No arithmetic operations + /// are supported. The following is a valid filter example: + /// $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. The + /// following is not a valid filter example: $filter=location eq + /// 'westus'. + /// + /// + /// The number of results to return per page for the list operation. + /// Valid range for top parameter is 1 to 100. If not specified, the + /// default number of results to be returned is 20 items per page. + /// + /// + /// The 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 + /// + Task>> ListByPartnerTopicWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get delivery attributes for an event subscription of a partner + /// topic. + /// + /// + /// Get all delivery attributes for an event subscription of a partner + /// topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription + /// names must be between 3 and 100 characters in length and use + /// alphanumeric letters only. + /// + /// + /// The 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 + /// + Task> GetDeliveryAttributesWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an event subscription of a partner topic. + /// + /// + /// Asynchronously creates or updates an event subscription of a + /// partner topic with the specified parameters. Existing event + /// subscriptions will be updated with this API. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription + /// names must be between 3 and 100 characters in length and use + /// alphanumeric letters only. + /// + /// + /// Event subscription properties containing the destination and filter + /// information. + /// + /// + /// The 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 + /// + Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete an event subscription of a partner topic. + /// + /// + /// Delete an event subscription of a partner topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription + /// names must be between 3 and 100 characters in length and use + /// alphanumeric letters only. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update event subscription of a partner topic. + /// + /// + /// Update event subscription of a partner topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription + /// names must be between 3 and 100 characters in length and use + /// alphanumeric letters only. + /// + /// + /// Updated event subscription information. + /// + /// + /// The 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 + /// + Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List event subscriptions of a partner topic. + /// + /// + /// List event subscriptions that belong to a specific partner topic. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The 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 + /// + Task>> ListByPartnerTopicNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerTopicsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerTopicsOperations.cs new file mode 100644 index 000000000000..f4c8f3eddaf8 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerTopicsOperations.cs @@ -0,0 +1,322 @@ +// +// 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 Microsoft.Azure.Management.EventGrid +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PartnerTopicsOperations operations. + /// + public partial interface IPartnerTopicsOperations + { + /// + /// Get a partner topic. + /// + /// + /// Get properties of a partner topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// The 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 + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete a partner topic. + /// + /// + /// Delete existing partner topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update a partner topic. + /// + /// + /// Asynchronously updates a partner topic with the specified + /// parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Tags of the partner topic. + /// + /// + /// The 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 + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List partner topics under an Azure subscription. + /// + /// + /// List all the partner topics under an Azure subscription. + /// + /// + /// The query used to filter the search results using OData syntax. + /// Filtering is permitted on the 'name' property only and with limited + /// number of OData operations. These operations are: the 'contains' + /// function as well as the following logical operations: not, and, or, + /// eq (for equal), and ne (for not equal). No arithmetic operations + /// are supported. The following is a valid filter example: + /// $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. The + /// following is not a valid filter example: $filter=location eq + /// 'westus'. + /// + /// + /// The number of results to return per page for the list operation. + /// Valid range for top parameter is 1 to 100. If not specified, the + /// default number of results to be returned is 20 items per page. + /// + /// + /// The 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 + /// + Task>> ListBySubscriptionWithHttpMessagesAsync(string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List partner topics under a resource group. + /// + /// + /// List all the partner topics under a resource group. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The query used to filter the search results using OData syntax. + /// Filtering is permitted on the 'name' property only and with limited + /// number of OData operations. These operations are: the 'contains' + /// function as well as the following logical operations: not, and, or, + /// eq (for equal), and ne (for not equal). No arithmetic operations + /// are supported. The following is a valid filter example: + /// $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. The + /// following is not a valid filter example: $filter=location eq + /// 'westus'. + /// + /// + /// The number of results to return per page for the list operation. + /// Valid range for top parameter is 1 to 100. If not specified, the + /// default number of results to be returned is 20 items per page. + /// + /// + /// The 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 + /// + Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Activate a partner topic. + /// + /// + /// Activate a newly created partner topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// The 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 + /// + Task> ActivateWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deactivate a partner topic. + /// + /// + /// Deactivate specific partner topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// The 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 + /// + Task> DeactivateWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete a partner topic. + /// + /// + /// Delete existing partner topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List partner topics under an Azure subscription. + /// + /// + /// List all the partner topics under an Azure subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The 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 + /// + Task>> ListBySubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List partner topics under a resource group. + /// + /// + /// List all the partner topics under a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The 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 + /// + Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ISystemTopicEventSubscriptionsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ISystemTopicEventSubscriptionsOperations.cs new file mode 100644 index 000000000000..f4610328eca7 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ISystemTopicEventSubscriptionsOperations.cs @@ -0,0 +1,406 @@ +// +// 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 Microsoft.Azure.Management.EventGrid +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SystemTopicEventSubscriptionsOperations operations. + /// + public partial interface ISystemTopicEventSubscriptionsOperations + { + /// + /// Get an event subscription of a system topic. + /// + /// + /// Get an event subscription. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription + /// names must be between 3 and 100 characters in length and use + /// alphanumeric letters only. + /// + /// + /// The 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 + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an event subscription for a system topic. + /// + /// + /// Asynchronously creates or updates an event subscription with the + /// specified parameters. Existing event subscriptions will be updated + /// with this API. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription + /// names must be between 3 and 100 characters in length and use + /// alphanumeric letters only. + /// + /// + /// Event subscription properties containing the destination and filter + /// information. + /// + /// + /// The 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 + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete an event subscription of a system topic. + /// + /// + /// Delete an event subscription of a system topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription + /// names must be between 3 and 100 characters in length and use + /// alphanumeric letters only. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update event subscription of a system topic. + /// + /// + /// Update event subscription of a system topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription + /// names must be between 3 and 100 characters in length and use + /// alphanumeric letters only. + /// + /// + /// Updated event subscription information. + /// + /// + /// The 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 + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get full URL of an event subscription of a system topic + /// + /// + /// Get the full endpoint URL for an event subscription of a system + /// topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription + /// names must be between 3 and 100 characters in length and use + /// alphanumeric letters only. + /// + /// + /// The 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 + /// + Task> GetFullUrlWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List event subscriptions of a system topic. + /// + /// + /// List event subscriptions that belong to a specific system topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// The query used to filter the search results using OData syntax. + /// Filtering is permitted on the 'name' property only and with limited + /// number of OData operations. These operations are: the 'contains' + /// function as well as the following logical operations: not, and, or, + /// eq (for equal), and ne (for not equal). No arithmetic operations + /// are supported. The following is a valid filter example: + /// $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. The + /// following is not a valid filter example: $filter=location eq + /// 'westus'. + /// + /// + /// The number of results to return per page for the list operation. + /// Valid range for top parameter is 1 to 100. If not specified, the + /// default number of results to be returned is 20 items per page. + /// + /// + /// The 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 + /// + Task>> ListBySystemTopicWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get delivery attributes for an event subscription. + /// + /// + /// Get all delivery attributes for an event subscription. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription + /// names must be between 3 and 100 characters in length and use + /// alphanumeric letters only. + /// + /// + /// The 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 + /// + Task> GetDeliveryAttributesWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an event subscription for a system topic. + /// + /// + /// Asynchronously creates or updates an event subscription with the + /// specified parameters. Existing event subscriptions will be updated + /// with this API. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription + /// names must be between 3 and 100 characters in length and use + /// alphanumeric letters only. + /// + /// + /// Event subscription properties containing the destination and filter + /// information. + /// + /// + /// The 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 + /// + Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete an event subscription of a system topic. + /// + /// + /// Delete an event subscription of a system topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription + /// names must be between 3 and 100 characters in length and use + /// alphanumeric letters only. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update event subscription of a system topic. + /// + /// + /// Update event subscription of a system topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription + /// names must be between 3 and 100 characters in length and use + /// alphanumeric letters only. + /// + /// + /// Updated event subscription information. + /// + /// + /// The 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 + /// + Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List event subscriptions of a system topic. + /// + /// + /// List event subscriptions that belong to a specific system topic. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The 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 + /// + Task>> ListBySystemTopicNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ISystemTopicsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ISystemTopicsOperations.cs new file mode 100644 index 000000000000..cb157fe68a18 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ISystemTopicsOperations.cs @@ -0,0 +1,362 @@ +// +// 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 Microsoft.Azure.Management.EventGrid +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SystemTopicsOperations operations. + /// + public partial interface ISystemTopicsOperations + { + /// + /// Get a system topic. + /// + /// + /// Get properties of a system topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// The 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 + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create a system topic. + /// + /// + /// Asynchronously creates a new system topic with the specified + /// parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// System Topic information. + /// + /// + /// The 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 + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, SystemTopic systemTopicInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete a system topic. + /// + /// + /// Delete existing system topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update a system topic. + /// + /// + /// Asynchronously updates a system topic with the specified + /// parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// SystemTopic update information. + /// + /// + /// The 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 + /// + Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, SystemTopicUpdateParameters systemTopicUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List system topics under an Azure subscription. + /// + /// + /// List all the system topics under an Azure subscription. + /// + /// + /// The query used to filter the search results using OData syntax. + /// Filtering is permitted on the 'name' property only and with limited + /// number of OData operations. These operations are: the 'contains' + /// function as well as the following logical operations: not, and, or, + /// eq (for equal), and ne (for not equal). No arithmetic operations + /// are supported. The following is a valid filter example: + /// $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. The + /// following is not a valid filter example: $filter=location eq + /// 'westus'. + /// + /// + /// The number of results to return per page for the list operation. + /// Valid range for top parameter is 1 to 100. If not specified, the + /// default number of results to be returned is 20 items per page. + /// + /// + /// The 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 + /// + Task>> ListBySubscriptionWithHttpMessagesAsync(string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List system topics under a resource group. + /// + /// + /// List all the system topics under a resource group. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The query used to filter the search results using OData syntax. + /// Filtering is permitted on the 'name' property only and with limited + /// number of OData operations. These operations are: the 'contains' + /// function as well as the following logical operations: not, and, or, + /// eq (for equal), and ne (for not equal). No arithmetic operations + /// are supported. The following is a valid filter example: + /// $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. The + /// following is not a valid filter example: $filter=location eq + /// 'westus'. + /// + /// + /// The number of results to return per page for the list operation. + /// Valid range for top parameter is 1 to 100. If not specified, the + /// default number of results to be returned is 20 items per page. + /// + /// + /// The 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 + /// + Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create a system topic. + /// + /// + /// Asynchronously creates a new system topic with the specified + /// parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// System Topic information. + /// + /// + /// The 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 + /// + Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, SystemTopic systemTopicInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete a system topic. + /// + /// + /// Delete existing system topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update a system topic. + /// + /// + /// Asynchronously updates a system topic with the specified + /// parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// SystemTopic update information. + /// + /// + /// The 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 + /// + Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, SystemTopicUpdateParameters systemTopicUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List system topics under an Azure subscription. + /// + /// + /// List all the system topics under an Azure subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The 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 + /// + Task>> ListBySubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List system topics under a resource group. + /// + /// + /// List all the system topics under a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The 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 + /// + Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ITopicsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ITopicsOperations.cs index 7370dffe508b..9e0fe7764146 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ITopicsOperations.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ITopicsOperations.cs @@ -398,6 +398,37 @@ public partial interface ITopicsOperations /// Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string topicName, TopicUpdateParameters topicUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// + /// Regenerate key for a topic. + /// + /// + /// Regenerate a shared access key for a topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the topic. + /// + /// + /// Key name to regenerate key1 or key2 + /// + /// + /// The 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 + /// + Task> BeginRegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string topicName, string keyName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// /// List topics under an Azure subscription. /// /// diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/AdvancedFilter.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/AdvancedFilter.cs index c2fe81ab1c01..371d80a647b3 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/AdvancedFilter.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/AdvancedFilter.cs @@ -21,7 +21,6 @@ namespace Microsoft.Azure.Management.EventGrid.Models /// StringEqualsAdvancedFilter etc. depending on the type of the key based /// on which you want to filter. /// - [Newtonsoft.Json.JsonObject("AdvancedFilter")] public partial class AdvancedFilter { /// diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/AzureFunctionEventSubscriptionDestination.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/AzureFunctionEventSubscriptionDestination.cs index f4565316b35f..a5bd1835bdfd 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/AzureFunctionEventSubscriptionDestination.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/AzureFunctionEventSubscriptionDestination.cs @@ -13,6 +13,8 @@ namespace Microsoft.Azure.Management.EventGrid.Models using Microsoft.Rest; using Microsoft.Rest.Serialization; using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; using System.Linq; /// @@ -43,11 +45,14 @@ public AzureFunctionEventSubscriptionDestination() /// batch. /// Preferred batch size in /// Kilobytes. - public AzureFunctionEventSubscriptionDestination(string resourceId = default(string), int? maxEventsPerBatch = default(int?), int? preferredBatchSizeInKilobytes = default(int?)) + /// Delivery attribute + /// details. + public AzureFunctionEventSubscriptionDestination(string resourceId = default(string), int? maxEventsPerBatch = default(int?), int? preferredBatchSizeInKilobytes = default(int?), IList deliveryAttributeMappings = default(IList)) { ResourceId = resourceId; MaxEventsPerBatch = maxEventsPerBatch; PreferredBatchSizeInKilobytes = preferredBatchSizeInKilobytes; + DeliveryAttributeMappings = deliveryAttributeMappings; CustomInit(); } @@ -75,5 +80,11 @@ public AzureFunctionEventSubscriptionDestination() [JsonProperty(PropertyName = "properties.preferredBatchSizeInKilobytes")] public int? PreferredBatchSizeInKilobytes { get; set; } + /// + /// Gets or sets delivery attribute details. + /// + [JsonProperty(PropertyName = "properties.deliveryAttributeMappings")] + public IList DeliveryAttributeMappings { get; set; } + } } diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/CreatedByType.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/CreatedByType.cs new file mode 100644 index 000000000000..c319250ec5c5 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/CreatedByType.cs @@ -0,0 +1,24 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + + /// + /// Defines values for CreatedByType. + /// + public static class CreatedByType + { + public const string User = "User"; + public const string Application = "Application"; + public const string ManagedIdentity = "ManagedIdentity"; + public const string Key = "Key"; + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DeadLetterDestination.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DeadLetterDestination.cs index e6ae3ec7e7e4..ba2339e8ee02 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DeadLetterDestination.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DeadLetterDestination.cs @@ -10,7 +10,6 @@ namespace Microsoft.Azure.Management.EventGrid.Models { - using Newtonsoft.Json; using System.Linq; /// @@ -20,7 +19,6 @@ namespace Microsoft.Azure.Management.EventGrid.Models /// a derived class. Currently, StorageBlobDeadLetterDestination is the /// only class that derives from this class. /// - [Newtonsoft.Json.JsonObject("DeadLetterDestination")] public partial class DeadLetterDestination { /// diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DeadLetterWithResourceIdentity.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DeadLetterWithResourceIdentity.cs new file mode 100644 index 000000000000..eeb484d8e462 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DeadLetterWithResourceIdentity.cs @@ -0,0 +1,71 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Information about the deadletter destination with resource identity. + /// + public partial class DeadLetterWithResourceIdentity + { + /// + /// Initializes a new instance of the DeadLetterWithResourceIdentity + /// class. + /// + public DeadLetterWithResourceIdentity() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DeadLetterWithResourceIdentity + /// class. + /// + /// The identity to use when dead-lettering + /// events. + /// Information about the + /// destination where events have to be delivered for the event + /// subscription. + /// Uses the managed identity setup on the parent resource (namely, + /// topic or domain) to acquire the authentication tokens being used + /// during delivery / dead-lettering. + public DeadLetterWithResourceIdentity(EventSubscriptionIdentity identity = default(EventSubscriptionIdentity), DeadLetterDestination deadLetterDestination = default(DeadLetterDestination)) + { + Identity = identity; + DeadLetterDestination = deadLetterDestination; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the identity to use when dead-lettering events. + /// + [JsonProperty(PropertyName = "identity")] + public EventSubscriptionIdentity Identity { get; set; } + + /// + /// Gets or sets information about the destination where events have to + /// be delivered for the event subscription. + /// Uses the managed identity setup on the parent resource (namely, + /// topic or domain) to acquire the authentication tokens being used + /// during delivery / dead-lettering. + /// + [JsonProperty(PropertyName = "deadLetterDestination")] + public DeadLetterDestination DeadLetterDestination { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DeliveryAttributeListResult.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DeliveryAttributeListResult.cs new file mode 100644 index 000000000000..fdbad339b338 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DeliveryAttributeListResult.cs @@ -0,0 +1,56 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Result of the Get delivery attributes operation. + /// + public partial class DeliveryAttributeListResult + { + /// + /// Initializes a new instance of the DeliveryAttributeListResult + /// class. + /// + public DeliveryAttributeListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DeliveryAttributeListResult + /// class. + /// + /// A collection of + /// DeliveryAttributeMapping + public DeliveryAttributeListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a collection of DeliveryAttributeMapping + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DeliveryAttributeMapping.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DeliveryAttributeMapping.cs new file mode 100644 index 000000000000..2ee4e40e7bb6 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DeliveryAttributeMapping.cs @@ -0,0 +1,52 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Delivery attribute mapping details. + /// + public partial class DeliveryAttributeMapping + { + /// + /// Initializes a new instance of the DeliveryAttributeMapping class. + /// + public DeliveryAttributeMapping() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DeliveryAttributeMapping class. + /// + /// Name of the delivery attribute or + /// header. + public DeliveryAttributeMapping(string name = default(string)) + { + Name = name; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the delivery attribute or header. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DeliveryWithResourceIdentity.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DeliveryWithResourceIdentity.cs new file mode 100644 index 000000000000..54d916608d5f --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DeliveryWithResourceIdentity.cs @@ -0,0 +1,69 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Information about the delivery for an event subscription with resource + /// identity. + /// + public partial class DeliveryWithResourceIdentity + { + /// + /// Initializes a new instance of the DeliveryWithResourceIdentity + /// class. + /// + public DeliveryWithResourceIdentity() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DeliveryWithResourceIdentity + /// class. + /// + /// The identity to use when delivering + /// events. + /// Information about the destination where + /// events have to be delivered for the event subscription. + /// Uses Azure Event Grid's identity to acquire the authentication + /// tokens being used during delivery / dead-lettering. + public DeliveryWithResourceIdentity(EventSubscriptionIdentity identity = default(EventSubscriptionIdentity), EventSubscriptionDestination destination = default(EventSubscriptionDestination)) + { + Identity = identity; + Destination = destination; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the identity to use when delivering events. + /// + [JsonProperty(PropertyName = "identity")] + public EventSubscriptionIdentity Identity { get; set; } + + /// + /// Gets or sets information about the destination where events have to + /// be delivered for the event subscription. + /// Uses Azure Event Grid's identity to acquire the authentication + /// tokens being used during delivery / dead-lettering. + /// + [JsonProperty(PropertyName = "destination")] + public EventSubscriptionDestination Destination { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Domain.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Domain.cs index 47b3e7468044..585a500079b7 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Domain.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Domain.cs @@ -63,7 +63,10 @@ public Domain() /// This can be used to restrict traffic /// from specific IPs instead of all IPs. Note: These are considered /// only if PublicNetworkAccess is enabled. - public Domain(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), IList privateEndpointConnections = default(IList), string provisioningState = default(string), string endpoint = default(string), string inputSchema = default(string), InputSchemaMapping inputSchemaMapping = default(InputSchemaMapping), string metricResourceId = default(string), string publicNetworkAccess = default(string), IList inboundIpRules = default(IList)) + /// The Sku pricing tier for the domain. + /// Identity information for the + /// resource. + public Domain(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), IList privateEndpointConnections = default(IList), string provisioningState = default(string), string endpoint = default(string), string inputSchema = default(string), InputSchemaMapping inputSchemaMapping = default(InputSchemaMapping), string metricResourceId = default(string), string publicNetworkAccess = default(string), IList inboundIpRules = default(IList), ResourceSku sku = default(ResourceSku), IdentityInfo identity = default(IdentityInfo)) : base(location, id, name, type, tags) { PrivateEndpointConnections = privateEndpointConnections; @@ -74,6 +77,8 @@ public Domain() MetricResourceId = metricResourceId; PublicNetworkAccess = publicNetworkAccess; InboundIpRules = inboundIpRules; + Sku = sku; + Identity = identity; CustomInit(); } @@ -143,6 +148,18 @@ public Domain() [JsonProperty(PropertyName = "properties.inboundIpRules")] public IList InboundIpRules { get; set; } + /// + /// Gets or sets the Sku pricing tier for the domain. + /// + [JsonProperty(PropertyName = "sku")] + public ResourceSku Sku { get; set; } + + /// + /// Gets or sets identity information for the resource. + /// + [JsonProperty(PropertyName = "identity")] + public IdentityInfo Identity { get; set; } + /// /// Validate the object. /// diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DomainUpdateParameters.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DomainUpdateParameters.cs index 3ba6fef56bb8..646ddc11716b 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DomainUpdateParameters.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DomainUpdateParameters.cs @@ -43,11 +43,16 @@ public DomainUpdateParameters() /// This can be used to restrict traffic /// from specific IPs instead of all IPs. Note: These are considered /// only if PublicNetworkAccess is enabled. - public DomainUpdateParameters(IDictionary tags = default(IDictionary), string publicNetworkAccess = default(string), IList inboundIpRules = default(IList)) + /// Identity information for the + /// resource. + /// The Sku pricing tier for the domain. + public DomainUpdateParameters(IDictionary tags = default(IDictionary), string publicNetworkAccess = default(string), IList inboundIpRules = default(IList), IdentityInfo identity = default(IdentityInfo), ResourceSku sku = default(ResourceSku)) { Tags = tags; PublicNetworkAccess = publicNetworkAccess; InboundIpRules = inboundIpRules; + Identity = identity; + Sku = sku; CustomInit(); } @@ -81,5 +86,17 @@ public DomainUpdateParameters() [JsonProperty(PropertyName = "properties.inboundIpRules")] public IList InboundIpRules { get; set; } + /// + /// Gets or sets identity information for the resource. + /// + [JsonProperty(PropertyName = "identity")] + public IdentityInfo Identity { get; set; } + + /// + /// Gets or sets the Sku pricing tier for the domain. + /// + [JsonProperty(PropertyName = "sku")] + public ResourceSku Sku { get; set; } + } } diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DynamicDeliveryAttributeMapping.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DynamicDeliveryAttributeMapping.cs new file mode 100644 index 000000000000..895464b8b901 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DynamicDeliveryAttributeMapping.cs @@ -0,0 +1,61 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Dynamic delivery attribute mapping details. + /// + [Newtonsoft.Json.JsonObject("Dynamic")] + [Rest.Serialization.JsonTransformation] + public partial class DynamicDeliveryAttributeMapping : DeliveryAttributeMapping + { + /// + /// Initializes a new instance of the DynamicDeliveryAttributeMapping + /// class. + /// + public DynamicDeliveryAttributeMapping() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DynamicDeliveryAttributeMapping + /// class. + /// + /// Name of the delivery attribute or + /// header. + /// JSON path in the event which contains + /// attribute value. + public DynamicDeliveryAttributeMapping(string name = default(string), string sourceField = default(string)) + : base(name) + { + SourceField = sourceField; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets JSON path in the event which contains attribute value. + /// + [JsonProperty(PropertyName = "properties.sourceField")] + public string SourceField { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventChannel.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventChannel.cs new file mode 100644 index 000000000000..8d27a3aa7bb3 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventChannel.cs @@ -0,0 +1,143 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Event Channel. + /// + [Rest.Serialization.JsonTransformation] + public partial class EventChannel : Resource + { + /// + /// Initializes a new instance of the EventChannel class. + /// + public EventChannel() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EventChannel class. + /// + /// Fully qualified identifier of the + /// resource. + /// Name of the resource. + /// Type of the resource. + /// Source of the event channel. This represents a + /// unique resource in the partner's resource model. + /// Represents the destination of an event + /// channel. + /// Provisioning state of the event + /// channel. Possible values include: 'Creating', 'Updating', + /// 'Deleting', 'Succeeded', 'Canceled', 'Failed' + /// The readiness state of the + /// corresponding partner topic. Possible values include: + /// 'NotActivatedByUserYet', 'ActivatedByUser', 'DeactivatedByUser', + /// 'DeletedByUser' + /// Expiration time of + /// the event channel. If this timer expires while the corresponding + /// partner topic is never activated, + /// the event channel and corresponding partner topic are + /// deleted. + /// Information about the filter for the event + /// channel. + /// Friendly description + /// about the topic. This can be set by the publisher/partner to show + /// custom description for the customer partner topic. + /// This will be helpful to remove any ambiguity of the origin of + /// creation of the partner topic for the customer. + /// The system metadata relating to this + /// resource. + public EventChannel(string id = default(string), string name = default(string), string type = default(string), EventChannelSource source = default(EventChannelSource), EventChannelDestination destination = default(EventChannelDestination), string provisioningState = default(string), string partnerTopicReadinessState = default(string), System.DateTime? expirationTimeIfNotActivatedUtc = default(System.DateTime?), EventChannelFilter filter = default(EventChannelFilter), string partnerTopicFriendlyDescription = default(string), SystemData systemData = default(SystemData)) + : base(id, name, type) + { + Source = source; + Destination = destination; + ProvisioningState = provisioningState; + PartnerTopicReadinessState = partnerTopicReadinessState; + ExpirationTimeIfNotActivatedUtc = expirationTimeIfNotActivatedUtc; + Filter = filter; + PartnerTopicFriendlyDescription = partnerTopicFriendlyDescription; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets source of the event channel. This represents a unique + /// resource in the partner's resource model. + /// + [JsonProperty(PropertyName = "properties.source")] + public EventChannelSource Source { get; set; } + + /// + /// Gets or sets represents the destination of an event channel. + /// + [JsonProperty(PropertyName = "properties.destination")] + public EventChannelDestination Destination { get; set; } + + /// + /// Gets provisioning state of the event channel. Possible values + /// include: 'Creating', 'Updating', 'Deleting', 'Succeeded', + /// 'Canceled', 'Failed' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets the readiness state of the corresponding partner topic. + /// Possible values include: 'NotActivatedByUserYet', + /// 'ActivatedByUser', 'DeactivatedByUser', 'DeletedByUser' + /// + [JsonProperty(PropertyName = "properties.partnerTopicReadinessState")] + public string PartnerTopicReadinessState { get; private set; } + + /// + /// Gets or sets expiration time of the event channel. If this timer + /// expires while the corresponding partner topic is never activated, + /// the event channel and corresponding partner topic are deleted. + /// + [JsonProperty(PropertyName = "properties.expirationTimeIfNotActivatedUtc")] + public System.DateTime? ExpirationTimeIfNotActivatedUtc { get; set; } + + /// + /// Gets or sets information about the filter for the event channel. + /// + [JsonProperty(PropertyName = "properties.filter")] + public EventChannelFilter Filter { get; set; } + + /// + /// Gets or sets friendly description about the topic. This can be set + /// by the publisher/partner to show custom description for the + /// customer partner topic. + /// This will be helpful to remove any ambiguity of the origin of + /// creation of the partner topic for the customer. + /// + [JsonProperty(PropertyName = "properties.partnerTopicFriendlyDescription")] + public string PartnerTopicFriendlyDescription { get; set; } + + /// + /// Gets the system metadata relating to this resource. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventChannelDestination.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventChannelDestination.cs new file mode 100644 index 000000000000..e3b559e9d200 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventChannelDestination.cs @@ -0,0 +1,81 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Properties of the destination of an event channel. + /// + public partial class EventChannelDestination + { + /// + /// Initializes a new instance of the EventChannelDestination class. + /// + public EventChannelDestination() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EventChannelDestination class. + /// + /// Azure subscription ID of the + /// customer creating the event channel. The partner topic + /// associated with the event channel will be created under this Azure + /// subscription. + /// Azure Resource Group of the customer + /// creating the event channel. The partner topic + /// associated with the event channel will be created under this + /// resource group. + /// Name of the partner topic associated + /// with the event channel. + public EventChannelDestination(string azureSubscriptionId = default(string), string resourceGroup = default(string), string partnerTopicName = default(string)) + { + AzureSubscriptionId = azureSubscriptionId; + ResourceGroup = resourceGroup; + PartnerTopicName = partnerTopicName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets azure subscription ID of the customer creating the + /// event channel. The partner topic + /// associated with the event channel will be created under this Azure + /// subscription. + /// + [JsonProperty(PropertyName = "azureSubscriptionId")] + public string AzureSubscriptionId { get; set; } + + /// + /// Gets or sets azure Resource Group of the customer creating the + /// event channel. The partner topic + /// associated with the event channel will be created under this + /// resource group. + /// + [JsonProperty(PropertyName = "resourceGroup")] + public string ResourceGroup { get; set; } + + /// + /// Gets or sets name of the partner topic associated with the event + /// channel. + /// + [JsonProperty(PropertyName = "partnerTopicName")] + public string PartnerTopicName { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventChannelFilter.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventChannelFilter.cs new file mode 100644 index 000000000000..7c4f32d884b5 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventChannelFilter.cs @@ -0,0 +1,66 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Filter for the Event Channel. + /// + public partial class EventChannelFilter + { + /// + /// Initializes a new instance of the EventChannelFilter class. + /// + public EventChannelFilter() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EventChannelFilter class. + /// + /// Allows advanced + /// filters to be evaluated against an array of values instead of + /// expecting a singular value. + /// An array of advanced filters that are + /// used for filtering event channels. + public EventChannelFilter(bool? enableAdvancedFilteringOnArrays = default(bool?), IList advancedFilters = default(IList)) + { + EnableAdvancedFilteringOnArrays = enableAdvancedFilteringOnArrays; + AdvancedFilters = advancedFilters; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets allows advanced filters to be evaluated against an + /// array of values instead of expecting a singular value. + /// + [JsonProperty(PropertyName = "enableAdvancedFilteringOnArrays")] + public bool? EnableAdvancedFilteringOnArrays { get; set; } + + /// + /// Gets or sets an array of advanced filters that are used for + /// filtering event channels. + /// + [JsonProperty(PropertyName = "advancedFilters")] + public IList AdvancedFilters { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventChannelProvisioningState.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventChannelProvisioningState.cs new file mode 100644 index 000000000000..0583d8001a61 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventChannelProvisioningState.cs @@ -0,0 +1,26 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + + /// + /// Defines values for EventChannelProvisioningState. + /// + public static class EventChannelProvisioningState + { + public const string Creating = "Creating"; + public const string Updating = "Updating"; + public const string Deleting = "Deleting"; + public const string Succeeded = "Succeeded"; + public const string Canceled = "Canceled"; + public const string Failed = "Failed"; + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventChannelSource.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventChannelSource.cs new file mode 100644 index 000000000000..0d498701f6ff --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventChannelSource.cs @@ -0,0 +1,56 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Properties of the source of an event channel. + /// + public partial class EventChannelSource + { + /// + /// Initializes a new instance of the EventChannelSource class. + /// + public EventChannelSource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EventChannelSource class. + /// + /// The identifier of the resource that's the + /// source of the events. + /// This represents a unique resource in the partner's resource + /// model. + public EventChannelSource(string source = default(string)) + { + Source = source; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the identifier of the resource that's the source of + /// the events. + /// This represents a unique resource in the partner's resource model. + /// + [JsonProperty(PropertyName = "source")] + public string Source { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventHubEventSubscriptionDestination.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventHubEventSubscriptionDestination.cs index 316004562aea..4b6f88cd679e 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventHubEventSubscriptionDestination.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventHubEventSubscriptionDestination.cs @@ -13,6 +13,8 @@ namespace Microsoft.Azure.Management.EventGrid.Models using Microsoft.Rest; using Microsoft.Rest.Serialization; using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; using System.Linq; /// @@ -38,9 +40,12 @@ public EventHubEventSubscriptionDestination() /// The Azure Resource Id that represents the /// endpoint of an Event Hub destination of an event /// subscription. - public EventHubEventSubscriptionDestination(string resourceId = default(string)) + /// Delivery attribute + /// details. + public EventHubEventSubscriptionDestination(string resourceId = default(string), IList deliveryAttributeMappings = default(IList)) { ResourceId = resourceId; + DeliveryAttributeMappings = deliveryAttributeMappings; CustomInit(); } @@ -56,5 +61,11 @@ public EventHubEventSubscriptionDestination() [JsonProperty(PropertyName = "properties.resourceId")] public string ResourceId { get; set; } + /// + /// Gets or sets delivery attribute details. + /// + [JsonProperty(PropertyName = "properties.deliveryAttributeMappings")] + public IList DeliveryAttributeMappings { get; set; } + } } diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventSubscription.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventSubscription.cs index 2b2f7d2e57ff..d27417e28e14 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventSubscription.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventSubscription.cs @@ -45,7 +45,15 @@ public EventSubscription() /// 'Deleting', 'Succeeded', 'Canceled', 'Failed', /// 'AwaitingManualAction' /// Information about the destination where - /// events have to be delivered for the event subscription. + /// events have to be delivered for the event subscription. + /// Uses Azure Event Grid's identity to acquire the authentication + /// tokens being used during delivery / dead-lettering. + /// Information about the + /// destination where events have to be delivered for the event + /// subscription. + /// Uses the managed identity setup on the parent resource (namely, + /// topic or domain) to acquire the authentication tokens being used + /// during delivery / dead-lettering. /// Information about the filter for the event /// subscription. /// List of user defined labels. @@ -57,20 +65,35 @@ public EventSubscription() /// The retry policy for events. This can be /// used to configure maximum number of delivery attempts and time to /// live for events. - /// The DeadLetter destination of - /// the event subscription. - public EventSubscription(string id = default(string), string name = default(string), string type = default(string), string topic = default(string), string provisioningState = default(string), EventSubscriptionDestination destination = default(EventSubscriptionDestination), EventSubscriptionFilter filter = default(EventSubscriptionFilter), IList labels = default(IList), System.DateTime? expirationTimeUtc = default(System.DateTime?), string eventDeliverySchema = default(string), RetryPolicy retryPolicy = default(RetryPolicy), DeadLetterDestination deadLetterDestination = default(DeadLetterDestination)) + /// The dead letter destination of + /// the event subscription. Any event that cannot be delivered to its' + /// destination is sent to the dead letter destination. + /// Uses Azure Event Grid's identity to acquire the authentication + /// tokens being used during delivery / dead-lettering. + /// The dead letter + /// destination of the event subscription. Any event that cannot be + /// delivered to its' destination is sent to the dead letter + /// destination. + /// Uses the managed identity setup on the parent resource (namely, + /// topic or domain) to acquire the authentication tokens being used + /// during delivery / dead-lettering. + /// The system metadata relating to this + /// resource. + public EventSubscription(string id = default(string), string name = default(string), string type = default(string), string topic = default(string), string provisioningState = default(string), EventSubscriptionDestination destination = default(EventSubscriptionDestination), DeliveryWithResourceIdentity deliveryWithResourceIdentity = default(DeliveryWithResourceIdentity), EventSubscriptionFilter filter = default(EventSubscriptionFilter), IList labels = default(IList), System.DateTime? expirationTimeUtc = default(System.DateTime?), string eventDeliverySchema = default(string), RetryPolicy retryPolicy = default(RetryPolicy), DeadLetterDestination deadLetterDestination = default(DeadLetterDestination), DeadLetterWithResourceIdentity deadLetterWithResourceIdentity = default(DeadLetterWithResourceIdentity), SystemData systemData = default(SystemData)) : base(id, name, type) { Topic = topic; ProvisioningState = provisioningState; Destination = destination; + DeliveryWithResourceIdentity = deliveryWithResourceIdentity; Filter = filter; Labels = labels; ExpirationTimeUtc = expirationTimeUtc; EventDeliverySchema = eventDeliverySchema; RetryPolicy = retryPolicy; DeadLetterDestination = deadLetterDestination; + DeadLetterWithResourceIdentity = deadLetterWithResourceIdentity; + SystemData = systemData; CustomInit(); } @@ -96,10 +119,22 @@ public EventSubscription() /// /// Gets or sets information about the destination where events have to /// be delivered for the event subscription. + /// Uses Azure Event Grid's identity to acquire the authentication + /// tokens being used during delivery / dead-lettering. /// [JsonProperty(PropertyName = "properties.destination")] public EventSubscriptionDestination Destination { get; set; } + /// + /// Gets or sets information about the destination where events have to + /// be delivered for the event subscription. + /// Uses the managed identity setup on the parent resource (namely, + /// topic or domain) to acquire the authentication tokens being used + /// during delivery / dead-lettering. + /// + [JsonProperty(PropertyName = "properties.deliveryWithResourceIdentity")] + public DeliveryWithResourceIdentity DeliveryWithResourceIdentity { get; set; } + /// /// Gets or sets information about the filter for the event /// subscription. @@ -136,10 +171,31 @@ public EventSubscription() public RetryPolicy RetryPolicy { get; set; } /// - /// Gets or sets the DeadLetter destination of the event subscription. + /// Gets or sets the dead letter destination of the event subscription. + /// Any event that cannot be delivered to its' destination is sent to + /// the dead letter destination. + /// Uses Azure Event Grid's identity to acquire the authentication + /// tokens being used during delivery / dead-lettering. /// [JsonProperty(PropertyName = "properties.deadLetterDestination")] public DeadLetterDestination DeadLetterDestination { get; set; } + /// + /// Gets or sets the dead letter destination of the event subscription. + /// Any event that cannot be delivered to its' destination is sent to + /// the dead letter destination. + /// Uses the managed identity setup on the parent resource (namely, + /// topic or domain) to acquire the authentication tokens being used + /// during delivery / dead-lettering. + /// + [JsonProperty(PropertyName = "properties.deadLetterWithResourceIdentity")] + public DeadLetterWithResourceIdentity DeadLetterWithResourceIdentity { get; set; } + + /// + /// Gets the system metadata relating to this resource. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + } } diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventSubscriptionDestination.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventSubscriptionDestination.cs index f9ec84760c93..394af8038969 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventSubscriptionDestination.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventSubscriptionDestination.cs @@ -10,13 +10,11 @@ namespace Microsoft.Azure.Management.EventGrid.Models { - using Newtonsoft.Json; using System.Linq; /// /// Information about the destination for an event subscription. /// - [Newtonsoft.Json.JsonObject("EventSubscriptionDestination")] public partial class EventSubscriptionDestination { /// diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventSubscriptionFilter.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventSubscriptionFilter.cs index 6dfffd825501..b1df539479e4 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventSubscriptionFilter.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventSubscriptionFilter.cs @@ -45,14 +45,18 @@ public EventSubscriptionFilter() /// Specifies if the /// SubjectBeginsWith and SubjectEndsWith properties of the filter /// should be compared in a case sensitive manner. + /// Allows advanced + /// filters to be evaluated against an array of values instead of + /// expecting a singular value. /// An array of advanced filters that are /// used for filtering event subscriptions. - public EventSubscriptionFilter(string subjectBeginsWith = default(string), string subjectEndsWith = default(string), IList includedEventTypes = default(IList), bool? isSubjectCaseSensitive = default(bool?), IList advancedFilters = default(IList)) + public EventSubscriptionFilter(string subjectBeginsWith = default(string), string subjectEndsWith = default(string), IList includedEventTypes = default(IList), bool? isSubjectCaseSensitive = default(bool?), bool? enableAdvancedFilteringOnArrays = default(bool?), IList advancedFilters = default(IList)) { SubjectBeginsWith = subjectBeginsWith; SubjectEndsWith = subjectEndsWith; IncludedEventTypes = includedEventTypes; IsSubjectCaseSensitive = isSubjectCaseSensitive; + EnableAdvancedFilteringOnArrays = enableAdvancedFilteringOnArrays; AdvancedFilters = advancedFilters; CustomInit(); } @@ -95,6 +99,13 @@ public EventSubscriptionFilter() [JsonProperty(PropertyName = "isSubjectCaseSensitive")] public bool? IsSubjectCaseSensitive { get; set; } + /// + /// Gets or sets allows advanced filters to be evaluated against an + /// array of values instead of expecting a singular value. + /// + [JsonProperty(PropertyName = "enableAdvancedFilteringOnArrays")] + public bool? EnableAdvancedFilteringOnArrays { get; set; } + /// /// Gets or sets an array of advanced filters that are used for /// filtering event subscriptions. diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventSubscriptionIdentity.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventSubscriptionIdentity.cs new file mode 100644 index 000000000000..84aa816df9c1 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventSubscriptionIdentity.cs @@ -0,0 +1,68 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The identity information with the event subscription. + /// + public partial class EventSubscriptionIdentity + { + /// + /// Initializes a new instance of the EventSubscriptionIdentity class. + /// + public EventSubscriptionIdentity() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EventSubscriptionIdentity class. + /// + /// The type of managed identity used. The type + /// 'SystemAssigned, UserAssigned' includes both an implicitly created + /// identity and a set of user-assigned identities. The type 'None' + /// will remove any identity. Possible values include: + /// 'SystemAssigned', 'UserAssigned' + /// The user identity associated + /// with the resource. + public EventSubscriptionIdentity(string type = default(string), string userAssignedIdentity = default(string)) + { + Type = type; + UserAssignedIdentity = userAssignedIdentity; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the type of managed identity used. The type + /// 'SystemAssigned, UserAssigned' includes both an implicitly created + /// identity and a set of user-assigned identities. The type 'None' + /// will remove any identity. Possible values include: + /// 'SystemAssigned', 'UserAssigned' + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets the user identity associated with the resource. + /// + [JsonProperty(PropertyName = "userAssignedIdentity")] + public string UserAssignedIdentity { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventSubscriptionIdentityType.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventSubscriptionIdentityType.cs new file mode 100644 index 000000000000..06c41887dab5 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventSubscriptionIdentityType.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.EventGrid.Models +{ + + /// + /// Defines values for EventSubscriptionIdentityType. + /// + public static class EventSubscriptionIdentityType + { + public const string SystemAssigned = "SystemAssigned"; + public const string UserAssigned = "UserAssigned"; + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventSubscriptionUpdateParameters.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventSubscriptionUpdateParameters.cs index 59903e2c7ef8..d6fb28f6b55e 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventSubscriptionUpdateParameters.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventSubscriptionUpdateParameters.cs @@ -34,7 +34,15 @@ public EventSubscriptionUpdateParameters() /// class. /// /// Information about the destination where - /// events have to be delivered for the event subscription. + /// events have to be delivered for the event subscription. + /// Uses Azure Event Grid's identity to acquire the authentication + /// tokens being used during delivery / dead-lettering. + /// Information about the + /// destination where events have to be delivered for the event + /// subscription. + /// Uses the managed identity setup on the parent resource (topic / + /// domain) to acquire the authentication tokens being used during + /// delivery / dead-lettering. /// Information about the filter for the event /// subscription. /// List of user defined labels. @@ -46,17 +54,29 @@ public EventSubscriptionUpdateParameters() /// The retry policy for events. This can be /// used to configure maximum number of delivery attempts and time to /// live for events. - /// The DeadLetter destination of - /// the event subscription. - public EventSubscriptionUpdateParameters(EventSubscriptionDestination destination = default(EventSubscriptionDestination), EventSubscriptionFilter filter = default(EventSubscriptionFilter), IList labels = default(IList), System.DateTime? expirationTimeUtc = default(System.DateTime?), string eventDeliverySchema = default(string), RetryPolicy retryPolicy = default(RetryPolicy), DeadLetterDestination deadLetterDestination = default(DeadLetterDestination)) + /// The dead letter destination of + /// the event subscription. Any event that cannot be delivered to its' + /// destination is sent to the dead letter destination. + /// Uses Azure Event Grid's identity to acquire the authentication + /// tokens being used during delivery / dead-lettering. + /// The dead letter + /// destination of the event subscription. Any event that cannot be + /// delivered to its' destination is sent to the dead letter + /// destination. + /// Uses the managed identity setup on the parent resource (topic / + /// domain) to acquire the authentication tokens being used during + /// delivery / dead-lettering. + public EventSubscriptionUpdateParameters(EventSubscriptionDestination destination = default(EventSubscriptionDestination), DeliveryWithResourceIdentity deliveryWithResourceIdentity = default(DeliveryWithResourceIdentity), EventSubscriptionFilter filter = default(EventSubscriptionFilter), IList labels = default(IList), System.DateTime? expirationTimeUtc = default(System.DateTime?), string eventDeliverySchema = default(string), RetryPolicy retryPolicy = default(RetryPolicy), DeadLetterDestination deadLetterDestination = default(DeadLetterDestination), DeadLetterWithResourceIdentity deadLetterWithResourceIdentity = default(DeadLetterWithResourceIdentity)) { Destination = destination; + DeliveryWithResourceIdentity = deliveryWithResourceIdentity; Filter = filter; Labels = labels; ExpirationTimeUtc = expirationTimeUtc; EventDeliverySchema = eventDeliverySchema; RetryPolicy = retryPolicy; DeadLetterDestination = deadLetterDestination; + DeadLetterWithResourceIdentity = deadLetterWithResourceIdentity; CustomInit(); } @@ -68,10 +88,22 @@ public EventSubscriptionUpdateParameters() /// /// Gets or sets information about the destination where events have to /// be delivered for the event subscription. + /// Uses Azure Event Grid's identity to acquire the authentication + /// tokens being used during delivery / dead-lettering. /// [JsonProperty(PropertyName = "destination")] public EventSubscriptionDestination Destination { get; set; } + /// + /// Gets or sets information about the destination where events have to + /// be delivered for the event subscription. + /// Uses the managed identity setup on the parent resource (topic / + /// domain) to acquire the authentication tokens being used during + /// delivery / dead-lettering. + /// + [JsonProperty(PropertyName = "deliveryWithResourceIdentity")] + public DeliveryWithResourceIdentity DeliveryWithResourceIdentity { get; set; } + /// /// Gets or sets information about the filter for the event /// subscription. @@ -109,10 +141,25 @@ public EventSubscriptionUpdateParameters() public RetryPolicy RetryPolicy { get; set; } /// - /// Gets or sets the DeadLetter destination of the event subscription. + /// Gets or sets the dead letter destination of the event subscription. + /// Any event that cannot be delivered to its' destination is sent to + /// the dead letter destination. + /// Uses Azure Event Grid's identity to acquire the authentication + /// tokens being used during delivery / dead-lettering. /// [JsonProperty(PropertyName = "deadLetterDestination")] public DeadLetterDestination DeadLetterDestination { get; set; } + /// + /// Gets or sets the dead letter destination of the event subscription. + /// Any event that cannot be delivered to its' destination is sent to + /// the dead letter destination. + /// Uses the managed identity setup on the parent resource (topic / + /// domain) to acquire the authentication tokens being used during + /// delivery / dead-lettering. + /// + [JsonProperty(PropertyName = "deadLetterWithResourceIdentity")] + public DeadLetterWithResourceIdentity DeadLetterWithResourceIdentity { get; set; } + } } diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ExtendedLocation.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ExtendedLocation.cs new file mode 100644 index 000000000000..91bf327c7a5f --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ExtendedLocation.cs @@ -0,0 +1,60 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Definition of an Extended Location + /// + public partial class ExtendedLocation + { + /// + /// Initializes a new instance of the ExtendedLocation class. + /// + public ExtendedLocation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ExtendedLocation class. + /// + /// Fully qualified name of the extended + /// location. + /// Type of the extended location. + public ExtendedLocation(string name = default(string), string type = default(string)) + { + Name = name; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets fully qualified name of the extended location. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets type of the extended location. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ExtensionTopic.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ExtensionTopic.cs new file mode 100644 index 000000000000..71f5c25b919d --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ExtensionTopic.cs @@ -0,0 +1,71 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Event grid Extension Topic. This is used for getting Event Grid related + /// metrics for Azure resources. + /// + [Rest.Serialization.JsonTransformation] + public partial class ExtensionTopic : Resource + { + /// + /// Initializes a new instance of the ExtensionTopic class. + /// + public ExtensionTopic() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ExtensionTopic class. + /// + /// Fully qualified identifier of the + /// resource. + /// Name of the resource. + /// Type of the resource. + /// Description of the extension + /// topic. + /// System topic resource id which is mapped + /// to the source. + public ExtensionTopic(string id = default(string), string name = default(string), string type = default(string), string description = default(string), string systemTopic = default(string)) + : base(id, name, type) + { + Description = description; + SystemTopic = systemTopic; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets description of the extension topic. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets system topic resource id which is mapped to the + /// source. + /// + [JsonProperty(PropertyName = "properties.systemTopic")] + public string SystemTopic { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/HybridConnectionEventSubscriptionDestination.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/HybridConnectionEventSubscriptionDestination.cs index 218a89fcbc6d..e136a13f09e9 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/HybridConnectionEventSubscriptionDestination.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/HybridConnectionEventSubscriptionDestination.cs @@ -13,6 +13,8 @@ namespace Microsoft.Azure.Management.EventGrid.Models using Microsoft.Rest; using Microsoft.Rest.Serialization; using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; using System.Linq; /// @@ -39,9 +41,12 @@ public HybridConnectionEventSubscriptionDestination() /// The Azure Resource ID of an hybrid /// connection that is the destination of an event /// subscription. - public HybridConnectionEventSubscriptionDestination(string resourceId = default(string)) + /// Delivery attribute + /// details. + public HybridConnectionEventSubscriptionDestination(string resourceId = default(string), IList deliveryAttributeMappings = default(IList)) { ResourceId = resourceId; + DeliveryAttributeMappings = deliveryAttributeMappings; CustomInit(); } @@ -57,5 +62,11 @@ public HybridConnectionEventSubscriptionDestination() [JsonProperty(PropertyName = "properties.resourceId")] public string ResourceId { get; set; } + /// + /// Gets or sets delivery attribute details. + /// + [JsonProperty(PropertyName = "properties.deliveryAttributeMappings")] + public IList DeliveryAttributeMappings { get; set; } + } } diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/IdentityInfo.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/IdentityInfo.cs new file mode 100644 index 000000000000..c860851f8f3b --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/IdentityInfo.cs @@ -0,0 +1,96 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The identity information for the resource. + /// + public partial class IdentityInfo + { + /// + /// Initializes a new instance of the IdentityInfo class. + /// + public IdentityInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IdentityInfo class. + /// + /// The type of managed identity used. The type + /// 'SystemAssigned, UserAssigned' includes both an implicitly created + /// identity and a set of user-assigned identities. The type 'None' + /// will remove any identity. Possible values include: 'None', + /// 'SystemAssigned', 'UserAssigned', 'SystemAssigned, + /// UserAssigned' + /// The principal ID of resource + /// identity. + /// The tenant ID of resource. + /// The list of user identities + /// associated with the resource. The user identity dictionary key + /// references will be ARM resource ids in the form: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + /// This property is currently not used and reserved for future + /// usage. + public IdentityInfo(string type = default(string), string principalId = default(string), string tenantId = default(string), IDictionary userAssignedIdentities = default(IDictionary)) + { + Type = type; + PrincipalId = principalId; + TenantId = tenantId; + UserAssignedIdentities = userAssignedIdentities; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the type of managed identity used. The type + /// 'SystemAssigned, UserAssigned' includes both an implicitly created + /// identity and a set of user-assigned identities. The type 'None' + /// will remove any identity. Possible values include: 'None', + /// 'SystemAssigned', 'UserAssigned', 'SystemAssigned, UserAssigned' + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets the principal ID of resource identity. + /// + [JsonProperty(PropertyName = "principalId")] + public string PrincipalId { get; set; } + + /// + /// Gets or sets the tenant ID of resource. + /// + [JsonProperty(PropertyName = "tenantId")] + public string TenantId { get; set; } + + /// + /// Gets or sets the list of user identities associated with the + /// resource. The user identity dictionary key references will be ARM + /// resource ids in the form: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + /// This property is currently not used and reserved for future usage. + /// + [JsonProperty(PropertyName = "userAssignedIdentities")] + public IDictionary UserAssignedIdentities { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/IdentityType.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/IdentityType.cs new file mode 100644 index 000000000000..4a04461638d5 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/IdentityType.cs @@ -0,0 +1,24 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + + /// + /// Defines values for IdentityType. + /// + public static class IdentityType + { + public const string None = "None"; + public const string SystemAssigned = "SystemAssigned"; + public const string UserAssigned = "UserAssigned"; + public const string SystemAssignedUserAssigned = "SystemAssigned, UserAssigned"; + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/InputSchemaMapping.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/InputSchemaMapping.cs index e1558f810985..18a9bec9d083 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/InputSchemaMapping.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/InputSchemaMapping.cs @@ -10,7 +10,6 @@ namespace Microsoft.Azure.Management.EventGrid.Models { - using Newtonsoft.Json; using System.Linq; /// @@ -19,7 +18,6 @@ namespace Microsoft.Azure.Management.EventGrid.Models /// Grid using a custom input schema. Currently, the only supported type of /// InputSchemaMapping is 'JsonInputSchemaMapping'. /// - [Newtonsoft.Json.JsonObject("InputSchemaMapping")] public partial class InputSchemaMapping { /// diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/IsNotNullAdvancedFilter.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/IsNotNullAdvancedFilter.cs new file mode 100644 index 000000000000..4599cd6b34b1 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/IsNotNullAdvancedFilter.cs @@ -0,0 +1,47 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// IsNotNull Advanced Filter. + /// + [Newtonsoft.Json.JsonObject("IsNotNull")] + public partial class IsNotNullAdvancedFilter : AdvancedFilter + { + /// + /// Initializes a new instance of the IsNotNullAdvancedFilter class. + /// + public IsNotNullAdvancedFilter() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IsNotNullAdvancedFilter class. + /// + /// The field/property in the event based on which + /// you want to filter. + public IsNotNullAdvancedFilter(string key = default(string)) + : base(key) + { + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/IsNullOrUndefinedAdvancedFilter.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/IsNullOrUndefinedAdvancedFilter.cs new file mode 100644 index 000000000000..8a85bcb88ba1 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/IsNullOrUndefinedAdvancedFilter.cs @@ -0,0 +1,49 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// IsNullOrUndefined Advanced Filter. + /// + [Newtonsoft.Json.JsonObject("IsNullOrUndefined")] + public partial class IsNullOrUndefinedAdvancedFilter : AdvancedFilter + { + /// + /// Initializes a new instance of the IsNullOrUndefinedAdvancedFilter + /// class. + /// + public IsNullOrUndefinedAdvancedFilter() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IsNullOrUndefinedAdvancedFilter + /// class. + /// + /// The field/property in the event based on which + /// you want to filter. + public IsNullOrUndefinedAdvancedFilter(string key = default(string)) + : base(key) + { + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/NumberInRangeAdvancedFilter.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/NumberInRangeAdvancedFilter.cs new file mode 100644 index 000000000000..f353c5512efe --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/NumberInRangeAdvancedFilter.cs @@ -0,0 +1,59 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// NumberInRange Advanced Filter. + /// + [Newtonsoft.Json.JsonObject("NumberInRange")] + public partial class NumberInRangeAdvancedFilter : AdvancedFilter + { + /// + /// Initializes a new instance of the NumberInRangeAdvancedFilter + /// class. + /// + public NumberInRangeAdvancedFilter() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NumberInRangeAdvancedFilter + /// class. + /// + /// The field/property in the event based on which + /// you want to filter. + /// The set of filter values. + public NumberInRangeAdvancedFilter(string key = default(string), IList> values = default(IList>)) + : base(key) + { + Values = values; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the set of filter values. + /// + [JsonProperty(PropertyName = "values")] + public IList> Values { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/NumberNotInRangeAdvancedFilter.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/NumberNotInRangeAdvancedFilter.cs new file mode 100644 index 000000000000..8498db863dde --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/NumberNotInRangeAdvancedFilter.cs @@ -0,0 +1,59 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// NumberNotInRange Advanced Filter. + /// + [Newtonsoft.Json.JsonObject("NumberNotInRange")] + public partial class NumberNotInRangeAdvancedFilter : AdvancedFilter + { + /// + /// Initializes a new instance of the NumberNotInRangeAdvancedFilter + /// class. + /// + public NumberNotInRangeAdvancedFilter() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NumberNotInRangeAdvancedFilter + /// class. + /// + /// The field/property in the event based on which + /// you want to filter. + /// The set of filter values. + public NumberNotInRangeAdvancedFilter(string key = default(string), IList> values = default(IList>)) + : base(key) + { + Values = values; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the set of filter values. + /// + [JsonProperty(PropertyName = "values")] + public IList> Values { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerNamespace.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerNamespace.cs new file mode 100644 index 000000000000..48704d0e4f58 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerNamespace.cs @@ -0,0 +1,109 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// EventGrid Partner Namespace. + /// + [Rest.Serialization.JsonTransformation] + public partial class PartnerNamespace : TrackedResource + { + /// + /// Initializes a new instance of the PartnerNamespace class. + /// + public PartnerNamespace() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PartnerNamespace class. + /// + /// Location of the resource. + /// Fully qualified identifier of the + /// resource. + /// Name of the resource. + /// Type of the resource. + /// Tags of the resource. + /// Provisioning state of the partner + /// namespace. Possible values include: 'Creating', 'Updating', + /// 'Deleting', 'Succeeded', 'Canceled', 'Failed' + /// The fully + /// qualified ARM Id of the partner registration that should be + /// associated with this partner namespace. This takes the following + /// format: + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}. + /// Endpoint for the partner namespace. + /// The system metadata relating to this + /// resource. + public PartnerNamespace(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string provisioningState = default(string), string partnerRegistrationFullyQualifiedId = default(string), string endpoint = default(string), SystemData systemData = default(SystemData)) + : base(location, id, name, type, tags) + { + ProvisioningState = provisioningState; + PartnerRegistrationFullyQualifiedId = partnerRegistrationFullyQualifiedId; + Endpoint = endpoint; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets provisioning state of the partner namespace. Possible values + /// include: 'Creating', 'Updating', 'Deleting', 'Succeeded', + /// 'Canceled', 'Failed' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets the fully qualified ARM Id of the partner registration + /// that should be associated with this partner namespace. This takes + /// the following format: + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}. + /// + [JsonProperty(PropertyName = "properties.partnerRegistrationFullyQualifiedId")] + public string PartnerRegistrationFullyQualifiedId { get; set; } + + /// + /// Gets endpoint for the partner namespace. + /// + [JsonProperty(PropertyName = "properties.endpoint")] + public string Endpoint { get; private set; } + + /// + /// Gets the system metadata relating to this resource. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + } + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerNamespaceProvisioningState.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerNamespaceProvisioningState.cs new file mode 100644 index 000000000000..a93d8ed974e0 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerNamespaceProvisioningState.cs @@ -0,0 +1,26 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + + /// + /// Defines values for PartnerNamespaceProvisioningState. + /// + public static class PartnerNamespaceProvisioningState + { + public const string Creating = "Creating"; + public const string Updating = "Updating"; + public const string Deleting = "Deleting"; + public const string Succeeded = "Succeeded"; + public const string Canceled = "Canceled"; + public const string Failed = "Failed"; + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerNamespaceRegenerateKeyRequest.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerNamespaceRegenerateKeyRequest.cs new file mode 100644 index 000000000000..87f6e0700a98 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerNamespaceRegenerateKeyRequest.cs @@ -0,0 +1,68 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// PartnerNamespace regenerate shared access key request. + /// + public partial class PartnerNamespaceRegenerateKeyRequest + { + /// + /// Initializes a new instance of the + /// PartnerNamespaceRegenerateKeyRequest class. + /// + public PartnerNamespaceRegenerateKeyRequest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// PartnerNamespaceRegenerateKeyRequest class. + /// + /// Key name to regenerate (key1 or + /// key2). + public PartnerNamespaceRegenerateKeyRequest(string keyName) + { + KeyName = keyName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets key name to regenerate (key1 or key2). + /// + [JsonProperty(PropertyName = "keyName")] + public string KeyName { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (KeyName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "KeyName"); + } + } + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerNamespaceSharedAccessKeys.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerNamespaceSharedAccessKeys.cs new file mode 100644 index 000000000000..16ada036cecb --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerNamespaceSharedAccessKeys.cs @@ -0,0 +1,63 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Shared access keys of the partner namespace. + /// + public partial class PartnerNamespaceSharedAccessKeys + { + /// + /// Initializes a new instance of the PartnerNamespaceSharedAccessKeys + /// class. + /// + public PartnerNamespaceSharedAccessKeys() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PartnerNamespaceSharedAccessKeys + /// class. + /// + /// Shared access key1 for the partner + /// namespace. + /// Shared access key2 for the partner + /// namespace. + public PartnerNamespaceSharedAccessKeys(string key1 = default(string), string key2 = default(string)) + { + Key1 = key1; + Key2 = key2; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets shared access key1 for the partner namespace. + /// + [JsonProperty(PropertyName = "key1")] + public string Key1 { get; set; } + + /// + /// Gets or sets shared access key2 for the partner namespace. + /// + [JsonProperty(PropertyName = "key2")] + public string Key2 { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerNamespaceUpdateParameters.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerNamespaceUpdateParameters.cs new file mode 100644 index 000000000000..7b8cbbacd418 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerNamespaceUpdateParameters.cs @@ -0,0 +1,55 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Properties of the PartnerNamespace update. + /// + public partial class PartnerNamespaceUpdateParameters + { + /// + /// Initializes a new instance of the PartnerNamespaceUpdateParameters + /// class. + /// + public PartnerNamespaceUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PartnerNamespaceUpdateParameters + /// class. + /// + /// Tags of the partner namespace. + public PartnerNamespaceUpdateParameters(IDictionary tags = default(IDictionary)) + { + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets tags of the partner namespace. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerRegistration.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerRegistration.cs new file mode 100644 index 000000000000..edcf663a92db --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerRegistration.cs @@ -0,0 +1,234 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Information about a partner registration. + /// + [Rest.Serialization.JsonTransformation] + public partial class PartnerRegistration : TrackedResource + { + /// + /// Initializes a new instance of the PartnerRegistration class. + /// + public PartnerRegistration() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PartnerRegistration class. + /// + /// Location of the resource. + /// Fully qualified identifier of the + /// resource. + /// Name of the resource. + /// Type of the resource. + /// Tags of the resource. + /// Provisioning state of the partner + /// registration. Possible values include: 'Creating', 'Updating', + /// 'Deleting', 'Succeeded', 'Canceled', 'Failed' + /// Official name of the partner name. For + /// example: "Contoso". + /// Name of the partner resource + /// type. + /// Display name of the + /// partner resource type. + /// Short description of + /// the partner resource type. The length of this description should + /// not exceed 256 characters. + /// Long description for the custom + /// scenarios and integration to be displayed in the portal if needed. + /// Length of this description should not exceed 2048 + /// characters. + /// The customer service + /// number of the publisher. The expected phone format should start + /// with a '+' sign + /// followed by the country code. The remaining digits are then + /// followed. Only digits and spaces are allowed and its + /// length cannot exceed 16 digits including country code. Examples of + /// valid phone numbers are: +1 515 123 4567 and + /// +966 7 5115 2471. Examples of invalid phone numbers are: +1 (515) + /// 123-4567, 1 515 123 4567 and +966 121 5115 24 7 551 1234 43 + /// The extension of the + /// customer service number of the publisher. Only digits are allowed + /// and number of digits should not exceed 10. + /// The extension of the customer + /// service URI of the publisher. + /// URI of the partner website that can be used + /// by Azure customers to setup Event Grid + /// integration on an event source. + /// URI of the logo. + /// Visibility state of the partner + /// registration. Possible values include: 'Hidden', 'PublicPreview', + /// 'GenerallyAvailable' + /// List of Azure + /// subscription Ids that are authorized to create a partner namespace + /// associated with this partner registration. This is an optional + /// property. Creating + /// partner namespaces is always permitted under the same Azure + /// subscription as the one used + /// for creating the partner registration. + /// The system metadata relating to this + /// resource. + public PartnerRegistration(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string provisioningState = default(string), string partnerName = default(string), string partnerResourceTypeName = default(string), string partnerResourceTypeDisplayName = default(string), string partnerResourceTypeDescription = default(string), string longDescription = default(string), string partnerCustomerServiceNumber = default(string), string partnerCustomerServiceExtension = default(string), string customerServiceUri = default(string), string setupUri = default(string), string logoUri = default(string), string visibilityState = default(string), IList authorizedAzureSubscriptionIds = default(IList), SystemData systemData = default(SystemData)) + : base(location, id, name, type, tags) + { + ProvisioningState = provisioningState; + PartnerName = partnerName; + PartnerResourceTypeName = partnerResourceTypeName; + PartnerResourceTypeDisplayName = partnerResourceTypeDisplayName; + PartnerResourceTypeDescription = partnerResourceTypeDescription; + LongDescription = longDescription; + PartnerCustomerServiceNumber = partnerCustomerServiceNumber; + PartnerCustomerServiceExtension = partnerCustomerServiceExtension; + CustomerServiceUri = customerServiceUri; + SetupUri = setupUri; + LogoUri = logoUri; + VisibilityState = visibilityState; + AuthorizedAzureSubscriptionIds = authorizedAzureSubscriptionIds; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets provisioning state of the partner registration. Possible + /// values include: 'Creating', 'Updating', 'Deleting', 'Succeeded', + /// 'Canceled', 'Failed' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets official name of the partner name. For example: + /// "Contoso". + /// + [JsonProperty(PropertyName = "properties.partnerName")] + public string PartnerName { get; set; } + + /// + /// Gets or sets name of the partner resource type. + /// + [JsonProperty(PropertyName = "properties.partnerResourceTypeName")] + public string PartnerResourceTypeName { get; set; } + + /// + /// Gets or sets display name of the partner resource type. + /// + [JsonProperty(PropertyName = "properties.partnerResourceTypeDisplayName")] + public string PartnerResourceTypeDisplayName { get; set; } + + /// + /// Gets or sets short description of the partner resource type. The + /// length of this description should not exceed 256 characters. + /// + [JsonProperty(PropertyName = "properties.partnerResourceTypeDescription")] + public string PartnerResourceTypeDescription { get; set; } + + /// + /// Gets or sets long description for the custom scenarios and + /// integration to be displayed in the portal if needed. + /// Length of this description should not exceed 2048 characters. + /// + [JsonProperty(PropertyName = "properties.longDescription")] + public string LongDescription { get; set; } + + /// + /// Gets or sets the customer service number of the publisher. The + /// expected phone format should start with a '+' sign + /// followed by the country code. The remaining digits are then + /// followed. Only digits and spaces are allowed and its + /// length cannot exceed 16 digits including country code. Examples of + /// valid phone numbers are: +1 515 123 4567 and + /// +966 7 5115 2471. Examples of invalid phone numbers are: +1 (515) + /// 123-4567, 1 515 123 4567 and +966 121 5115 24 7 551 1234 43 + /// + [JsonProperty(PropertyName = "properties.partnerCustomerServiceNumber")] + public string PartnerCustomerServiceNumber { get; set; } + + /// + /// Gets or sets the extension of the customer service number of the + /// publisher. Only digits are allowed and number of digits should not + /// exceed 10. + /// + [JsonProperty(PropertyName = "properties.partnerCustomerServiceExtension")] + public string PartnerCustomerServiceExtension { get; set; } + + /// + /// Gets or sets the extension of the customer service URI of the + /// publisher. + /// + [JsonProperty(PropertyName = "properties.customerServiceUri")] + public string CustomerServiceUri { get; set; } + + /// + /// Gets or sets URI of the partner website that can be used by Azure + /// customers to setup Event Grid + /// integration on an event source. + /// + [JsonProperty(PropertyName = "properties.setupUri")] + public string SetupUri { get; set; } + + /// + /// Gets or sets URI of the logo. + /// + [JsonProperty(PropertyName = "properties.logoUri")] + public string LogoUri { get; set; } + + /// + /// Gets or sets visibility state of the partner registration. Possible + /// values include: 'Hidden', 'PublicPreview', 'GenerallyAvailable' + /// + [JsonProperty(PropertyName = "properties.visibilityState")] + public string VisibilityState { get; set; } + + /// + /// Gets or sets list of Azure subscription Ids that are authorized to + /// create a partner namespace + /// associated with this partner registration. This is an optional + /// property. Creating + /// partner namespaces is always permitted under the same Azure + /// subscription as the one used + /// for creating the partner registration. + /// + [JsonProperty(PropertyName = "properties.authorizedAzureSubscriptionIds")] + public IList AuthorizedAzureSubscriptionIds { get; set; } + + /// + /// Gets the system metadata relating to this resource. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + } + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerRegistrationEventTypesListResult.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerRegistrationEventTypesListResult.cs new file mode 100644 index 000000000000..860e809317c4 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerRegistrationEventTypesListResult.cs @@ -0,0 +1,66 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Result of the List Partner Registration Event Types operation. + /// + public partial class PartnerRegistrationEventTypesListResult + { + /// + /// Initializes a new instance of the + /// PartnerRegistrationEventTypesListResult class. + /// + public PartnerRegistrationEventTypesListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// PartnerRegistrationEventTypesListResult class. + /// + /// A collection of partner registration event + /// types. + /// A link for the next page of partner + /// registration event types. + public PartnerRegistrationEventTypesListResult(IList value = default(IList), string nextLink = default(string)) + { + Value = value; + NextLink = nextLink; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a collection of partner registration event types. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + /// + /// Gets or sets a link for the next page of partner registration event + /// types. + /// + [JsonProperty(PropertyName = "nextLink")] + public string NextLink { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerRegistrationProvisioningState.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerRegistrationProvisioningState.cs new file mode 100644 index 000000000000..e08bf8afb566 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerRegistrationProvisioningState.cs @@ -0,0 +1,26 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + + /// + /// Defines values for PartnerRegistrationProvisioningState. + /// + public static class PartnerRegistrationProvisioningState + { + public const string Creating = "Creating"; + public const string Updating = "Updating"; + public const string Deleting = "Deleting"; + public const string Succeeded = "Succeeded"; + public const string Canceled = "Canceled"; + public const string Failed = "Failed"; + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerRegistrationUpdateParameters.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerRegistrationUpdateParameters.cs new file mode 100644 index 000000000000..5574b3a872f0 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerRegistrationUpdateParameters.cs @@ -0,0 +1,123 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Properties of the Partner Registration update. + /// + public partial class PartnerRegistrationUpdateParameters + { + /// + /// Initializes a new instance of the + /// PartnerRegistrationUpdateParameters class. + /// + public PartnerRegistrationUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// PartnerRegistrationUpdateParameters class. + /// + /// Tags of the partner registration + /// resource. + /// Name of the partner topic + /// type. + /// Display name of the + /// partner topic type. + /// Description of the + /// partner topic type. + /// URI of the partner website that can be used + /// by Azure customers to setup Event Grid + /// integration on an event source. + /// URI of the partner logo. + /// List of IDs of Azure + /// AD applications that are authorized to create a partner namespace + /// associated with this partner registration. This is an optional + /// property. Creating + /// partner namespaces is always permitted under the same Azure + /// subscription as the one used + /// for creating the partner registration. + public PartnerRegistrationUpdateParameters(IDictionary tags = default(IDictionary), string partnerTopicTypeName = default(string), string partnerTopicTypeDisplayName = default(string), string partnerTopicTypeDescription = default(string), string setupUri = default(string), string logoUri = default(string), IList authorizedAzureSubscriptionIds = default(IList)) + { + Tags = tags; + PartnerTopicTypeName = partnerTopicTypeName; + PartnerTopicTypeDisplayName = partnerTopicTypeDisplayName; + PartnerTopicTypeDescription = partnerTopicTypeDescription; + SetupUri = setupUri; + LogoUri = logoUri; + AuthorizedAzureSubscriptionIds = authorizedAzureSubscriptionIds; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets tags of the partner registration resource. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets name of the partner topic type. + /// + [JsonProperty(PropertyName = "partnerTopicTypeName")] + public string PartnerTopicTypeName { get; set; } + + /// + /// Gets or sets display name of the partner topic type. + /// + [JsonProperty(PropertyName = "partnerTopicTypeDisplayName")] + public string PartnerTopicTypeDisplayName { get; set; } + + /// + /// Gets or sets description of the partner topic type. + /// + [JsonProperty(PropertyName = "partnerTopicTypeDescription")] + public string PartnerTopicTypeDescription { get; set; } + + /// + /// Gets or sets URI of the partner website that can be used by Azure + /// customers to setup Event Grid + /// integration on an event source. + /// + [JsonProperty(PropertyName = "setupUri")] + public string SetupUri { get; set; } + + /// + /// Gets or sets URI of the partner logo. + /// + [JsonProperty(PropertyName = "logoUri")] + public string LogoUri { get; set; } + + /// + /// Gets or sets list of IDs of Azure AD applications that are + /// authorized to create a partner namespace + /// associated with this partner registration. This is an optional + /// property. Creating + /// partner namespaces is always permitted under the same Azure + /// subscription as the one used + /// for creating the partner registration. + /// + [JsonProperty(PropertyName = "authorizedAzureSubscriptionIds")] + public IList AuthorizedAzureSubscriptionIds { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerRegistrationVisibilityState.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerRegistrationVisibilityState.cs new file mode 100644 index 000000000000..7a4343c5fc7e --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerRegistrationVisibilityState.cs @@ -0,0 +1,23 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + + /// + /// Defines values for PartnerRegistrationVisibilityState. + /// + public static class PartnerRegistrationVisibilityState + { + public const string Hidden = "Hidden"; + public const string PublicPreview = "PublicPreview"; + public const string GenerallyAvailable = "GenerallyAvailable"; + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopic.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopic.cs new file mode 100644 index 000000000000..f2ce5ae3f574 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopic.cs @@ -0,0 +1,146 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// EventGrid Partner Topic. + /// + [Rest.Serialization.JsonTransformation] + public partial class PartnerTopic : TrackedResource + { + /// + /// Initializes a new instance of the PartnerTopic class. + /// + public PartnerTopic() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PartnerTopic class. + /// + /// Location of the resource. + /// Fully qualified identifier of the + /// resource. + /// Name of the resource. + /// Type of the resource. + /// Tags of the resource. + /// Source associated with this partner topic. + /// This represents a unique partner resource. + /// Expiration time of + /// the partner topic. If this timer expires while the partner topic is + /// still never activated, + /// the partner topic and corresponding event channel are + /// deleted. + /// Provisioning state of the partner + /// topic. Possible values include: 'Creating', 'Updating', 'Deleting', + /// 'Succeeded', 'Canceled', 'Failed' + /// Activation state of the partner + /// topic. Possible values include: 'NeverActivated', 'Activated', + /// 'Deactivated' + /// Friendly description + /// about the topic. This can be set by the publisher/partner to show + /// custom description for the customer partner topic. + /// This will be helpful to remove any ambiguity of the origin of + /// creation of the partner topic for the customer. + /// Identity information for the + /// resource. + /// The system metadata relating to this + /// resource. + public PartnerTopic(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string source = default(string), System.DateTime? expirationTimeIfNotActivatedUtc = default(System.DateTime?), string provisioningState = default(string), string activationState = default(string), string partnerTopicFriendlyDescription = default(string), IdentityInfo identity = default(IdentityInfo), SystemData systemData = default(SystemData)) + : base(location, id, name, type, tags) + { + Source = source; + ExpirationTimeIfNotActivatedUtc = expirationTimeIfNotActivatedUtc; + ProvisioningState = provisioningState; + ActivationState = activationState; + PartnerTopicFriendlyDescription = partnerTopicFriendlyDescription; + Identity = identity; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets source associated with this partner topic. This + /// represents a unique partner resource. + /// + [JsonProperty(PropertyName = "properties.source")] + public string Source { get; set; } + + /// + /// Gets or sets expiration time of the partner topic. If this timer + /// expires while the partner topic is still never activated, + /// the partner topic and corresponding event channel are deleted. + /// + [JsonProperty(PropertyName = "properties.expirationTimeIfNotActivatedUtc")] + public System.DateTime? ExpirationTimeIfNotActivatedUtc { get; set; } + + /// + /// Gets provisioning state of the partner topic. Possible values + /// include: 'Creating', 'Updating', 'Deleting', 'Succeeded', + /// 'Canceled', 'Failed' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets activation state of the partner topic. Possible values + /// include: 'NeverActivated', 'Activated', 'Deactivated' + /// + [JsonProperty(PropertyName = "properties.activationState")] + public string ActivationState { get; set; } + + /// + /// Gets or sets friendly description about the topic. This can be set + /// by the publisher/partner to show custom description for the + /// customer partner topic. + /// This will be helpful to remove any ambiguity of the origin of + /// creation of the partner topic for the customer. + /// + [JsonProperty(PropertyName = "properties.partnerTopicFriendlyDescription")] + public string PartnerTopicFriendlyDescription { get; set; } + + /// + /// Gets or sets identity information for the resource. + /// + [JsonProperty(PropertyName = "identity")] + public IdentityInfo Identity { get; set; } + + /// + /// Gets the system metadata relating to this resource. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + } + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicActivationState.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicActivationState.cs new file mode 100644 index 000000000000..da853a2b216c --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicActivationState.cs @@ -0,0 +1,23 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + + /// + /// Defines values for PartnerTopicActivationState. + /// + public static class PartnerTopicActivationState + { + public const string NeverActivated = "NeverActivated"; + public const string Activated = "Activated"; + public const string Deactivated = "Deactivated"; + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicProvisioningState.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicProvisioningState.cs new file mode 100644 index 000000000000..9eb90ce309ad --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicProvisioningState.cs @@ -0,0 +1,26 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + + /// + /// Defines values for PartnerTopicProvisioningState. + /// + public static class PartnerTopicProvisioningState + { + public const string Creating = "Creating"; + public const string Updating = "Updating"; + public const string Deleting = "Deleting"; + public const string Succeeded = "Succeeded"; + public const string Canceled = "Canceled"; + public const string Failed = "Failed"; + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicReadinessState.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicReadinessState.cs new file mode 100644 index 000000000000..2b4a5b43a492 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicReadinessState.cs @@ -0,0 +1,24 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + + /// + /// Defines values for PartnerTopicReadinessState. + /// + public static class PartnerTopicReadinessState + { + public const string NotActivatedByUserYet = "NotActivatedByUserYet"; + public const string ActivatedByUser = "ActivatedByUser"; + public const string DeactivatedByUser = "DeactivatedByUser"; + public const string DeletedByUser = "DeletedByUser"; + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicType.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicType.cs new file mode 100644 index 000000000000..c1391303d3ac --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicType.cs @@ -0,0 +1,113 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Properties of a partner topic type. + /// + [Rest.Serialization.JsonTransformation] + public partial class PartnerTopicType : Resource + { + /// + /// Initializes a new instance of the PartnerTopicType class. + /// + public PartnerTopicType() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PartnerTopicType class. + /// + /// Fully qualified identifier of the + /// resource. + /// Name of the resource. + /// Type of the resource. + /// Official name of the partner. + /// Name of the partner topic type. This + /// name should be unique among all partner topic types names. + /// Display Name for the partner topic + /// type. + /// Description of the partner topic + /// type. + /// URI of the partner website that can be used + /// by Azure customers to setup Event Grid + /// integration on an event source. + /// Status of whether the customer has + /// authorized a partner to create partner topics + /// in the customer's subscription. Possible values include: + /// 'NotApplicable', 'NotAuthorized', 'Authorized' + public PartnerTopicType(string id = default(string), string name = default(string), string type = default(string), string partnerName = default(string), string topicTypeName = default(string), string displayName = default(string), string description = default(string), string setupUri = default(string), string authorizationState = default(string)) + : base(id, name, type) + { + PartnerName = partnerName; + TopicTypeName = topicTypeName; + DisplayName = displayName; + Description = description; + SetupUri = setupUri; + AuthorizationState = authorizationState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets official name of the partner. + /// + [JsonProperty(PropertyName = "properties.partnerName")] + public string PartnerName { get; set; } + + /// + /// Gets or sets name of the partner topic type. This name should be + /// unique among all partner topic types names. + /// + [JsonProperty(PropertyName = "properties.topicTypeName")] + public string TopicTypeName { get; set; } + + /// + /// Gets or sets display Name for the partner topic type. + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets description of the partner topic type. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets URI of the partner website that can be used by Azure + /// customers to setup Event Grid + /// integration on an event source. + /// + [JsonProperty(PropertyName = "properties.setupUri")] + public string SetupUri { get; set; } + + /// + /// Gets or sets status of whether the customer has authorized a + /// partner to create partner topics + /// in the customer's subscription. Possible values include: + /// 'NotApplicable', 'NotAuthorized', 'Authorized' + /// + [JsonProperty(PropertyName = "properties.authorizationState")] + public string AuthorizationState { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicTypeAuthorizationState.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicTypeAuthorizationState.cs new file mode 100644 index 000000000000..48554203ed03 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicTypeAuthorizationState.cs @@ -0,0 +1,23 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + + /// + /// Defines values for PartnerTopicTypeAuthorizationState. + /// + public static class PartnerTopicTypeAuthorizationState + { + public const string NotApplicable = "NotApplicable"; + public const string NotAuthorized = "NotAuthorized"; + public const string Authorized = "Authorized"; + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicTypesListResult.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicTypesListResult.cs new file mode 100644 index 000000000000..712f3e05686c --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicTypesListResult.cs @@ -0,0 +1,55 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Result of the List Partner Topic Types operation. + /// + public partial class PartnerTopicTypesListResult + { + /// + /// Initializes a new instance of the PartnerTopicTypesListResult + /// class. + /// + public PartnerTopicTypesListResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PartnerTopicTypesListResult + /// class. + /// + /// A collection of partner topic types. + public PartnerTopicTypesListResult(IList value = default(IList)) + { + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a collection of partner topic types. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicUpdateParameters.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicUpdateParameters.cs new file mode 100644 index 000000000000..c682c8cfdb00 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicUpdateParameters.cs @@ -0,0 +1,55 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Properties of the Partner Topic update. + /// + public partial class PartnerTopicUpdateParameters + { + /// + /// Initializes a new instance of the PartnerTopicUpdateParameters + /// class. + /// + public PartnerTopicUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PartnerTopicUpdateParameters + /// class. + /// + /// Tags of the partner topic. + public PartnerTopicUpdateParameters(IDictionary tags = default(IDictionary)) + { + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets tags of the partner topic. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PrivateLinkResource.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PrivateLinkResource.cs index a3f3e56b602e..141807a9564a 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PrivateLinkResource.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PrivateLinkResource.cs @@ -36,8 +36,8 @@ public PrivateLinkResource() /// /// Fully qualified identifier of the /// resource. - /// Name of the resource - /// Type of the resource + /// Name of the resource. + /// Type of the resource. public PrivateLinkResource(string groupId = default(string), string displayName = default(string), IList requiredMembers = default(IList), IList requiredZoneNames = default(IList), string id = default(string), string name = default(string), string type = default(string)) { GroupId = groupId; @@ -82,13 +82,13 @@ public PrivateLinkResource() public string Id { get; set; } /// - /// Gets or sets name of the resource + /// Gets or sets name of the resource. /// [JsonProperty(PropertyName = "name")] public string Name { get; set; } /// - /// Gets or sets type of the resource + /// Gets or sets type of the resource. /// [JsonProperty(PropertyName = "type")] public string Type { get; set; } diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Resource.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Resource.cs index 641e05f45021..667f107b78d9 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Resource.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Resource.cs @@ -16,7 +16,7 @@ namespace Microsoft.Azure.Management.EventGrid.Models using System.Linq; /// - /// Definition of a Resource. + /// Definition of a Resource /// public partial class Resource : IResource { diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ResourceKind.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ResourceKind.cs new file mode 100644 index 000000000000..9b91794a16f1 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ResourceKind.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.EventGrid.Models +{ + + /// + /// Defines values for ResourceKind. + /// + public static class ResourceKind + { + public const string Azure = "Azure"; + public const string AzureArc = "AzureArc"; + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ResourceSku.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ResourceSku.cs new file mode 100644 index 000000000000..eb5add078805 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ResourceSku.cs @@ -0,0 +1,54 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Describes an EventGrid Resource Sku. + /// + public partial class ResourceSku + { + /// + /// Initializes a new instance of the ResourceSku class. + /// + public ResourceSku() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourceSku class. + /// + /// The Sku name of the resource. The possible + /// values are: Basic or Premium. Possible values include: 'Basic', + /// 'Premium' + public ResourceSku(string name = default(string)) + { + Name = name; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the Sku name of the resource. The possible values are: + /// Basic or Premium. Possible values include: 'Basic', 'Premium' + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ServiceBusQueueEventSubscriptionDestination.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ServiceBusQueueEventSubscriptionDestination.cs index d3cde149ce48..6d0009412ed2 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ServiceBusQueueEventSubscriptionDestination.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ServiceBusQueueEventSubscriptionDestination.cs @@ -13,6 +13,8 @@ namespace Microsoft.Azure.Management.EventGrid.Models using Microsoft.Rest; using Microsoft.Rest.Serialization; using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; using System.Linq; /// @@ -39,9 +41,12 @@ public ServiceBusQueueEventSubscriptionDestination() /// The Azure Resource Id that represents the /// endpoint of the Service Bus destination of an event /// subscription. - public ServiceBusQueueEventSubscriptionDestination(string resourceId = default(string)) + /// Delivery attribute + /// details. + public ServiceBusQueueEventSubscriptionDestination(string resourceId = default(string), IList deliveryAttributeMappings = default(IList)) { ResourceId = resourceId; + DeliveryAttributeMappings = deliveryAttributeMappings; CustomInit(); } @@ -57,5 +62,11 @@ public ServiceBusQueueEventSubscriptionDestination() [JsonProperty(PropertyName = "properties.resourceId")] public string ResourceId { get; set; } + /// + /// Gets or sets delivery attribute details. + /// + [JsonProperty(PropertyName = "properties.deliveryAttributeMappings")] + public IList DeliveryAttributeMappings { get; set; } + } } diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ServiceBusTopicEventSubscriptionDestination.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ServiceBusTopicEventSubscriptionDestination.cs index 30f7bfdb5a6a..df5b42b1679c 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ServiceBusTopicEventSubscriptionDestination.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ServiceBusTopicEventSubscriptionDestination.cs @@ -13,6 +13,8 @@ namespace Microsoft.Azure.Management.EventGrid.Models using Microsoft.Rest; using Microsoft.Rest.Serialization; using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; using System.Linq; /// @@ -39,9 +41,12 @@ public ServiceBusTopicEventSubscriptionDestination() /// The Azure Resource Id that represents the /// endpoint of the Service Bus Topic destination of an event /// subscription. - public ServiceBusTopicEventSubscriptionDestination(string resourceId = default(string)) + /// Delivery attribute + /// details. + public ServiceBusTopicEventSubscriptionDestination(string resourceId = default(string), IList deliveryAttributeMappings = default(IList)) { ResourceId = resourceId; + DeliveryAttributeMappings = deliveryAttributeMappings; CustomInit(); } @@ -57,5 +62,11 @@ public ServiceBusTopicEventSubscriptionDestination() [JsonProperty(PropertyName = "properties.resourceId")] public string ResourceId { get; set; } + /// + /// Gets or sets delivery attribute details. + /// + [JsonProperty(PropertyName = "properties.deliveryAttributeMappings")] + public IList DeliveryAttributeMappings { get; set; } + } } diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Sku.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Sku.cs new file mode 100644 index 000000000000..7edc81720014 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Sku.cs @@ -0,0 +1,22 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.EventGrid.Models +{ + + /// + /// Defines values for Sku. + /// + public static class Sku + { + public const string Basic = "Basic"; + public const string Premium = "Premium"; + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/StaticDeliveryAttributeMapping.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/StaticDeliveryAttributeMapping.cs new file mode 100644 index 000000000000..27b4d74b7ed1 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/StaticDeliveryAttributeMapping.cs @@ -0,0 +1,70 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Static delivery attribute mapping details. + /// + [Newtonsoft.Json.JsonObject("Static")] + [Rest.Serialization.JsonTransformation] + public partial class StaticDeliveryAttributeMapping : DeliveryAttributeMapping + { + /// + /// Initializes a new instance of the StaticDeliveryAttributeMapping + /// class. + /// + public StaticDeliveryAttributeMapping() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the StaticDeliveryAttributeMapping + /// class. + /// + /// Name of the delivery attribute or + /// header. + /// Value of the delivery attribute. + /// Boolean flag to tell if the attribute + /// contains sensitive information . + public StaticDeliveryAttributeMapping(string name = default(string), string value = default(string), bool? isSecret = default(bool?)) + : base(name) + { + Value = value; + IsSecret = isSecret; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets value of the delivery attribute. + /// + [JsonProperty(PropertyName = "properties.value")] + public string Value { get; set; } + + /// + /// Gets or sets boolean flag to tell if the attribute contains + /// sensitive information . + /// + [JsonProperty(PropertyName = "properties.isSecret")] + public bool? IsSecret { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/StorageQueueEventSubscriptionDestination.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/StorageQueueEventSubscriptionDestination.cs index d4ef3196b932..a861d82846e2 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/StorageQueueEventSubscriptionDestination.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/StorageQueueEventSubscriptionDestination.cs @@ -42,10 +42,13 @@ public StorageQueueEventSubscriptionDestination() /// The name of the Storage queue under a /// storage account that is the destination of an event /// subscription. - public StorageQueueEventSubscriptionDestination(string resourceId = default(string), string queueName = default(string)) + /// Storage queue message + /// time to live in seconds. + public StorageQueueEventSubscriptionDestination(string resourceId = default(string), string queueName = default(string), long? queueMessageTimeToLiveInSeconds = default(long?)) { ResourceId = resourceId; QueueName = queueName; + QueueMessageTimeToLiveInSeconds = queueMessageTimeToLiveInSeconds; CustomInit(); } @@ -69,5 +72,11 @@ public StorageQueueEventSubscriptionDestination() [JsonProperty(PropertyName = "properties.queueName")] public string QueueName { get; set; } + /// + /// Gets or sets storage queue message time to live in seconds. + /// + [JsonProperty(PropertyName = "properties.queueMessageTimeToLiveInSeconds")] + public long? QueueMessageTimeToLiveInSeconds { get; set; } + } } diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/StringNotBeginsWithAdvancedFilter.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/StringNotBeginsWithAdvancedFilter.cs new file mode 100644 index 000000000000..d955bdea9798 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/StringNotBeginsWithAdvancedFilter.cs @@ -0,0 +1,59 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// StringNotBeginsWith Advanced Filter. + /// + [Newtonsoft.Json.JsonObject("StringNotBeginsWith")] + public partial class StringNotBeginsWithAdvancedFilter : AdvancedFilter + { + /// + /// Initializes a new instance of the StringNotBeginsWithAdvancedFilter + /// class. + /// + public StringNotBeginsWithAdvancedFilter() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the StringNotBeginsWithAdvancedFilter + /// class. + /// + /// The field/property in the event based on which + /// you want to filter. + /// The set of filter values. + public StringNotBeginsWithAdvancedFilter(string key = default(string), IList values = default(IList)) + : base(key) + { + Values = values; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the set of filter values. + /// + [JsonProperty(PropertyName = "values")] + public IList Values { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/StringNotContainsAdvancedFilter.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/StringNotContainsAdvancedFilter.cs new file mode 100644 index 000000000000..d388ad51614a --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/StringNotContainsAdvancedFilter.cs @@ -0,0 +1,59 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// StringNotContains Advanced Filter. + /// + [Newtonsoft.Json.JsonObject("StringNotContains")] + public partial class StringNotContainsAdvancedFilter : AdvancedFilter + { + /// + /// Initializes a new instance of the StringNotContainsAdvancedFilter + /// class. + /// + public StringNotContainsAdvancedFilter() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the StringNotContainsAdvancedFilter + /// class. + /// + /// The field/property in the event based on which + /// you want to filter. + /// The set of filter values. + public StringNotContainsAdvancedFilter(string key = default(string), IList values = default(IList)) + : base(key) + { + Values = values; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the set of filter values. + /// + [JsonProperty(PropertyName = "values")] + public IList Values { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/StringNotEndsWithAdvancedFilter.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/StringNotEndsWithAdvancedFilter.cs new file mode 100644 index 000000000000..0190c9d4499e --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/StringNotEndsWithAdvancedFilter.cs @@ -0,0 +1,59 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// StringNotEndsWith Advanced Filter. + /// + [Newtonsoft.Json.JsonObject("StringNotEndsWith")] + public partial class StringNotEndsWithAdvancedFilter : AdvancedFilter + { + /// + /// Initializes a new instance of the StringNotEndsWithAdvancedFilter + /// class. + /// + public StringNotEndsWithAdvancedFilter() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the StringNotEndsWithAdvancedFilter + /// class. + /// + /// The field/property in the event based on which + /// you want to filter. + /// The set of filter values. + public StringNotEndsWithAdvancedFilter(string key = default(string), IList values = default(IList)) + : base(key) + { + Values = values; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the set of filter values. + /// + [JsonProperty(PropertyName = "values")] + public IList Values { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/SystemData.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/SystemData.cs new file mode 100644 index 000000000000..6c7dc716171c --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/SystemData.cs @@ -0,0 +1,103 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Metadata pertaining to creation and last modification of the resource. + /// + public partial class SystemData + { + /// + /// Initializes a new instance of the SystemData class. + /// + public SystemData() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SystemData class. + /// + /// The identity that created the + /// resource. + /// The type of identity that created the + /// resource. Possible values include: 'User', 'Application', + /// 'ManagedIdentity', 'Key' + /// The timestamp of resource creation + /// (UTC). + /// The identity that last modified the + /// resource. + /// The type of identity that last + /// modified the resource. Possible values include: 'User', + /// 'Application', 'ManagedIdentity', 'Key' + /// The timestamp of resource last + /// modification (UTC) + public SystemData(string createdBy = default(string), string createdByType = default(string), System.DateTime? createdAt = default(System.DateTime?), string lastModifiedBy = default(string), string lastModifiedByType = default(string), System.DateTime? lastModifiedAt = default(System.DateTime?)) + { + CreatedBy = createdBy; + CreatedByType = createdByType; + CreatedAt = createdAt; + LastModifiedBy = lastModifiedBy; + LastModifiedByType = lastModifiedByType; + LastModifiedAt = lastModifiedAt; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the identity that created the resource. + /// + [JsonProperty(PropertyName = "createdBy")] + public string CreatedBy { get; set; } + + /// + /// Gets or sets the type of identity that created the resource. + /// Possible values include: 'User', 'Application', 'ManagedIdentity', + /// 'Key' + /// + [JsonProperty(PropertyName = "createdByType")] + public string CreatedByType { get; set; } + + /// + /// Gets or sets the timestamp of resource creation (UTC). + /// + [JsonProperty(PropertyName = "createdAt")] + public System.DateTime? CreatedAt { get; set; } + + /// + /// Gets or sets the identity that last modified the resource. + /// + [JsonProperty(PropertyName = "lastModifiedBy")] + public string LastModifiedBy { get; set; } + + /// + /// Gets or sets the type of identity that last modified the resource. + /// Possible values include: 'User', 'Application', 'ManagedIdentity', + /// 'Key' + /// + [JsonProperty(PropertyName = "lastModifiedByType")] + public string LastModifiedByType { get; set; } + + /// + /// Gets or sets the timestamp of resource last modification (UTC) + /// + [JsonProperty(PropertyName = "lastModifiedAt")] + public System.DateTime? LastModifiedAt { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/SystemTopic.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/SystemTopic.cs new file mode 100644 index 000000000000..2f030cd064e2 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/SystemTopic.cs @@ -0,0 +1,120 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// EventGrid System Topic. + /// + [Rest.Serialization.JsonTransformation] + public partial class SystemTopic : TrackedResource + { + /// + /// Initializes a new instance of the SystemTopic class. + /// + public SystemTopic() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SystemTopic class. + /// + /// Location of the resource. + /// Fully qualified identifier of the + /// resource. + /// Name of the resource. + /// Type of the resource. + /// Tags of the resource. + /// Provisioning state of the system + /// topic. Possible values include: 'Creating', 'Updating', 'Deleting', + /// 'Succeeded', 'Canceled', 'Failed' + /// Source for the system topic. + /// TopicType for the system topic. + /// Metric resource id for the system + /// topic. + /// Identity information for the + /// resource. + /// The system metadata relating to this + /// resource. + public SystemTopic(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string provisioningState = default(string), string source = default(string), string topicType = default(string), string metricResourceId = default(string), IdentityInfo identity = default(IdentityInfo), SystemData systemData = default(SystemData)) + : base(location, id, name, type, tags) + { + ProvisioningState = provisioningState; + Source = source; + TopicType = topicType; + MetricResourceId = metricResourceId; + Identity = identity; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets provisioning state of the system topic. Possible values + /// include: 'Creating', 'Updating', 'Deleting', 'Succeeded', + /// 'Canceled', 'Failed' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets source for the system topic. + /// + [JsonProperty(PropertyName = "properties.source")] + public string Source { get; set; } + + /// + /// Gets or sets topicType for the system topic. + /// + [JsonProperty(PropertyName = "properties.topicType")] + public string TopicType { get; set; } + + /// + /// Gets metric resource id for the system topic. + /// + [JsonProperty(PropertyName = "properties.metricResourceId")] + public string MetricResourceId { get; private set; } + + /// + /// Gets or sets identity information for the resource. + /// + [JsonProperty(PropertyName = "identity")] + public IdentityInfo Identity { get; set; } + + /// + /// Gets the system metadata relating to this resource. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + } + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/SystemTopicUpdateParameters.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/SystemTopicUpdateParameters.cs new file mode 100644 index 000000000000..7109dc732ce6 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/SystemTopicUpdateParameters.cs @@ -0,0 +1,63 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Properties of the System Topic update. + /// + public partial class SystemTopicUpdateParameters + { + /// + /// Initializes a new instance of the SystemTopicUpdateParameters + /// class. + /// + public SystemTopicUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SystemTopicUpdateParameters + /// class. + /// + /// Tags of the system topic. + /// Resource identity information. + public SystemTopicUpdateParameters(IDictionary tags = default(IDictionary), IdentityInfo identity = default(IdentityInfo)) + { + Tags = tags; + Identity = identity; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets tags of the system topic. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets resource identity information. + /// + [JsonProperty(PropertyName = "identity")] + public IdentityInfo Identity { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Topic.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Topic.cs index d22682e62e0c..df2db31f6f96 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Topic.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Topic.cs @@ -62,7 +62,14 @@ public Topic() /// This can be used to restrict traffic /// from specific IPs instead of all IPs. Note: These are considered /// only if PublicNetworkAccess is enabled. - public Topic(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), IList privateEndpointConnections = default(IList), string provisioningState = default(string), string endpoint = default(string), string inputSchema = default(string), InputSchemaMapping inputSchemaMapping = default(InputSchemaMapping), string metricResourceId = default(string), string publicNetworkAccess = default(string), IList inboundIpRules = default(IList)) + /// The Sku pricing tier for the topic. + /// Identity information for the + /// resource. + /// Kind of the resource. Possible values include: + /// 'Azure', 'AzureArc' + /// Extended location of the + /// resource. + public Topic(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), IList privateEndpointConnections = default(IList), string provisioningState = default(string), string endpoint = default(string), string inputSchema = default(string), InputSchemaMapping inputSchemaMapping = default(InputSchemaMapping), string metricResourceId = default(string), string publicNetworkAccess = default(string), IList inboundIpRules = default(IList), ResourceSku sku = default(ResourceSku), IdentityInfo identity = default(IdentityInfo), string kind = default(string), ExtendedLocation extendedLocation = default(ExtendedLocation)) : base(location, id, name, type, tags) { PrivateEndpointConnections = privateEndpointConnections; @@ -73,6 +80,10 @@ public Topic() MetricResourceId = metricResourceId; PublicNetworkAccess = publicNetworkAccess; InboundIpRules = inboundIpRules; + Sku = sku; + Identity = identity; + Kind = kind; + ExtendedLocation = extendedLocation; CustomInit(); } @@ -143,6 +154,31 @@ public Topic() [JsonProperty(PropertyName = "properties.inboundIpRules")] public IList InboundIpRules { get; set; } + /// + /// Gets or sets the Sku pricing tier for the topic. + /// + [JsonProperty(PropertyName = "sku")] + public ResourceSku Sku { get; set; } + + /// + /// Gets or sets identity information for the resource. + /// + [JsonProperty(PropertyName = "identity")] + public IdentityInfo Identity { get; set; } + + /// + /// Gets or sets kind of the resource. Possible values include: + /// 'Azure', 'AzureArc' + /// + [JsonProperty(PropertyName = "kind")] + public string Kind { get; set; } + + /// + /// Gets or sets extended location of the resource. + /// + [JsonProperty(PropertyName = "extendedLocation")] + public ExtendedLocation ExtendedLocation { get; set; } + /// /// Validate the object. /// diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/TopicTypeInfo.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/TopicTypeInfo.cs index 2ebf9ab30e0e..34164e95fd70 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/TopicTypeInfo.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/TopicTypeInfo.cs @@ -51,7 +51,9 @@ public TopicTypeInfo() /// List of locations supported by /// this topic type. /// Source resource format. - public TopicTypeInfo(string id = default(string), string name = default(string), string type = default(string), string provider = default(string), string displayName = default(string), string description = default(string), string resourceRegionType = default(string), string provisioningState = default(string), IList supportedLocations = default(IList), string sourceResourceFormat = default(string)) + /// Supported source + /// scopes. + public TopicTypeInfo(string id = default(string), string name = default(string), string type = default(string), string provider = default(string), string displayName = default(string), string description = default(string), string resourceRegionType = default(string), string provisioningState = default(string), IList supportedLocations = default(IList), string sourceResourceFormat = default(string), IList supportedScopesForSource = default(IList)) : base(id, name, type) { Provider = provider; @@ -61,6 +63,7 @@ public TopicTypeInfo() ProvisioningState = provisioningState; SupportedLocations = supportedLocations; SourceResourceFormat = sourceResourceFormat; + SupportedScopesForSource = supportedScopesForSource; CustomInit(); } @@ -114,5 +117,11 @@ public TopicTypeInfo() [JsonProperty(PropertyName = "properties.sourceResourceFormat")] public string SourceResourceFormat { get; set; } + /// + /// Gets or sets supported source scopes. + /// + [JsonProperty(PropertyName = "properties.supportedScopesForSource")] + public IList SupportedScopesForSource { get; set; } + } } diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/TopicUpdateParameters.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/TopicUpdateParameters.cs index 268ac9df3efb..2335d02c40c4 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/TopicUpdateParameters.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/TopicUpdateParameters.cs @@ -35,6 +35,7 @@ public TopicUpdateParameters() /// Initializes a new instance of the TopicUpdateParameters class. /// /// Tags of the resource. + /// Resource identity information. /// This determines if traffic is /// allowed over public network. By default it is enabled. /// You can further restrict to specific IPs by configuring <seealso @@ -43,11 +44,14 @@ public TopicUpdateParameters() /// This can be used to restrict traffic /// from specific IPs instead of all IPs. Note: These are considered /// only if PublicNetworkAccess is enabled. - public TopicUpdateParameters(IDictionary tags = default(IDictionary), string publicNetworkAccess = default(string), IList inboundIpRules = default(IList)) + /// The Sku pricing tier for the topic. + public TopicUpdateParameters(IDictionary tags = default(IDictionary), IdentityInfo identity = default(IdentityInfo), string publicNetworkAccess = default(string), IList inboundIpRules = default(IList), ResourceSku sku = default(ResourceSku)) { Tags = tags; + Identity = identity; PublicNetworkAccess = publicNetworkAccess; InboundIpRules = inboundIpRules; + Sku = sku; CustomInit(); } @@ -62,6 +66,12 @@ public TopicUpdateParameters() [JsonProperty(PropertyName = "tags")] public IDictionary Tags { get; set; } + /// + /// Gets or sets resource identity information. + /// + [JsonProperty(PropertyName = "identity")] + public IdentityInfo Identity { get; set; } + /// /// Gets or sets this determines if traffic is allowed over public /// network. By default it is enabled. @@ -81,5 +91,11 @@ public TopicUpdateParameters() [JsonProperty(PropertyName = "properties.inboundIpRules")] public IList InboundIpRules { get; set; } + /// + /// Gets or sets the Sku pricing tier for the topic. + /// + [JsonProperty(PropertyName = "sku")] + public ResourceSku Sku { get; set; } + } } diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/UserIdentityProperties.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/UserIdentityProperties.cs new file mode 100644 index 000000000000..5fdc4d4ddd9d --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/UserIdentityProperties.cs @@ -0,0 +1,61 @@ +// +// 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 Microsoft.Azure.Management.EventGrid.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The information about the user identity. + /// + public partial class UserIdentityProperties + { + /// + /// Initializes a new instance of the UserIdentityProperties class. + /// + public UserIdentityProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the UserIdentityProperties class. + /// + /// The principal id of user assigned + /// identity. + /// The client id of user assigned + /// identity. + public UserIdentityProperties(string principalId = default(string), string clientId = default(string)) + { + PrincipalId = principalId; + ClientId = clientId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the principal id of user assigned identity. + /// + [JsonProperty(PropertyName = "principalId")] + public string PrincipalId { get; set; } + + /// + /// Gets or sets the client id of user assigned identity. + /// + [JsonProperty(PropertyName = "clientId")] + public string ClientId { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/WebHookEventSubscriptionDestination.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/WebHookEventSubscriptionDestination.cs index fb95c06fe24f..ffe074154d2b 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/WebHookEventSubscriptionDestination.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/WebHookEventSubscriptionDestination.cs @@ -13,6 +13,8 @@ namespace Microsoft.Azure.Management.EventGrid.Models using Microsoft.Rest; using Microsoft.Rest.Serialization; using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; using System.Linq; /// @@ -49,7 +51,9 @@ public WebHookEventSubscriptionDestination() /// The Azure /// Active Directory Application ID or URI to get the access token that /// will be included as the bearer token in delivery requests. - public WebHookEventSubscriptionDestination(string endpointUrl = default(string), string endpointBaseUrl = default(string), int? maxEventsPerBatch = default(int?), int? preferredBatchSizeInKilobytes = default(int?), string azureActiveDirectoryTenantId = default(string), string azureActiveDirectoryApplicationIdOrUri = default(string)) + /// Delivery attribute + /// details. + public WebHookEventSubscriptionDestination(string endpointUrl = default(string), string endpointBaseUrl = default(string), int? maxEventsPerBatch = default(int?), int? preferredBatchSizeInKilobytes = default(int?), string azureActiveDirectoryTenantId = default(string), string azureActiveDirectoryApplicationIdOrUri = default(string), IList deliveryAttributeMappings = default(IList)) { EndpointUrl = endpointUrl; EndpointBaseUrl = endpointBaseUrl; @@ -57,6 +61,7 @@ public WebHookEventSubscriptionDestination() PreferredBatchSizeInKilobytes = preferredBatchSizeInKilobytes; AzureActiveDirectoryTenantId = azureActiveDirectoryTenantId; AzureActiveDirectoryApplicationIdOrUri = azureActiveDirectoryApplicationIdOrUri; + DeliveryAttributeMappings = deliveryAttributeMappings; CustomInit(); } @@ -107,5 +112,11 @@ public WebHookEventSubscriptionDestination() [JsonProperty(PropertyName = "properties.azureActiveDirectoryApplicationIdOrUri")] public string AzureActiveDirectoryApplicationIdOrUri { get; set; } + /// + /// Gets or sets delivery attribute details. + /// + [JsonProperty(PropertyName = "properties.deliveryAttributeMappings")] + public IList DeliveryAttributeMappings { get; set; } + } } diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerNamespacesOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerNamespacesOperations.cs new file mode 100644 index 000000000000..224ea6bfa48d --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerNamespacesOperations.cs @@ -0,0 +1,2133 @@ +// +// 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 Microsoft.Azure.Management.EventGrid +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PartnerNamespacesOperations operations. + /// + internal partial class PartnerNamespacesOperations : IServiceOperations, IPartnerNamespacesOperations + { + /// + /// Initializes a new instance of the PartnerNamespacesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PartnerNamespacesOperations(EventGridManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the EventGridManagementClient + /// + public EventGridManagementClient Client { get; private set; } + + /// + /// Get a partner namespace. + /// + /// + /// Get properties of a partner namespace. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// 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> GetWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerNamespaceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerNamespaceName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerNamespaceName", partnerNamespaceName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerNamespaceName}", System.Uri.EscapeDataString(partnerNamespaceName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create a partner namespace. + /// + /// + /// Asynchronously creates a new partner namespace with the specified + /// parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// PartnerNamespace information. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, PartnerNamespace partnerNamespaceInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, partnerNamespaceInfo, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Delete a partner namespace. + /// + /// + /// Delete existing partner namespace. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Update a partner namespace. + /// + /// + /// Asynchronously updates a partner namespace with the specified parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Tags of the partner namespace. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, tags, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// List partner namespaces under an Azure subscription. + /// + /// + /// List all the partner namespaces under an Azure subscription. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + /// + /// 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>> ListBySubscriptionWithHttpMessagesAsync(string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("filter", filter); + tracingParameters.Add("top", top); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerNamespaces").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List partner namespaces under a resource group. + /// + /// + /// List all the partner namespaces under a resource group. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + /// + /// 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("filter", filter); + tracingParameters.Add("top", top); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List keys for a partner namespace. + /// + /// + /// List the two keys used to publish to a partner namespace. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// 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> ListSharedAccessKeysWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerNamespaceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerNamespaceName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerNamespaceName", partnerNamespaceName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListSharedAccessKeys", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/listKeys").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerNamespaceName}", System.Uri.EscapeDataString(partnerNamespaceName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Regenerate key for a partner namespace. + /// + /// + /// Regenerate a shared access key for a partner namespace. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Key name to regenerate (key1 or key2). + /// + /// + /// 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> RegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, string keyName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerNamespaceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerNamespaceName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (keyName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "keyName"); + } + PartnerNamespaceRegenerateKeyRequest regenerateKeyRequest = new PartnerNamespaceRegenerateKeyRequest(); + if (keyName != null) + { + regenerateKeyRequest.KeyName = keyName; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerNamespaceName", partnerNamespaceName); + tracingParameters.Add("regenerateKeyRequest", regenerateKeyRequest); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "RegenerateKey", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/regenerateKey").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerNamespaceName}", System.Uri.EscapeDataString(partnerNamespaceName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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(regenerateKeyRequest != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(regenerateKeyRequest, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create a partner namespace. + /// + /// + /// Asynchronously creates a new partner namespace with the specified + /// parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// PartnerNamespace information. + /// + /// + /// 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> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, PartnerNamespace partnerNamespaceInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerNamespaceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerNamespaceName"); + } + if (partnerNamespaceInfo == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerNamespaceInfo"); + } + if (partnerNamespaceInfo != null) + { + partnerNamespaceInfo.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerNamespaceName", partnerNamespaceName); + tracingParameters.Add("partnerNamespaceInfo", partnerNamespaceInfo); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerNamespaceName}", System.Uri.EscapeDataString(partnerNamespaceName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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(partnerNamespaceInfo != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(partnerNamespaceInfo, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete a partner namespace. + /// + /// + /// Delete existing partner namespace. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// 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 BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerNamespaceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerNamespaceName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerNamespaceName", partnerNamespaceName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerNamespaceName}", System.Uri.EscapeDataString(partnerNamespaceName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update a partner namespace. + /// + /// + /// Asynchronously updates a partner namespace with the specified parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Tags of the partner namespace. + /// + /// + /// 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> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerNamespaceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerNamespaceName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + PartnerNamespaceUpdateParameters partnerNamespaceUpdateParameters = new PartnerNamespaceUpdateParameters(); + if (tags != null) + { + partnerNamespaceUpdateParameters.Tags = tags; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerNamespaceName", partnerNamespaceName); + tracingParameters.Add("partnerNamespaceUpdateParameters", partnerNamespaceUpdateParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerNamespaceName}", System.Uri.EscapeDataString(partnerNamespaceName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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(partnerNamespaceUpdateParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(partnerNamespaceUpdateParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List partner namespaces under an Azure subscription. + /// + /// + /// List all the partner namespaces under an Azure subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// 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>> ListBySubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySubscriptionNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List partner namespaces under a resource group. + /// + /// + /// List all the partner namespaces under a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// 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>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroupNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerNamespacesOperationsExtensions.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerNamespacesOperationsExtensions.cs new file mode 100644 index 000000000000..37c6fe07f35a --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerNamespacesOperationsExtensions.cs @@ -0,0 +1,679 @@ +// +// 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 Microsoft.Azure.Management.EventGrid +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PartnerNamespacesOperations. + /// + public static partial class PartnerNamespacesOperationsExtensions + { + /// + /// Get a partner namespace. + /// + /// + /// Get properties of a partner namespace. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + public static PartnerNamespace Get(this IPartnerNamespacesOperations operations, string resourceGroupName, string partnerNamespaceName) + { + return operations.GetAsync(resourceGroupName, partnerNamespaceName).GetAwaiter().GetResult(); + } + + /// + /// Get a partner namespace. + /// + /// + /// Get properties of a partner namespace. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPartnerNamespacesOperations operations, string resourceGroupName, string partnerNamespaceName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create a partner namespace. + /// + /// + /// Asynchronously creates a new partner namespace with the specified + /// parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// PartnerNamespace information. + /// + public static PartnerNamespace CreateOrUpdate(this IPartnerNamespacesOperations operations, string resourceGroupName, string partnerNamespaceName, PartnerNamespace partnerNamespaceInfo) + { + return operations.CreateOrUpdateAsync(resourceGroupName, partnerNamespaceName, partnerNamespaceInfo).GetAwaiter().GetResult(); + } + + /// + /// Create a partner namespace. + /// + /// + /// Asynchronously creates a new partner namespace with the specified + /// parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// PartnerNamespace information. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IPartnerNamespacesOperations operations, string resourceGroupName, string partnerNamespaceName, PartnerNamespace partnerNamespaceInfo, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, partnerNamespaceInfo, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete a partner namespace. + /// + /// + /// Delete existing partner namespace. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + public static void Delete(this IPartnerNamespacesOperations operations, string resourceGroupName, string partnerNamespaceName) + { + operations.DeleteAsync(resourceGroupName, partnerNamespaceName).GetAwaiter().GetResult(); + } + + /// + /// Delete a partner namespace. + /// + /// + /// Delete existing partner namespace. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IPartnerNamespacesOperations operations, string resourceGroupName, string partnerNamespaceName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update a partner namespace. + /// + /// + /// Asynchronously updates a partner namespace with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Tags of the partner namespace. + /// + public static PartnerNamespace Update(this IPartnerNamespacesOperations operations, string resourceGroupName, string partnerNamespaceName, IDictionary tags = default(IDictionary)) + { + return operations.UpdateAsync(resourceGroupName, partnerNamespaceName, tags).GetAwaiter().GetResult(); + } + + /// + /// Update a partner namespace. + /// + /// + /// Asynchronously updates a partner namespace with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Tags of the partner namespace. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IPartnerNamespacesOperations operations, string resourceGroupName, string partnerNamespaceName, IDictionary tags = default(IDictionary), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, tags, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List partner namespaces under an Azure subscription. + /// + /// + /// List all the partner namespaces under an Azure subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + public static IPage ListBySubscription(this IPartnerNamespacesOperations operations, string filter = default(string), int? top = default(int?)) + { + return operations.ListBySubscriptionAsync(filter, top).GetAwaiter().GetResult(); + } + + /// + /// List partner namespaces under an Azure subscription. + /// + /// + /// List all the partner namespaces under an Azure subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionAsync(this IPartnerNamespacesOperations operations, string filter = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(filter, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List partner namespaces under a resource group. + /// + /// + /// List all the partner namespaces under a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + public static IPage ListByResourceGroup(this IPartnerNamespacesOperations operations, string resourceGroupName, string filter = default(string), int? top = default(int?)) + { + return operations.ListByResourceGroupAsync(resourceGroupName, filter, top).GetAwaiter().GetResult(); + } + + /// + /// List partner namespaces under a resource group. + /// + /// + /// List all the partner namespaces under a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IPartnerNamespacesOperations operations, string resourceGroupName, string filter = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, filter, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List keys for a partner namespace. + /// + /// + /// List the two keys used to publish to a partner namespace. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + public static PartnerNamespaceSharedAccessKeys ListSharedAccessKeys(this IPartnerNamespacesOperations operations, string resourceGroupName, string partnerNamespaceName) + { + return operations.ListSharedAccessKeysAsync(resourceGroupName, partnerNamespaceName).GetAwaiter().GetResult(); + } + + /// + /// List keys for a partner namespace. + /// + /// + /// List the two keys used to publish to a partner namespace. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// The cancellation token. + /// + public static async Task ListSharedAccessKeysAsync(this IPartnerNamespacesOperations operations, string resourceGroupName, string partnerNamespaceName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListSharedAccessKeysWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Regenerate key for a partner namespace. + /// + /// + /// Regenerate a shared access key for a partner namespace. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Key name to regenerate (key1 or key2). + /// + public static PartnerNamespaceSharedAccessKeys RegenerateKey(this IPartnerNamespacesOperations operations, string resourceGroupName, string partnerNamespaceName, string keyName) + { + return operations.RegenerateKeyAsync(resourceGroupName, partnerNamespaceName, keyName).GetAwaiter().GetResult(); + } + + /// + /// Regenerate key for a partner namespace. + /// + /// + /// Regenerate a shared access key for a partner namespace. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Key name to regenerate (key1 or key2). + /// + /// + /// The cancellation token. + /// + public static async Task RegenerateKeyAsync(this IPartnerNamespacesOperations operations, string resourceGroupName, string partnerNamespaceName, string keyName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.RegenerateKeyWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, keyName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create a partner namespace. + /// + /// + /// Asynchronously creates a new partner namespace with the specified + /// parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// PartnerNamespace information. + /// + public static PartnerNamespace BeginCreateOrUpdate(this IPartnerNamespacesOperations operations, string resourceGroupName, string partnerNamespaceName, PartnerNamespace partnerNamespaceInfo) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, partnerNamespaceName, partnerNamespaceInfo).GetAwaiter().GetResult(); + } + + /// + /// Create a partner namespace. + /// + /// + /// Asynchronously creates a new partner namespace with the specified + /// parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// PartnerNamespace information. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IPartnerNamespacesOperations operations, string resourceGroupName, string partnerNamespaceName, PartnerNamespace partnerNamespaceInfo, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, partnerNamespaceInfo, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete a partner namespace. + /// + /// + /// Delete existing partner namespace. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + public static void BeginDelete(this IPartnerNamespacesOperations operations, string resourceGroupName, string partnerNamespaceName) + { + operations.BeginDeleteAsync(resourceGroupName, partnerNamespaceName).GetAwaiter().GetResult(); + } + + /// + /// Delete a partner namespace. + /// + /// + /// Delete existing partner namespace. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IPartnerNamespacesOperations operations, string resourceGroupName, string partnerNamespaceName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update a partner namespace. + /// + /// + /// Asynchronously updates a partner namespace with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Tags of the partner namespace. + /// + public static PartnerNamespace BeginUpdate(this IPartnerNamespacesOperations operations, string resourceGroupName, string partnerNamespaceName, IDictionary tags = default(IDictionary)) + { + return operations.BeginUpdateAsync(resourceGroupName, partnerNamespaceName, tags).GetAwaiter().GetResult(); + } + + /// + /// Update a partner namespace. + /// + /// + /// Asynchronously updates a partner namespace with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Tags of the partner namespace. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this IPartnerNamespacesOperations operations, string resourceGroupName, string partnerNamespaceName, IDictionary tags = default(IDictionary), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, tags, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List partner namespaces under an Azure subscription. + /// + /// + /// List all the partner namespaces under an Azure subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListBySubscriptionNext(this IPartnerNamespacesOperations operations, string nextPageLink) + { + return operations.ListBySubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List partner namespaces under an Azure subscription. + /// + /// + /// List all the partner namespaces under an Azure subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionNextAsync(this IPartnerNamespacesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List partner namespaces under a resource group. + /// + /// + /// List all the partner namespaces under a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByResourceGroupNext(this IPartnerNamespacesOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List partner namespaces under a resource group. + /// + /// + /// List all the partner namespaces under a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupNextAsync(this IPartnerNamespacesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerRegistrationsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerRegistrationsOperations.cs new file mode 100644 index 000000000000..81fd633c0b60 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerRegistrationsOperations.cs @@ -0,0 +1,1826 @@ +// +// 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 Microsoft.Azure.Management.EventGrid +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PartnerRegistrationsOperations operations. + /// + internal partial class PartnerRegistrationsOperations : IServiceOperations, IPartnerRegistrationsOperations + { + /// + /// Initializes a new instance of the PartnerRegistrationsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PartnerRegistrationsOperations(EventGridManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the EventGridManagementClient + /// + public EventGridManagementClient Client { get; private set; } + + /// + /// Get a partner registration. + /// + /// + /// Gets a partner registration with the specified parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner registration. + /// + /// + /// 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> GetWithHttpMessagesAsync(string resourceGroupName, string partnerRegistrationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerRegistrationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerRegistrationName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerRegistrationName", partnerRegistrationName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerRegistrationName}", System.Uri.EscapeDataString(partnerRegistrationName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create a partner registration. + /// + /// + /// Creates a new partner registration with the specified parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner registration. + /// + /// + /// PartnerRegistration information. + /// + /// + /// 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> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string partnerRegistrationName, PartnerRegistration partnerRegistrationInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerRegistrationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerRegistrationName"); + } + if (partnerRegistrationInfo == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerRegistrationInfo"); + } + if (partnerRegistrationInfo != null) + { + partnerRegistrationInfo.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerRegistrationName", partnerRegistrationName); + tracingParameters.Add("partnerRegistrationInfo", partnerRegistrationInfo); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerRegistrationName}", System.Uri.EscapeDataString(partnerRegistrationName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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(partnerRegistrationInfo != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(partnerRegistrationInfo, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 202) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete a partner registration. + /// + /// + /// Deletes a partner registration with the specified parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner registration. + /// + /// + /// 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 DeleteWithHttpMessagesAsync(string resourceGroupName, string partnerRegistrationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerRegistrationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerRegistrationName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerRegistrationName", partnerRegistrationName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerRegistrationName}", System.Uri.EscapeDataString(partnerRegistrationName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update a partner registration. + /// + /// + /// Updates a partner registration with the specified parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner registration. + /// + /// + /// Partner registration update information. + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string partnerRegistrationName, PartnerRegistrationUpdateParameters partnerRegistrationUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerRegistrationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerRegistrationName"); + } + if (partnerRegistrationUpdateParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerRegistrationUpdateParameters"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerRegistrationName", partnerRegistrationName); + tracingParameters.Add("partnerRegistrationUpdateParameters", partnerRegistrationUpdateParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerRegistrationName}", System.Uri.EscapeDataString(partnerRegistrationName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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(partnerRegistrationUpdateParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(partnerRegistrationUpdateParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List partner registrations under an Azure subscription. + /// + /// + /// List all the partner registrations under an Azure subscription. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + /// + /// 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>> ListBySubscriptionWithHttpMessagesAsync(string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("filter", filter); + tracingParameters.Add("top", top); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerRegistrations").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List partner registrations under a resource group. + /// + /// + /// List all the partner registrations under a resource group. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + /// + /// 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("filter", filter); + tracingParameters.Add("top", top); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List all available partners registrations. + /// + /// + /// List all partners registrations. + /// + /// + /// 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>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.EventGrid/partnerRegistrations").ToString(); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List partner registrations under an Azure subscription. + /// + /// + /// List all the partner registrations under an Azure subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// 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>> ListBySubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySubscriptionNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List partner registrations under a resource group. + /// + /// + /// List all the partner registrations under a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// 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>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroupNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerRegistrationsOperationsExtensions.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerRegistrationsOperationsExtensions.cs new file mode 100644 index 000000000000..184a2024b381 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerRegistrationsOperationsExtensions.cs @@ -0,0 +1,464 @@ +// +// 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 Microsoft.Azure.Management.EventGrid +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PartnerRegistrationsOperations. + /// + public static partial class PartnerRegistrationsOperationsExtensions + { + /// + /// Get a partner registration. + /// + /// + /// Gets a partner registration with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner registration. + /// + public static PartnerRegistration Get(this IPartnerRegistrationsOperations operations, string resourceGroupName, string partnerRegistrationName) + { + return operations.GetAsync(resourceGroupName, partnerRegistrationName).GetAwaiter().GetResult(); + } + + /// + /// Get a partner registration. + /// + /// + /// Gets a partner registration with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner registration. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPartnerRegistrationsOperations operations, string resourceGroupName, string partnerRegistrationName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, partnerRegistrationName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create a partner registration. + /// + /// + /// Creates a new partner registration with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner registration. + /// + /// + /// PartnerRegistration information. + /// + public static PartnerRegistration CreateOrUpdate(this IPartnerRegistrationsOperations operations, string resourceGroupName, string partnerRegistrationName, PartnerRegistration partnerRegistrationInfo) + { + return operations.CreateOrUpdateAsync(resourceGroupName, partnerRegistrationName, partnerRegistrationInfo).GetAwaiter().GetResult(); + } + + /// + /// Create a partner registration. + /// + /// + /// Creates a new partner registration with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner registration. + /// + /// + /// PartnerRegistration information. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IPartnerRegistrationsOperations operations, string resourceGroupName, string partnerRegistrationName, PartnerRegistration partnerRegistrationInfo, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, partnerRegistrationName, partnerRegistrationInfo, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete a partner registration. + /// + /// + /// Deletes a partner registration with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner registration. + /// + public static void Delete(this IPartnerRegistrationsOperations operations, string resourceGroupName, string partnerRegistrationName) + { + operations.DeleteAsync(resourceGroupName, partnerRegistrationName).GetAwaiter().GetResult(); + } + + /// + /// Delete a partner registration. + /// + /// + /// Deletes a partner registration with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner registration. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IPartnerRegistrationsOperations operations, string resourceGroupName, string partnerRegistrationName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, partnerRegistrationName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update a partner registration. + /// + /// + /// Updates a partner registration with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner registration. + /// + /// + /// Partner registration update information. + /// + public static PartnerRegistration Update(this IPartnerRegistrationsOperations operations, string resourceGroupName, string partnerRegistrationName, PartnerRegistrationUpdateParameters partnerRegistrationUpdateParameters) + { + return operations.UpdateAsync(resourceGroupName, partnerRegistrationName, partnerRegistrationUpdateParameters).GetAwaiter().GetResult(); + } + + /// + /// Update a partner registration. + /// + /// + /// Updates a partner registration with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner registration. + /// + /// + /// Partner registration update information. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IPartnerRegistrationsOperations operations, string resourceGroupName, string partnerRegistrationName, PartnerRegistrationUpdateParameters partnerRegistrationUpdateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, partnerRegistrationName, partnerRegistrationUpdateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List partner registrations under an Azure subscription. + /// + /// + /// List all the partner registrations under an Azure subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + public static IPage ListBySubscription(this IPartnerRegistrationsOperations operations, string filter = default(string), int? top = default(int?)) + { + return operations.ListBySubscriptionAsync(filter, top).GetAwaiter().GetResult(); + } + + /// + /// List partner registrations under an Azure subscription. + /// + /// + /// List all the partner registrations under an Azure subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionAsync(this IPartnerRegistrationsOperations operations, string filter = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(filter, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List partner registrations under a resource group. + /// + /// + /// List all the partner registrations under a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + public static IPage ListByResourceGroup(this IPartnerRegistrationsOperations operations, string resourceGroupName, string filter = default(string), int? top = default(int?)) + { + return operations.ListByResourceGroupAsync(resourceGroupName, filter, top).GetAwaiter().GetResult(); + } + + /// + /// List partner registrations under a resource group. + /// + /// + /// List all the partner registrations under a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IPartnerRegistrationsOperations operations, string resourceGroupName, string filter = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, filter, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all available partners registrations. + /// + /// + /// List all partners registrations. + /// + /// + /// The operations group for this extension method. + /// + public static IEnumerable List(this IPartnerRegistrationsOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// List all available partners registrations. + /// + /// + /// List all partners registrations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IPartnerRegistrationsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List partner registrations under an Azure subscription. + /// + /// + /// List all the partner registrations under an Azure subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListBySubscriptionNext(this IPartnerRegistrationsOperations operations, string nextPageLink) + { + return operations.ListBySubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List partner registrations under an Azure subscription. + /// + /// + /// List all the partner registrations under an Azure subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionNextAsync(this IPartnerRegistrationsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List partner registrations under a resource group. + /// + /// + /// List all the partner registrations under a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByResourceGroupNext(this IPartnerRegistrationsOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List partner registrations under a resource group. + /// + /// + /// List all the partner registrations under a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupNextAsync(this IPartnerRegistrationsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerTopicEventSubscriptionsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerTopicEventSubscriptionsOperations.cs new file mode 100644 index 000000000000..df3f5ccc9bdf --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerTopicEventSubscriptionsOperations.cs @@ -0,0 +1,1822 @@ +// +// 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 Microsoft.Azure.Management.EventGrid +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PartnerTopicEventSubscriptionsOperations operations. + /// + internal partial class PartnerTopicEventSubscriptionsOperations : IServiceOperations, IPartnerTopicEventSubscriptionsOperations + { + /// + /// Initializes a new instance of the PartnerTopicEventSubscriptionsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PartnerTopicEventSubscriptionsOperations(EventGridManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the EventGridManagementClient + /// + public EventGridManagementClient Client { get; private set; } + + /// + /// Get an event subscription of a partner topic. + /// + /// + /// Get an event subscription of a partner topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be found. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// 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> GetWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerTopicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerTopicName"); + } + if (eventSubscriptionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "eventSubscriptionName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerTopicName", partnerTopicName); + tracingParameters.Add("eventSubscriptionName", eventSubscriptionName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerTopicName}", System.Uri.EscapeDataString(partnerTopicName)); + _url = _url.Replace("{eventSubscriptionName}", System.Uri.EscapeDataString(eventSubscriptionName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update an event subscription of a partner topic. + /// + /// + /// Asynchronously creates or updates an event subscription of a partner topic + /// with the specified parameters. Existing event subscriptions will be updated + /// with this API. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// Event subscription properties containing the destination and filter + /// information. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, partnerTopicName, eventSubscriptionName, eventSubscriptionInfo, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Delete an event subscription of a partner topic. + /// + /// + /// Delete an event subscription of a partner topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, partnerTopicName, eventSubscriptionName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Update event subscription of a partner topic. + /// + /// + /// Update event subscription of a partner topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// Updated event subscription information. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, partnerTopicName, eventSubscriptionName, eventSubscriptionUpdateParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get full URL of an event subscription of a partner topic. + /// + /// + /// Get the full endpoint URL for an event subscription of a partner topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// 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> GetFullUrlWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerTopicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerTopicName"); + } + if (eventSubscriptionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "eventSubscriptionName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerTopicName", partnerTopicName); + tracingParameters.Add("eventSubscriptionName", eventSubscriptionName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetFullUrl", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerTopicName}", System.Uri.EscapeDataString(partnerTopicName)); + _url = _url.Replace("{eventSubscriptionName}", System.Uri.EscapeDataString(eventSubscriptionName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List event subscriptions of a partner topic. + /// + /// + /// List event subscriptions that belong to a specific partner topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + /// + /// 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>> ListByPartnerTopicWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerTopicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerTopicName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerTopicName", partnerTopicName); + tracingParameters.Add("filter", filter); + tracingParameters.Add("top", top); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByPartnerTopic", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerTopicName}", System.Uri.EscapeDataString(partnerTopicName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get delivery attributes for an event subscription of a partner topic. + /// + /// + /// Get all delivery attributes for an event subscription of a partner topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// 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> GetDeliveryAttributesWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerTopicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerTopicName"); + } + if (eventSubscriptionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "eventSubscriptionName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerTopicName", partnerTopicName); + tracingParameters.Add("eventSubscriptionName", eventSubscriptionName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetDeliveryAttributes", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerTopicName}", System.Uri.EscapeDataString(partnerTopicName)); + _url = _url.Replace("{eventSubscriptionName}", System.Uri.EscapeDataString(eventSubscriptionName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update an event subscription of a partner topic. + /// + /// + /// Asynchronously creates or updates an event subscription of a partner topic + /// with the specified parameters. Existing event subscriptions will be updated + /// with this API. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// Event subscription properties containing the destination and filter + /// information. + /// + /// + /// 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> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerTopicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerTopicName"); + } + if (eventSubscriptionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "eventSubscriptionName"); + } + if (eventSubscriptionInfo == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "eventSubscriptionInfo"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerTopicName", partnerTopicName); + tracingParameters.Add("eventSubscriptionName", eventSubscriptionName); + tracingParameters.Add("eventSubscriptionInfo", eventSubscriptionInfo); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerTopicName}", System.Uri.EscapeDataString(partnerTopicName)); + _url = _url.Replace("{eventSubscriptionName}", System.Uri.EscapeDataString(eventSubscriptionName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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(eventSubscriptionInfo != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(eventSubscriptionInfo, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete an event subscription of a partner topic. + /// + /// + /// Delete an event subscription of a partner topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// 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 BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerTopicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerTopicName"); + } + if (eventSubscriptionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "eventSubscriptionName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerTopicName", partnerTopicName); + tracingParameters.Add("eventSubscriptionName", eventSubscriptionName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerTopicName}", System.Uri.EscapeDataString(partnerTopicName)); + _url = _url.Replace("{eventSubscriptionName}", System.Uri.EscapeDataString(eventSubscriptionName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update event subscription of a partner topic. + /// + /// + /// Update event subscription of a partner topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// Updated event subscription information. + /// + /// + /// 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> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerTopicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerTopicName"); + } + if (eventSubscriptionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "eventSubscriptionName"); + } + if (eventSubscriptionUpdateParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "eventSubscriptionUpdateParameters"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerTopicName", partnerTopicName); + tracingParameters.Add("eventSubscriptionName", eventSubscriptionName); + tracingParameters.Add("eventSubscriptionUpdateParameters", eventSubscriptionUpdateParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerTopicName}", System.Uri.EscapeDataString(partnerTopicName)); + _url = _url.Replace("{eventSubscriptionName}", System.Uri.EscapeDataString(eventSubscriptionName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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(eventSubscriptionUpdateParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(eventSubscriptionUpdateParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List event subscriptions of a partner topic. + /// + /// + /// List event subscriptions that belong to a specific partner topic. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// 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>> ListByPartnerTopicNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByPartnerTopicNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerTopicEventSubscriptionsOperationsExtensions.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerTopicEventSubscriptionsOperationsExtensions.cs new file mode 100644 index 000000000000..4324b5b3754d --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerTopicEventSubscriptionsOperationsExtensions.cs @@ -0,0 +1,673 @@ +// +// 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 Microsoft.Azure.Management.EventGrid +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PartnerTopicEventSubscriptionsOperations. + /// + public static partial class PartnerTopicEventSubscriptionsOperationsExtensions + { + /// + /// Get an event subscription of a partner topic. + /// + /// + /// Get an event subscription of a partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be found. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + public static EventSubscription Get(this IPartnerTopicEventSubscriptionsOperations operations, string resourceGroupName, string partnerTopicName, string eventSubscriptionName) + { + return operations.GetAsync(resourceGroupName, partnerTopicName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Get an event subscription of a partner topic. + /// + /// + /// Get an event subscription of a partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be found. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPartnerTopicEventSubscriptionsOperations operations, string resourceGroupName, string partnerTopicName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, partnerTopicName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an event subscription of a partner topic. + /// + /// + /// Asynchronously creates or updates an event subscription of a partner topic + /// with the specified parameters. Existing event subscriptions will be updated + /// with this API. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// Event subscription properties containing the destination and filter + /// information. + /// + public static EventSubscription CreateOrUpdate(this IPartnerTopicEventSubscriptionsOperations operations, string resourceGroupName, string partnerTopicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo) + { + return operations.CreateOrUpdateAsync(resourceGroupName, partnerTopicName, eventSubscriptionName, eventSubscriptionInfo).GetAwaiter().GetResult(); + } + + /// + /// Create or update an event subscription of a partner topic. + /// + /// + /// Asynchronously creates or updates an event subscription of a partner topic + /// with the specified parameters. Existing event subscriptions will be updated + /// with this API. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// Event subscription properties containing the destination and filter + /// information. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IPartnerTopicEventSubscriptionsOperations operations, string resourceGroupName, string partnerTopicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, partnerTopicName, eventSubscriptionName, eventSubscriptionInfo, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete an event subscription of a partner topic. + /// + /// + /// Delete an event subscription of a partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + public static void Delete(this IPartnerTopicEventSubscriptionsOperations operations, string resourceGroupName, string partnerTopicName, string eventSubscriptionName) + { + operations.DeleteAsync(resourceGroupName, partnerTopicName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Delete an event subscription of a partner topic. + /// + /// + /// Delete an event subscription of a partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IPartnerTopicEventSubscriptionsOperations operations, string resourceGroupName, string partnerTopicName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, partnerTopicName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update event subscription of a partner topic. + /// + /// + /// Update event subscription of a partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// Updated event subscription information. + /// + public static EventSubscription Update(this IPartnerTopicEventSubscriptionsOperations operations, string resourceGroupName, string partnerTopicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters) + { + return operations.UpdateAsync(resourceGroupName, partnerTopicName, eventSubscriptionName, eventSubscriptionUpdateParameters).GetAwaiter().GetResult(); + } + + /// + /// Update event subscription of a partner topic. + /// + /// + /// Update event subscription of a partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// Updated event subscription information. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IPartnerTopicEventSubscriptionsOperations operations, string resourceGroupName, string partnerTopicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, partnerTopicName, eventSubscriptionName, eventSubscriptionUpdateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get full URL of an event subscription of a partner topic. + /// + /// + /// Get the full endpoint URL for an event subscription of a partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + public static EventSubscriptionFullUrl GetFullUrl(this IPartnerTopicEventSubscriptionsOperations operations, string resourceGroupName, string partnerTopicName, string eventSubscriptionName) + { + return operations.GetFullUrlAsync(resourceGroupName, partnerTopicName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Get full URL of an event subscription of a partner topic. + /// + /// + /// Get the full endpoint URL for an event subscription of a partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// The cancellation token. + /// + public static async Task GetFullUrlAsync(this IPartnerTopicEventSubscriptionsOperations operations, string resourceGroupName, string partnerTopicName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetFullUrlWithHttpMessagesAsync(resourceGroupName, partnerTopicName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List event subscriptions of a partner topic. + /// + /// + /// List event subscriptions that belong to a specific partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + public static IPage ListByPartnerTopic(this IPartnerTopicEventSubscriptionsOperations operations, string resourceGroupName, string partnerTopicName, string filter = default(string), int? top = default(int?)) + { + return operations.ListByPartnerTopicAsync(resourceGroupName, partnerTopicName, filter, top).GetAwaiter().GetResult(); + } + + /// + /// List event subscriptions of a partner topic. + /// + /// + /// List event subscriptions that belong to a specific partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByPartnerTopicAsync(this IPartnerTopicEventSubscriptionsOperations operations, string resourceGroupName, string partnerTopicName, string filter = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByPartnerTopicWithHttpMessagesAsync(resourceGroupName, partnerTopicName, filter, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get delivery attributes for an event subscription of a partner topic. + /// + /// + /// Get all delivery attributes for an event subscription of a partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + public static DeliveryAttributeListResult GetDeliveryAttributes(this IPartnerTopicEventSubscriptionsOperations operations, string resourceGroupName, string partnerTopicName, string eventSubscriptionName) + { + return operations.GetDeliveryAttributesAsync(resourceGroupName, partnerTopicName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Get delivery attributes for an event subscription of a partner topic. + /// + /// + /// Get all delivery attributes for an event subscription of a partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// The cancellation token. + /// + public static async Task GetDeliveryAttributesAsync(this IPartnerTopicEventSubscriptionsOperations operations, string resourceGroupName, string partnerTopicName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetDeliveryAttributesWithHttpMessagesAsync(resourceGroupName, partnerTopicName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an event subscription of a partner topic. + /// + /// + /// Asynchronously creates or updates an event subscription of a partner topic + /// with the specified parameters. Existing event subscriptions will be updated + /// with this API. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// Event subscription properties containing the destination and filter + /// information. + /// + public static EventSubscription BeginCreateOrUpdate(this IPartnerTopicEventSubscriptionsOperations operations, string resourceGroupName, string partnerTopicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, partnerTopicName, eventSubscriptionName, eventSubscriptionInfo).GetAwaiter().GetResult(); + } + + /// + /// Create or update an event subscription of a partner topic. + /// + /// + /// Asynchronously creates or updates an event subscription of a partner topic + /// with the specified parameters. Existing event subscriptions will be updated + /// with this API. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// Event subscription properties containing the destination and filter + /// information. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IPartnerTopicEventSubscriptionsOperations operations, string resourceGroupName, string partnerTopicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, partnerTopicName, eventSubscriptionName, eventSubscriptionInfo, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete an event subscription of a partner topic. + /// + /// + /// Delete an event subscription of a partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + public static void BeginDelete(this IPartnerTopicEventSubscriptionsOperations operations, string resourceGroupName, string partnerTopicName, string eventSubscriptionName) + { + operations.BeginDeleteAsync(resourceGroupName, partnerTopicName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Delete an event subscription of a partner topic. + /// + /// + /// Delete an event subscription of a partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IPartnerTopicEventSubscriptionsOperations operations, string resourceGroupName, string partnerTopicName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, partnerTopicName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update event subscription of a partner topic. + /// + /// + /// Update event subscription of a partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// Updated event subscription information. + /// + public static EventSubscription BeginUpdate(this IPartnerTopicEventSubscriptionsOperations operations, string resourceGroupName, string partnerTopicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters) + { + return operations.BeginUpdateAsync(resourceGroupName, partnerTopicName, eventSubscriptionName, eventSubscriptionUpdateParameters).GetAwaiter().GetResult(); + } + + /// + /// Update event subscription of a partner topic. + /// + /// + /// Update event subscription of a partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// Updated event subscription information. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this IPartnerTopicEventSubscriptionsOperations operations, string resourceGroupName, string partnerTopicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, partnerTopicName, eventSubscriptionName, eventSubscriptionUpdateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List event subscriptions of a partner topic. + /// + /// + /// List event subscriptions that belong to a specific partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByPartnerTopicNext(this IPartnerTopicEventSubscriptionsOperations operations, string nextPageLink) + { + return operations.ListByPartnerTopicNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List event subscriptions of a partner topic. + /// + /// + /// List event subscriptions that belong to a specific partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByPartnerTopicNextAsync(this IPartnerTopicEventSubscriptionsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByPartnerTopicNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerTopicsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerTopicsOperations.cs new file mode 100644 index 000000000000..bf86b49676d7 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerTopicsOperations.cs @@ -0,0 +1,1839 @@ +// +// 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 Microsoft.Azure.Management.EventGrid +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// PartnerTopicsOperations operations. + /// + internal partial class PartnerTopicsOperations : IServiceOperations, IPartnerTopicsOperations + { + /// + /// Initializes a new instance of the PartnerTopicsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PartnerTopicsOperations(EventGridManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the EventGridManagementClient + /// + public EventGridManagementClient Client { get; private set; } + + /// + /// Get a partner topic. + /// + /// + /// Get properties of a partner topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// 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> GetWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerTopicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerTopicName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerTopicName", partnerTopicName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerTopicName}", System.Uri.EscapeDataString(partnerTopicName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete a partner topic. + /// + /// + /// Delete existing partner topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, partnerTopicName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Update a partner topic. + /// + /// + /// Asynchronously updates a partner topic with the specified parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Tags of the partner topic. + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerTopicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerTopicName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + PartnerTopicUpdateParameters partnerTopicUpdateParameters = new PartnerTopicUpdateParameters(); + if (tags != null) + { + partnerTopicUpdateParameters.Tags = tags; + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerTopicName", partnerTopicName); + tracingParameters.Add("partnerTopicUpdateParameters", partnerTopicUpdateParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerTopicName}", System.Uri.EscapeDataString(partnerTopicName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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(partnerTopicUpdateParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(partnerTopicUpdateParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List partner topics under an Azure subscription. + /// + /// + /// List all the partner topics under an Azure subscription. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + /// + /// 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>> ListBySubscriptionWithHttpMessagesAsync(string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("filter", filter); + tracingParameters.Add("top", top); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerTopics").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List partner topics under a resource group. + /// + /// + /// List all the partner topics under a resource group. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + /// + /// 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("filter", filter); + tracingParameters.Add("top", top); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Activate a partner topic. + /// + /// + /// Activate a newly created partner topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// 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> ActivateWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerTopicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerTopicName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerTopicName", partnerTopicName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Activate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/activate").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerTopicName}", System.Uri.EscapeDataString(partnerTopicName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deactivate a partner topic. + /// + /// + /// Deactivate specific partner topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// 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> DeactivateWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerTopicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerTopicName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerTopicName", partnerTopicName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Deactivate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/deactivate").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerTopicName}", System.Uri.EscapeDataString(partnerTopicName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete a partner topic. + /// + /// + /// Delete existing partner topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// 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 BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (partnerTopicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerTopicName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("partnerTopicName", partnerTopicName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerTopicName}", System.Uri.EscapeDataString(partnerTopicName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List partner topics under an Azure subscription. + /// + /// + /// List all the partner topics under an Azure subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// 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>> ListBySubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySubscriptionNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List partner topics under a resource group. + /// + /// + /// List all the partner topics under a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// 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>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroupNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerTopicsOperationsExtensions.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerTopicsOperationsExtensions.cs new file mode 100644 index 000000000000..8e5b32dc1dc5 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerTopicsOperationsExtensions.cs @@ -0,0 +1,513 @@ +// +// 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 Microsoft.Azure.Management.EventGrid +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for PartnerTopicsOperations. + /// + public static partial class PartnerTopicsOperationsExtensions + { + /// + /// Get a partner topic. + /// + /// + /// Get properties of a partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + public static PartnerTopic Get(this IPartnerTopicsOperations operations, string resourceGroupName, string partnerTopicName) + { + return operations.GetAsync(resourceGroupName, partnerTopicName).GetAwaiter().GetResult(); + } + + /// + /// Get a partner topic. + /// + /// + /// Get properties of a partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPartnerTopicsOperations operations, string resourceGroupName, string partnerTopicName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, partnerTopicName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete a partner topic. + /// + /// + /// Delete existing partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + public static void Delete(this IPartnerTopicsOperations operations, string resourceGroupName, string partnerTopicName) + { + operations.DeleteAsync(resourceGroupName, partnerTopicName).GetAwaiter().GetResult(); + } + + /// + /// Delete a partner topic. + /// + /// + /// Delete existing partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IPartnerTopicsOperations operations, string resourceGroupName, string partnerTopicName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, partnerTopicName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update a partner topic. + /// + /// + /// Asynchronously updates a partner topic with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Tags of the partner topic. + /// + public static PartnerTopic Update(this IPartnerTopicsOperations operations, string resourceGroupName, string partnerTopicName, IDictionary tags = default(IDictionary)) + { + return operations.UpdateAsync(resourceGroupName, partnerTopicName, tags).GetAwaiter().GetResult(); + } + + /// + /// Update a partner topic. + /// + /// + /// Asynchronously updates a partner topic with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Tags of the partner topic. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IPartnerTopicsOperations operations, string resourceGroupName, string partnerTopicName, IDictionary tags = default(IDictionary), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, partnerTopicName, tags, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List partner topics under an Azure subscription. + /// + /// + /// List all the partner topics under an Azure subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + public static IPage ListBySubscription(this IPartnerTopicsOperations operations, string filter = default(string), int? top = default(int?)) + { + return operations.ListBySubscriptionAsync(filter, top).GetAwaiter().GetResult(); + } + + /// + /// List partner topics under an Azure subscription. + /// + /// + /// List all the partner topics under an Azure subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionAsync(this IPartnerTopicsOperations operations, string filter = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(filter, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List partner topics under a resource group. + /// + /// + /// List all the partner topics under a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + public static IPage ListByResourceGroup(this IPartnerTopicsOperations operations, string resourceGroupName, string filter = default(string), int? top = default(int?)) + { + return operations.ListByResourceGroupAsync(resourceGroupName, filter, top).GetAwaiter().GetResult(); + } + + /// + /// List partner topics under a resource group. + /// + /// + /// List all the partner topics under a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IPartnerTopicsOperations operations, string resourceGroupName, string filter = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, filter, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Activate a partner topic. + /// + /// + /// Activate a newly created partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + public static PartnerTopic Activate(this IPartnerTopicsOperations operations, string resourceGroupName, string partnerTopicName) + { + return operations.ActivateAsync(resourceGroupName, partnerTopicName).GetAwaiter().GetResult(); + } + + /// + /// Activate a partner topic. + /// + /// + /// Activate a newly created partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// The cancellation token. + /// + public static async Task ActivateAsync(this IPartnerTopicsOperations operations, string resourceGroupName, string partnerTopicName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ActivateWithHttpMessagesAsync(resourceGroupName, partnerTopicName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deactivate a partner topic. + /// + /// + /// Deactivate specific partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + public static PartnerTopic Deactivate(this IPartnerTopicsOperations operations, string resourceGroupName, string partnerTopicName) + { + return operations.DeactivateAsync(resourceGroupName, partnerTopicName).GetAwaiter().GetResult(); + } + + /// + /// Deactivate a partner topic. + /// + /// + /// Deactivate specific partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// The cancellation token. + /// + public static async Task DeactivateAsync(this IPartnerTopicsOperations operations, string resourceGroupName, string partnerTopicName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.DeactivateWithHttpMessagesAsync(resourceGroupName, partnerTopicName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete a partner topic. + /// + /// + /// Delete existing partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + public static void BeginDelete(this IPartnerTopicsOperations operations, string resourceGroupName, string partnerTopicName) + { + operations.BeginDeleteAsync(resourceGroupName, partnerTopicName).GetAwaiter().GetResult(); + } + + /// + /// Delete a partner topic. + /// + /// + /// Delete existing partner topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IPartnerTopicsOperations operations, string resourceGroupName, string partnerTopicName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, partnerTopicName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// List partner topics under an Azure subscription. + /// + /// + /// List all the partner topics under an Azure subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListBySubscriptionNext(this IPartnerTopicsOperations operations, string nextPageLink) + { + return operations.ListBySubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List partner topics under an Azure subscription. + /// + /// + /// List all the partner topics under an Azure subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionNextAsync(this IPartnerTopicsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List partner topics under a resource group. + /// + /// + /// List all the partner topics under a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByResourceGroupNext(this IPartnerTopicsOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List partner topics under a resource group. + /// + /// + /// List all the partner topics under a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupNextAsync(this IPartnerTopicsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/SdkInfo_EventGridManagementClient.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/SdkInfo_EventGridManagementClient.cs index 45ab9537aa98..0cecc6a0aa55 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/SdkInfo_EventGridManagementClient.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/SdkInfo_EventGridManagementClient.cs @@ -19,27 +19,24 @@ public static IEnumerable> ApiInfo_EventGridManage { return new Tuple[] { - new Tuple("EventGrid", "DomainTopics", "2020-06-01"), - new Tuple("EventGrid", "Domains", "2020-06-01"), - new Tuple("EventGrid", "EventSubscriptions", "2020-06-01"), - new Tuple("EventGrid", "Operations", "2020-06-01"), - new Tuple("EventGrid", "PrivateEndpointConnections", "2020-06-01"), - new Tuple("EventGrid", "PrivateLinkResources", "2020-06-01"), - new Tuple("EventGrid", "TopicTypes", "2020-06-01"), - new Tuple("EventGrid", "Topics", "2020-06-01"), + new Tuple("EventGrid", "DomainTopics", "2020-10-15-preview"), + new Tuple("EventGrid", "Domains", "2020-10-15-preview"), + new Tuple("EventGrid", "EventChannels", "2020-10-15-preview"), + new Tuple("EventGrid", "EventSubscriptions", "2020-10-15-preview"), + new Tuple("EventGrid", "ExtensionTopics", "2020-10-15-preview"), + new Tuple("EventGrid", "Operations", "2020-10-15-preview"), + new Tuple("EventGrid", "PartnerNamespaces", "2020-10-15-preview"), + new Tuple("EventGrid", "PartnerRegistrations", "2020-10-15-preview"), + new Tuple("EventGrid", "PartnerTopicEventSubscriptions", "2020-10-15-preview"), + new Tuple("EventGrid", "PartnerTopics", "2020-10-15-preview"), + new Tuple("EventGrid", "PrivateEndpointConnections", "2020-10-15-preview"), + new Tuple("EventGrid", "PrivateLinkResources", "2020-10-15-preview"), + new Tuple("EventGrid", "SystemTopicEventSubscriptions", "2020-10-15-preview"), + new Tuple("EventGrid", "SystemTopics", "2020-10-15-preview"), + new Tuple("EventGrid", "TopicTypes", "2020-10-15-preview"), + new Tuple("EventGrid", "Topics", "2020-10-15-preview"), }.AsEnumerable(); } } - // BEGIN: Code Generation Metadata Section - public static readonly String AutoRestVersion = "v2"; - public static readonly String AutoRestBootStrapperVersion = "autorest@2.0.4413"; - public static readonly String AutoRestCmdExecuted = "cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/eventgrid/resource-manager/readme.md --csharp --version=v2 --reflect-api-versions --csharp-sdks-folder=E:\\build2020\\net1\\azure-sdk-for-net\\sdk"; - public static readonly String GithubForkName = "Azure"; - public static readonly String GithubBranchName = "master"; - public static readonly String GithubCommidId = "e3e0fff3be9befda4fd2cc18ee355b88b024fac7"; - public static readonly String CodeGenerationErrors = ""; - public static readonly String GithubRepoName = "azure-rest-api-specs"; - // END: Code Generation Metadata Section } } - diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/SystemTopicEventSubscriptionsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/SystemTopicEventSubscriptionsOperations.cs new file mode 100644 index 000000000000..e0189270e1c0 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/SystemTopicEventSubscriptionsOperations.cs @@ -0,0 +1,1820 @@ +// +// 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 Microsoft.Azure.Management.EventGrid +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SystemTopicEventSubscriptionsOperations operations. + /// + internal partial class SystemTopicEventSubscriptionsOperations : IServiceOperations, ISystemTopicEventSubscriptionsOperations + { + /// + /// Initializes a new instance of the SystemTopicEventSubscriptionsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal SystemTopicEventSubscriptionsOperations(EventGridManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the EventGridManagementClient + /// + public EventGridManagementClient Client { get; private set; } + + /// + /// Get an event subscription of a system topic. + /// + /// + /// Get an event subscription. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// 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> GetWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (systemTopicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "systemTopicName"); + } + if (eventSubscriptionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "eventSubscriptionName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("systemTopicName", systemTopicName); + tracingParameters.Add("eventSubscriptionName", eventSubscriptionName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{systemTopicName}", System.Uri.EscapeDataString(systemTopicName)); + _url = _url.Replace("{eventSubscriptionName}", System.Uri.EscapeDataString(eventSubscriptionName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update an event subscription for a system topic. + /// + /// + /// Asynchronously creates or updates an event subscription with the specified + /// parameters. Existing event subscriptions will be updated with this API. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// Event subscription properties containing the destination and filter + /// information. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, systemTopicName, eventSubscriptionName, eventSubscriptionInfo, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Delete an event subscription of a system topic. + /// + /// + /// Delete an event subscription of a system topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, systemTopicName, eventSubscriptionName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Update event subscription of a system topic. + /// + /// + /// Update event subscription of a system topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// Updated event subscription information. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, systemTopicName, eventSubscriptionName, eventSubscriptionUpdateParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get full URL of an event subscription of a system topic + /// + /// + /// Get the full endpoint URL for an event subscription of a system topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// 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> GetFullUrlWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (systemTopicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "systemTopicName"); + } + if (eventSubscriptionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "eventSubscriptionName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("systemTopicName", systemTopicName); + tracingParameters.Add("eventSubscriptionName", eventSubscriptionName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetFullUrl", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{systemTopicName}", System.Uri.EscapeDataString(systemTopicName)); + _url = _url.Replace("{eventSubscriptionName}", System.Uri.EscapeDataString(eventSubscriptionName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List event subscriptions of a system topic. + /// + /// + /// List event subscriptions that belong to a specific system topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + /// + /// 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>> ListBySystemTopicWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (systemTopicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "systemTopicName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("systemTopicName", systemTopicName); + tracingParameters.Add("filter", filter); + tracingParameters.Add("top", top); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySystemTopic", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{systemTopicName}", System.Uri.EscapeDataString(systemTopicName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get delivery attributes for an event subscription. + /// + /// + /// Get all delivery attributes for an event subscription. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// 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> GetDeliveryAttributesWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (systemTopicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "systemTopicName"); + } + if (eventSubscriptionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "eventSubscriptionName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("systemTopicName", systemTopicName); + tracingParameters.Add("eventSubscriptionName", eventSubscriptionName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetDeliveryAttributes", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{systemTopicName}", System.Uri.EscapeDataString(systemTopicName)); + _url = _url.Replace("{eventSubscriptionName}", System.Uri.EscapeDataString(eventSubscriptionName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update an event subscription for a system topic. + /// + /// + /// Asynchronously creates or updates an event subscription with the specified + /// parameters. Existing event subscriptions will be updated with this API. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// Event subscription properties containing the destination and filter + /// information. + /// + /// + /// 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> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (systemTopicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "systemTopicName"); + } + if (eventSubscriptionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "eventSubscriptionName"); + } + if (eventSubscriptionInfo == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "eventSubscriptionInfo"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("systemTopicName", systemTopicName); + tracingParameters.Add("eventSubscriptionName", eventSubscriptionName); + tracingParameters.Add("eventSubscriptionInfo", eventSubscriptionInfo); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{systemTopicName}", System.Uri.EscapeDataString(systemTopicName)); + _url = _url.Replace("{eventSubscriptionName}", System.Uri.EscapeDataString(eventSubscriptionName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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(eventSubscriptionInfo != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(eventSubscriptionInfo, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete an event subscription of a system topic. + /// + /// + /// Delete an event subscription of a system topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// 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 BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (systemTopicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "systemTopicName"); + } + if (eventSubscriptionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "eventSubscriptionName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("systemTopicName", systemTopicName); + tracingParameters.Add("eventSubscriptionName", eventSubscriptionName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{systemTopicName}", System.Uri.EscapeDataString(systemTopicName)); + _url = _url.Replace("{eventSubscriptionName}", System.Uri.EscapeDataString(eventSubscriptionName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update event subscription of a system topic. + /// + /// + /// Update event subscription of a system topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// Updated event subscription information. + /// + /// + /// 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> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (systemTopicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "systemTopicName"); + } + if (eventSubscriptionName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "eventSubscriptionName"); + } + if (eventSubscriptionUpdateParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "eventSubscriptionUpdateParameters"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("systemTopicName", systemTopicName); + tracingParameters.Add("eventSubscriptionName", eventSubscriptionName); + tracingParameters.Add("eventSubscriptionUpdateParameters", eventSubscriptionUpdateParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{systemTopicName}", System.Uri.EscapeDataString(systemTopicName)); + _url = _url.Replace("{eventSubscriptionName}", System.Uri.EscapeDataString(eventSubscriptionName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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(eventSubscriptionUpdateParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(eventSubscriptionUpdateParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List event subscriptions of a system topic. + /// + /// + /// List event subscriptions that belong to a specific system topic. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// 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>> ListBySystemTopicNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySystemTopicNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/SystemTopicEventSubscriptionsOperationsExtensions.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/SystemTopicEventSubscriptionsOperationsExtensions.cs new file mode 100644 index 000000000000..e0cd40093816 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/SystemTopicEventSubscriptionsOperationsExtensions.cs @@ -0,0 +1,669 @@ +// +// 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 Microsoft.Azure.Management.EventGrid +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for SystemTopicEventSubscriptionsOperations. + /// + public static partial class SystemTopicEventSubscriptionsOperationsExtensions + { + /// + /// Get an event subscription of a system topic. + /// + /// + /// Get an event subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + public static EventSubscription Get(this ISystemTopicEventSubscriptionsOperations operations, string resourceGroupName, string systemTopicName, string eventSubscriptionName) + { + return operations.GetAsync(resourceGroupName, systemTopicName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Get an event subscription of a system topic. + /// + /// + /// Get an event subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this ISystemTopicEventSubscriptionsOperations operations, string resourceGroupName, string systemTopicName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, systemTopicName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an event subscription for a system topic. + /// + /// + /// Asynchronously creates or updates an event subscription with the specified + /// parameters. Existing event subscriptions will be updated with this API. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// Event subscription properties containing the destination and filter + /// information. + /// + public static EventSubscription CreateOrUpdate(this ISystemTopicEventSubscriptionsOperations operations, string resourceGroupName, string systemTopicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo) + { + return operations.CreateOrUpdateAsync(resourceGroupName, systemTopicName, eventSubscriptionName, eventSubscriptionInfo).GetAwaiter().GetResult(); + } + + /// + /// Create or update an event subscription for a system topic. + /// + /// + /// Asynchronously creates or updates an event subscription with the specified + /// parameters. Existing event subscriptions will be updated with this API. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// Event subscription properties containing the destination and filter + /// information. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this ISystemTopicEventSubscriptionsOperations operations, string resourceGroupName, string systemTopicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, systemTopicName, eventSubscriptionName, eventSubscriptionInfo, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete an event subscription of a system topic. + /// + /// + /// Delete an event subscription of a system topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + public static void Delete(this ISystemTopicEventSubscriptionsOperations operations, string resourceGroupName, string systemTopicName, string eventSubscriptionName) + { + operations.DeleteAsync(resourceGroupName, systemTopicName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Delete an event subscription of a system topic. + /// + /// + /// Delete an event subscription of a system topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this ISystemTopicEventSubscriptionsOperations operations, string resourceGroupName, string systemTopicName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, systemTopicName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update event subscription of a system topic. + /// + /// + /// Update event subscription of a system topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// Updated event subscription information. + /// + public static EventSubscription Update(this ISystemTopicEventSubscriptionsOperations operations, string resourceGroupName, string systemTopicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters) + { + return operations.UpdateAsync(resourceGroupName, systemTopicName, eventSubscriptionName, eventSubscriptionUpdateParameters).GetAwaiter().GetResult(); + } + + /// + /// Update event subscription of a system topic. + /// + /// + /// Update event subscription of a system topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// Updated event subscription information. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this ISystemTopicEventSubscriptionsOperations operations, string resourceGroupName, string systemTopicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, systemTopicName, eventSubscriptionName, eventSubscriptionUpdateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get full URL of an event subscription of a system topic + /// + /// + /// Get the full endpoint URL for an event subscription of a system topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + public static EventSubscriptionFullUrl GetFullUrl(this ISystemTopicEventSubscriptionsOperations operations, string resourceGroupName, string systemTopicName, string eventSubscriptionName) + { + return operations.GetFullUrlAsync(resourceGroupName, systemTopicName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Get full URL of an event subscription of a system topic + /// + /// + /// Get the full endpoint URL for an event subscription of a system topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// The cancellation token. + /// + public static async Task GetFullUrlAsync(this ISystemTopicEventSubscriptionsOperations operations, string resourceGroupName, string systemTopicName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetFullUrlWithHttpMessagesAsync(resourceGroupName, systemTopicName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List event subscriptions of a system topic. + /// + /// + /// List event subscriptions that belong to a specific system topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + public static IPage ListBySystemTopic(this ISystemTopicEventSubscriptionsOperations operations, string resourceGroupName, string systemTopicName, string filter = default(string), int? top = default(int?)) + { + return operations.ListBySystemTopicAsync(resourceGroupName, systemTopicName, filter, top).GetAwaiter().GetResult(); + } + + /// + /// List event subscriptions of a system topic. + /// + /// + /// List event subscriptions that belong to a specific system topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySystemTopicAsync(this ISystemTopicEventSubscriptionsOperations operations, string resourceGroupName, string systemTopicName, string filter = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySystemTopicWithHttpMessagesAsync(resourceGroupName, systemTopicName, filter, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get delivery attributes for an event subscription. + /// + /// + /// Get all delivery attributes for an event subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + public static DeliveryAttributeListResult GetDeliveryAttributes(this ISystemTopicEventSubscriptionsOperations operations, string resourceGroupName, string systemTopicName, string eventSubscriptionName) + { + return operations.GetDeliveryAttributesAsync(resourceGroupName, systemTopicName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Get delivery attributes for an event subscription. + /// + /// + /// Get all delivery attributes for an event subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// The cancellation token. + /// + public static async Task GetDeliveryAttributesAsync(this ISystemTopicEventSubscriptionsOperations operations, string resourceGroupName, string systemTopicName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetDeliveryAttributesWithHttpMessagesAsync(resourceGroupName, systemTopicName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an event subscription for a system topic. + /// + /// + /// Asynchronously creates or updates an event subscription with the specified + /// parameters. Existing event subscriptions will be updated with this API. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// Event subscription properties containing the destination and filter + /// information. + /// + public static EventSubscription BeginCreateOrUpdate(this ISystemTopicEventSubscriptionsOperations operations, string resourceGroupName, string systemTopicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, systemTopicName, eventSubscriptionName, eventSubscriptionInfo).GetAwaiter().GetResult(); + } + + /// + /// Create or update an event subscription for a system topic. + /// + /// + /// Asynchronously creates or updates an event subscription with the specified + /// parameters. Existing event subscriptions will be updated with this API. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// Event subscription properties containing the destination and filter + /// information. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this ISystemTopicEventSubscriptionsOperations operations, string resourceGroupName, string systemTopicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, systemTopicName, eventSubscriptionName, eventSubscriptionInfo, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete an event subscription of a system topic. + /// + /// + /// Delete an event subscription of a system topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + public static void BeginDelete(this ISystemTopicEventSubscriptionsOperations operations, string resourceGroupName, string systemTopicName, string eventSubscriptionName) + { + operations.BeginDeleteAsync(resourceGroupName, systemTopicName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Delete an event subscription of a system topic. + /// + /// + /// Delete an event subscription of a system topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this ISystemTopicEventSubscriptionsOperations operations, string resourceGroupName, string systemTopicName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, systemTopicName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update event subscription of a system topic. + /// + /// + /// Update event subscription of a system topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// Updated event subscription information. + /// + public static EventSubscription BeginUpdate(this ISystemTopicEventSubscriptionsOperations operations, string resourceGroupName, string systemTopicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters) + { + return operations.BeginUpdateAsync(resourceGroupName, systemTopicName, eventSubscriptionName, eventSubscriptionUpdateParameters).GetAwaiter().GetResult(); + } + + /// + /// Update event subscription of a system topic. + /// + /// + /// Update event subscription of a system topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// Name of the event subscription to be created. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + /// + /// Updated event subscription information. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this ISystemTopicEventSubscriptionsOperations operations, string resourceGroupName, string systemTopicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, systemTopicName, eventSubscriptionName, eventSubscriptionUpdateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List event subscriptions of a system topic. + /// + /// + /// List event subscriptions that belong to a specific system topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListBySystemTopicNext(this ISystemTopicEventSubscriptionsOperations operations, string nextPageLink) + { + return operations.ListBySystemTopicNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List event subscriptions of a system topic. + /// + /// + /// List event subscriptions that belong to a specific system topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySystemTopicNextAsync(this ISystemTopicEventSubscriptionsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySystemTopicNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/SystemTopicsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/SystemTopicsOperations.cs new file mode 100644 index 000000000000..d69e20b3f8b4 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/SystemTopicsOperations.cs @@ -0,0 +1,1749 @@ +// +// 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 Microsoft.Azure.Management.EventGrid +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// SystemTopicsOperations operations. + /// + internal partial class SystemTopicsOperations : IServiceOperations, ISystemTopicsOperations + { + /// + /// Initializes a new instance of the SystemTopicsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal SystemTopicsOperations(EventGridManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the EventGridManagementClient + /// + public EventGridManagementClient Client { get; private set; } + + /// + /// Get a system topic. + /// + /// + /// Get properties of a system topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// 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> GetWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (systemTopicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "systemTopicName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("systemTopicName", systemTopicName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{systemTopicName}", System.Uri.EscapeDataString(systemTopicName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create a system topic. + /// + /// + /// Asynchronously creates a new system topic with the specified parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// System Topic information. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, SystemTopic systemTopicInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, systemTopicName, systemTopicInfo, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Delete a system topic. + /// + /// + /// Delete existing system topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, systemTopicName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Update a system topic. + /// + /// + /// Asynchronously updates a system topic with the specified parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// SystemTopic update information. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, SystemTopicUpdateParameters systemTopicUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, systemTopicName, systemTopicUpdateParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// List system topics under an Azure subscription. + /// + /// + /// List all the system topics under an Azure subscription. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + /// + /// 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>> ListBySubscriptionWithHttpMessagesAsync(string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("filter", filter); + tracingParameters.Add("top", top); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/systemTopics").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List system topics under a resource group. + /// + /// + /// List all the system topics under a resource group. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + /// + /// 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("filter", filter); + tracingParameters.Add("top", top); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create a system topic. + /// + /// + /// Asynchronously creates a new system topic with the specified parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// System Topic information. + /// + /// + /// 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> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, SystemTopic systemTopicInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (systemTopicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "systemTopicName"); + } + if (systemTopicInfo == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "systemTopicInfo"); + } + if (systemTopicInfo != null) + { + systemTopicInfo.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("systemTopicName", systemTopicName); + tracingParameters.Add("systemTopicInfo", systemTopicInfo); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{systemTopicName}", System.Uri.EscapeDataString(systemTopicName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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(systemTopicInfo != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(systemTopicInfo, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete a system topic. + /// + /// + /// Delete existing system topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// 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 BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (systemTopicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "systemTopicName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("systemTopicName", systemTopicName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{systemTopicName}", System.Uri.EscapeDataString(systemTopicName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + 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 (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Update a system topic. + /// + /// + /// Asynchronously updates a system topic with the specified parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// SystemTopic update information. + /// + /// + /// 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> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string systemTopicName, SystemTopicUpdateParameters systemTopicUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (systemTopicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "systemTopicName"); + } + if (systemTopicUpdateParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "systemTopicUpdateParameters"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("systemTopicName", systemTopicName); + tracingParameters.Add("systemTopicUpdateParameters", systemTopicUpdateParameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{systemTopicName}", System.Uri.EscapeDataString(systemTopicName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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(systemTopicUpdateParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(systemTopicUpdateParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List system topics under an Azure subscription. + /// + /// + /// List all the system topics under an Azure subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// 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>> ListBySubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySubscriptionNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List system topics under a resource group. + /// + /// + /// List all the system topics under a resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// 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>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroupNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + 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; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/SystemTopicsOperationsExtensions.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/SystemTopicsOperationsExtensions.cs new file mode 100644 index 000000000000..e21413511587 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/SystemTopicsOperationsExtensions.cs @@ -0,0 +1,575 @@ +// +// 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 Microsoft.Azure.Management.EventGrid +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for SystemTopicsOperations. + /// + public static partial class SystemTopicsOperationsExtensions + { + /// + /// Get a system topic. + /// + /// + /// Get properties of a system topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + public static SystemTopic Get(this ISystemTopicsOperations operations, string resourceGroupName, string systemTopicName) + { + return operations.GetAsync(resourceGroupName, systemTopicName).GetAwaiter().GetResult(); + } + + /// + /// Get a system topic. + /// + /// + /// Get properties of a system topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this ISystemTopicsOperations operations, string resourceGroupName, string systemTopicName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, systemTopicName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create a system topic. + /// + /// + /// Asynchronously creates a new system topic with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// System Topic information. + /// + public static SystemTopic CreateOrUpdate(this ISystemTopicsOperations operations, string resourceGroupName, string systemTopicName, SystemTopic systemTopicInfo) + { + return operations.CreateOrUpdateAsync(resourceGroupName, systemTopicName, systemTopicInfo).GetAwaiter().GetResult(); + } + + /// + /// Create a system topic. + /// + /// + /// Asynchronously creates a new system topic with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// System Topic information. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this ISystemTopicsOperations operations, string resourceGroupName, string systemTopicName, SystemTopic systemTopicInfo, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, systemTopicName, systemTopicInfo, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete a system topic. + /// + /// + /// Delete existing system topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + public static void Delete(this ISystemTopicsOperations operations, string resourceGroupName, string systemTopicName) + { + operations.DeleteAsync(resourceGroupName, systemTopicName).GetAwaiter().GetResult(); + } + + /// + /// Delete a system topic. + /// + /// + /// Delete existing system topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this ISystemTopicsOperations operations, string resourceGroupName, string systemTopicName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, systemTopicName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update a system topic. + /// + /// + /// Asynchronously updates a system topic with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// SystemTopic update information. + /// + public static SystemTopic Update(this ISystemTopicsOperations operations, string resourceGroupName, string systemTopicName, SystemTopicUpdateParameters systemTopicUpdateParameters) + { + return operations.UpdateAsync(resourceGroupName, systemTopicName, systemTopicUpdateParameters).GetAwaiter().GetResult(); + } + + /// + /// Update a system topic. + /// + /// + /// Asynchronously updates a system topic with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// SystemTopic update information. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this ISystemTopicsOperations operations, string resourceGroupName, string systemTopicName, SystemTopicUpdateParameters systemTopicUpdateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, systemTopicName, systemTopicUpdateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List system topics under an Azure subscription. + /// + /// + /// List all the system topics under an Azure subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + public static IPage ListBySubscription(this ISystemTopicsOperations operations, string filter = default(string), int? top = default(int?)) + { + return operations.ListBySubscriptionAsync(filter, top).GetAwaiter().GetResult(); + } + + /// + /// List system topics under an Azure subscription. + /// + /// + /// List all the system topics under an Azure subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionAsync(this ISystemTopicsOperations operations, string filter = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(filter, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List system topics under a resource group. + /// + /// + /// List all the system topics under a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + public static IPage ListByResourceGroup(this ISystemTopicsOperations operations, string resourceGroupName, string filter = default(string), int? top = default(int?)) + { + return operations.ListByResourceGroupAsync(resourceGroupName, filter, top).GetAwaiter().GetResult(); + } + + /// + /// List system topics under a resource group. + /// + /// + /// List all the system topics under a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The query used to filter the search results using OData syntax. Filtering + /// is permitted on the 'name' property only and with limited number of OData + /// operations. These operations are: the 'contains' function as well as the + /// following logical operations: not, and, or, eq (for equal), and ne (for not + /// equal). No arithmetic operations are supported. The following is a valid + /// filter example: $filter=contains(namE, 'PATTERN') and name ne 'PATTERN-1'. + /// The following is not a valid filter example: $filter=location eq 'westus'. + /// + /// + /// The number of results to return per page for the list operation. Valid + /// range for top parameter is 1 to 100. If not specified, the default number + /// of results to be returned is 20 items per page. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this ISystemTopicsOperations operations, string resourceGroupName, string filter = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, filter, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create a system topic. + /// + /// + /// Asynchronously creates a new system topic with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// System Topic information. + /// + public static SystemTopic BeginCreateOrUpdate(this ISystemTopicsOperations operations, string resourceGroupName, string systemTopicName, SystemTopic systemTopicInfo) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, systemTopicName, systemTopicInfo).GetAwaiter().GetResult(); + } + + /// + /// Create a system topic. + /// + /// + /// Asynchronously creates a new system topic with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// System Topic information. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this ISystemTopicsOperations operations, string resourceGroupName, string systemTopicName, SystemTopic systemTopicInfo, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, systemTopicName, systemTopicInfo, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete a system topic. + /// + /// + /// Delete existing system topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + public static void BeginDelete(this ISystemTopicsOperations operations, string resourceGroupName, string systemTopicName) + { + operations.BeginDeleteAsync(resourceGroupName, systemTopicName).GetAwaiter().GetResult(); + } + + /// + /// Delete a system topic. + /// + /// + /// Delete existing system topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this ISystemTopicsOperations operations, string resourceGroupName, string systemTopicName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, systemTopicName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update a system topic. + /// + /// + /// Asynchronously updates a system topic with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// SystemTopic update information. + /// + public static SystemTopic BeginUpdate(this ISystemTopicsOperations operations, string resourceGroupName, string systemTopicName, SystemTopicUpdateParameters systemTopicUpdateParameters) + { + return operations.BeginUpdateAsync(resourceGroupName, systemTopicName, systemTopicUpdateParameters).GetAwaiter().GetResult(); + } + + /// + /// Update a system topic. + /// + /// + /// Asynchronously updates a system topic with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the system topic. + /// + /// + /// SystemTopic update information. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this ISystemTopicsOperations operations, string resourceGroupName, string systemTopicName, SystemTopicUpdateParameters systemTopicUpdateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, systemTopicName, systemTopicUpdateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List system topics under an Azure subscription. + /// + /// + /// List all the system topics under an Azure subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListBySubscriptionNext(this ISystemTopicsOperations operations, string nextPageLink) + { + return operations.ListBySubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List system topics under an Azure subscription. + /// + /// + /// List all the system topics under an Azure subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionNextAsync(this ISystemTopicsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List system topics under a resource group. + /// + /// + /// List all the system topics under a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByResourceGroupNext(this ISystemTopicsOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List system topics under a resource group. + /// + /// + /// List all the system topics under a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupNextAsync(this ISystemTopicsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/TopicsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/TopicsOperations.cs index 512713415598..6c5757f820f0 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/TopicsOperations.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/TopicsOperations.cs @@ -964,6 +964,37 @@ internal TopicsOperations(EventGridManagementClient client) /// Key name to regenerate key1 or key2 /// /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> RegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string topicName, string keyName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginRegenerateKeyWithHttpMessagesAsync(resourceGroupName, topicName, keyName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// List topic event types. + /// + /// + /// List event types for a topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Namespace of the provider of the topic. + /// + /// + /// Name of the topic type. + /// + /// + /// Name of the topic. + /// + /// /// Headers that will be added to request. /// /// @@ -984,7 +1015,7 @@ internal TopicsOperations(EventGridManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> RegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string topicName, string keyName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> ListEventTypesWithHttpMessagesAsync(string resourceGroupName, string providerNamespace, string resourceTypeName, string resourceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (Client.SubscriptionId == null) { @@ -994,22 +1025,21 @@ internal TopicsOperations(EventGridManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); } - if (topicName == null) + if (providerNamespace == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "topicName"); + throw new ValidationException(ValidationRules.CannotBeNull, "providerNamespace"); } - if (Client.ApiVersion == null) + if (resourceTypeName == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + throw new ValidationException(ValidationRules.CannotBeNull, "resourceTypeName"); } - if (keyName == null) + if (resourceName == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "keyName"); + throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); } - TopicRegenerateKeyRequest regenerateKeyRequest = new TopicRegenerateKeyRequest(); - if (keyName != null) + if (Client.ApiVersion == null) { - regenerateKeyRequest.KeyName = keyName; + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; @@ -1019,17 +1049,20 @@ internal TopicsOperations(EventGridManagementClient client) _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("topicName", topicName); - tracingParameters.Add("regenerateKeyRequest", regenerateKeyRequest); + tracingParameters.Add("providerNamespace", providerNamespace); + tracingParameters.Add("resourceTypeName", resourceTypeName); + tracingParameters.Add("resourceName", resourceName); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "RegenerateKey", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "ListEventTypes", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/regenerateKey").ToString(); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerNamespace}/{resourceTypeName}/{resourceName}/providers/Microsoft.EventGrid/eventTypes").ToString(); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{topicName}", System.Uri.EscapeDataString(topicName)); + _url = _url.Replace("{providerNamespace}", System.Uri.EscapeDataString(providerNamespace)); + _url = _url.Replace("{resourceTypeName}", System.Uri.EscapeDataString(resourceTypeName)); + _url = _url.Replace("{resourceName}", System.Uri.EscapeDataString(resourceName)); List _queryParameters = new List(); if (Client.ApiVersion != null) { @@ -1042,7 +1075,7 @@ internal TopicsOperations(EventGridManagementClient client) // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) @@ -1073,12 +1106,6 @@ internal TopicsOperations(EventGridManagementClient client) // Serialize Request string _requestContent = null; - if(regenerateKeyRequest != null) - { - _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(regenerateKeyRequest, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } // Set Credentials if (Client.Credentials != null) { @@ -1134,7 +1161,7 @@ internal TopicsOperations(EventGridManagementClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -1147,7 +1174,7 @@ internal TopicsOperations(EventGridManagementClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -1167,23 +1194,20 @@ internal TopicsOperations(EventGridManagementClient client) } /// - /// List topic event types. + /// Create a topic. /// /// - /// List event types for a topic. + /// Asynchronously creates a new topic with the specified parameters. /// /// /// The name of the resource group within the user's subscription. /// - /// - /// Namespace of the provider of the topic. - /// - /// - /// Name of the topic type. - /// - /// + /// /// Name of the topic. /// + /// + /// Topic information. + /// /// /// Headers that will be added to request. /// @@ -1205,7 +1229,7 @@ internal TopicsOperations(EventGridManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListEventTypesWithHttpMessagesAsync(string resourceGroupName, string providerNamespace, string resourceTypeName, string resourceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string topicName, Topic topicInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (Client.SubscriptionId == null) { @@ -1215,17 +1239,17 @@ internal TopicsOperations(EventGridManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); } - if (providerNamespace == null) + if (topicName == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "providerNamespace"); + throw new ValidationException(ValidationRules.CannotBeNull, "topicName"); } - if (resourceTypeName == null) + if (topicInfo == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceTypeName"); + throw new ValidationException(ValidationRules.CannotBeNull, "topicInfo"); } - if (resourceName == null) + if (topicInfo != null) { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); + topicInfo.Validate(); } if (Client.ApiVersion == null) { @@ -1239,20 +1263,17 @@ internal TopicsOperations(EventGridManagementClient client) _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("providerNamespace", providerNamespace); - tracingParameters.Add("resourceTypeName", resourceTypeName); - tracingParameters.Add("resourceName", resourceName); + tracingParameters.Add("topicName", topicName); + tracingParameters.Add("topicInfo", topicInfo); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListEventTypes", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerNamespace}/{resourceTypeName}/{resourceName}/providers/Microsoft.EventGrid/eventTypes").ToString(); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}").ToString(); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{providerNamespace}", System.Uri.EscapeDataString(providerNamespace)); - _url = _url.Replace("{resourceTypeName}", System.Uri.EscapeDataString(resourceTypeName)); - _url = _url.Replace("{resourceName}", System.Uri.EscapeDataString(resourceName)); + _url = _url.Replace("{topicName}", System.Uri.EscapeDataString(topicName)); List _queryParameters = new List(); if (Client.ApiVersion != null) { @@ -1265,7 +1286,7 @@ internal TopicsOperations(EventGridManagementClient client) // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.Method = new HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) @@ -1296,6 +1317,12 @@ internal TopicsOperations(EventGridManagementClient client) // Serialize Request string _requestContent = null; + if(topicInfo != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(topicInfo, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } // Set Credentials if (Client.Credentials != null) { @@ -1316,7 +1343,7 @@ internal TopicsOperations(EventGridManagementClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 200) + if ((int)_statusCode != 201) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try @@ -1351,7 +1378,7 @@ internal TopicsOperations(EventGridManagementClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse>(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -1359,12 +1386,12 @@ internal TopicsOperations(EventGridManagementClient client) _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } // Deserialize Response - if ((int)_statusCode == 200) + if ((int)_statusCode == 201) { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -1384,10 +1411,10 @@ internal TopicsOperations(EventGridManagementClient client) } /// - /// Create a topic. + /// Delete a topic. /// /// - /// Asynchronously creates a new topic with the specified parameters. + /// Delete existing topic. /// /// /// The name of the resource group within the user's subscription. @@ -1395,9 +1422,6 @@ internal TopicsOperations(EventGridManagementClient client) /// /// Name of the topic. /// - /// - /// Topic information. - /// /// /// Headers that will be added to request. /// @@ -1407,9 +1431,6 @@ internal TopicsOperations(EventGridManagementClient client) /// /// Thrown when the operation returned an invalid status code /// - /// - /// Thrown when unable to deserialize the response - /// /// /// Thrown when a required parameter is null /// @@ -1419,7 +1440,7 @@ internal TopicsOperations(EventGridManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string topicName, Topic topicInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string topicName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (Client.SubscriptionId == null) { @@ -1433,14 +1454,6 @@ internal TopicsOperations(EventGridManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "topicName"); } - if (topicInfo == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "topicInfo"); - } - if (topicInfo != null) - { - topicInfo.Validate(); - } if (Client.ApiVersion == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); @@ -1454,9 +1467,8 @@ internal TopicsOperations(EventGridManagementClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("topicName", topicName); - tracingParameters.Add("topicInfo", topicInfo); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; @@ -1476,7 +1488,7 @@ internal TopicsOperations(EventGridManagementClient client) // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.Method = new HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) @@ -1507,12 +1519,6 @@ internal TopicsOperations(EventGridManagementClient client) // Serialize Request string _requestContent = null; - if(topicInfo != null) - { - _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(topicInfo, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } // Set Credentials if (Client.Credentials != null) { @@ -1533,7 +1539,7 @@ internal TopicsOperations(EventGridManagementClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 201) + if ((int)_statusCode != 202 && (int)_statusCode != 204) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try @@ -1568,31 +1574,13 @@ internal TopicsOperations(EventGridManagementClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) { _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } if (_shouldTrace) { ServiceClientTracing.Exit(_invocationId, _result); @@ -1601,10 +1589,10 @@ internal TopicsOperations(EventGridManagementClient client) } /// - /// Delete a topic. + /// Update a topic. /// /// - /// Delete existing topic. + /// Asynchronously updates a topic with the specified parameters. /// /// /// The name of the resource group within the user's subscription. @@ -1612,6 +1600,9 @@ internal TopicsOperations(EventGridManagementClient client) /// /// Name of the topic. /// + /// + /// Topic update information. + /// /// /// Headers that will be added to request. /// @@ -1621,6 +1612,9 @@ internal TopicsOperations(EventGridManagementClient client) /// /// Thrown when the operation returned an invalid status code /// + /// + /// Thrown when unable to deserialize the response + /// /// /// Thrown when a required parameter is null /// @@ -1630,7 +1624,7 @@ internal TopicsOperations(EventGridManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string topicName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string topicName, TopicUpdateParameters topicUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (Client.SubscriptionId == null) { @@ -1644,6 +1638,10 @@ internal TopicsOperations(EventGridManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "topicName"); } + if (topicUpdateParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "topicUpdateParameters"); + } if (Client.ApiVersion == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); @@ -1657,8 +1655,9 @@ internal TopicsOperations(EventGridManagementClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("topicName", topicName); + tracingParameters.Add("topicUpdateParameters", topicUpdateParameters); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "BeginUpdate", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; @@ -1678,7 +1677,7 @@ internal TopicsOperations(EventGridManagementClient client) // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.Method = new HttpMethod("PATCH"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) @@ -1709,6 +1708,12 @@ internal TopicsOperations(EventGridManagementClient client) // Serialize Request string _requestContent = null; + if(topicUpdateParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(topicUpdateParameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } // Set Credentials if (Client.Credentials != null) { @@ -1729,7 +1734,7 @@ internal TopicsOperations(EventGridManagementClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 202 && (int)_statusCode != 204) + if ((int)_statusCode != 200 && (int)_statusCode != 201) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try @@ -1764,13 +1769,31 @@ internal TopicsOperations(EventGridManagementClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) { _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } if (_shouldTrace) { ServiceClientTracing.Exit(_invocationId, _result); @@ -1779,10 +1802,10 @@ internal TopicsOperations(EventGridManagementClient client) } /// - /// Update a topic. + /// Regenerate key for a topic. /// /// - /// Asynchronously updates a topic with the specified parameters. + /// Regenerate a shared access key for a topic. /// /// /// The name of the resource group within the user's subscription. @@ -1790,8 +1813,8 @@ internal TopicsOperations(EventGridManagementClient client) /// /// Name of the topic. /// - /// - /// Topic update information. + /// + /// Key name to regenerate key1 or key2 /// /// /// Headers that will be added to request. @@ -1814,7 +1837,7 @@ internal TopicsOperations(EventGridManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> BeginUpdateWithHttpMessagesAsync(string resourceGroupName, string topicName, TopicUpdateParameters topicUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> BeginRegenerateKeyWithHttpMessagesAsync(string resourceGroupName, string topicName, string keyName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (Client.SubscriptionId == null) { @@ -1828,14 +1851,19 @@ internal TopicsOperations(EventGridManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "topicName"); } - if (topicUpdateParameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "topicUpdateParameters"); - } if (Client.ApiVersion == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } + if (keyName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "keyName"); + } + TopicRegenerateKeyRequest regenerateKeyRequest = new TopicRegenerateKeyRequest(); + if (keyName != null) + { + regenerateKeyRequest.KeyName = keyName; + } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -1845,13 +1873,13 @@ internal TopicsOperations(EventGridManagementClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("topicName", topicName); - tracingParameters.Add("topicUpdateParameters", topicUpdateParameters); + tracingParameters.Add("regenerateKeyRequest", regenerateKeyRequest); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginUpdate", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "BeginRegenerateKey", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}").ToString(); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/regenerateKey").ToString(); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); _url = _url.Replace("{topicName}", System.Uri.EscapeDataString(topicName)); @@ -1867,7 +1895,7 @@ internal TopicsOperations(EventGridManagementClient client) // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) @@ -1898,9 +1926,9 @@ internal TopicsOperations(EventGridManagementClient client) // Serialize Request string _requestContent = null; - if(topicUpdateParameters != null) + if(regenerateKeyRequest != null) { - _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(topicUpdateParameters, Client.SerializationSettings); + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(regenerateKeyRequest, Client.SerializationSettings); _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } @@ -1924,7 +1952,7 @@ internal TopicsOperations(EventGridManagementClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 201) + if ((int)_statusCode != 200 && (int)_statusCode != 202) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try @@ -1959,7 +1987,7 @@ internal TopicsOperations(EventGridManagementClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -1967,12 +1995,12 @@ internal TopicsOperations(EventGridManagementClient client) _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } // Deserialize Response - if ((int)_statusCode == 201) + if ((int)_statusCode == 200) { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/TopicsOperationsExtensions.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/TopicsOperationsExtensions.cs index 8c3efa05753e..7d983f3a0cb7 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/TopicsOperationsExtensions.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/TopicsOperationsExtensions.cs @@ -649,6 +649,58 @@ public static Topic BeginUpdate(this ITopicsOperations operations, string resour } } + /// + /// Regenerate key for a topic. + /// + /// + /// Regenerate a shared access key for a topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the topic. + /// + /// + /// Key name to regenerate key1 or key2 + /// + public static TopicSharedAccessKeys BeginRegenerateKey(this ITopicsOperations operations, string resourceGroupName, string topicName, string keyName) + { + return operations.BeginRegenerateKeyAsync(resourceGroupName, topicName, keyName).GetAwaiter().GetResult(); + } + + /// + /// Regenerate key for a topic. + /// + /// + /// Regenerate a shared access key for a topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the topic. + /// + /// + /// Key name to regenerate key1 or key2 + /// + /// + /// The cancellation token. + /// + public static async Task BeginRegenerateKeyAsync(this ITopicsOperations operations, string resourceGroupName, string topicName, string keyName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginRegenerateKeyWithHttpMessagesAsync(resourceGroupName, topicName, keyName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// /// List topics under an Azure subscription. ///