From 51048bafdd309237b0e6d77b9c27e40510b8ac5c Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Sat, 26 Mar 2022 02:44:13 +0000 Subject: [PATCH] CodeGen from PR 18349 in Azure/azure-rest-api-specs Event Grid: add support for 2021-10-15-preview API version (#18349) * Using 2021-06-01-preview files as a baseline * Add swagger, example, and readme files for 2021-10-15-preview API version * Fix prettier errors and missing files * Fix Python readme file * Remove references to common-types files * Fix missing brace in example file * Fix ModelValidation errors * Fix more ModelValidation errors * Fix more ModelValidation errors * Make systemData read only * Run prettier for Channels_Update.json * Fix various linter errors * Data residency boundary fix --- .../src/Generated/ChannelsOperations.cs | 1526 ++++++++++++ .../Generated/ChannelsOperationsExtensions.cs | 456 ++++ .../DomainEventSubscriptionsOperations.cs | 1630 +++++++++++++ ...nEventSubscriptionsOperationsExtensions.cs | 587 +++++ ...DomainTopicEventSubscriptionsOperations.cs | 1701 +++++++++++++ ...cEventSubscriptionsOperationsExtensions.cs | 645 +++++ .../src/Generated/EventChannelsOperations.cs | 1098 +++++++++ .../EventChannelsOperationsExtensions.cs | 347 +++ .../Generated/EventGridManagementClient.cs | 90 +- .../Generated/EventSubscriptionsOperations.cs | 10 +- .../EventSubscriptionsOperationsExtensions.cs | 20 +- .../src/Generated/IChannelsOperations.cs | 280 +++ .../IDomainEventSubscriptionsOperations.cs | 355 +++ ...DomainTopicEventSubscriptionsOperations.cs | 385 +++ .../src/Generated/IEventChannelsOperations.cs | 218 ++ .../Generated/IEventGridManagementClient.cs | 64 +- .../IEventSubscriptionsOperations.cs | 8 +- .../IPartnerConfigurationsOperations.cs | 358 +++ .../IPartnerDestinationsOperations.cs | 326 +++ .../Generated/IPartnerNamespacesOperations.cs | 421 ++++ .../IPartnerRegistrationsOperations.cs | 358 +++ ...artnerTopicEventSubscriptionsOperations.cs | 408 ++++ .../src/Generated/IPartnerTopicsOperations.cs | 354 +++ .../IPrivateEndpointConnectionsOperations.cs | 79 +- .../IPrivateLinkResourcesOperations.cs | 28 +- ...SystemTopicEventSubscriptionsOperations.cs | 8 +- .../ITopicEventSubscriptionsOperations.cs | 355 +++ .../Generated/IVerifiedPartnersOperations.cs | 115 + .../AzureADPartnerClientAuthentication.cs | 73 + .../src/Generated/Models/Channel.cs | 143 ++ .../Models/ChannelProvisioningState.cs | 26 + .../src/Generated/Models/ChannelType.cs | 22 + .../Models/ChannelUpdateParameters.cs | 83 + .../Generated/Models/DataResidencyBoundary.cs | 22 + .../src/Generated/Models/Domain.cs | 58 +- .../Models/DomainUpdateParameters.cs | 21 +- .../src/Generated/Models/EventChannel.cs | 143 ++ .../Models/EventChannelDestination.cs | 81 + .../Generated/Models/EventChannelFilter.cs | 68 + .../Models/EventChannelProvisioningState.cs | 26 + .../Generated/Models/EventChannelSource.cs | 56 + .../Generated/Models/EventDefinitionKind.cs | 21 + .../src/Generated/Models/EventSubscription.cs | 19 +- .../EventSubscriptionUpdateParameters.cs | 19 +- .../src/Generated/Models/EventTypeInfo.cs | 74 + .../src/Generated/Models/ExtendedLocation.cs | 60 + .../src/Generated/Models/ExtensionTopic.cs | 6 +- .../Generated/Models/InlineEventProperties.cs | 70 + .../src/Generated/Models/Operation.cs | 30 +- .../src/Generated/Models/ParentType.cs | 23 + .../src/Generated/Models/Partner.cs | 85 + .../Generated/Models/PartnerAuthorization.cs | 70 + .../Models/PartnerClientAuthentication.cs | 36 + .../Generated/Models/PartnerConfiguration.cs | 100 + .../PartnerConfigurationProvisioningState.cs | 26 + .../PartnerConfigurationUpdateParameters.cs | 71 + .../Generated/Models/PartnerDestination.cs | 150 ++ .../PartnerDestinationActivationState.cs | 22 + .../Models/PartnerDestinationInfo.cs | 100 + .../PartnerDestinationProvisioningState.cs | 26 + .../PartnerDestinationUpdateParameters.cs | 56 + .../src/Generated/Models/PartnerDetails.cs | 78 + .../PartnerEventSubscriptionDestination.cs | 56 + .../src/Generated/Models/PartnerNamespace.cs | 177 ++ .../PartnerNamespaceProvisioningState.cs | 26 + .../PartnerNamespaceRegenerateKeyRequest.cs | 68 + .../PartnerNamespaceSharedAccessKeys.cs | 63 + .../PartnerNamespaceUpdateParameters.cs | 101 + .../Generated/Models/PartnerRegistration.cs | 244 ++ .../PartnerRegistrationProvisioningState.cs | 26 + .../PartnerRegistrationUpdateParameters.cs | 123 + .../PartnerRegistrationVisibilityState.cs | 23 + .../src/Generated/Models/PartnerTopic.cs | 176 ++ .../Models/PartnerTopicActivationState.cs | 23 + .../src/Generated/Models/PartnerTopicInfo.cs | 106 + .../Models/PartnerTopicProvisioningState.cs | 26 + .../Models/PartnerTopicReadinessState.cs | 24 + .../Models/PartnerTopicRoutingMode.cs | 22 + .../Models/PartnerTopicUpdateParameters.cs | 64 + .../Models/PartnerUpdateDestinationInfo.cs | 36 + .../Models/PartnerUpdateTopicInfo.cs | 52 + .../src/Generated/Models/ReadinessState.cs | 22 + .../src/Generated/Models/Resource.cs | 2 +- .../src/Generated/Models/ResourceKind.cs | 22 + .../Models/ResourceMoveChangeHistory.cs | 70 + .../src/Generated/Models/ResourceSku.cs | 54 + .../src/Generated/Models/Sku.cs | 22 + .../src/Generated/Models/SystemTopic.cs | 20 +- .../src/Generated/Models/Topic.cs | 40 +- .../Generated/Models/TopicUpdateParameters.cs | 25 +- .../src/Generated/Models/VerifiedPartner.cs | 117 + .../VerifiedPartnerProvisioningState.cs | 26 + .../Models/WebhookPartnerDestinationInfo.cs | 92 + .../WebhookUpdatePartnerDestinationInfo.cs | 75 + .../PartnerConfigurationsOperations.cs | 1914 +++++++++++++++ ...rtnerConfigurationsOperationsExtensions.cs | 571 +++++ .../PartnerDestinationsOperations.cs | 1876 +++++++++++++++ ...PartnerDestinationsOperationsExtensions.cs | 521 ++++ .../Generated/PartnerNamespacesOperations.cs | 2132 +++++++++++++++++ .../PartnerNamespacesOperationsExtensions.cs | 677 ++++++ .../PartnerRegistrationsOperations.cs | 1731 +++++++++++++ ...artnerRegistrationsOperationsExtensions.cs | 575 +++++ ...artnerTopicEventSubscriptionsOperations.cs | 1840 ++++++++++++++ ...cEventSubscriptionsOperationsExtensions.cs | 673 ++++++ .../src/Generated/PartnerTopicsOperations.cs | 2073 ++++++++++++++++ .../PartnerTopicsOperationsExtensions.cs | 563 +++++ .../PrivateEndpointConnectionsOperations.cs | 83 +- ...EndpointConnectionsOperationsExtensions.cs | 150 +- .../PrivateLinkResourcesOperations.cs | 28 +- ...rivateLinkResourcesOperationsExtensions.cs | 56 +- .../SdkInfo_EventGridManagementClient.cs | 45 +- ...SystemTopicEventSubscriptionsOperations.cs | 8 +- ...cEventSubscriptionsOperationsExtensions.cs | 16 +- .../TopicEventSubscriptionsOperations.cs | 1630 +++++++++++++ ...cEventSubscriptionsOperationsExtensions.cs | 587 +++++ .../src/Generated/TopicsOperations.cs | 2 +- .../Generated/VerifiedPartnersOperations.cs | 615 +++++ .../VerifiedPartnersOperationsExtensions.cs | 167 ++ 118 files changed, 34453 insertions(+), 297 deletions(-) create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ChannelsOperations.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ChannelsOperationsExtensions.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/DomainEventSubscriptionsOperations.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/DomainEventSubscriptionsOperationsExtensions.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/DomainTopicEventSubscriptionsOperations.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/DomainTopicEventSubscriptionsOperationsExtensions.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventChannelsOperations.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventChannelsOperationsExtensions.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IChannelsOperations.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IDomainEventSubscriptionsOperations.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IDomainTopicEventSubscriptionsOperations.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IEventChannelsOperations.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerConfigurationsOperations.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerDestinationsOperations.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerNamespacesOperations.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerRegistrationsOperations.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerTopicEventSubscriptionsOperations.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerTopicsOperations.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ITopicEventSubscriptionsOperations.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IVerifiedPartnersOperations.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/AzureADPartnerClientAuthentication.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Channel.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ChannelProvisioningState.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ChannelType.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ChannelUpdateParameters.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DataResidencyBoundary.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventChannel.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventChannelDestination.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventChannelFilter.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventChannelProvisioningState.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventChannelSource.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventDefinitionKind.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventTypeInfo.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ExtendedLocation.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/InlineEventProperties.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ParentType.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Partner.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerAuthorization.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerClientAuthentication.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerConfiguration.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerConfigurationProvisioningState.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerConfigurationUpdateParameters.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerDestination.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerDestinationActivationState.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerDestinationInfo.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerDestinationProvisioningState.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerDestinationUpdateParameters.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerDetails.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerEventSubscriptionDestination.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerNamespace.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerNamespaceProvisioningState.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerNamespaceRegenerateKeyRequest.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerNamespaceSharedAccessKeys.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerNamespaceUpdateParameters.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerRegistration.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerRegistrationProvisioningState.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerRegistrationUpdateParameters.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerRegistrationVisibilityState.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopic.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicActivationState.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicInfo.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicProvisioningState.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicReadinessState.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicRoutingMode.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicUpdateParameters.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerUpdateDestinationInfo.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerUpdateTopicInfo.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ReadinessState.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ResourceKind.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ResourceMoveChangeHistory.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ResourceSku.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Sku.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/VerifiedPartner.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/VerifiedPartnerProvisioningState.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/WebhookPartnerDestinationInfo.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/WebhookUpdatePartnerDestinationInfo.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerConfigurationsOperations.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerConfigurationsOperationsExtensions.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerDestinationsOperations.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerDestinationsOperationsExtensions.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerNamespacesOperations.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerNamespacesOperationsExtensions.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerRegistrationsOperations.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerRegistrationsOperationsExtensions.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerTopicEventSubscriptionsOperations.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerTopicEventSubscriptionsOperationsExtensions.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerTopicsOperations.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerTopicsOperationsExtensions.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/TopicEventSubscriptionsOperations.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/TopicEventSubscriptionsOperationsExtensions.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/VerifiedPartnersOperations.cs create mode 100644 sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/VerifiedPartnersOperationsExtensions.cs diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ChannelsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ChannelsOperations.cs new file mode 100644 index 0000000000000..00f6e4b5999f1 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ChannelsOperations.cs @@ -0,0 +1,1526 @@ +// +// 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; + + /// + /// ChannelsOperations operations. + /// + internal partial class ChannelsOperations : IServiceOperations, IChannelsOperations + { + /// + /// Initializes a new instance of the ChannelsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ChannelsOperations(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 channel. + /// + /// + /// Get properties of a channel. + /// + /// + /// The name of the resource group within the partners subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the 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 channelName, 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 (channelName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "channelName"); + } + 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("channelName", channelName); + 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}/channels/{channelName}").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("{channelName}", System.Uri.EscapeDataString(channelName)); + 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 a channel. + /// + /// + /// Synchronously creates or updates a new channel with the specified + /// parameters. + /// + /// + /// The name of the resource group within the partners subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the channel. + /// + /// + /// Channel 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 channelName, Channel channelInfo, 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 (channelName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "channelName"); + } + if (channelInfo == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "channelInfo"); + } + 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("channelName", channelName); + tracingParameters.Add("channelInfo", channelInfo); + 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}/channels/{channelName}").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("{channelName}", System.Uri.EscapeDataString(channelName)); + 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(channelInfo != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(channelInfo, 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 channel. + /// + /// + /// Delete an existing channel. + /// + /// + /// The name of the resource group within the partners subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the channel. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, string channelName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, channelName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Update a Channel. + /// + /// + /// Synchronously updates a channel with the specified parameters. + /// + /// + /// The name of the resource group within the partners subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the channel. + /// + /// + /// Channel update information. + /// + /// + /// 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 UpdateWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, string channelName, ChannelUpdateParameters channelUpdateParameters, 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 (channelName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "channelName"); + } + if (channelUpdateParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "channelUpdateParameters"); + } + 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("channelName", channelName); + tracingParameters.Add("channelUpdateParameters", channelUpdateParameters); + 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/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}").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("{channelName}", System.Uri.EscapeDataString(channelName)); + 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(channelUpdateParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(channelUpdateParameters, 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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List channels. + /// + /// + /// List all the channels in a partner namespace. + /// + /// + /// The name of the resource group within the partners 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}/channels").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; + } + + /// + /// Get full URL of partner destination channel. + /// + /// + /// Get the full endpoint URL of a partner destination channel. + /// + /// + /// The name of the resource group within the partners subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the 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> GetFullUrlWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, string channelName, 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 (channelName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "channelName"); + } + 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("channelName", channelName); + 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/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}/getFullUrl").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("{channelName}", System.Uri.EscapeDataString(channelName)); + 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 channel. + /// + /// + /// Delete an existing channel. + /// + /// + /// The name of the resource group within the partners subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the 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 channelName, 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 (channelName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "channelName"); + } + 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("channelName", channelName); + 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}/channels/{channelName}").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("{channelName}", System.Uri.EscapeDataString(channelName)); + 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 channels. + /// + /// + /// List all the 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/ChannelsOperationsExtensions.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ChannelsOperationsExtensions.cs new file mode 100644 index 0000000000000..6d283896cb9f3 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ChannelsOperationsExtensions.cs @@ -0,0 +1,456 @@ +// +// 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 ChannelsOperations. + /// + public static partial class ChannelsOperationsExtensions + { + /// + /// Get a channel. + /// + /// + /// Get properties of a channel. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the partners subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the channel. + /// + public static Channel Get(this IChannelsOperations operations, string resourceGroupName, string partnerNamespaceName, string channelName) + { + return operations.GetAsync(resourceGroupName, partnerNamespaceName, channelName).GetAwaiter().GetResult(); + } + + /// + /// Get a channel. + /// + /// + /// Get properties of a channel. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the partners subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the channel. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IChannelsOperations operations, string resourceGroupName, string partnerNamespaceName, string channelName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, channelName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update a channel. + /// + /// + /// Synchronously creates or updates a new channel with the specified + /// parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the partners subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the channel. + /// + /// + /// Channel information. + /// + public static Channel CreateOrUpdate(this IChannelsOperations operations, string resourceGroupName, string partnerNamespaceName, string channelName, Channel channelInfo) + { + return operations.CreateOrUpdateAsync(resourceGroupName, partnerNamespaceName, channelName, channelInfo).GetAwaiter().GetResult(); + } + + /// + /// Create or update a channel. + /// + /// + /// Synchronously creates or updates a new channel with the specified + /// parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the partners subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the channel. + /// + /// + /// Channel information. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IChannelsOperations operations, string resourceGroupName, string partnerNamespaceName, string channelName, Channel channelInfo, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, channelName, channelInfo, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete a channel. + /// + /// + /// Delete an existing channel. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the partners subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the channel. + /// + public static void Delete(this IChannelsOperations operations, string resourceGroupName, string partnerNamespaceName, string channelName) + { + operations.DeleteAsync(resourceGroupName, partnerNamespaceName, channelName).GetAwaiter().GetResult(); + } + + /// + /// Delete a channel. + /// + /// + /// Delete an existing channel. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the partners subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the channel. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IChannelsOperations operations, string resourceGroupName, string partnerNamespaceName, string channelName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, channelName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update a Channel. + /// + /// + /// Synchronously updates a channel with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the partners subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the channel. + /// + /// + /// Channel update information. + /// + public static void Update(this IChannelsOperations operations, string resourceGroupName, string partnerNamespaceName, string channelName, ChannelUpdateParameters channelUpdateParameters) + { + operations.UpdateAsync(resourceGroupName, partnerNamespaceName, channelName, channelUpdateParameters).GetAwaiter().GetResult(); + } + + /// + /// Update a Channel. + /// + /// + /// Synchronously updates a channel with the specified parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the partners subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the channel. + /// + /// + /// Channel update information. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IChannelsOperations operations, string resourceGroupName, string partnerNamespaceName, string channelName, ChannelUpdateParameters channelUpdateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.UpdateWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, channelName, channelUpdateParameters, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// List channels. + /// + /// + /// List all the channels in a partner namespace. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the partners 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 IChannelsOperations operations, string resourceGroupName, string partnerNamespaceName, string filter = default(string), int? top = default(int?)) + { + return operations.ListByPartnerNamespaceAsync(resourceGroupName, partnerNamespaceName, filter, top).GetAwaiter().GetResult(); + } + + /// + /// List channels. + /// + /// + /// List all the channels in a partner namespace. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the partners 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 IChannelsOperations 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; + } + } + + /// + /// Get full URL of partner destination channel. + /// + /// + /// Get the full endpoint URL of a partner destination channel. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the partners subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the Channel. + /// + public static EventSubscriptionFullUrl GetFullUrl(this IChannelsOperations operations, string resourceGroupName, string partnerNamespaceName, string channelName) + { + return operations.GetFullUrlAsync(resourceGroupName, partnerNamespaceName, channelName).GetAwaiter().GetResult(); + } + + /// + /// Get full URL of partner destination channel. + /// + /// + /// Get the full endpoint URL of a partner destination channel. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the partners subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the Channel. + /// + /// + /// The cancellation token. + /// + public static async Task GetFullUrlAsync(this IChannelsOperations operations, string resourceGroupName, string partnerNamespaceName, string channelName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetFullUrlWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, channelName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete a channel. + /// + /// + /// Delete an existing channel. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the partners subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the channel. + /// + public static void BeginDelete(this IChannelsOperations operations, string resourceGroupName, string partnerNamespaceName, string channelName) + { + operations.BeginDeleteAsync(resourceGroupName, partnerNamespaceName, channelName).GetAwaiter().GetResult(); + } + + /// + /// Delete a channel. + /// + /// + /// Delete an existing channel. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the partners subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the channel. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IChannelsOperations operations, string resourceGroupName, string partnerNamespaceName, string channelName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, channelName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// List channels. + /// + /// + /// List all the 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 IChannelsOperations operations, string nextPageLink) + { + return operations.ListByPartnerNamespaceNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List channels. + /// + /// + /// List all the 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 IChannelsOperations 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/DomainEventSubscriptionsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/DomainEventSubscriptionsOperations.cs new file mode 100644 index 0000000000000..91eb24b322296 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/DomainEventSubscriptionsOperations.cs @@ -0,0 +1,1630 @@ +// +// 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; + + /// + /// DomainEventSubscriptionsOperations operations. + /// + internal partial class DomainEventSubscriptionsOperations : IServiceOperations, IDomainEventSubscriptionsOperations + { + /// + /// Initializes a new instance of the DomainEventSubscriptionsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal DomainEventSubscriptionsOperations(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 domain. + /// + /// + /// Get properties of an event subscription of a domain. + /// + /// + /// 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 domainName, 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 (domainName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "domainName"); + } + 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("domainName", domainName); + 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/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{domainName}", System.Uri.EscapeDataString(domainName)); + _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 to a domain. + /// + /// + /// Asynchronously creates a new event subscription or updates an existing + /// event subscription. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain 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 domainName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, domainName, eventSubscriptionName, eventSubscriptionInfo, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Delete an event subscription for a domain. + /// + /// + /// Delete an existing event subscription for a domain. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the event subscription to be deleted. 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 domainName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, domainName, eventSubscriptionName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Update an event subscription for a domain. + /// + /// + /// Update an existing event subscription for a topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the event subscription to be updated. + /// + /// + /// Updated event subscription information. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string domainName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, domainName, eventSubscriptionName, eventSubscriptionUpdateParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get full URL of an event subscription for domain. + /// + /// + /// Get the full endpoint URL for an event subscription for domain. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain 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> GetFullUrlWithHttpMessagesAsync(string resourceGroupName, string domainName, 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 (domainName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "domainName"); + } + 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("domainName", domainName); + 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/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{domainName}", System.Uri.EscapeDataString(domainName)); + _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 all event subscriptions for a specific domain. + /// + /// + /// List all event subscriptions that have been created for a specific topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// 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(string resourceGroupName, string domainName, 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 (domainName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "domainName"); + } + 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("domainName", domainName); + 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("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{domainName}", System.Uri.EscapeDataString(domainName)); + 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; + } + + /// + /// Get delivery attributes for an event subscription for domain. + /// + /// + /// Get all delivery attributes for an event subscription for domain. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain 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 resourceGroupName, string domainName, 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 (domainName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "domainName"); + } + 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("domainName", domainName); + 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/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{domainName}", System.Uri.EscapeDataString(domainName)); + _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 to a domain. + /// + /// + /// Asynchronously creates a new event subscription or updates an existing + /// event subscription. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain 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 domainName, 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 (domainName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "domainName"); + } + 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("domainName", domainName); + 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/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{domainName}", System.Uri.EscapeDataString(domainName)); + _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 != 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 an event subscription for a domain. + /// + /// + /// Delete an existing event subscription for a domain. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the event subscription to be deleted. 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 domainName, 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 (domainName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "domainName"); + } + 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("domainName", domainName); + 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/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{domainName}", System.Uri.EscapeDataString(domainName)); + _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 an event subscription for a domain. + /// + /// + /// Update an existing event subscription for a topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the event subscription to be updated. + /// + /// + /// 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 domainName, 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 (domainName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "domainName"); + } + 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("domainName", domainName); + 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/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{domainName}", System.Uri.EscapeDataString(domainName)); + _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; + } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/DomainEventSubscriptionsOperationsExtensions.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/DomainEventSubscriptionsOperationsExtensions.cs new file mode 100644 index 0000000000000..19d6201ef585b --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/DomainEventSubscriptionsOperationsExtensions.cs @@ -0,0 +1,587 @@ +// +// 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 DomainEventSubscriptionsOperations. + /// + public static partial class DomainEventSubscriptionsOperationsExtensions + { + /// + /// Get an event subscription of a domain. + /// + /// + /// Get properties of an event subscription of a domain. + /// + /// + /// 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 IDomainEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string eventSubscriptionName) + { + return operations.GetAsync(resourceGroupName, domainName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Get an event subscription of a domain. + /// + /// + /// Get properties of an event subscription of a domain. + /// + /// + /// 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 IDomainEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, domainName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an event subscription to a domain. + /// + /// + /// Asynchronously creates a new event subscription or updates an existing + /// event subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain 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 IDomainEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo) + { + return operations.CreateOrUpdateAsync(resourceGroupName, domainName, eventSubscriptionName, eventSubscriptionInfo).GetAwaiter().GetResult(); + } + + /// + /// Create or update an event subscription to a domain. + /// + /// + /// Asynchronously creates a new event subscription or updates an existing + /// event subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain 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 IDomainEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, domainName, eventSubscriptionName, eventSubscriptionInfo, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete an event subscription for a domain. + /// + /// + /// Delete an existing event subscription for a domain. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the event subscription to be deleted. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + public static void Delete(this IDomainEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string eventSubscriptionName) + { + operations.DeleteAsync(resourceGroupName, domainName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Delete an event subscription for a domain. + /// + /// + /// Delete an existing event subscription for a domain. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the event subscription to be deleted. 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 IDomainEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, domainName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update an event subscription for a domain. + /// + /// + /// Update an existing event subscription for a topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the event subscription to be updated. + /// + /// + /// Updated event subscription information. + /// + public static EventSubscription Update(this IDomainEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters) + { + return operations.UpdateAsync(resourceGroupName, domainName, eventSubscriptionName, eventSubscriptionUpdateParameters).GetAwaiter().GetResult(); + } + + /// + /// Update an event subscription for a domain. + /// + /// + /// Update an existing event subscription for a topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the event subscription to be updated. + /// + /// + /// Updated event subscription information. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IDomainEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, domainName, eventSubscriptionName, eventSubscriptionUpdateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get full URL of an event subscription for domain. + /// + /// + /// Get the full endpoint URL for an event subscription for domain. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain topic. + /// + /// + /// Name of the event subscription. + /// + public static EventSubscriptionFullUrl GetFullUrl(this IDomainEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string eventSubscriptionName) + { + return operations.GetFullUrlAsync(resourceGroupName, domainName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Get full URL of an event subscription for domain. + /// + /// + /// Get the full endpoint URL for an event subscription for domain. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain topic. + /// + /// + /// Name of the event subscription. + /// + /// + /// The cancellation token. + /// + public static async Task GetFullUrlAsync(this IDomainEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetFullUrlWithHttpMessagesAsync(resourceGroupName, domainName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all event subscriptions for a specific domain. + /// + /// + /// List all event subscriptions that have been created for a specific topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + public static IEnumerable List(this IDomainEventSubscriptionsOperations operations, string resourceGroupName, string domainName) + { + return operations.ListAsync(resourceGroupName, domainName).GetAwaiter().GetResult(); + } + + /// + /// List all event subscriptions for a specific domain. + /// + /// + /// List all event subscriptions that have been created for a specific topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IDomainEventSubscriptionsOperations operations, string resourceGroupName, string domainName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, domainName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get delivery attributes for an event subscription for domain. + /// + /// + /// Get all delivery attributes for an event subscription for domain. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain topic. + /// + /// + /// Name of the event subscription. + /// + public static DeliveryAttributeListResult GetDeliveryAttributes(this IDomainEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string eventSubscriptionName) + { + return operations.GetDeliveryAttributesAsync(resourceGroupName, domainName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Get delivery attributes for an event subscription for domain. + /// + /// + /// Get all delivery attributes for an event subscription for domain. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain topic. + /// + /// + /// Name of the event subscription. + /// + /// + /// The cancellation token. + /// + public static async Task GetDeliveryAttributesAsync(this IDomainEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetDeliveryAttributesWithHttpMessagesAsync(resourceGroupName, domainName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an event subscription to a domain. + /// + /// + /// Asynchronously creates a new event subscription or updates an existing + /// event subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain 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 IDomainEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, domainName, eventSubscriptionName, eventSubscriptionInfo).GetAwaiter().GetResult(); + } + + /// + /// Create or update an event subscription to a domain. + /// + /// + /// Asynchronously creates a new event subscription or updates an existing + /// event subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain 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 IDomainEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, domainName, eventSubscriptionName, eventSubscriptionInfo, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete an event subscription for a domain. + /// + /// + /// Delete an existing event subscription for a domain. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the event subscription to be deleted. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + public static void BeginDelete(this IDomainEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string eventSubscriptionName) + { + operations.BeginDeleteAsync(resourceGroupName, domainName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Delete an event subscription for a domain. + /// + /// + /// Delete an existing event subscription for a domain. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the event subscription to be deleted. 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 IDomainEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, domainName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update an event subscription for a domain. + /// + /// + /// Update an existing event subscription for a topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the event subscription to be updated. + /// + /// + /// Updated event subscription information. + /// + public static EventSubscription BeginUpdate(this IDomainEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters) + { + return operations.BeginUpdateAsync(resourceGroupName, domainName, eventSubscriptionName, eventSubscriptionUpdateParameters).GetAwaiter().GetResult(); + } + + /// + /// Update an event subscription for a domain. + /// + /// + /// Update an existing event subscription for a topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the event subscription to be updated. + /// + /// + /// Updated event subscription information. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this IDomainEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, domainName, eventSubscriptionName, eventSubscriptionUpdateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/DomainTopicEventSubscriptionsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/DomainTopicEventSubscriptionsOperations.cs new file mode 100644 index 0000000000000..2a019c5ff21a6 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/DomainTopicEventSubscriptionsOperations.cs @@ -0,0 +1,1701 @@ +// +// 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; + + /// + /// DomainTopicEventSubscriptionsOperations operations. + /// + internal partial class DomainTopicEventSubscriptionsOperations : IServiceOperations, IDomainTopicEventSubscriptionsOperations + { + /// + /// Initializes a new instance of the DomainTopicEventSubscriptionsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal DomainTopicEventSubscriptionsOperations(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 nested event subscription for domain topic. + /// + /// + /// Get properties of a nested event subscription for a domain topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain 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> GetWithHttpMessagesAsync(string resourceGroupName, string domainName, string topicName, 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 (domainName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "domainName"); + } + if (topicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "topicName"); + } + 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("domainName", domainName); + tracingParameters.Add("topicName", topicName); + 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/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{domainName}", System.Uri.EscapeDataString(domainName)); + _url = _url.Replace("{topicName}", System.Uri.EscapeDataString(topicName)); + _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 a nested event subscription to a domain topic. + /// + /// + /// Asynchronously creates a new event subscription or updates an existing + /// event subscription. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain 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 domainName, string topicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, domainName, topicName, eventSubscriptionName, eventSubscriptionInfo, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Delete a nested event subscription for a domain topic. + /// + /// + /// Delete a nested existing event subscription for a domain topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain topic. + /// + /// + /// Name of the event subscription to be deleted. 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 domainName, string topicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, domainName, topicName, eventSubscriptionName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Update a nested event subscription for a domain topic. + /// + /// + /// Update an existing event subscription for a domain topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the topic. + /// + /// + /// Name of the event subscription to be updated. + /// + /// + /// Updated event subscription information. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string domainName, string topicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, domainName, topicName, eventSubscriptionName, eventSubscriptionUpdateParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get full URL of a nested event subscription for domain topic. + /// + /// + /// Get the full endpoint URL for a nested event subscription for domain topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain 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> GetFullUrlWithHttpMessagesAsync(string resourceGroupName, string domainName, string topicName, 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 (domainName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "domainName"); + } + if (topicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "topicName"); + } + 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("domainName", domainName); + tracingParameters.Add("topicName", topicName); + 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/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{domainName}", System.Uri.EscapeDataString(domainName)); + _url = _url.Replace("{topicName}", System.Uri.EscapeDataString(topicName)); + _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 all nested event subscriptions for a specific domain topic. + /// + /// + /// List all event subscriptions that have been created for a specific domain + /// topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain 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>> ListWithHttpMessagesAsync(string resourceGroupName, string domainName, string topicName, 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 (domainName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "domainName"); + } + if (topicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "topicName"); + } + 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("domainName", domainName); + tracingParameters.Add("topicName", topicName); + 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("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{domainName}", System.Uri.EscapeDataString(domainName)); + _url = _url.Replace("{topicName}", System.Uri.EscapeDataString(topicName)); + 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; + } + + /// + /// Get delivery attributes for an event subscription for domain topic. + /// + /// + /// Get all delivery attributes for an event subscription for domain topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain 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 resourceGroupName, string domainName, string topicName, 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 (domainName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "domainName"); + } + if (topicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "topicName"); + } + 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("domainName", domainName); + tracingParameters.Add("topicName", topicName); + 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/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{domainName}", System.Uri.EscapeDataString(domainName)); + _url = _url.Replace("{topicName}", System.Uri.EscapeDataString(topicName)); + _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 a nested event subscription to a domain topic. + /// + /// + /// Asynchronously creates a new event subscription or updates an existing + /// event subscription. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain 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 domainName, string topicName, 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 (domainName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "domainName"); + } + if (topicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "topicName"); + } + 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("domainName", domainName); + tracingParameters.Add("topicName", topicName); + 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/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{domainName}", System.Uri.EscapeDataString(domainName)); + _url = _url.Replace("{topicName}", System.Uri.EscapeDataString(topicName)); + _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 != 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 nested event subscription for a domain topic. + /// + /// + /// Delete a nested existing event subscription for a domain topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain topic. + /// + /// + /// Name of the event subscription to be deleted. 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 domainName, string topicName, 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 (domainName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "domainName"); + } + if (topicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "topicName"); + } + 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("domainName", domainName); + tracingParameters.Add("topicName", topicName); + 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/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{domainName}", System.Uri.EscapeDataString(domainName)); + _url = _url.Replace("{topicName}", System.Uri.EscapeDataString(topicName)); + _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 a nested event subscription for a domain topic. + /// + /// + /// Update an existing event subscription for a domain topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the topic. + /// + /// + /// Name of the event subscription to be updated. + /// + /// + /// 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 domainName, string topicName, 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 (domainName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "domainName"); + } + if (topicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "topicName"); + } + 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("domainName", domainName); + tracingParameters.Add("topicName", topicName); + 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/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{domainName}", System.Uri.EscapeDataString(domainName)); + _url = _url.Replace("{topicName}", System.Uri.EscapeDataString(topicName)); + _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; + } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/DomainTopicEventSubscriptionsOperationsExtensions.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/DomainTopicEventSubscriptionsOperationsExtensions.cs new file mode 100644 index 0000000000000..cc840a2583a53 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/DomainTopicEventSubscriptionsOperationsExtensions.cs @@ -0,0 +1,645 @@ +// +// 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 DomainTopicEventSubscriptionsOperations. + /// + public static partial class DomainTopicEventSubscriptionsOperationsExtensions + { + /// + /// Get a nested event subscription for domain topic. + /// + /// + /// Get properties of a nested event subscription for a domain topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain topic. + /// + /// + /// Name of the event subscription. + /// + public static EventSubscription Get(this IDomainTopicEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string topicName, string eventSubscriptionName) + { + return operations.GetAsync(resourceGroupName, domainName, topicName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Get a nested event subscription for domain topic. + /// + /// + /// Get properties of a nested event subscription for a domain topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain topic. + /// + /// + /// Name of the event subscription. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IDomainTopicEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string topicName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, domainName, topicName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update a nested event subscription to a domain topic. + /// + /// + /// Asynchronously creates a new event subscription or updates an existing + /// event subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain 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 IDomainTopicEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string topicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo) + { + return operations.CreateOrUpdateAsync(resourceGroupName, domainName, topicName, eventSubscriptionName, eventSubscriptionInfo).GetAwaiter().GetResult(); + } + + /// + /// Create or update a nested event subscription to a domain topic. + /// + /// + /// Asynchronously creates a new event subscription or updates an existing + /// event subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain 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 IDomainTopicEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string topicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, domainName, topicName, eventSubscriptionName, eventSubscriptionInfo, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete a nested event subscription for a domain topic. + /// + /// + /// Delete a nested existing event subscription for a domain topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain topic. + /// + /// + /// Name of the event subscription to be deleted. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + public static void Delete(this IDomainTopicEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string topicName, string eventSubscriptionName) + { + operations.DeleteAsync(resourceGroupName, domainName, topicName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Delete a nested event subscription for a domain topic. + /// + /// + /// Delete a nested existing event subscription for a domain topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain topic. + /// + /// + /// Name of the event subscription to be deleted. 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 IDomainTopicEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string topicName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, domainName, topicName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update a nested event subscription for a domain topic. + /// + /// + /// Update an existing event subscription for a domain topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the topic. + /// + /// + /// Name of the event subscription to be updated. + /// + /// + /// Updated event subscription information. + /// + public static EventSubscription Update(this IDomainTopicEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string topicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters) + { + return operations.UpdateAsync(resourceGroupName, domainName, topicName, eventSubscriptionName, eventSubscriptionUpdateParameters).GetAwaiter().GetResult(); + } + + /// + /// Update a nested event subscription for a domain topic. + /// + /// + /// Update an existing event subscription for a domain topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the topic. + /// + /// + /// Name of the event subscription to be updated. + /// + /// + /// Updated event subscription information. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IDomainTopicEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string topicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, domainName, topicName, eventSubscriptionName, eventSubscriptionUpdateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get full URL of a nested event subscription for domain topic. + /// + /// + /// Get the full endpoint URL for a nested event subscription for domain topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain topic. + /// + /// + /// Name of the event subscription. + /// + public static EventSubscriptionFullUrl GetFullUrl(this IDomainTopicEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string topicName, string eventSubscriptionName) + { + return operations.GetFullUrlAsync(resourceGroupName, domainName, topicName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Get full URL of a nested event subscription for domain topic. + /// + /// + /// Get the full endpoint URL for a nested event subscription for domain topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain topic. + /// + /// + /// Name of the event subscription. + /// + /// + /// The cancellation token. + /// + public static async Task GetFullUrlAsync(this IDomainTopicEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string topicName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetFullUrlWithHttpMessagesAsync(resourceGroupName, domainName, topicName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all nested event subscriptions for a specific domain topic. + /// + /// + /// List all event subscriptions that have been created for a specific domain + /// topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain topic. + /// + public static IEnumerable List(this IDomainTopicEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string topicName) + { + return operations.ListAsync(resourceGroupName, domainName, topicName).GetAwaiter().GetResult(); + } + + /// + /// List all nested event subscriptions for a specific domain topic. + /// + /// + /// List all event subscriptions that have been created for a specific domain + /// topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain topic. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IDomainTopicEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string topicName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, domainName, topicName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get delivery attributes for an event subscription for domain topic. + /// + /// + /// Get all delivery attributes for an event subscription for domain topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain topic. + /// + /// + /// Name of the event subscription. + /// + public static DeliveryAttributeListResult GetDeliveryAttributes(this IDomainTopicEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string topicName, string eventSubscriptionName) + { + return operations.GetDeliveryAttributesAsync(resourceGroupName, domainName, topicName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Get delivery attributes for an event subscription for domain topic. + /// + /// + /// Get all delivery attributes for an event subscription for domain topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain topic. + /// + /// + /// Name of the event subscription. + /// + /// + /// The cancellation token. + /// + public static async Task GetDeliveryAttributesAsync(this IDomainTopicEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string topicName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetDeliveryAttributesWithHttpMessagesAsync(resourceGroupName, domainName, topicName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update a nested event subscription to a domain topic. + /// + /// + /// Asynchronously creates a new event subscription or updates an existing + /// event subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain 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 IDomainTopicEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string topicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, domainName, topicName, eventSubscriptionName, eventSubscriptionInfo).GetAwaiter().GetResult(); + } + + /// + /// Create or update a nested event subscription to a domain topic. + /// + /// + /// Asynchronously creates a new event subscription or updates an existing + /// event subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain 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 IDomainTopicEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string topicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, domainName, topicName, eventSubscriptionName, eventSubscriptionInfo, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete a nested event subscription for a domain topic. + /// + /// + /// Delete a nested existing event subscription for a domain topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain topic. + /// + /// + /// Name of the event subscription to be deleted. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + public static void BeginDelete(this IDomainTopicEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string topicName, string eventSubscriptionName) + { + operations.BeginDeleteAsync(resourceGroupName, domainName, topicName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Delete a nested event subscription for a domain topic. + /// + /// + /// Delete a nested existing event subscription for a domain topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain topic. + /// + /// + /// Name of the event subscription to be deleted. 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 IDomainTopicEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string topicName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, domainName, topicName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update a nested event subscription for a domain topic. + /// + /// + /// Update an existing event subscription for a domain topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the topic. + /// + /// + /// Name of the event subscription to be updated. + /// + /// + /// Updated event subscription information. + /// + public static EventSubscription BeginUpdate(this IDomainTopicEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string topicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters) + { + return operations.BeginUpdateAsync(resourceGroupName, domainName, topicName, eventSubscriptionName, eventSubscriptionUpdateParameters).GetAwaiter().GetResult(); + } + + /// + /// Update a nested event subscription for a domain topic. + /// + /// + /// Update an existing event subscription for a domain topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the topic. + /// + /// + /// Name of the event subscription to be updated. + /// + /// + /// Updated event subscription information. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this IDomainTopicEventSubscriptionsOperations operations, string resourceGroupName, string domainName, string topicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, domainName, topicName, eventSubscriptionName, eventSubscriptionUpdateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} 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 0000000000000..7e3c982312e86 --- /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 0000000000000..69bb2a0d215ef --- /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 c04b859cac578..2bf858fb20291 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventGridManagementClient.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventGridManagementClient.cs @@ -76,6 +76,11 @@ public partial class EventGridManagementClient : ServiceClient public bool? GenerateClientRequestId { get; set; } + /// + /// Gets the IChannelsOperations. + /// + public virtual IChannelsOperations Channels { get; private set; } + /// /// Gets the IDomainsOperations. /// @@ -86,25 +91,70 @@ 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 IDomainTopicEventSubscriptionsOperations. + /// + public virtual IDomainTopicEventSubscriptionsOperations DomainTopicEventSubscriptions { get; private set; } + + /// + /// Gets the ITopicEventSubscriptionsOperations. + /// + public virtual ITopicEventSubscriptionsOperations TopicEventSubscriptions { get; private set; } + + /// + /// Gets the IDomainEventSubscriptionsOperations. + /// + public virtual IDomainEventSubscriptionsOperations DomainEventSubscriptions { 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 IPartnerConfigurationsOperations. /// - public virtual ITopicsOperations Topics { get; private set; } + public virtual IPartnerConfigurationsOperations PartnerConfigurations { get; private set; } + + /// + /// Gets the IPartnerDestinationsOperations. + /// + public virtual IPartnerDestinationsOperations PartnerDestinations { get; private set; } + + /// + /// Gets the IPartnerNamespacesOperations. + /// + 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. @@ -121,6 +171,11 @@ public partial class EventGridManagementClient : ServiceClient public virtual ISystemTopicsOperations SystemTopics { get; private set; } + /// + /// Gets the ITopicsOperations. + /// + public virtual ITopicsOperations Topics { get; private set; } + /// /// Gets the IExtensionTopicsOperations. /// @@ -131,6 +186,11 @@ public partial class EventGridManagementClient : ServiceClient public virtual ITopicTypesOperations TopicTypes { get; private set; } + /// + /// Gets the IVerifiedPartnersOperations. + /// + public virtual IVerifiedPartnersOperations VerifiedPartners { get; private set; } + /// /// Initializes a new instance of the EventGridManagementClient class. /// @@ -372,19 +432,31 @@ public EventGridManagementClient(System.Uri baseUri, ServiceClientCredentials cr /// private void Initialize() { + Channels = new ChannelsOperations(this); Domains = new DomainsOperations(this); DomainTopics = new DomainTopicsOperations(this); + EventChannels = new EventChannelsOperations(this); EventSubscriptions = new EventSubscriptionsOperations(this); + DomainTopicEventSubscriptions = new DomainTopicEventSubscriptionsOperations(this); + TopicEventSubscriptions = new TopicEventSubscriptionsOperations(this); + DomainEventSubscriptions = new DomainEventSubscriptionsOperations(this); SystemTopicEventSubscriptions = new SystemTopicEventSubscriptionsOperations(this); + PartnerTopicEventSubscriptions = new PartnerTopicEventSubscriptionsOperations(this); Operations = new Operations(this); - Topics = new TopicsOperations(this); + PartnerConfigurations = new PartnerConfigurationsOperations(this); + PartnerDestinations = new PartnerDestinationsOperations(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); + VerifiedPartners = new VerifiedPartnersOperations(this); BaseUri = new System.Uri("https://management.azure.com"); - ApiVersion = "2021-12-01"; + ApiVersion = "2021-10-15-preview"; AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; @@ -414,12 +486,18 @@ private void Initialize() new Iso8601TimeSpanConverter() } }; + SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("endpointType")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("endpointType")); + SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("clientAuthenticationType")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("clientAuthenticationType")); + SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("endpointType")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("endpointType")); 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")); 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 87b0edcf05ee3..7aaae6ca64aa2 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventSubscriptionsOperations.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventSubscriptionsOperations.cs @@ -2331,10 +2331,11 @@ internal EventSubscriptionsOperations(EventGridManagementClient client) } /// - /// List all event subscriptions for a specific topic. + /// List all event subscriptions. /// /// - /// List all event subscriptions that have been created for a specific topic. + /// List all event subscriptions that have been created for a specific + /// resource. /// /// /// The name of the resource group within the user's subscription. @@ -5050,10 +5051,11 @@ internal EventSubscriptionsOperations(EventGridManagementClient client) } /// - /// List all event subscriptions for a specific topic. + /// List all event subscriptions. /// /// - /// List all event subscriptions that have been created for a specific topic. + /// List all event subscriptions that have been created for a specific + /// resource. /// /// /// The NextLink from the previous successful call to List operation. 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 502da598df1d2..c8f8dcb6e7290 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventSubscriptionsOperationsExtensions.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/EventSubscriptionsOperationsExtensions.cs @@ -955,10 +955,11 @@ public static EventSubscriptionFullUrl GetFullUrl(this IEventSubscriptionsOperat } /// - /// List all event subscriptions for a specific topic. + /// List all event subscriptions. /// /// - /// List all event subscriptions that have been created for a specific topic. + /// List all event subscriptions that have been created for a specific + /// resource. /// /// /// The operations group for this extension method. @@ -995,10 +996,11 @@ public static EventSubscriptionFullUrl GetFullUrl(this IEventSubscriptionsOperat } /// - /// List all event subscriptions for a specific topic. + /// List all event subscriptions. /// /// - /// List all event subscriptions that have been created for a specific topic. + /// List all event subscriptions that have been created for a specific + /// resource. /// /// /// The operations group for this extension method. @@ -1744,10 +1746,11 @@ public static IPage ListRegionalByResourceGroupForTopicTypeNe } /// - /// List all event subscriptions for a specific topic. + /// List all event subscriptions. /// /// - /// List all event subscriptions that have been created for a specific topic. + /// List all event subscriptions that have been created for a specific + /// resource. /// /// /// The operations group for this extension method. @@ -1761,10 +1764,11 @@ public static IPage ListByResourceNext(this IEventSubscriptio } /// - /// List all event subscriptions for a specific topic. + /// List all event subscriptions. /// /// - /// List all event subscriptions that have been created for a specific topic. + /// List all event subscriptions that have been created for a specific + /// resource. /// /// /// The operations group for this extension method. diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IChannelsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IChannelsOperations.cs new file mode 100644 index 0000000000000..9bc20aa5079f1 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IChannelsOperations.cs @@ -0,0 +1,280 @@ +// +// 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; + + /// + /// ChannelsOperations operations. + /// + public partial interface IChannelsOperations + { + /// + /// Get a channel. + /// + /// + /// Get properties of a channel. + /// + /// + /// The name of the resource group within the partners subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the 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 channelName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update a channel. + /// + /// + /// Synchronously creates or updates a new channel with the specified + /// parameters. + /// + /// + /// The name of the resource group within the partners subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the channel. + /// + /// + /// Channel 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 channelName, Channel channelInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete a channel. + /// + /// + /// Delete an existing channel. + /// + /// + /// The name of the resource group within the partners subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the 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 channelName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update a Channel. + /// + /// + /// Synchronously updates a channel with the specified parameters. + /// + /// + /// The name of the resource group within the partners subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the channel. + /// + /// + /// Channel update information. + /// + /// + /// 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 UpdateWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, string channelName, ChannelUpdateParameters channelUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List channels. + /// + /// + /// List all the channels in a partner namespace. + /// + /// + /// The name of the resource group within the partners 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)); + /// + /// Get full URL of partner destination channel. + /// + /// + /// Get the full endpoint URL of a partner destination channel. + /// + /// + /// The name of the resource group within the partners subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the 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> GetFullUrlWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, string channelName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete a channel. + /// + /// + /// Delete an existing channel. + /// + /// + /// The name of the resource group within the partners subscription. + /// + /// + /// Name of the partner namespace. + /// + /// + /// Name of the 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 channelName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List channels. + /// + /// + /// List all the 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/IDomainEventSubscriptionsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IDomainEventSubscriptionsOperations.cs new file mode 100644 index 0000000000000..3e4e2edf23fa0 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IDomainEventSubscriptionsOperations.cs @@ -0,0 +1,355 @@ +// +// 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; + + /// + /// DomainEventSubscriptionsOperations operations. + /// + public partial interface IDomainEventSubscriptionsOperations + { + /// + /// Get an event subscription of a domain. + /// + /// + /// Get properties of an event subscription of a domain. + /// + /// + /// 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 domainName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an event subscription to a domain. + /// + /// + /// Asynchronously creates a new event subscription or updates an + /// existing event subscription. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain 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 domainName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete an event subscription for a domain. + /// + /// + /// Delete an existing event subscription for a domain. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the event subscription to be deleted. 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 domainName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update an event subscription for a domain. + /// + /// + /// Update an existing event subscription for a topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the event subscription to be updated. + /// + /// + /// 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 domainName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get full URL of an event subscription for domain. + /// + /// + /// Get the full endpoint URL for an event subscription for domain. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain 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> GetFullUrlWithHttpMessagesAsync(string resourceGroupName, string domainName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all event subscriptions for a specific domain. + /// + /// + /// List all event subscriptions that have been created for a specific + /// topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// 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(string resourceGroupName, string domainName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get delivery attributes for an event subscription for domain. + /// + /// + /// Get all delivery attributes for an event subscription for domain. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain 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 resourceGroupName, string domainName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an event subscription to a domain. + /// + /// + /// Asynchronously creates a new event subscription or updates an + /// existing event subscription. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain 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 domainName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete an event subscription for a domain. + /// + /// + /// Delete an existing event subscription for a domain. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the event subscription to be deleted. 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 domainName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update an event subscription for a domain. + /// + /// + /// Update an existing event subscription for a topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the event subscription to be updated. + /// + /// + /// 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 domainName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IDomainTopicEventSubscriptionsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IDomainTopicEventSubscriptionsOperations.cs new file mode 100644 index 0000000000000..e27ea90865024 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IDomainTopicEventSubscriptionsOperations.cs @@ -0,0 +1,385 @@ +// +// 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; + + /// + /// DomainTopicEventSubscriptionsOperations operations. + /// + public partial interface IDomainTopicEventSubscriptionsOperations + { + /// + /// Get a nested event subscription for domain topic. + /// + /// + /// Get properties of a nested event subscription for a domain topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain 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> GetWithHttpMessagesAsync(string resourceGroupName, string domainName, string topicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update a nested event subscription to a domain topic. + /// + /// + /// Asynchronously creates a new event subscription or updates an + /// existing event subscription. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain 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 domainName, string topicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete a nested event subscription for a domain topic. + /// + /// + /// Delete a nested existing event subscription for a domain topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain topic. + /// + /// + /// Name of the event subscription to be deleted. 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 domainName, string topicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update a nested event subscription for a domain topic. + /// + /// + /// Update an existing event subscription for a domain topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the topic. + /// + /// + /// Name of the event subscription to be updated. + /// + /// + /// 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 domainName, string topicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get full URL of a nested event subscription for domain topic. + /// + /// + /// Get the full endpoint URL for a nested event subscription for + /// domain topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain 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> GetFullUrlWithHttpMessagesAsync(string resourceGroupName, string domainName, string topicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all nested event subscriptions for a specific domain topic. + /// + /// + /// List all event subscriptions that have been created for a specific + /// domain topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain 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>> ListWithHttpMessagesAsync(string resourceGroupName, string domainName, string topicName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get delivery attributes for an event subscription for domain topic. + /// + /// + /// Get all delivery attributes for an event subscription for domain + /// topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain 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 resourceGroupName, string domainName, string topicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update a nested event subscription to a domain topic. + /// + /// + /// Asynchronously creates a new event subscription or updates an + /// existing event subscription. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain 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 domainName, string topicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete a nested event subscription for a domain topic. + /// + /// + /// Delete a nested existing event subscription for a domain topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the top level domain. + /// + /// + /// Name of the domain topic. + /// + /// + /// Name of the event subscription to be deleted. 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 domainName, string topicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update a nested event subscription for a domain topic. + /// + /// + /// Update an existing event subscription for a domain topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the topic. + /// + /// + /// Name of the event subscription to be updated. + /// + /// + /// 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 domainName, string topicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} 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 0000000000000..e15cbd6411c78 --- /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 58811dd25d58c..1e1d2515530be 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IEventGridManagementClient.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IEventGridManagementClient.cs @@ -71,6 +71,11 @@ public partial interface IEventGridManagementClient : System.IDisposable bool? GenerateClientRequestId { get; set; } + /// + /// Gets the IChannelsOperations. + /// + IChannelsOperations Channels { get; } + /// /// Gets the IDomainsOperations. /// @@ -81,25 +86,70 @@ public partial interface IEventGridManagementClient : System.IDisposable /// IDomainTopicsOperations DomainTopics { get; } + /// + /// Gets the IEventChannelsOperations. + /// + IEventChannelsOperations EventChannels { get; } + /// /// Gets the IEventSubscriptionsOperations. /// IEventSubscriptionsOperations EventSubscriptions { get; } + /// + /// Gets the IDomainTopicEventSubscriptionsOperations. + /// + IDomainTopicEventSubscriptionsOperations DomainTopicEventSubscriptions { get; } + + /// + /// Gets the ITopicEventSubscriptionsOperations. + /// + ITopicEventSubscriptionsOperations TopicEventSubscriptions { get; } + + /// + /// Gets the IDomainEventSubscriptionsOperations. + /// + IDomainEventSubscriptionsOperations DomainEventSubscriptions { get; } + /// /// Gets the ISystemTopicEventSubscriptionsOperations. /// ISystemTopicEventSubscriptionsOperations SystemTopicEventSubscriptions { get; } + /// + /// Gets the IPartnerTopicEventSubscriptionsOperations. + /// + IPartnerTopicEventSubscriptionsOperations PartnerTopicEventSubscriptions { get; } + /// /// Gets the IOperations. /// IOperations Operations { get; } /// - /// Gets the ITopicsOperations. + /// Gets the IPartnerConfigurationsOperations. /// - ITopicsOperations Topics { get; } + IPartnerConfigurationsOperations PartnerConfigurations { get; } + + /// + /// Gets the IPartnerDestinationsOperations. + /// + IPartnerDestinationsOperations PartnerDestinations { get; } + + /// + /// Gets the IPartnerNamespacesOperations. + /// + IPartnerNamespacesOperations PartnerNamespaces { get; } + + /// + /// Gets the IPartnerRegistrationsOperations. + /// + IPartnerRegistrationsOperations PartnerRegistrations { get; } + + /// + /// Gets the IPartnerTopicsOperations. + /// + IPartnerTopicsOperations PartnerTopics { get; } /// /// Gets the IPrivateEndpointConnectionsOperations. @@ -116,6 +166,11 @@ public partial interface IEventGridManagementClient : System.IDisposable /// ISystemTopicsOperations SystemTopics { get; } + /// + /// Gets the ITopicsOperations. + /// + ITopicsOperations Topics { get; } + /// /// Gets the IExtensionTopicsOperations. /// @@ -126,5 +181,10 @@ public partial interface IEventGridManagementClient : System.IDisposable /// ITopicTypesOperations TopicTypes { get; } + /// + /// Gets the IVerifiedPartnersOperations. + /// + IVerifiedPartnersOperations VerifiedPartners { get; } + } } 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 16d48daec43a8..05102a897befb 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IEventSubscriptionsOperations.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IEventSubscriptionsOperations.cs @@ -575,11 +575,11 @@ public partial interface IEventSubscriptionsOperations /// Task>> ListRegionalByResourceGroupForTopicTypeWithHttpMessagesAsync(string resourceGroupName, string location, string topicTypeName, string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// - /// List all event subscriptions for a specific topic. + /// List all event subscriptions. /// /// /// List all event subscriptions that have been created for a specific - /// topic. + /// resource. /// /// /// The name of the resource group within the user's subscription. @@ -1047,11 +1047,11 @@ public partial interface IEventSubscriptionsOperations /// Task>> ListRegionalByResourceGroupForTopicTypeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// - /// List all event subscriptions for a specific topic. + /// List all event subscriptions. /// /// /// List all event subscriptions that have been created for a specific - /// topic. + /// resource. /// /// /// The NextLink from the previous successful call to List operation. diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerConfigurationsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerConfigurationsOperations.cs new file mode 100644 index 0000000000000..9769d20c57e43 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerConfigurationsOperations.cs @@ -0,0 +1,358 @@ +// +// 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; + + /// + /// PartnerConfigurationsOperations operations. + /// + public partial interface IPartnerConfigurationsOperations + { + /// + /// Get a partner configuration. + /// + /// + /// Get properties of a partner configuration. + /// + /// + /// The name of the resource group within the user's 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> GetWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update a partner configuration. + /// + /// + /// Synchronously creates or updates a partner configuration with the + /// specified parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Partner configuration 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, PartnerConfiguration partnerConfigurationInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete a partner configuration. + /// + /// + /// Delete existing partner configuration. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// 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, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update a partner configuration. + /// + /// + /// Synchronously updates a partner configuration with the specified + /// parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Partner configuration 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, PartnerConfigurationUpdateParameters partnerConfigurationUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List partner configurations under a resource group. + /// + /// + /// List all the partner configurations under a resource group. + /// + /// + /// The name of the resource group within the user's 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List partner configurations under an Azure subscription. + /// + /// + /// List all the partner configurations 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)); + /// + /// Authorize a partner. + /// + /// + /// Authorize a single partner either by partner registration immutable + /// Id or by partner name. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The information of the partner to be authorized. + /// + /// + /// 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> AuthorizePartnerWithHttpMessagesAsync(string resourceGroupName, Partner partnerInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Unauthorize a partner. + /// + /// + /// Unauthorize a single partner either by partner registration + /// immutable Id or by partner name. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The information of the partner to be unauthorized. + /// + /// + /// 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> UnauthorizePartnerWithHttpMessagesAsync(string resourceGroupName, Partner partnerInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update a partner configuration. + /// + /// + /// Synchronously creates or updates a partner configuration with the + /// specified parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Partner configuration 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, PartnerConfiguration partnerConfigurationInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete a partner configuration. + /// + /// + /// Delete existing partner configuration. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// 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, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update a partner configuration. + /// + /// + /// Synchronously updates a partner configuration with the specified + /// parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Partner configuration 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, PartnerConfigurationUpdateParameters partnerConfigurationUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List partner configurations under an Azure subscription. + /// + /// + /// List all the partner configurations 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)); + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerDestinationsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerDestinationsOperations.cs new file mode 100644 index 0000000000000..58d599212edd4 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerDestinationsOperations.cs @@ -0,0 +1,326 @@ +// +// 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; + + /// + /// PartnerDestinationsOperations operations. + /// + public partial interface IPartnerDestinationsOperations + { + /// + /// Get a partner destination. + /// + /// + /// Get properties of a partner destination. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner destination. + /// + /// + /// 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 partnerDestinationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create a partner destination. + /// + /// + /// Asynchronously creates a new partner destination with the specified + /// parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner destination. + /// + /// + /// Partner destination create 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 partnerDestinationName, PartnerDestination partnerDestination, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete a partner destination. + /// + /// + /// Delete existing partner destination. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner destination. + /// + /// + /// 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 partnerDestinationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update a partner destination. + /// + /// + /// Asynchronously updates a partner destination with the specified + /// parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner destination. + /// + /// + /// Tags of the Partner Destination 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string partnerDestinationName, IDictionary tags = default(IDictionary), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List partner destinations under an Azure subscription. + /// + /// + /// List all the partner destinations 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 destinations under a resource group. + /// + /// + /// List all the partner destinations 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 destination. + /// + /// + /// Activate a newly created partner destination. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner destination. + /// + /// + /// 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 partnerDestinationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete a partner destination. + /// + /// + /// Delete existing partner destination. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner destination. + /// + /// + /// 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 partnerDestinationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List partner destinations under an Azure subscription. + /// + /// + /// List all the partner destinations 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 destinations under a resource group. + /// + /// + /// List all the partner destinations 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/IPartnerNamespacesOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerNamespacesOperations.cs new file mode 100644 index 0000000000000..9d942e4f5364f --- /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. + /// + /// + /// Partner namespace 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 partnerNamespaceName, PartnerNamespaceUpdateParameters partnerNamespaceUpdateParameters, 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. + /// + /// + /// Partner namespace 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 partnerNamespaceName, PartnerNamespaceUpdateParameters partnerNamespaceUpdateParameters, 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 0000000000000..109b42d8caa92 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerRegistrationsOperations.cs @@ -0,0 +1,358 @@ +// +// 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)); + /// + /// 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> BeginCreateOrUpdateWithHttpMessagesAsync(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 BeginDeleteWithHttpMessagesAsync(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> BeginUpdateWithHttpMessagesAsync(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 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 0000000000000..133a0277db92a --- /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 properties of 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 existing 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 an existing 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 existing 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 an existing 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 0000000000000..a9191f6e8a9a3 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPartnerTopicsOperations.cs @@ -0,0 +1,354 @@ +// +// 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)); + /// + /// Create a partner topic. + /// + /// + /// Asynchronously creates a new partner topic with the specified + /// parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Partner 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 partnerTopicName, PartnerTopic partnerTopicInfo, 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. + /// + /// + /// PartnerTopic 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 partnerTopicName, PartnerTopicUpdateParameters partnerTopicUpdateParameters, 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/IPrivateEndpointConnectionsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPrivateEndpointConnectionsOperations.cs index 43246030c6337..40e714287e1b9 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPrivateEndpointConnectionsOperations.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPrivateEndpointConnectionsOperations.cs @@ -27,18 +27,20 @@ public partial interface IPrivateEndpointConnectionsOperations /// Get a specific private endpoint connection. /// /// - /// Get a specific private endpoint connection under a topic or domain. + /// Get a specific private endpoint connection under a topic, domain, + /// or partner namespace. /// /// /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. Possible values include: 'topics', 'domains' + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. Possible values include: + /// 'topics', 'domains', 'partnerNamespaces' /// /// - /// The name of the parent resource (namely, either, the topic name or - /// domain name). + /// The name of the parent resource (namely, either, the topic name, + /// domain name, or partner namespace name). /// /// /// The name of the private endpoint connection connection. @@ -63,19 +65,20 @@ public partial interface IPrivateEndpointConnectionsOperations /// Update a specific private endpoint connection. /// /// - /// Update a specific private endpoint connection under a topic or - /// domain. + /// Update a specific private endpoint connection under a topic, domain + /// or partner namespace. /// /// /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. Possible values include: 'topics', 'domains' + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. Possible values include: + /// 'topics', 'domains', 'partnerNamespaces' /// /// - /// The name of the parent resource (namely, either, the topic name or - /// domain name). + /// The name of the parent resource (namely, either, the topic name, + /// domain name, or partner namespace name). /// /// /// The name of the private endpoint connection connection. @@ -103,19 +106,20 @@ public partial interface IPrivateEndpointConnectionsOperations /// Delete a specific private endpoint connection. /// /// - /// Delete a specific private endpoint connection under a topic or - /// domain. + /// Delete a specific private endpoint connection under a topic, + /// domain, or partner namespace. /// /// /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. Possible values include: 'topics', 'domains' + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. Possible values include: + /// 'topics', 'domains', 'partnerNamespaces' /// /// - /// The name of the parent resource (namely, either, the topic name or - /// domain name). + /// The name of the parent resource (namely, either, the topic name, + /// domain name, or partner namespace name). /// /// /// The name of the private endpoint connection connection. @@ -137,18 +141,20 @@ public partial interface IPrivateEndpointConnectionsOperations /// Lists all private endpoint connections under a resource. /// /// - /// Get all private endpoint connections under a topic or domain. + /// Get all private endpoint connections under a topic, domain, or + /// partner namespace. /// /// /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. Possible values include: 'topics', 'domains' + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. Possible values include: + /// 'topics', 'domains', 'partnerNamespaces' /// /// - /// The name of the parent resource (namely, either, the topic name or - /// domain name). + /// The name of the parent resource (namely, either, the topic name, + /// domain name, or partner namespace name). /// /// /// The query used to filter the search results using OData syntax. @@ -186,19 +192,20 @@ public partial interface IPrivateEndpointConnectionsOperations /// Update a specific private endpoint connection. /// /// - /// Update a specific private endpoint connection under a topic or - /// domain. + /// Update a specific private endpoint connection under a topic, domain + /// or partner namespace. /// /// /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. Possible values include: 'topics', 'domains' + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. Possible values include: + /// 'topics', 'domains', 'partnerNamespaces' /// /// - /// The name of the parent resource (namely, either, the topic name or - /// domain name). + /// The name of the parent resource (namely, either, the topic name, + /// domain name, or partner namespace name). /// /// /// The name of the private endpoint connection connection. @@ -226,19 +233,20 @@ public partial interface IPrivateEndpointConnectionsOperations /// Delete a specific private endpoint connection. /// /// - /// Delete a specific private endpoint connection under a topic or - /// domain. + /// Delete a specific private endpoint connection under a topic, + /// domain, or partner namespace. /// /// /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. Possible values include: 'topics', 'domains' + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. Possible values include: + /// 'topics', 'domains', 'partnerNamespaces' /// /// - /// The name of the parent resource (namely, either, the topic name or - /// domain name). + /// The name of the parent resource (namely, either, the topic name, + /// domain name, or partner namespace name). /// /// /// The name of the private endpoint connection connection. @@ -260,7 +268,8 @@ public partial interface IPrivateEndpointConnectionsOperations /// Lists all private endpoint connections under a resource. /// /// - /// Get all private endpoint connections under a topic or domain. + /// Get all private endpoint connections under a topic, domain, or + /// partner namespace. /// /// /// The NextLink from the previous successful call to List operation. diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPrivateLinkResourcesOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPrivateLinkResourcesOperations.cs index ba46deb269104..a32356e5f4cc3 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPrivateLinkResourcesOperations.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IPrivateLinkResourcesOperations.cs @@ -33,12 +33,12 @@ public partial interface IPrivateLinkResourcesOperations /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. /// /// - /// The name of the parent resource (namely, either, the topic name or - /// domain name). + /// The name of the parent resource (namely, either, the topic name, + /// domain name, or partner namespace name). /// /// /// The name of private link resource. @@ -60,21 +60,23 @@ public partial interface IPrivateLinkResourcesOperations /// Task> GetWithHttpMessagesAsync(string resourceGroupName, string parentType, string parentName, string privateLinkResourceName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// - /// List private link resources under specific topic or domain. + /// List private link resources under specific topic, domain, or + /// partner namespace. /// /// - /// List all the private link resources under a topic or domain. + /// List all the private link resources under a topic, domain, or + /// partner namespace. /// /// /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. /// /// - /// The name of the parent resource (namely, either, the topic name or - /// domain name). + /// The name of the parent resource (namely, either, the topic name, + /// domain name, or partner namespace name). /// /// /// The query used to filter the search results using OData syntax. @@ -109,10 +111,12 @@ public partial interface IPrivateLinkResourcesOperations /// Task>> ListByResourceWithHttpMessagesAsync(string resourceGroupName, string parentType, string parentName, string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// - /// List private link resources under specific topic or domain. + /// List private link resources under specific topic, domain, or + /// partner namespace. /// /// - /// List all the private link resources under a topic or domain. + /// List all the private link resources under a topic, domain, or + /// partner namespace. /// /// /// The NextLink from the previous successful call to List operation. diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ISystemTopicEventSubscriptionsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ISystemTopicEventSubscriptionsOperations.cs index f4610328eca79..b62d833e334e7 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ISystemTopicEventSubscriptionsOperations.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ISystemTopicEventSubscriptionsOperations.cs @@ -99,7 +99,7 @@ public partial interface ISystemTopicEventSubscriptionsOperations /// Delete an event subscription of a system topic. /// /// - /// Delete an event subscription of a system topic. + /// Delete an existing event subscription of a system topic. /// /// /// The name of the resource group within the user's subscription. @@ -129,7 +129,7 @@ public partial interface ISystemTopicEventSubscriptionsOperations /// Update event subscription of a system topic. /// /// - /// Update event subscription of a system topic. + /// Update an existing event subscription of a system topic. /// /// /// The name of the resource group within the user's subscription. @@ -315,7 +315,7 @@ public partial interface ISystemTopicEventSubscriptionsOperations /// Delete an event subscription of a system topic. /// /// - /// Delete an event subscription of a system topic. + /// Delete an existing event subscription of a system topic. /// /// /// The name of the resource group within the user's subscription. @@ -345,7 +345,7 @@ public partial interface ISystemTopicEventSubscriptionsOperations /// Update event subscription of a system topic. /// /// - /// Update event subscription of a system topic. + /// Update an existing event subscription of a system topic. /// /// /// The name of the resource group within the user's subscription. diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ITopicEventSubscriptionsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ITopicEventSubscriptionsOperations.cs new file mode 100644 index 0000000000000..5d8c6034e26d2 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/ITopicEventSubscriptionsOperations.cs @@ -0,0 +1,355 @@ +// +// 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; + + /// + /// TopicEventSubscriptionsOperations operations. + /// + public partial interface ITopicEventSubscriptionsOperations + { + /// + /// Get an event subscription of a topic. + /// + /// + /// Get properties of an event subscription of a 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 topicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an event subscription to a topic. + /// + /// + /// Asynchronously creates a new event subscription or updates an + /// existing event subscription. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain 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 topicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete an event subscription for a topic. + /// + /// + /// Delete an existing event subscription for a topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the topic. + /// + /// + /// Name of the event subscription to be deleted. 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 topicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update an event subscription for a topic. + /// + /// + /// Update an existing event subscription for a topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the event subscription to be updated. + /// + /// + /// 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 topicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get full URL of an event subscription for topic. + /// + /// + /// Get the full endpoint URL for an event subscription for topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain 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> GetFullUrlWithHttpMessagesAsync(string resourceGroupName, string topicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all event subscriptions for a specific topic. + /// + /// + /// List all event subscriptions that have been created for a specific + /// topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the 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>> ListWithHttpMessagesAsync(string resourceGroupName, string topicName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get delivery attributes for an event subscription for topic. + /// + /// + /// Get all delivery attributes for an event subscription for topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain 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 resourceGroupName, string topicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update an event subscription to a topic. + /// + /// + /// Asynchronously creates a new event subscription or updates an + /// existing event subscription. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain 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 topicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete an event subscription for a topic. + /// + /// + /// Delete an existing event subscription for a topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the topic. + /// + /// + /// Name of the event subscription to be deleted. 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 topicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update an event subscription for a topic. + /// + /// + /// Update an existing event subscription for a topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the event subscription to be updated. + /// + /// + /// 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 topicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IVerifiedPartnersOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IVerifiedPartnersOperations.cs new file mode 100644 index 0000000000000..e03bf7590fc5e --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/IVerifiedPartnersOperations.cs @@ -0,0 +1,115 @@ +// +// 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; + + /// + /// VerifiedPartnersOperations operations. + /// + public partial interface IVerifiedPartnersOperations + { + /// + /// Get a verified partner. + /// + /// + /// Get properties of a verified partner. + /// + /// + /// Name of the verified partner. + /// + /// + /// 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 verifiedPartnerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all verified partners. + /// + /// + /// Get a list of all verified partners. + /// + /// + /// 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>> ListWithHttpMessagesAsync(string filter = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all verified partners. + /// + /// + /// Get a list of all verified partners. + /// + /// + /// 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>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/AzureADPartnerClientAuthentication.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/AzureADPartnerClientAuthentication.cs new file mode 100644 index 0000000000000..2855f91bd4fc0 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/AzureADPartnerClientAuthentication.cs @@ -0,0 +1,73 @@ +// +// 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; + + /// + /// Azure Active Directory Partner Client Authentication + /// + [Newtonsoft.Json.JsonObject("AzureAD")] + [Rest.Serialization.JsonTransformation] + public partial class AzureADPartnerClientAuthentication : PartnerClientAuthentication + { + /// + /// Initializes a new instance of the + /// AzureADPartnerClientAuthentication class. + /// + public AzureADPartnerClientAuthentication() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// AzureADPartnerClientAuthentication class. + /// + /// The Azure Active + /// Directory Tenant ID to get the access token that will be included + /// as the bearer token in delivery requests. + /// 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 AzureADPartnerClientAuthentication(string azureActiveDirectoryTenantId = default(string), string azureActiveDirectoryApplicationIdOrUri = default(string)) + { + AzureActiveDirectoryTenantId = azureActiveDirectoryTenantId; + AzureActiveDirectoryApplicationIdOrUri = azureActiveDirectoryApplicationIdOrUri; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the Azure Active Directory Tenant ID to get the access + /// token that will be included as the bearer token in delivery + /// requests. + /// + [JsonProperty(PropertyName = "properties.azureActiveDirectoryTenantId")] + public string AzureActiveDirectoryTenantId { get; set; } + + /// + /// Gets or sets the Azure Active Directory Application ID or URI to + /// get the access token that will be included as the bearer token in + /// delivery requests. + /// + [JsonProperty(PropertyName = "properties.azureActiveDirectoryApplicationIdOrUri")] + public string AzureActiveDirectoryApplicationIdOrUri { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Channel.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Channel.cs new file mode 100644 index 0000000000000..6bc9a37b3a639 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Channel.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; + + /// + /// Channel info. + /// + [Rest.Serialization.JsonTransformation] + public partial class Channel : Resource + { + /// + /// Initializes a new instance of the Channel class. + /// + public Channel() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Channel class. + /// + /// Fully qualified identifier of the + /// resource. + /// Name of the resource. + /// Type of the resource. + /// The type of the event channel which + /// represents the direction flow of events. Possible values include: + /// 'PartnerTopic', 'PartnerDestination' + /// This property should be populated + /// when channelType is PartnerTopic and represents information about + /// the partner topic resource corresponding to the channel. + /// This property should be + /// populated when channelType is PartnerDestination and represents + /// information about the partner destination resource corresponding to + /// the channel. + /// Context or helpful message that + /// can be used during the approval process by the subscriber. + /// Provisioning state of the channel. + /// Possible values include: 'Creating', 'Updating', 'Deleting', + /// 'Succeeded', 'Canceled', 'Failed' + /// The readiness state of the + /// corresponding partner topic. Possible values include: + /// 'NeverActivated', 'Activated' + /// Expiration time of + /// the channel. If this timer expires while the corresponding partner + /// topic is never activated, + /// the channel and corresponding partner topic are deleted. + /// The system metadata relating to Channel + /// resource. + public Channel(string id = default(string), string name = default(string), string type = default(string), string channelType = default(string), PartnerTopicInfo partnerTopicInfo = default(PartnerTopicInfo), PartnerDestinationInfo partnerDestinationInfo = default(PartnerDestinationInfo), string messageForActivation = default(string), string provisioningState = default(string), string readinessState = default(string), System.DateTime? expirationTimeIfNotActivatedUtc = default(System.DateTime?), SystemData systemData = default(SystemData)) + : base(id, name, type) + { + ChannelType = channelType; + PartnerTopicInfo = partnerTopicInfo; + PartnerDestinationInfo = partnerDestinationInfo; + MessageForActivation = messageForActivation; + ProvisioningState = provisioningState; + ReadinessState = readinessState; + ExpirationTimeIfNotActivatedUtc = expirationTimeIfNotActivatedUtc; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the type of the event channel which represents the + /// direction flow of events. Possible values include: 'PartnerTopic', + /// 'PartnerDestination' + /// + [JsonProperty(PropertyName = "properties.channelType")] + public string ChannelType { get; set; } + + /// + /// Gets or sets this property should be populated when channelType is + /// PartnerTopic and represents information about the partner topic + /// resource corresponding to the channel. + /// + [JsonProperty(PropertyName = "properties.partnerTopicInfo")] + public PartnerTopicInfo PartnerTopicInfo { get; set; } + + /// + /// Gets or sets this property should be populated when channelType is + /// PartnerDestination and represents information about the partner + /// destination resource corresponding to the channel. + /// + [JsonProperty(PropertyName = "properties.partnerDestinationInfo")] + public PartnerDestinationInfo PartnerDestinationInfo { get; set; } + + /// + /// Gets or sets context or helpful message that can be used during the + /// approval process by the subscriber. + /// + [JsonProperty(PropertyName = "properties.messageForActivation")] + public string MessageForActivation { get; set; } + + /// + /// Gets or sets provisioning state of the channel. Possible values + /// include: 'Creating', 'Updating', 'Deleting', 'Succeeded', + /// 'Canceled', 'Failed' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets or sets the readiness state of the corresponding partner + /// topic. Possible values include: 'NeverActivated', 'Activated' + /// + [JsonProperty(PropertyName = "properties.readinessState")] + public string ReadinessState { get; set; } + + /// + /// Gets or sets expiration time of the channel. If this timer expires + /// while the corresponding partner topic is never activated, + /// the channel and corresponding partner topic are deleted. + /// + [JsonProperty(PropertyName = "properties.expirationTimeIfNotActivatedUtc")] + public System.DateTime? ExpirationTimeIfNotActivatedUtc { get; set; } + + /// + /// Gets the system metadata relating to Channel resource. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ChannelProvisioningState.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ChannelProvisioningState.cs new file mode 100644 index 0000000000000..d433b0ff2c813 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ChannelProvisioningState.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 ChannelProvisioningState. + /// + public static class ChannelProvisioningState + { + 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/ChannelType.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ChannelType.cs new file mode 100644 index 0000000000000..f9b74ef385cb0 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ChannelType.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 ChannelType. + /// + public static class ChannelType + { + public const string PartnerTopic = "PartnerTopic"; + public const string PartnerDestination = "PartnerDestination"; + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ChannelUpdateParameters.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ChannelUpdateParameters.cs new file mode 100644 index 0000000000000..2a51a25bd34f6 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ChannelUpdateParameters.cs @@ -0,0 +1,83 @@ +// +// 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 the Channel update. + /// + [Rest.Serialization.JsonTransformation] + public partial class ChannelUpdateParameters + { + /// + /// Initializes a new instance of the ChannelUpdateParameters class. + /// + public ChannelUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ChannelUpdateParameters class. + /// + /// Expiration time of + /// the event channel. If this timer expires while the corresponding + /// partner topic or partner destination is never activated, + /// the channel and corresponding partner topic or partner destination + /// are deleted. + /// Partner destination properties + /// which can be updated if the channel is of type + /// PartnerDestination. + /// Partner topic properties which can + /// be updated if the channel is of type PartnerTopic. + public ChannelUpdateParameters(System.DateTime? expirationTimeIfNotActivatedUtc = default(System.DateTime?), PartnerUpdateDestinationInfo partnerDestinationInfo = default(PartnerUpdateDestinationInfo), PartnerUpdateTopicInfo partnerTopicInfo = default(PartnerUpdateTopicInfo)) + { + ExpirationTimeIfNotActivatedUtc = expirationTimeIfNotActivatedUtc; + PartnerDestinationInfo = partnerDestinationInfo; + PartnerTopicInfo = partnerTopicInfo; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets expiration time of the event channel. If this timer + /// expires while the corresponding partner topic or partner + /// destination is never activated, + /// the channel and corresponding partner topic or partner destination + /// are deleted. + /// + [JsonProperty(PropertyName = "properties.expirationTimeIfNotActivatedUtc")] + public System.DateTime? ExpirationTimeIfNotActivatedUtc { get; set; } + + /// + /// Gets or sets partner destination properties which can be updated if + /// the channel is of type PartnerDestination. + /// + [JsonProperty(PropertyName = "properties.partnerDestinationInfo")] + public PartnerUpdateDestinationInfo PartnerDestinationInfo { get; set; } + + /// + /// Gets or sets partner topic properties which can be updated if the + /// channel is of type PartnerTopic. + /// + [JsonProperty(PropertyName = "properties.partnerTopicInfo")] + public PartnerUpdateTopicInfo PartnerTopicInfo { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DataResidencyBoundary.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DataResidencyBoundary.cs new file mode 100644 index 0000000000000..546af74df3640 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/DataResidencyBoundary.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 DataResidencyBoundary. + /// + public static class DataResidencyBoundary + { + public const string WithinGeopair = "WithinGeopair"; + public const string WithinRegion = "WithinRegion"; + } +} 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 599e1ed396d44..10bbb0acc4c1f 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 @@ -45,16 +45,17 @@ public Domain() /// Provisioning state of the Event /// Grid Domain Resource. Possible values include: 'Creating', /// 'Updating', 'Deleting', 'Succeeded', 'Canceled', 'Failed' - /// Endpoint for the domain. + /// Endpoint for the Event Grid Domain Resource + /// which is used for publishing the events. /// This determines the format that Event - /// Grid should expect for incoming events published to the domain. - /// Possible values include: 'EventGridSchema', 'CustomEventSchema', - /// 'CloudEventSchemaV1_0' + /// Grid should expect for incoming events published to the Event Grid + /// Domain Resource. Possible values include: 'EventGridSchema', + /// 'CustomEventSchema', 'CloudEventSchemaV1_0' /// Information about the /// InputSchemaMapping which specified the info about mapping event /// payload. - /// Metric resource id for the - /// domain. + /// Metric resource id for the Event + /// Grid Domain Resource. /// This determines if traffic is /// allowed over public network. By default it is enabled. /// You can further restrict to specific IPs by configuring <seealso @@ -105,11 +106,16 @@ public Domain() /// auto-managed mode provides the flexibility to perform less /// operations and manage fewer /// resources by the user. - /// The system metadata relating to Domain + /// Data Residency Boundary of the + /// resource. Possible values include: 'WithinGeopair', + /// 'WithinRegion' + /// The Sku pricing tier for the Event Grid Domain /// resource. /// Identity information for the Event Grid /// Domain 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), bool? disableLocalAuth = default(bool?), bool? autoCreateTopicWithFirstSubscription = default(bool?), bool? autoDeleteTopicWithLastSubscription = default(bool?), SystemData systemData = default(SystemData), IdentityInfo identity = default(IdentityInfo)) + /// The system metadata relating to the Event + /// Grid Domain 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), bool? disableLocalAuth = default(bool?), bool? autoCreateTopicWithFirstSubscription = default(bool?), bool? autoDeleteTopicWithLastSubscription = default(bool?), string dataResidencyBoundary = default(string), ResourceSku sku = default(ResourceSku), IdentityInfo identity = default(IdentityInfo), SystemData systemData = default(SystemData)) : base(location, id, name, type, tags) { PrivateEndpointConnections = privateEndpointConnections; @@ -123,8 +129,10 @@ public Domain() DisableLocalAuth = disableLocalAuth; AutoCreateTopicWithFirstSubscription = autoCreateTopicWithFirstSubscription; AutoDeleteTopicWithLastSubscription = autoDeleteTopicWithLastSubscription; - SystemData = systemData; + DataResidencyBoundary = dataResidencyBoundary; + Sku = sku; Identity = identity; + SystemData = systemData; CustomInit(); } @@ -148,16 +156,17 @@ public Domain() public string ProvisioningState { get; private set; } /// - /// Gets endpoint for the domain. + /// Gets endpoint for the Event Grid Domain Resource which is used for + /// publishing the events. /// [JsonProperty(PropertyName = "properties.endpoint")] public string Endpoint { get; private set; } /// /// Gets or sets this determines the format that Event Grid should - /// expect for incoming events published to the domain. Possible values - /// include: 'EventGridSchema', 'CustomEventSchema', - /// 'CloudEventSchemaV1_0' + /// expect for incoming events published to the Event Grid Domain + /// Resource. Possible values include: 'EventGridSchema', + /// 'CustomEventSchema', 'CloudEventSchemaV1_0' /// [JsonProperty(PropertyName = "properties.inputSchema")] public string InputSchema { get; set; } @@ -170,7 +179,7 @@ public Domain() public InputSchemaMapping InputSchemaMapping { get; set; } /// - /// Gets metric resource id for the domain. + /// Gets metric resource id for the Event Grid Domain Resource. /// [JsonProperty(PropertyName = "properties.metricResourceId")] public string MetricResourceId { get; private set; } @@ -252,10 +261,18 @@ public Domain() public bool? AutoDeleteTopicWithLastSubscription { get; set; } /// - /// Gets the system metadata relating to Domain resource. + /// Gets or sets data Residency Boundary of the resource. Possible + /// values include: 'WithinGeopair', 'WithinRegion' /// - [JsonProperty(PropertyName = "systemData")] - public SystemData SystemData { get; private set; } + [JsonProperty(PropertyName = "properties.dataResidencyBoundary")] + public string DataResidencyBoundary { get; set; } + + /// + /// Gets or sets the Sku pricing tier for the Event Grid Domain + /// resource. + /// + [JsonProperty(PropertyName = "sku")] + public ResourceSku Sku { get; set; } /// /// Gets or sets identity information for the Event Grid Domain @@ -264,6 +281,13 @@ public Domain() [JsonProperty(PropertyName = "identity")] public IdentityInfo Identity { get; set; } + /// + /// Gets the system metadata relating to the Event Grid Domain + /// resource. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private 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 b1cbbd8181608..48519ef576f81 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 @@ -85,9 +85,13 @@ public DomainUpdateParameters() /// auto-managed mode provides the flexibility to perform less /// operations and manage fewer /// resources by the user. + /// The data residency boundary for + /// the domain. Possible values include: 'WithinGeopair', + /// 'WithinRegion' /// Identity information for the /// resource. - public DomainUpdateParameters(IDictionary tags = default(IDictionary), string publicNetworkAccess = default(string), IList inboundIpRules = default(IList), bool? disableLocalAuth = default(bool?), bool? autoCreateTopicWithFirstSubscription = default(bool?), bool? autoDeleteTopicWithLastSubscription = default(bool?), IdentityInfo identity = default(IdentityInfo)) + /// The Sku pricing tier for the domain. + public DomainUpdateParameters(IDictionary tags = default(IDictionary), string publicNetworkAccess = default(string), IList inboundIpRules = default(IList), bool? disableLocalAuth = default(bool?), bool? autoCreateTopicWithFirstSubscription = default(bool?), bool? autoDeleteTopicWithLastSubscription = default(bool?), string dataResidencyBoundary = default(string), IdentityInfo identity = default(IdentityInfo), ResourceSku sku = default(ResourceSku)) { Tags = tags; PublicNetworkAccess = publicNetworkAccess; @@ -95,7 +99,9 @@ public DomainUpdateParameters() DisableLocalAuth = disableLocalAuth; AutoCreateTopicWithFirstSubscription = autoCreateTopicWithFirstSubscription; AutoDeleteTopicWithLastSubscription = autoDeleteTopicWithLastSubscription; + DataResidencyBoundary = dataResidencyBoundary; Identity = identity; + Sku = sku; CustomInit(); } @@ -186,11 +192,24 @@ public DomainUpdateParameters() [JsonProperty(PropertyName = "properties.autoDeleteTopicWithLastSubscription")] public bool? AutoDeleteTopicWithLastSubscription { get; set; } + /// + /// Gets or sets the data residency boundary for the domain. Possible + /// values include: 'WithinGeopair', 'WithinRegion' + /// + [JsonProperty(PropertyName = "properties.dataResidencyBoundary")] + public string DataResidencyBoundary { 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/EventChannel.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventChannel.cs new file mode 100644 index 0000000000000..4041a86d11655 --- /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 Event + /// Channel 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 Event Channel 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 0000000000000..e3b559e9d2008 --- /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 0000000000000..286462dda8146 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventChannelFilter.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.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. The default value is either false or + /// null. + /// 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. The default + /// value is either false or null. + /// + [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 0000000000000..0583d8001a613 --- /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 0000000000000..0d498701f6ff4 --- /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/EventDefinitionKind.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventDefinitionKind.cs new file mode 100644 index 0000000000000..de166457197ee --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventDefinitionKind.cs @@ -0,0 +1,21 @@ +// +// 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 EventDefinitionKind. + /// + public static class EventDefinitionKind + { + public const string Inline = "Inline"; + } +} 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 1bb4a6b544a24..f86b274b834c0 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,9 @@ 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. @@ -63,8 +65,11 @@ 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. + /// 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 @@ -114,6 +119,8 @@ 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; } @@ -164,7 +171,11 @@ 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; } 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 2cd8e224d14d7..d6fb28f6b55e5 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,9 @@ 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. @@ -52,8 +54,11 @@ 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. + /// 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 @@ -83,6 +88,8 @@ 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; } @@ -134,7 +141,11 @@ 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; } diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventTypeInfo.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventTypeInfo.cs new file mode 100644 index 0000000000000..b57b3e19f3096 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/EventTypeInfo.cs @@ -0,0 +1,74 @@ +// +// 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 event type information for Channels. + /// + public partial class EventTypeInfo + { + /// + /// Initializes a new instance of the EventTypeInfo class. + /// + public EventTypeInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EventTypeInfo class. + /// + /// The kind of event type used. Possible values + /// include: 'Inline' + /// A collection of inline event types + /// for the resource. The inline event type keys are of type string + /// which represents the name of the event. + /// An example of a valid inline event name is "Contoso.OrderCreated". + /// The inline event type values are of type InlineEventProperties and + /// will contain additional information for every inline event + /// type. + public EventTypeInfo(string kind = default(string), IDictionary inlineEventTypes = default(IDictionary)) + { + Kind = kind; + InlineEventTypes = inlineEventTypes; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the kind of event type used. Possible values include: + /// 'Inline' + /// + [JsonProperty(PropertyName = "kind")] + public string Kind { get; set; } + + /// + /// Gets or sets a collection of inline event types for the resource. + /// The inline event type keys are of type string which represents the + /// name of the event. + /// An example of a valid inline event name is "Contoso.OrderCreated". + /// The inline event type values are of type InlineEventProperties and + /// will contain additional information for every inline event type. + /// + [JsonProperty(PropertyName = "inlineEventTypes")] + public IDictionary InlineEventTypes { 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 0000000000000..91bf327c7a5fd --- /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 index 1fc1c9204e350..2022a7e17d535 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ExtensionTopic.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ExtensionTopic.cs @@ -41,8 +41,8 @@ public ExtensionTopic() /// topic. /// System topic resource id which is mapped /// to the source. - /// The system metadata relating to the - /// Extension Topic resource. + /// The system metadata relating to Extension + /// Topic resource. public ExtensionTopic(string id = default(string), string name = default(string), string type = default(string), string description = default(string), string systemTopic = default(string), SystemData systemData = default(SystemData)) : base(id, name, type) { @@ -71,7 +71,7 @@ public ExtensionTopic() public string SystemTopic { get; set; } /// - /// Gets the system metadata relating to the Extension Topic resource. + /// Gets the system metadata relating to Extension Topic resource. /// [JsonProperty(PropertyName = "systemData")] public SystemData SystemData { get; private set; } diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/InlineEventProperties.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/InlineEventProperties.cs new file mode 100644 index 0000000000000..5021279bc6272 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/InlineEventProperties.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 Newtonsoft.Json; + using System.Linq; + + /// + /// Additional information about every inline event. + /// + public partial class InlineEventProperties + { + /// + /// Initializes a new instance of the InlineEventProperties class. + /// + public InlineEventProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the InlineEventProperties class. + /// + /// The description for the inline + /// event. + /// The documentationUrl for the inline + /// event. + /// The dataSchemaUrl for the inline + /// event. + public InlineEventProperties(string description = default(string), string documentationUrl = default(string), string dataSchemaUrl = default(string)) + { + Description = description; + DocumentationUrl = documentationUrl; + DataSchemaUrl = dataSchemaUrl; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the description for the inline event. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + /// + /// Gets or sets the documentationUrl for the inline event. + /// + [JsonProperty(PropertyName = "documentationUrl")] + public string DocumentationUrl { get; set; } + + /// + /// Gets or sets the dataSchemaUrl for the inline event. + /// + [JsonProperty(PropertyName = "dataSchemaUrl")] + public string DataSchemaUrl { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Operation.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Operation.cs index c12e891224307..9b38ea632fd24 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Operation.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Operation.cs @@ -14,7 +14,7 @@ namespace Microsoft.Azure.Management.EventGrid.Models using System.Linq; /// - /// Represents an operation returned by the GetOperations request + /// Represents an operation returned by the GetOperations request. /// public partial class Operation { @@ -29,15 +29,18 @@ public Operation() /// /// Initializes a new instance of the Operation class. /// - /// Name of the operation - /// Display name of the operation - /// Origin of the operation - /// Properties of the operation - public Operation(string name = default(string), OperationInfo display = default(OperationInfo), string origin = default(string), object properties = default(object)) + /// Name of the operation. + /// Display name of the operation. + /// Origin of the operation. + /// This Boolean is used to determine if the + /// operation is a data plane action or not. + /// Properties of the operation. + public Operation(string name = default(string), OperationInfo display = default(OperationInfo), string origin = default(string), bool? isDataAction = default(bool?), object properties = default(object)) { Name = name; Display = display; Origin = origin; + IsDataAction = isDataAction; Properties = properties; CustomInit(); } @@ -48,25 +51,32 @@ public Operation() partial void CustomInit(); /// - /// Gets or sets name of the operation + /// Gets or sets name of the operation. /// [JsonProperty(PropertyName = "name")] public string Name { get; set; } /// - /// Gets or sets display name of the operation + /// Gets or sets display name of the operation. /// [JsonProperty(PropertyName = "display")] public OperationInfo Display { get; set; } /// - /// Gets or sets origin of the operation + /// Gets or sets origin of the operation. /// [JsonProperty(PropertyName = "origin")] public string Origin { get; set; } /// - /// Gets or sets properties of the operation + /// Gets or sets this Boolean is used to determine if the operation is + /// a data plane action or not. + /// + [JsonProperty(PropertyName = "isDataAction")] + public bool? IsDataAction { get; set; } + + /// + /// Gets or sets properties of the operation. /// [JsonProperty(PropertyName = "properties")] public object Properties { get; set; } diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ParentType.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ParentType.cs new file mode 100644 index 0000000000000..89c0eeb8868f6 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ParentType.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 ParentType. + /// + public static class ParentType + { + public const string Topics = "topics"; + public const string Domains = "domains"; + public const string PartnerNamespaces = "partnerNamespaces"; + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Partner.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Partner.cs new file mode 100644 index 0000000000000..6e659cb607f08 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Partner.cs @@ -0,0 +1,85 @@ +// +// 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 partner. + /// + public partial class Partner + { + /// + /// Initializes a new instance of the Partner class. + /// + public Partner() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Partner class. + /// + /// The immutableId of the + /// corresponding partner registration. + /// The partner name. + /// Expiration time of + /// the partner authorization. If this timer expires, any request from + /// this partner to create, update or delete resources in subscriber's + /// context will fail. If specified, the allowed values are between 1 + /// to the value of defaultMaximumExpirationTimeInDays specified in + /// PartnerConfiguration. + /// If not specified, the default value will be the value of + /// defaultMaximumExpirationTimeInDays specified in + /// PartnerConfiguration or 7 if this value is not specified. + public Partner(System.Guid? partnerRegistrationImmutableId = default(System.Guid?), string partnerName = default(string), System.DateTime? authorizationExpirationTimeInUtc = default(System.DateTime?)) + { + PartnerRegistrationImmutableId = partnerRegistrationImmutableId; + PartnerName = partnerName; + AuthorizationExpirationTimeInUtc = authorizationExpirationTimeInUtc; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the immutableId of the corresponding partner + /// registration. + /// + [JsonProperty(PropertyName = "partnerRegistrationImmutableId")] + public System.Guid? PartnerRegistrationImmutableId { get; set; } + + /// + /// Gets or sets the partner name. + /// + [JsonProperty(PropertyName = "partnerName")] + public string PartnerName { get; set; } + + /// + /// Gets or sets expiration time of the partner authorization. If this + /// timer expires, any request from this partner to create, update or + /// delete resources in subscriber's + /// context will fail. If specified, the allowed values are between 1 + /// to the value of defaultMaximumExpirationTimeInDays specified in + /// PartnerConfiguration. + /// If not specified, the default value will be the value of + /// defaultMaximumExpirationTimeInDays specified in + /// PartnerConfiguration or 7 if this value is not specified. + /// + [JsonProperty(PropertyName = "authorizationExpirationTimeInUtc")] + public System.DateTime? AuthorizationExpirationTimeInUtc { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerAuthorization.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerAuthorization.cs new file mode 100644 index 0000000000000..e5d6e5d16014c --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerAuthorization.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 Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The partner authorization details. + /// + public partial class PartnerAuthorization + { + /// + /// Initializes a new instance of the PartnerAuthorization class. + /// + public PartnerAuthorization() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PartnerAuthorization class. + /// + /// Time used to + /// validate the authorization expiration time for each authorized + /// partner. If DefaultMaximumExpirationTimeInDays is + /// not specified, the default is 7 days. Otherwise, allowed values are + /// between 1 and 365 days. + /// The list of authorized + /// partners. + public PartnerAuthorization(int? defaultMaximumExpirationTimeInDays = default(int?), IList authorizedPartnersList = default(IList)) + { + DefaultMaximumExpirationTimeInDays = defaultMaximumExpirationTimeInDays; + AuthorizedPartnersList = authorizedPartnersList; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets time used to validate the authorization expiration + /// time for each authorized partner. If + /// DefaultMaximumExpirationTimeInDays is + /// not specified, the default is 7 days. Otherwise, allowed values are + /// between 1 and 365 days. + /// + [JsonProperty(PropertyName = "defaultMaximumExpirationTimeInDays")] + public int? DefaultMaximumExpirationTimeInDays { get; set; } + + /// + /// Gets or sets the list of authorized partners. + /// + [JsonProperty(PropertyName = "authorizedPartnersList")] + public IList AuthorizedPartnersList { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerClientAuthentication.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerClientAuthentication.cs new file mode 100644 index 0000000000000..d6634d8e77c10 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerClientAuthentication.cs @@ -0,0 +1,36 @@ +// +// 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 System.Linq; + + /// + /// Partner client authentication + /// + public partial class PartnerClientAuthentication + { + /// + /// Initializes a new instance of the PartnerClientAuthentication + /// class. + /// + public PartnerClientAuthentication() + { + 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/PartnerConfiguration.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerConfiguration.cs new file mode 100644 index 0000000000000..0811b21be1e3f --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerConfiguration.cs @@ -0,0 +1,100 @@ +// +// 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; + + /// + /// Partner configuration information + /// + [Rest.Serialization.JsonTransformation] + public partial class PartnerConfiguration : Resource + { + /// + /// Initializes a new instance of the PartnerConfiguration class. + /// + public PartnerConfiguration() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PartnerConfiguration class. + /// + /// Fully qualified identifier of the + /// resource. + /// Name of the resource. + /// Type of the resource. + /// The details of authorized + /// partners. + /// Provisioning state of the partner + /// configuration. Possible values include: 'Creating', 'Updating', + /// 'Deleting', 'Succeeded', 'Canceled', 'Failed' + /// The system metadata relating to partner + /// configuration resource. + /// Location of the resource. + /// Tags of the resource. + public PartnerConfiguration(string id = default(string), string name = default(string), string type = default(string), PartnerAuthorization partnerAuthorization = default(PartnerAuthorization), string provisioningState = default(string), SystemData systemData = default(SystemData), string location = default(string), IDictionary tags = default(IDictionary)) + : base(id, name, type) + { + PartnerAuthorization = partnerAuthorization; + ProvisioningState = provisioningState; + SystemData = systemData; + Location = location; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the details of authorized partners. + /// + [JsonProperty(PropertyName = "properties.partnerAuthorization")] + public PartnerAuthorization PartnerAuthorization { get; set; } + + /// + /// Gets or sets provisioning state of the partner configuration. + /// Possible values include: 'Creating', 'Updating', 'Deleting', + /// 'Succeeded', 'Canceled', 'Failed' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets the system metadata relating to partner configuration + /// resource. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + + /// + /// Gets or sets location of the resource. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets tags of the resource. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerConfigurationProvisioningState.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerConfigurationProvisioningState.cs new file mode 100644 index 0000000000000..39db170f4016d --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerConfigurationProvisioningState.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 PartnerConfigurationProvisioningState. + /// + public static class PartnerConfigurationProvisioningState + { + 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/PartnerConfigurationUpdateParameters.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerConfigurationUpdateParameters.cs new file mode 100644 index 0000000000000..8ddf2386964d4 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerConfigurationUpdateParameters.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.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Properties of the partner configuration update. + /// + [Rest.Serialization.JsonTransformation] + public partial class PartnerConfigurationUpdateParameters + { + /// + /// Initializes a new instance of the + /// PartnerConfigurationUpdateParameters class. + /// + public PartnerConfigurationUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// PartnerConfigurationUpdateParameters class. + /// + /// Tags of the partner configuration + /// resource. + /// The default time + /// used to validate the maximum expiration time for each authorized + /// partners in days. Allowed values ar between 1 and 365 days. + public PartnerConfigurationUpdateParameters(IDictionary tags = default(IDictionary), int? defaultMaximumExpirationTimeInDays = default(int?)) + { + Tags = tags; + DefaultMaximumExpirationTimeInDays = defaultMaximumExpirationTimeInDays; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets tags of the partner configuration resource. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets the default time used to validate the maximum + /// expiration time for each authorized partners in days. Allowed + /// values ar between 1 and 365 days. + /// + [JsonProperty(PropertyName = "properties.defaultMaximumExpirationTimeInDays")] + public int? DefaultMaximumExpirationTimeInDays { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerDestination.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerDestination.cs new file mode 100644 index 0000000000000..c22832c63dbf0 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerDestination.cs @@ -0,0 +1,150 @@ +// +// 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; + + /// + /// Event Grid Partner Destination. + /// + [Rest.Serialization.JsonTransformation] + public partial class PartnerDestination : TrackedResource + { + /// + /// Initializes a new instance of the PartnerDestination class. + /// + public PartnerDestination() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PartnerDestination class. + /// + /// Location of the resource. + /// Fully qualified identifier of the + /// resource. + /// Name of the resource. + /// Type of the resource. + /// Tags of the resource. + /// The immutable Id of + /// the corresponding partner registration. + /// Endpoint context associated + /// with this partner destination. + /// Expiration time of + /// the partner destination. If this timer expires and the partner + /// destination was never activated, + /// the partner destination and corresponding channel are + /// deleted. + /// Provisioning state of the partner + /// destination. Possible values include: 'Creating', 'Updating', + /// 'Deleting', 'Succeeded', 'Canceled', 'Failed' + /// Activation state of the partner + /// destination. Possible values include: 'NeverActivated', + /// 'Activated' + /// Endpoint Base URL of the partner + /// destination + /// Context or helpful message that + /// can be used during the approval process. + /// The system metadata relating to Partner + /// Destination resource. + public PartnerDestination(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), System.Guid? partnerRegistrationImmutableId = default(System.Guid?), string endpointServiceContext = default(string), System.DateTime? expirationTimeIfNotActivatedUtc = default(System.DateTime?), string provisioningState = default(string), string activationState = default(string), string endpointBaseUrl = default(string), string messageForActivation = default(string), SystemData systemData = default(SystemData)) + : base(location, id, name, type, tags) + { + PartnerRegistrationImmutableId = partnerRegistrationImmutableId; + EndpointServiceContext = endpointServiceContext; + ExpirationTimeIfNotActivatedUtc = expirationTimeIfNotActivatedUtc; + ProvisioningState = provisioningState; + ActivationState = activationState; + EndpointBaseUrl = endpointBaseUrl; + MessageForActivation = messageForActivation; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the immutable Id of the corresponding partner + /// registration. + /// + [JsonProperty(PropertyName = "properties.partnerRegistrationImmutableId")] + public System.Guid? PartnerRegistrationImmutableId { get; set; } + + /// + /// Gets or sets endpoint context associated with this partner + /// destination. + /// + [JsonProperty(PropertyName = "properties.endpointServiceContext")] + public string EndpointServiceContext { get; set; } + + /// + /// Gets or sets expiration time of the partner destination. If this + /// timer expires and the partner destination was never activated, + /// the partner destination and corresponding channel are deleted. + /// + [JsonProperty(PropertyName = "properties.expirationTimeIfNotActivatedUtc")] + public System.DateTime? ExpirationTimeIfNotActivatedUtc { get; set; } + + /// + /// Gets or sets provisioning state of the partner destination. + /// Possible values include: 'Creating', 'Updating', 'Deleting', + /// 'Succeeded', 'Canceled', 'Failed' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets or sets activation state of the partner destination. Possible + /// values include: 'NeverActivated', 'Activated' + /// + [JsonProperty(PropertyName = "properties.activationState")] + public string ActivationState { get; set; } + + /// + /// Gets or sets endpoint Base URL of the partner destination + /// + [JsonProperty(PropertyName = "properties.endpointBaseUrl")] + public string EndpointBaseUrl { get; set; } + + /// + /// Gets or sets context or helpful message that can be used during the + /// approval process. + /// + [JsonProperty(PropertyName = "properties.messageForActivation")] + public string MessageForActivation { get; set; } + + /// + /// Gets the system metadata relating to Partner Destination 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/PartnerDestinationActivationState.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerDestinationActivationState.cs new file mode 100644 index 0000000000000..f55428b7f8a94 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerDestinationActivationState.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 PartnerDestinationActivationState. + /// + public static class PartnerDestinationActivationState + { + public const string NeverActivated = "NeverActivated"; + public const string Activated = "Activated"; + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerDestinationInfo.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerDestinationInfo.cs new file mode 100644 index 0000000000000..a99cb6f342445 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerDestinationInfo.cs @@ -0,0 +1,100 @@ +// +// 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 corresponding partner destination of a Channel. + /// + public partial class PartnerDestinationInfo + { + /// + /// Initializes a new instance of the PartnerDestinationInfo class. + /// + public PartnerDestinationInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PartnerDestinationInfo class. + /// + /// Azure subscription ID of the + /// subscriber. The partner destination associated with the channel + /// will be + /// created under this Azure subscription. + /// Azure Resource Group of the + /// subscriber. The partner destination associated with the channel + /// will be + /// created under this resource group. + /// Name of the partner destination associated with + /// the channel. + /// Additional context of the + /// partner destination endpoint. + /// Change history of the + /// resource move. + public PartnerDestinationInfo(string azureSubscriptionId = default(string), string resourceGroupName = default(string), string name = default(string), string endpointServiceContext = default(string), IList resourceMoveChangeHistory = default(IList)) + { + AzureSubscriptionId = azureSubscriptionId; + ResourceGroupName = resourceGroupName; + Name = name; + EndpointServiceContext = endpointServiceContext; + ResourceMoveChangeHistory = resourceMoveChangeHistory; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets azure subscription ID of the subscriber. The partner + /// destination associated with the channel will be + /// created under this Azure subscription. + /// + [JsonProperty(PropertyName = "azureSubscriptionId")] + public string AzureSubscriptionId { get; set; } + + /// + /// Gets or sets azure Resource Group of the subscriber. The partner + /// destination associated with the channel will be + /// created under this resource group. + /// + [JsonProperty(PropertyName = "resourceGroupName")] + public string ResourceGroupName { get; set; } + + /// + /// Gets or sets name of the partner destination associated with the + /// channel. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets additional context of the partner destination + /// endpoint. + /// + [JsonProperty(PropertyName = "endpointServiceContext")] + public string EndpointServiceContext { get; set; } + + /// + /// Gets or sets change history of the resource move. + /// + [JsonProperty(PropertyName = "resourceMoveChangeHistory")] + public IList ResourceMoveChangeHistory { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerDestinationProvisioningState.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerDestinationProvisioningState.cs new file mode 100644 index 0000000000000..3d589a0aa3f7e --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerDestinationProvisioningState.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 PartnerDestinationProvisioningState. + /// + public static class PartnerDestinationProvisioningState + { + 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/PartnerDestinationUpdateParameters.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerDestinationUpdateParameters.cs new file mode 100644 index 0000000000000..fa066cf9c1e4a --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerDestinationUpdateParameters.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; + + /// + /// Properties of the Partner Destination that can be updated. + /// + public partial class PartnerDestinationUpdateParameters + { + /// + /// Initializes a new instance of the + /// PartnerDestinationUpdateParameters class. + /// + public PartnerDestinationUpdateParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// PartnerDestinationUpdateParameters class. + /// + /// Tags of the Partner Destination + /// resource. + public PartnerDestinationUpdateParameters(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 Destination resource. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerDetails.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerDetails.cs new file mode 100644 index 0000000000000..14d08b8559afc --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerDetails.cs @@ -0,0 +1,78 @@ +// +// 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 partner. + /// + public partial class PartnerDetails + { + /// + /// Initializes a new instance of the PartnerDetails class. + /// + public PartnerDetails() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PartnerDetails class. + /// + /// This is short description about the + /// partner. The length of this description should not exceed 256 + /// characters. + /// Long description for the partner's + /// scenarios and integration.Length of this description should not + /// exceed 2048 characters. + /// URI of the partner website that can be used + /// by Azure customers to setup Event Grid + /// integration on an event source. + public PartnerDetails(string description = default(string), string longDescription = default(string), string setupUri = default(string)) + { + Description = description; + LongDescription = longDescription; + SetupUri = setupUri; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets this is short description about the partner. The + /// length of this description should not exceed 256 characters. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + /// + /// Gets or sets long description for the partner's scenarios and + /// integration.Length of this description should not exceed 2048 + /// characters. + /// + [JsonProperty(PropertyName = "longDescription")] + public string LongDescription { 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; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerEventSubscriptionDestination.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerEventSubscriptionDestination.cs new file mode 100644 index 0000000000000..bc646f14cf3a6 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerEventSubscriptionDestination.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 Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + [Newtonsoft.Json.JsonObject("PartnerDestination")] + [Rest.Serialization.JsonTransformation] + public partial class PartnerEventSubscriptionDestination : EventSubscriptionDestination + { + /// + /// Initializes a new instance of the + /// PartnerEventSubscriptionDestination class. + /// + public PartnerEventSubscriptionDestination() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// PartnerEventSubscriptionDestination class. + /// + /// The Azure Resource Id that represents the + /// endpoint of a Partner Destination of an event subscription. + public PartnerEventSubscriptionDestination(string resourceId = default(string)) + { + ResourceId = resourceId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the Azure Resource Id that represents the endpoint of + /// a Partner Destination of an event subscription. + /// + [JsonProperty(PropertyName = "properties.resourceId")] + public string ResourceId { 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 0000000000000..5bd25d6ada9b4 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerNamespace.cs @@ -0,0 +1,177 @@ +// +// 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. + /// This determines if traffic is + /// allowed over public network. By default it is enabled. + /// You can further restrict to specific IPs by configuring <seealso + /// cref="P:Microsoft.Azure.Events.ResourceProvider.Common.Contracts.PartnerNamespaceProperties.InboundIpRules" + /// />. Possible values include: 'Enabled', 'Disabled' + /// This can be used to restrict traffic + /// from specific IPs instead of all IPs. Note: These are considered + /// only if PublicNetworkAccess is enabled. + /// This boolean is used to enable or + /// disable local auth. Default value is false. When the property is + /// set to true, only AAD token will be used to authenticate if user is + /// allowed to publish to the partner namespace. + /// This determines if events + /// published to this partner namespace should use the source attribute + /// in the event payload + /// or use the channel name in the header when matching to the partner + /// topic. If none is specified, source attribute routing will be used + /// to match the partner topic. Possible values include: + /// 'SourceEventAttribute', 'ChannelNameHeader' + /// The system metadata relating to Partner + /// Namespace resource. + public PartnerNamespace(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 partnerRegistrationFullyQualifiedId = default(string), string endpoint = default(string), string publicNetworkAccess = default(string), IList inboundIpRules = default(IList), bool? disableLocalAuth = default(bool?), string partnerTopicRoutingMode = default(string), SystemData systemData = default(SystemData)) + : base(location, id, name, type, tags) + { + PrivateEndpointConnections = privateEndpointConnections; + ProvisioningState = provisioningState; + PartnerRegistrationFullyQualifiedId = partnerRegistrationFullyQualifiedId; + Endpoint = endpoint; + PublicNetworkAccess = publicNetworkAccess; + InboundIpRules = inboundIpRules; + DisableLocalAuth = disableLocalAuth; + PartnerTopicRoutingMode = partnerTopicRoutingMode; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// + [JsonProperty(PropertyName = "properties.privateEndpointConnections")] + public IList PrivateEndpointConnections { get; private set; } + + /// + /// 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 or sets this determines if traffic is allowed over public + /// network. By default it is enabled. + /// You can further restrict to specific IPs by configuring + /// &lt;seealso + /// cref="P:Microsoft.Azure.Events.ResourceProvider.Common.Contracts.PartnerNamespaceProperties.InboundIpRules" + /// /&gt;. Possible values include: 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "properties.publicNetworkAccess")] + public string PublicNetworkAccess { get; set; } + + /// + /// Gets or sets this can be used to restrict traffic from specific IPs + /// instead of all IPs. Note: These are considered only if + /// PublicNetworkAccess is enabled. + /// + [JsonProperty(PropertyName = "properties.inboundIpRules")] + public IList InboundIpRules { get; set; } + + /// + /// Gets or sets this boolean is used to enable or disable local auth. + /// Default value is false. When the property is set to true, only AAD + /// token will be used to authenticate if user is allowed to publish to + /// the partner namespace. + /// + [JsonProperty(PropertyName = "properties.disableLocalAuth")] + public bool? DisableLocalAuth { get; set; } + + /// + /// Gets or sets this determines if events published to this partner + /// namespace should use the source attribute in the event payload + /// or use the channel name in the header when matching to the partner + /// topic. If none is specified, source attribute routing will be used + /// to match the partner topic. Possible values include: + /// 'SourceEventAttribute', 'ChannelNameHeader' + /// + [JsonProperty(PropertyName = "properties.partnerTopicRoutingMode")] + public string PartnerTopicRoutingMode { get; set; } + + /// + /// Gets the system metadata relating to Partner Namespace 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 0000000000000..a93d8ed974e07 --- /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 0000000000000..87f6e0700a986 --- /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 0000000000000..16ada036cecb9 --- /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 0000000000000..3a43bb2adae9e --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerNamespaceUpdateParameters.cs @@ -0,0 +1,101 @@ +// +// 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; + + /// + /// Properties of the Partner Namespace update. + /// + [Rest.Serialization.JsonTransformation] + 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. + /// This determines if traffic is + /// allowed over public network. By default it is enabled. + /// You can further restrict to specific IPs by configuring <seealso + /// cref="P:Microsoft.Azure.Events.ResourceProvider.Common.Contracts.PartnerNamespaceUpdateParameterProperties.InboundIpRules" + /// />. Possible values include: 'Enabled', 'Disabled' + /// This can be used to restrict traffic + /// from specific IPs instead of all IPs. Note: These are considered + /// only if PublicNetworkAccess is enabled. + /// This boolean is used to enable or + /// disable local auth. Default value is false. When the property is + /// set to true, only AAD token will be used to authenticate if user is + /// allowed to publish to the partner namespace. + public PartnerNamespaceUpdateParameters(IDictionary tags = default(IDictionary), string publicNetworkAccess = default(string), IList inboundIpRules = default(IList), bool? disableLocalAuth = default(bool?)) + { + Tags = tags; + PublicNetworkAccess = publicNetworkAccess; + InboundIpRules = inboundIpRules; + DisableLocalAuth = disableLocalAuth; + 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; } + + /// + /// Gets or sets this determines if traffic is allowed over public + /// network. By default it is enabled. + /// You can further restrict to specific IPs by configuring + /// &lt;seealso + /// cref="P:Microsoft.Azure.Events.ResourceProvider.Common.Contracts.PartnerNamespaceUpdateParameterProperties.InboundIpRules" + /// /&gt;. Possible values include: 'Enabled', 'Disabled' + /// + [JsonProperty(PropertyName = "properties.publicNetworkAccess")] + public string PublicNetworkAccess { get; set; } + + /// + /// Gets or sets this can be used to restrict traffic from specific IPs + /// instead of all IPs. Note: These are considered only if + /// PublicNetworkAccess is enabled. + /// + [JsonProperty(PropertyName = "properties.inboundIpRules")] + public IList InboundIpRules { get; set; } + + /// + /// Gets or sets this boolean is used to enable or disable local auth. + /// Default value is false. When the property is set to true, only AAD + /// token will be used to authenticate if user is allowed to publish to + /// the partner namespace. + /// + [JsonProperty(PropertyName = "properties.disableLocalAuth")] + public bool? DisableLocalAuth { 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 0000000000000..398841be36601 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerRegistration.cs @@ -0,0 +1,244 @@ +// +// 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' + /// The immutableId of the + /// corresponding partner registration. + /// 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 Partner + /// Registration 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), System.Guid? partnerRegistrationImmutableId = default(System.Guid?), 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; + PartnerRegistrationImmutableId = partnerRegistrationImmutableId; + 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 the immutableId of the corresponding partner + /// registration. + /// + [JsonProperty(PropertyName = "properties.partnerRegistrationImmutableId")] + public System.Guid? PartnerRegistrationImmutableId { get; 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 Partner Registration 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/PartnerRegistrationProvisioningState.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerRegistrationProvisioningState.cs new file mode 100644 index 0000000000000..e08bf8afb5661 --- /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 0000000000000..5574b3a872f07 --- /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 0000000000000..7a4343c5fc7e3 --- /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 0000000000000..c2e8d883052a6 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopic.cs @@ -0,0 +1,176 @@ +// +// 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; + + /// + /// Event Grid 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. + /// The immutableId of the + /// corresponding partner registration. + /// Source associated with this partner topic. + /// This represents a unique partner resource. + /// Event Type information from the + /// corresponding event channel. + /// 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. + /// Context or helpful message that + /// can be used during the approval process by the subscriber. + /// The system metadata relating to Partner + /// Topic resource. + /// Identity information for the Partner Topic + /// resource. + public PartnerTopic(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), System.Guid? partnerRegistrationImmutableId = default(System.Guid?), string source = default(string), EventTypeInfo eventTypeInfo = default(EventTypeInfo), System.DateTime? expirationTimeIfNotActivatedUtc = default(System.DateTime?), string provisioningState = default(string), string activationState = default(string), string partnerTopicFriendlyDescription = default(string), string messageForActivation = default(string), SystemData systemData = default(SystemData), IdentityInfo identity = default(IdentityInfo)) + : base(location, id, name, type, tags) + { + PartnerRegistrationImmutableId = partnerRegistrationImmutableId; + Source = source; + EventTypeInfo = eventTypeInfo; + ExpirationTimeIfNotActivatedUtc = expirationTimeIfNotActivatedUtc; + ProvisioningState = provisioningState; + ActivationState = activationState; + PartnerTopicFriendlyDescription = partnerTopicFriendlyDescription; + MessageForActivation = messageForActivation; + SystemData = systemData; + Identity = identity; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the immutableId of the corresponding partner + /// registration. + /// + [JsonProperty(PropertyName = "properties.partnerRegistrationImmutableId")] + public System.Guid? PartnerRegistrationImmutableId { get; set; } + + /// + /// 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 event Type information from the corresponding event + /// channel. + /// + [JsonProperty(PropertyName = "properties.eventTypeInfo")] + public EventTypeInfo EventTypeInfo { 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 context or helpful message that can be used during the + /// approval process by the subscriber. + /// + [JsonProperty(PropertyName = "properties.messageForActivation")] + public string MessageForActivation { get; set; } + + /// + /// Gets the system metadata relating to Partner Topic resource. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + + /// + /// Gets or sets identity information for the Partner Topic resource. + /// + [JsonProperty(PropertyName = "identity")] + public IdentityInfo Identity { get; 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 0000000000000..da853a2b216c5 --- /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/PartnerTopicInfo.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicInfo.cs new file mode 100644 index 0000000000000..e7410d122f5d2 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicInfo.cs @@ -0,0 +1,106 @@ +// +// 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 corresponding partner topic of a Channel. + /// + public partial class PartnerTopicInfo + { + /// + /// Initializes a new instance of the PartnerTopicInfo class. + /// + public PartnerTopicInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PartnerTopicInfo class. + /// + /// Azure subscription ID of the + /// subscriber. The partner topic associated with the channel will be + /// created under this Azure subscription. + /// Azure Resource Group of the + /// subscriber. The partner topic associated with the channel will be + /// created under this resource group. + /// Name of the partner topic associated with the + /// channel. + /// Event Type Information for the partner + /// topic. This information is provided by the publisher and can be + /// used by the + /// subscriber to view different types of events that are + /// published. + /// The source information is provided by the + /// publisher to determine the scope or context from which the events + /// are originating. This information can be used by the subscriber + /// during the approval process of the + /// created partner topic. + public PartnerTopicInfo(string azureSubscriptionId = default(string), string resourceGroupName = default(string), string name = default(string), EventTypeInfo eventTypeInfo = default(EventTypeInfo), string source = default(string)) + { + AzureSubscriptionId = azureSubscriptionId; + ResourceGroupName = resourceGroupName; + Name = name; + EventTypeInfo = eventTypeInfo; + Source = source; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets azure subscription ID of the subscriber. The partner + /// topic associated with the channel will be + /// created under this Azure subscription. + /// + [JsonProperty(PropertyName = "azureSubscriptionId")] + public string AzureSubscriptionId { get; set; } + + /// + /// Gets or sets azure Resource Group of the subscriber. The partner + /// topic associated with the channel will be + /// created under this resource group. + /// + [JsonProperty(PropertyName = "resourceGroupName")] + public string ResourceGroupName { get; set; } + + /// + /// Gets or sets name of the partner topic associated with the channel. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets event Type Information for the partner topic. This + /// information is provided by the publisher and can be used by the + /// subscriber to view different types of events that are published. + /// + [JsonProperty(PropertyName = "eventTypeInfo")] + public EventTypeInfo EventTypeInfo { get; set; } + + /// + /// Gets or sets the source information is provided by the publisher to + /// determine the scope or context from which the events + /// are originating. This information can be used by the subscriber + /// during the approval process of the + /// created partner topic. + /// + [JsonProperty(PropertyName = "source")] + public string Source { get; set; } + + } +} 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 0000000000000..9eb90ce309ade --- /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 0000000000000..2b4a5b43a492d --- /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/PartnerTopicRoutingMode.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicRoutingMode.cs new file mode 100644 index 0000000000000..3303d84e00392 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicRoutingMode.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 PartnerTopicRoutingMode. + /// + public static class PartnerTopicRoutingMode + { + public const string SourceEventAttribute = "SourceEventAttribute"; + public const string ChannelNameHeader = "ChannelNameHeader"; + } +} 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 0000000000000..60784516fad93 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerTopicUpdateParameters.cs @@ -0,0 +1,64 @@ +// +// 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 resource. + /// Identity information for the Partner Topic + /// resource. + public PartnerTopicUpdateParameters(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 Partner Topic resource. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Gets or sets identity information for the Partner Topic resource. + /// + [JsonProperty(PropertyName = "identity")] + public IdentityInfo Identity { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerUpdateDestinationInfo.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerUpdateDestinationInfo.cs new file mode 100644 index 0000000000000..f29233a43c83f --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerUpdateDestinationInfo.cs @@ -0,0 +1,36 @@ +// +// 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 System.Linq; + + /// + /// Properties of the corresponding partner destination of a Channel. + /// + public partial class PartnerUpdateDestinationInfo + { + /// + /// Initializes a new instance of the PartnerUpdateDestinationInfo + /// class. + /// + public PartnerUpdateDestinationInfo() + { + 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/PartnerUpdateTopicInfo.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerUpdateTopicInfo.cs new file mode 100644 index 0000000000000..21ecc85167257 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/PartnerUpdateTopicInfo.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; + + /// + /// Update properties for the corresponding partner topic of a channel. + /// + public partial class PartnerUpdateTopicInfo + { + /// + /// Initializes a new instance of the PartnerUpdateTopicInfo class. + /// + public PartnerUpdateTopicInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PartnerUpdateTopicInfo class. + /// + /// Event type info for the partner + /// topic + public PartnerUpdateTopicInfo(EventTypeInfo eventTypeInfo = default(EventTypeInfo)) + { + EventTypeInfo = eventTypeInfo; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets event type info for the partner topic + /// + [JsonProperty(PropertyName = "eventTypeInfo")] + public EventTypeInfo EventTypeInfo { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ReadinessState.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ReadinessState.cs new file mode 100644 index 0000000000000..3106a8be23d1b --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ReadinessState.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 ReadinessState. + /// + public static class ReadinessState + { + public const string NeverActivated = "NeverActivated"; + public const string Activated = "Activated"; + } +} 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 641e05f45021d..667f107b78d9c 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 0000000000000..9b91794a16f18 --- /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/ResourceMoveChangeHistory.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ResourceMoveChangeHistory.cs new file mode 100644 index 0000000000000..9efe49061b6da --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/ResourceMoveChangeHistory.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 Newtonsoft.Json; + using System.Linq; + + /// + /// The change history of the resource move. + /// + public partial class ResourceMoveChangeHistory + { + /// + /// Initializes a new instance of the ResourceMoveChangeHistory class. + /// + public ResourceMoveChangeHistory() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourceMoveChangeHistory class. + /// + /// Azure subscription ID of the + /// resource. + /// Azure Resource Group of the + /// resource. + /// UTC timestamp of when the resource was + /// changed. + public ResourceMoveChangeHistory(string azureSubscriptionId = default(string), string resourceGroupName = default(string), System.DateTime? changedTimeUtc = default(System.DateTime?)) + { + AzureSubscriptionId = azureSubscriptionId; + ResourceGroupName = resourceGroupName; + ChangedTimeUtc = changedTimeUtc; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets azure subscription ID of the resource. + /// + [JsonProperty(PropertyName = "azureSubscriptionId")] + public string AzureSubscriptionId { get; set; } + + /// + /// Gets or sets azure Resource Group of the resource. + /// + [JsonProperty(PropertyName = "resourceGroupName")] + public string ResourceGroupName { get; set; } + + /// + /// Gets or sets UTC timestamp of when the resource was changed. + /// + [JsonProperty(PropertyName = "changedTimeUtc")] + public System.DateTime? ChangedTimeUtc { get; set; } + + } +} 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 0000000000000..eb5add0788059 --- /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/Sku.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Sku.cs new file mode 100644 index 0000000000000..7edc817200141 --- /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/SystemTopic.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/SystemTopic.cs index d4212ef0834a6..ac46b43e24ec9 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/SystemTopic.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/SystemTopic.cs @@ -47,19 +47,19 @@ public SystemTopic() /// TopicType for the system topic. /// Metric resource id for the system /// topic. - /// Identity information for the - /// resource. /// The system metadata relating to System /// Topic 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)) + /// Identity information for the + /// 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), SystemData systemData = default(SystemData), IdentityInfo identity = default(IdentityInfo)) : base(location, id, name, type, tags) { ProvisioningState = provisioningState; Source = source; TopicType = topicType; MetricResourceId = metricResourceId; - Identity = identity; SystemData = systemData; + Identity = identity; CustomInit(); } @@ -94,18 +94,18 @@ public SystemTopic() [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 System Topic resource. /// [JsonProperty(PropertyName = "systemData")] public SystemData SystemData { get; private 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/Topic.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/Topic.cs index b7d494abede42..8244bd905db3e 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 @@ -66,11 +66,19 @@ public Topic() /// disable local auth. Default value is false. When the property is /// set to true, only AAD token will be used to authenticate if user is /// allowed to publish to the topic. + /// Data Residency Boundary of the + /// resource. Possible values include: 'WithinGeopair', + /// 'WithinRegion' + /// 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. /// The system metadata relating to Topic /// 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), bool? disableLocalAuth = default(bool?), IdentityInfo identity = default(IdentityInfo), SystemData systemData = default(SystemData)) + 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), bool? disableLocalAuth = default(bool?), string dataResidencyBoundary = default(string), ResourceSku sku = default(ResourceSku), IdentityInfo identity = default(IdentityInfo), string kind = default(string), ExtendedLocation extendedLocation = default(ExtendedLocation), SystemData systemData = default(SystemData)) : base(location, id, name, type, tags) { PrivateEndpointConnections = privateEndpointConnections; @@ -82,7 +90,11 @@ public Topic() PublicNetworkAccess = publicNetworkAccess; InboundIpRules = inboundIpRules; DisableLocalAuth = disableLocalAuth; + DataResidencyBoundary = dataResidencyBoundary; + Sku = sku; Identity = identity; + Kind = kind; + ExtendedLocation = extendedLocation; SystemData = systemData; CustomInit(); } @@ -163,12 +175,38 @@ public Topic() [JsonProperty(PropertyName = "properties.disableLocalAuth")] public bool? DisableLocalAuth { get; set; } + /// + /// Gets or sets data Residency Boundary of the resource. Possible + /// values include: 'WithinGeopair', 'WithinRegion' + /// + [JsonProperty(PropertyName = "properties.dataResidencyBoundary")] + public string DataResidencyBoundary { 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; } + /// /// Gets the system metadata relating to Topic resource. /// 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 06adc09d1d3d2..cf0869aa63dae 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 @@ -34,7 +34,7 @@ public TopicUpdateParameters() /// /// Initializes a new instance of the TopicUpdateParameters class. /// - /// Tags of the resource. + /// Tags of the Topic resource. /// Topic resource identity information. /// This determines if traffic is /// allowed over public network. By default it is enabled. @@ -48,13 +48,19 @@ public TopicUpdateParameters() /// disable local auth. Default value is false. When the property is /// set to true, only AAD token will be used to authenticate if user is /// allowed to publish to the topic. - public TopicUpdateParameters(IDictionary tags = default(IDictionary), IdentityInfo identity = default(IdentityInfo), string publicNetworkAccess = default(string), IList inboundIpRules = default(IList), bool? disableLocalAuth = default(bool?)) + /// The data residency boundary for + /// the topic. Possible values include: 'WithinGeopair', + /// 'WithinRegion' + /// 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), bool? disableLocalAuth = default(bool?), string dataResidencyBoundary = default(string), ResourceSku sku = default(ResourceSku)) { Tags = tags; Identity = identity; PublicNetworkAccess = publicNetworkAccess; InboundIpRules = inboundIpRules; DisableLocalAuth = disableLocalAuth; + DataResidencyBoundary = dataResidencyBoundary; + Sku = sku; CustomInit(); } @@ -64,7 +70,7 @@ public TopicUpdateParameters() partial void CustomInit(); /// - /// Gets or sets tags of the resource. + /// Gets or sets tags of the Topic resource. /// [JsonProperty(PropertyName = "tags")] public IDictionary Tags { get; set; } @@ -103,5 +109,18 @@ public TopicUpdateParameters() [JsonProperty(PropertyName = "properties.disableLocalAuth")] public bool? DisableLocalAuth { get; set; } + /// + /// Gets or sets the data residency boundary for the topic. Possible + /// values include: 'WithinGeopair', 'WithinRegion' + /// + [JsonProperty(PropertyName = "properties.dataResidencyBoundary")] + public string DataResidencyBoundary { 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/VerifiedPartner.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/VerifiedPartner.cs new file mode 100644 index 0000000000000..e662e6711c38f --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/VerifiedPartner.cs @@ -0,0 +1,117 @@ +// +// 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; + + /// + /// Verified partner information + /// + [Rest.Serialization.JsonTransformation] + public partial class VerifiedPartner : Resource + { + /// + /// Initializes a new instance of the VerifiedPartner class. + /// + public VerifiedPartner() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VerifiedPartner class. + /// + /// Fully qualified identifier of the + /// resource. + /// Name of the resource. + /// Type of the resource. + /// ImmutableId of the + /// corresponding partner registration. + /// Official name of the + /// Partner. + /// Display name of the verified + /// partner. + /// Details of the partner topic + /// scenario. + /// Details of the partner + /// destination scenario. + /// Provisioning state of the verified + /// partner. Possible values include: 'Creating', 'Updating', + /// 'Deleting', 'Succeeded', 'Canceled', 'Failed' + /// The system metadata relating to Verified + /// Partner resource. + public VerifiedPartner(string id = default(string), string name = default(string), string type = default(string), System.Guid? partnerRegistrationImmutableId = default(System.Guid?), string organizationName = default(string), string partnerDisplayName = default(string), PartnerDetails partnerTopicDetails = default(PartnerDetails), PartnerDetails partnerDestinationDetails = default(PartnerDetails), string provisioningState = default(string), SystemData systemData = default(SystemData)) + : base(id, name, type) + { + PartnerRegistrationImmutableId = partnerRegistrationImmutableId; + OrganizationName = organizationName; + PartnerDisplayName = partnerDisplayName; + PartnerTopicDetails = partnerTopicDetails; + PartnerDestinationDetails = partnerDestinationDetails; + ProvisioningState = provisioningState; + SystemData = systemData; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets immutableId of the corresponding partner registration. + /// + [JsonProperty(PropertyName = "properties.partnerRegistrationImmutableId")] + public System.Guid? PartnerRegistrationImmutableId { get; set; } + + /// + /// Gets or sets official name of the Partner. + /// + [JsonProperty(PropertyName = "properties.organizationName")] + public string OrganizationName { get; set; } + + /// + /// Gets or sets display name of the verified partner. + /// + [JsonProperty(PropertyName = "properties.partnerDisplayName")] + public string PartnerDisplayName { get; set; } + + /// + /// Gets or sets details of the partner topic scenario. + /// + [JsonProperty(PropertyName = "properties.partnerTopicDetails")] + public PartnerDetails PartnerTopicDetails { get; set; } + + /// + /// Gets or sets details of the partner destination scenario. + /// + [JsonProperty(PropertyName = "properties.partnerDestinationDetails")] + public PartnerDetails PartnerDestinationDetails { get; set; } + + /// + /// Gets or sets provisioning state of the verified partner. Possible + /// values include: 'Creating', 'Updating', 'Deleting', 'Succeeded', + /// 'Canceled', 'Failed' + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets the system metadata relating to Verified Partner resource. + /// + [JsonProperty(PropertyName = "systemData")] + public SystemData SystemData { get; private set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/VerifiedPartnerProvisioningState.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/VerifiedPartnerProvisioningState.cs new file mode 100644 index 0000000000000..b3543e7edf444 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/VerifiedPartnerProvisioningState.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 VerifiedPartnerProvisioningState. + /// + public static class VerifiedPartnerProvisioningState + { + 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/WebhookPartnerDestinationInfo.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/WebhookPartnerDestinationInfo.cs new file mode 100644 index 0000000000000..ec351f7e998f8 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/WebhookPartnerDestinationInfo.cs @@ -0,0 +1,92 @@ +// +// 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 the WebHook of the partner destination. + /// + [Newtonsoft.Json.JsonObject("WebHook")] + [Rest.Serialization.JsonTransformation] + public partial class WebhookPartnerDestinationInfo : PartnerDestinationInfo + { + /// + /// Initializes a new instance of the WebhookPartnerDestinationInfo + /// class. + /// + public WebhookPartnerDestinationInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the WebhookPartnerDestinationInfo + /// class. + /// + /// Azure subscription ID of the + /// subscriber. The partner destination associated with the channel + /// will be + /// created under this Azure subscription. + /// Azure Resource Group of the + /// subscriber. The partner destination associated with the channel + /// will be + /// created under this resource group. + /// Name of the partner destination associated with + /// the channel. + /// Additional context of the + /// partner destination endpoint. + /// Change history of the + /// resource move. + /// The URL that represents the endpoint of + /// the partner destination. + /// The base URL that represents the + /// endpoint of the partner destination. + public WebhookPartnerDestinationInfo(string azureSubscriptionId = default(string), string resourceGroupName = default(string), string name = default(string), string endpointServiceContext = default(string), IList resourceMoveChangeHistory = default(IList), string endpointUrl = default(string), string endpointBaseUrl = default(string), PartnerClientAuthentication clientAuthentication = default(PartnerClientAuthentication)) + : base(azureSubscriptionId, resourceGroupName, name, endpointServiceContext, resourceMoveChangeHistory) + { + EndpointUrl = endpointUrl; + EndpointBaseUrl = endpointBaseUrl; + ClientAuthentication = clientAuthentication; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the URL that represents the endpoint of the partner + /// destination. + /// + [JsonProperty(PropertyName = "properties.endpointUrl")] + public string EndpointUrl { get; set; } + + /// + /// Gets or sets the base URL that represents the endpoint of the + /// partner destination. + /// + [JsonProperty(PropertyName = "properties.endpointBaseUrl")] + public string EndpointBaseUrl { get; set; } + + /// + /// + [JsonProperty(PropertyName = "properties.clientAuthentication")] + public PartnerClientAuthentication ClientAuthentication { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/WebhookUpdatePartnerDestinationInfo.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/WebhookUpdatePartnerDestinationInfo.cs new file mode 100644 index 0000000000000..af4811cd82ff9 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/Models/WebhookUpdatePartnerDestinationInfo.cs @@ -0,0 +1,75 @@ +// +// 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; + + /// + /// Information about the update of the WebHook of the partner destination. + /// + [Newtonsoft.Json.JsonObject("WebHook")] + [Rest.Serialization.JsonTransformation] + public partial class WebhookUpdatePartnerDestinationInfo : PartnerUpdateDestinationInfo + { + /// + /// Initializes a new instance of the + /// WebhookUpdatePartnerDestinationInfo class. + /// + public WebhookUpdatePartnerDestinationInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// WebhookUpdatePartnerDestinationInfo class. + /// + /// The URL that represents the endpoint of + /// the partner destination. + /// The base URL that represents the + /// endpoint of the partner destination. + public WebhookUpdatePartnerDestinationInfo(string endpointUrl = default(string), string endpointBaseUrl = default(string), PartnerClientAuthentication clientAuthentication = default(PartnerClientAuthentication)) + { + EndpointUrl = endpointUrl; + EndpointBaseUrl = endpointBaseUrl; + ClientAuthentication = clientAuthentication; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the URL that represents the endpoint of the partner + /// destination. + /// + [JsonProperty(PropertyName = "properties.endpointUrl")] + public string EndpointUrl { get; set; } + + /// + /// Gets or sets the base URL that represents the endpoint of the + /// partner destination. + /// + [JsonProperty(PropertyName = "properties.endpointBaseUrl")] + public string EndpointBaseUrl { get; set; } + + /// + /// + [JsonProperty(PropertyName = "properties.clientAuthentication")] + public PartnerClientAuthentication ClientAuthentication { get; set; } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerConfigurationsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerConfigurationsOperations.cs new file mode 100644 index 0000000000000..e56935488d57e --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerConfigurationsOperations.cs @@ -0,0 +1,1914 @@ +// +// 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; + + /// + /// PartnerConfigurationsOperations operations. + /// + internal partial class PartnerConfigurationsOperations : IServiceOperations, IPartnerConfigurationsOperations + { + /// + /// Initializes a new instance of the PartnerConfigurationsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PartnerConfigurationsOperations(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 configuration. + /// + /// + /// Get properties of a partner configuration. + /// + /// + /// The name of the resource group within the user's 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> GetWithHttpMessagesAsync(string resourceGroupName, 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("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/partnerConfigurations/default").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 (_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 a partner configuration. + /// + /// + /// Synchronously creates or updates a partner configuration with the specified + /// parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Partner configuration information. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, PartnerConfiguration partnerConfigurationInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, partnerConfigurationInfo, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Delete a partner configuration. + /// + /// + /// Delete existing partner configuration. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Update a partner configuration. + /// + /// + /// Synchronously updates a partner configuration with the specified + /// parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Partner configuration update information. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, PartnerConfigurationUpdateParameters partnerConfigurationUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, partnerConfigurationUpdateParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// List partner configurations under a resource group. + /// + /// + /// List all the partner configurations under a resource group. + /// + /// + /// The name of the resource group within the user's 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, 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("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/partnerConfigurations").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 (_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 configurations under an Azure subscription. + /// + /// + /// List all the partner configurations 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/partnerConfigurations").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; + } + + /// + /// Authorize a partner. + /// + /// + /// Authorize a single partner either by partner registration immutable Id or + /// by partner name. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The information of the partner to be authorized. + /// + /// + /// 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> AuthorizePartnerWithHttpMessagesAsync(string resourceGroupName, Partner partnerInfo, 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 (partnerInfo == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerInfo"); + } + 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("partnerInfo", partnerInfo); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "AuthorizePartner", 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/partnerConfigurations/default/authorizePartner").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 (_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(partnerInfo != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(partnerInfo, 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; + } + + /// + /// Unauthorize a partner. + /// + /// + /// Unauthorize a single partner either by partner registration immutable Id or + /// by partner name. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The information of the partner to be unauthorized. + /// + /// + /// 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> UnauthorizePartnerWithHttpMessagesAsync(string resourceGroupName, Partner partnerInfo, 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 (partnerInfo == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerInfo"); + } + 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("partnerInfo", partnerInfo); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "UnauthorizePartner", 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/partnerConfigurations/default/unauthorizePartner").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 (_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(partnerInfo != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(partnerInfo, 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 or update a partner configuration. + /// + /// + /// Synchronously creates or updates a partner configuration with the specified + /// parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Partner configuration 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, PartnerConfiguration partnerConfigurationInfo, 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 (partnerConfigurationInfo == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerConfigurationInfo"); + } + 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("partnerConfigurationInfo", partnerConfigurationInfo); + 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/partnerConfigurations/default").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 (_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(partnerConfigurationInfo != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(partnerConfigurationInfo, 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 partner configuration. + /// + /// + /// Delete existing partner configuration. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// 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, 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("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/partnerConfigurations/default").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 (_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 configuration. + /// + /// + /// Synchronously updates a partner configuration with the specified + /// parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Partner configuration 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, PartnerConfigurationUpdateParameters partnerConfigurationUpdateParameters, 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 (partnerConfigurationUpdateParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerConfigurationUpdateParameters"); + } + 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("partnerConfigurationUpdateParameters", partnerConfigurationUpdateParameters); + 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/partnerConfigurations/default").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 (_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(partnerConfigurationUpdateParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(partnerConfigurationUpdateParameters, 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 partner configurations under an Azure subscription. + /// + /// + /// List all the partner configurations 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; + } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerConfigurationsOperationsExtensions.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerConfigurationsOperationsExtensions.cs new file mode 100644 index 0000000000000..bdddbbe2938dd --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerConfigurationsOperationsExtensions.cs @@ -0,0 +1,571 @@ +// +// 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 PartnerConfigurationsOperations. + /// + public static partial class PartnerConfigurationsOperationsExtensions + { + /// + /// Get a partner configuration. + /// + /// + /// Get properties of a partner configuration. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + public static PartnerConfiguration Get(this IPartnerConfigurationsOperations operations, string resourceGroupName) + { + return operations.GetAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Get a partner configuration. + /// + /// + /// Get properties of a partner configuration. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPartnerConfigurationsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update a partner configuration. + /// + /// + /// Synchronously creates or updates a partner configuration with the specified + /// parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Partner configuration information. + /// + public static PartnerConfiguration CreateOrUpdate(this IPartnerConfigurationsOperations operations, string resourceGroupName, PartnerConfiguration partnerConfigurationInfo) + { + return operations.CreateOrUpdateAsync(resourceGroupName, partnerConfigurationInfo).GetAwaiter().GetResult(); + } + + /// + /// Create or update a partner configuration. + /// + /// + /// Synchronously creates or updates a partner configuration with the specified + /// parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Partner configuration information. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IPartnerConfigurationsOperations operations, string resourceGroupName, PartnerConfiguration partnerConfigurationInfo, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, partnerConfigurationInfo, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete a partner configuration. + /// + /// + /// Delete existing partner configuration. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + public static void Delete(this IPartnerConfigurationsOperations operations, string resourceGroupName) + { + operations.DeleteAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Delete a partner configuration. + /// + /// + /// Delete existing partner configuration. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IPartnerConfigurationsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update a partner configuration. + /// + /// + /// Synchronously updates a partner configuration with the specified + /// parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Partner configuration update information. + /// + public static PartnerConfiguration Update(this IPartnerConfigurationsOperations operations, string resourceGroupName, PartnerConfigurationUpdateParameters partnerConfigurationUpdateParameters) + { + return operations.UpdateAsync(resourceGroupName, partnerConfigurationUpdateParameters).GetAwaiter().GetResult(); + } + + /// + /// Update a partner configuration. + /// + /// + /// Synchronously updates a partner configuration with the specified + /// parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Partner configuration update information. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IPartnerConfigurationsOperations operations, string resourceGroupName, PartnerConfigurationUpdateParameters partnerConfigurationUpdateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, partnerConfigurationUpdateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List partner configurations under a resource group. + /// + /// + /// List all the partner configurations under a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + public static IEnumerable ListByResourceGroup(this IPartnerConfigurationsOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// List partner configurations under a resource group. + /// + /// + /// List all the partner configurations under a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IPartnerConfigurationsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List partner configurations under an Azure subscription. + /// + /// + /// List all the partner configurations 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 IPartnerConfigurationsOperations operations, string filter = default(string), int? top = default(int?)) + { + return operations.ListBySubscriptionAsync(filter, top).GetAwaiter().GetResult(); + } + + /// + /// List partner configurations under an Azure subscription. + /// + /// + /// List all the partner configurations 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 IPartnerConfigurationsOperations 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; + } + } + + /// + /// Authorize a partner. + /// + /// + /// Authorize a single partner either by partner registration immutable Id or + /// by partner name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The information of the partner to be authorized. + /// + public static PartnerConfiguration AuthorizePartner(this IPartnerConfigurationsOperations operations, string resourceGroupName, Partner partnerInfo) + { + return operations.AuthorizePartnerAsync(resourceGroupName, partnerInfo).GetAwaiter().GetResult(); + } + + /// + /// Authorize a partner. + /// + /// + /// Authorize a single partner either by partner registration immutable Id or + /// by partner name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The information of the partner to be authorized. + /// + /// + /// The cancellation token. + /// + public static async Task AuthorizePartnerAsync(this IPartnerConfigurationsOperations operations, string resourceGroupName, Partner partnerInfo, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.AuthorizePartnerWithHttpMessagesAsync(resourceGroupName, partnerInfo, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Unauthorize a partner. + /// + /// + /// Unauthorize a single partner either by partner registration immutable Id or + /// by partner name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The information of the partner to be unauthorized. + /// + public static PartnerConfiguration UnauthorizePartner(this IPartnerConfigurationsOperations operations, string resourceGroupName, Partner partnerInfo) + { + return operations.UnauthorizePartnerAsync(resourceGroupName, partnerInfo).GetAwaiter().GetResult(); + } + + /// + /// Unauthorize a partner. + /// + /// + /// Unauthorize a single partner either by partner registration immutable Id or + /// by partner name. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The information of the partner to be unauthorized. + /// + /// + /// The cancellation token. + /// + public static async Task UnauthorizePartnerAsync(this IPartnerConfigurationsOperations operations, string resourceGroupName, Partner partnerInfo, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UnauthorizePartnerWithHttpMessagesAsync(resourceGroupName, partnerInfo, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update a partner configuration. + /// + /// + /// Synchronously creates or updates a partner configuration with the specified + /// parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Partner configuration information. + /// + public static PartnerConfiguration BeginCreateOrUpdate(this IPartnerConfigurationsOperations operations, string resourceGroupName, PartnerConfiguration partnerConfigurationInfo) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, partnerConfigurationInfo).GetAwaiter().GetResult(); + } + + /// + /// Create or update a partner configuration. + /// + /// + /// Synchronously creates or updates a partner configuration with the specified + /// parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Partner configuration information. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IPartnerConfigurationsOperations operations, string resourceGroupName, PartnerConfiguration partnerConfigurationInfo, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, partnerConfigurationInfo, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete a partner configuration. + /// + /// + /// Delete existing partner configuration. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + public static void BeginDelete(this IPartnerConfigurationsOperations operations, string resourceGroupName) + { + operations.BeginDeleteAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Delete a partner configuration. + /// + /// + /// Delete existing partner configuration. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IPartnerConfigurationsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update a partner configuration. + /// + /// + /// Synchronously updates a partner configuration with the specified + /// parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Partner configuration update information. + /// + public static PartnerConfiguration BeginUpdate(this IPartnerConfigurationsOperations operations, string resourceGroupName, PartnerConfigurationUpdateParameters partnerConfigurationUpdateParameters) + { + return operations.BeginUpdateAsync(resourceGroupName, partnerConfigurationUpdateParameters).GetAwaiter().GetResult(); + } + + /// + /// Update a partner configuration. + /// + /// + /// Synchronously updates a partner configuration with the specified + /// parameters. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Partner configuration update information. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this IPartnerConfigurationsOperations operations, string resourceGroupName, PartnerConfigurationUpdateParameters partnerConfigurationUpdateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, partnerConfigurationUpdateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List partner configurations under an Azure subscription. + /// + /// + /// List all the partner configurations 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 IPartnerConfigurationsOperations operations, string nextPageLink) + { + return operations.ListBySubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List partner configurations under an Azure subscription. + /// + /// + /// List all the partner configurations 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 IPartnerConfigurationsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerDestinationsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerDestinationsOperations.cs new file mode 100644 index 0000000000000..ed3e55f4b5b25 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerDestinationsOperations.cs @@ -0,0 +1,1876 @@ +// +// 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; + + /// + /// PartnerDestinationsOperations operations. + /// + internal partial class PartnerDestinationsOperations : IServiceOperations, IPartnerDestinationsOperations + { + /// + /// Initializes a new instance of the PartnerDestinationsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal PartnerDestinationsOperations(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 destination. + /// + /// + /// Get properties of a partner destination. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner destination. + /// + /// + /// 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 partnerDestinationName, 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 (partnerDestinationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerDestinationName"); + } + 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("partnerDestinationName", partnerDestinationName); + 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/partnerDestinations/{partnerDestinationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerDestinationName}", System.Uri.EscapeDataString(partnerDestinationName)); + 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 destination. + /// + /// + /// Asynchronously creates a new partner destination with the specified + /// parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner destination. + /// + /// + /// Partner destination create 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 partnerDestinationName, PartnerDestination partnerDestination, 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 (partnerDestinationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerDestinationName"); + } + if (partnerDestination == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerDestination"); + } + if (partnerDestination != null) + { + partnerDestination.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("partnerDestinationName", partnerDestinationName); + tracingParameters.Add("partnerDestination", partnerDestination); + 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/partnerDestinations/{partnerDestinationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerDestinationName}", System.Uri.EscapeDataString(partnerDestinationName)); + 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(partnerDestination != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(partnerDestination, 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 partner destination. + /// + /// + /// Delete existing partner destination. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner destination. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string partnerDestinationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, partnerDestinationName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Update a partner destination. + /// + /// + /// Asynchronously updates a partner destination with the specified parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner destination. + /// + /// + /// Tags of the Partner Destination 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string partnerDestinationName, 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 (partnerDestinationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerDestinationName"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + PartnerDestinationUpdateParameters partnerDestinationUpdateParameters = new PartnerDestinationUpdateParameters(); + if (tags != null) + { + partnerDestinationUpdateParameters.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("partnerDestinationName", partnerDestinationName); + tracingParameters.Add("partnerDestinationUpdateParameters", partnerDestinationUpdateParameters); + 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/partnerDestinations/{partnerDestinationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerDestinationName}", System.Uri.EscapeDataString(partnerDestinationName)); + 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(partnerDestinationUpdateParameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(partnerDestinationUpdateParameters, 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 destinations under an Azure subscription. + /// + /// + /// List all the partner destinations 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/partnerDestinations").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 destinations under a resource group. + /// + /// + /// List all the partner destinations 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/partnerDestinations").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 destination. + /// + /// + /// Activate a newly created partner destination. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner destination. + /// + /// + /// 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 partnerDestinationName, 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 (partnerDestinationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerDestinationName"); + } + 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("partnerDestinationName", partnerDestinationName); + 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/partnerDestinations/{partnerDestinationName}/activate").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerDestinationName}", System.Uri.EscapeDataString(partnerDestinationName)); + 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 destination. + /// + /// + /// Delete existing partner destination. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner destination. + /// + /// + /// 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 partnerDestinationName, 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 (partnerDestinationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerDestinationName"); + } + 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("partnerDestinationName", partnerDestinationName); + 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/partnerDestinations/{partnerDestinationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{partnerDestinationName}", System.Uri.EscapeDataString(partnerDestinationName)); + 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 destinations under an Azure subscription. + /// + /// + /// List all the partner destinations 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 destinations under a resource group. + /// + /// + /// List all the partner destinations 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/PartnerDestinationsOperationsExtensions.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerDestinationsOperationsExtensions.cs new file mode 100644 index 0000000000000..bc21510fb8fd4 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerDestinationsOperationsExtensions.cs @@ -0,0 +1,521 @@ +// +// 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 PartnerDestinationsOperations. + /// + public static partial class PartnerDestinationsOperationsExtensions + { + /// + /// Get a partner destination. + /// + /// + /// Get properties of a partner destination. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner destination. + /// + public static PartnerDestination Get(this IPartnerDestinationsOperations operations, string resourceGroupName, string partnerDestinationName) + { + return operations.GetAsync(resourceGroupName, partnerDestinationName).GetAwaiter().GetResult(); + } + + /// + /// Get a partner destination. + /// + /// + /// Get properties of a partner destination. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner destination. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IPartnerDestinationsOperations operations, string resourceGroupName, string partnerDestinationName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, partnerDestinationName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create a partner destination. + /// + /// + /// Asynchronously creates a new partner destination 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 destination. + /// + /// + /// Partner destination create information. + /// + public static PartnerDestination CreateOrUpdate(this IPartnerDestinationsOperations operations, string resourceGroupName, string partnerDestinationName, PartnerDestination partnerDestination) + { + return operations.CreateOrUpdateAsync(resourceGroupName, partnerDestinationName, partnerDestination).GetAwaiter().GetResult(); + } + + /// + /// Create a partner destination. + /// + /// + /// Asynchronously creates a new partner destination 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 destination. + /// + /// + /// Partner destination create information. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IPartnerDestinationsOperations operations, string resourceGroupName, string partnerDestinationName, PartnerDestination partnerDestination, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, partnerDestinationName, partnerDestination, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete a partner destination. + /// + /// + /// Delete existing partner destination. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner destination. + /// + public static void Delete(this IPartnerDestinationsOperations operations, string resourceGroupName, string partnerDestinationName) + { + operations.DeleteAsync(resourceGroupName, partnerDestinationName).GetAwaiter().GetResult(); + } + + /// + /// Delete a partner destination. + /// + /// + /// Delete existing partner destination. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner destination. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IPartnerDestinationsOperations operations, string resourceGroupName, string partnerDestinationName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, partnerDestinationName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update a partner destination. + /// + /// + /// Asynchronously updates a partner destination 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 destination. + /// + /// + /// Tags of the Partner Destination resource. + /// + public static PartnerDestination Update(this IPartnerDestinationsOperations operations, string resourceGroupName, string partnerDestinationName, IDictionary tags = default(IDictionary)) + { + return operations.UpdateAsync(resourceGroupName, partnerDestinationName, tags).GetAwaiter().GetResult(); + } + + /// + /// Update a partner destination. + /// + /// + /// Asynchronously updates a partner destination 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 destination. + /// + /// + /// Tags of the Partner Destination resource. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IPartnerDestinationsOperations operations, string resourceGroupName, string partnerDestinationName, IDictionary tags = default(IDictionary), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, partnerDestinationName, tags, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List partner destinations under an Azure subscription. + /// + /// + /// List all the partner destinations 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 IPartnerDestinationsOperations operations, string filter = default(string), int? top = default(int?)) + { + return operations.ListBySubscriptionAsync(filter, top).GetAwaiter().GetResult(); + } + + /// + /// List partner destinations under an Azure subscription. + /// + /// + /// List all the partner destinations 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 IPartnerDestinationsOperations 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 destinations under a resource group. + /// + /// + /// List all the partner destinations 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 IPartnerDestinationsOperations operations, string resourceGroupName, string filter = default(string), int? top = default(int?)) + { + return operations.ListByResourceGroupAsync(resourceGroupName, filter, top).GetAwaiter().GetResult(); + } + + /// + /// List partner destinations under a resource group. + /// + /// + /// List all the partner destinations 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 IPartnerDestinationsOperations 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 destination. + /// + /// + /// Activate a newly created partner destination. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner destination. + /// + public static PartnerDestination Activate(this IPartnerDestinationsOperations operations, string resourceGroupName, string partnerDestinationName) + { + return operations.ActivateAsync(resourceGroupName, partnerDestinationName).GetAwaiter().GetResult(); + } + + /// + /// Activate a partner destination. + /// + /// + /// Activate a newly created partner destination. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner destination. + /// + /// + /// The cancellation token. + /// + public static async Task ActivateAsync(this IPartnerDestinationsOperations operations, string resourceGroupName, string partnerDestinationName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ActivateWithHttpMessagesAsync(resourceGroupName, partnerDestinationName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete a partner destination. + /// + /// + /// Delete existing partner destination. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner destination. + /// + public static void BeginDelete(this IPartnerDestinationsOperations operations, string resourceGroupName, string partnerDestinationName) + { + operations.BeginDeleteAsync(resourceGroupName, partnerDestinationName).GetAwaiter().GetResult(); + } + + /// + /// Delete a partner destination. + /// + /// + /// Delete existing partner destination. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner destination. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IPartnerDestinationsOperations operations, string resourceGroupName, string partnerDestinationName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, partnerDestinationName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// List partner destinations under an Azure subscription. + /// + /// + /// List all the partner destinations 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 IPartnerDestinationsOperations operations, string nextPageLink) + { + return operations.ListBySubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List partner destinations under an Azure subscription. + /// + /// + /// List all the partner destinations 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 IPartnerDestinationsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List partner destinations under a resource group. + /// + /// + /// List all the partner destinations 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 IPartnerDestinationsOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List partner destinations under a resource group. + /// + /// + /// List all the partner destinations 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 IPartnerDestinationsOperations 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/PartnerNamespacesOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerNamespacesOperations.cs new file mode 100644 index 0000000000000..5cd0ddc3212a1 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerNamespacesOperations.cs @@ -0,0 +1,2132 @@ +// +// 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. + /// + /// + /// Partner namespace update information. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string partnerNamespaceName, PartnerNamespaceUpdateParameters partnerNamespaceUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, partnerNamespaceUpdateParameters, 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. + /// + /// + /// Partner namespace 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 partnerNamespaceName, PartnerNamespaceUpdateParameters partnerNamespaceUpdateParameters, 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 (partnerNamespaceUpdateParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerNamespaceUpdateParameters"); + } + 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("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 0000000000000..e8c5a1ec0576f --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerNamespacesOperationsExtensions.cs @@ -0,0 +1,677 @@ +// +// 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 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. + /// + /// + /// Partner namespace update information. + /// + public static PartnerNamespace Update(this IPartnerNamespacesOperations operations, string resourceGroupName, string partnerNamespaceName, PartnerNamespaceUpdateParameters partnerNamespaceUpdateParameters) + { + return operations.UpdateAsync(resourceGroupName, partnerNamespaceName, partnerNamespaceUpdateParameters).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. + /// + /// + /// Partner namespace update information. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IPartnerNamespacesOperations operations, string resourceGroupName, string partnerNamespaceName, PartnerNamespaceUpdateParameters partnerNamespaceUpdateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, partnerNamespaceUpdateParameters, 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. + /// + /// + /// Partner namespace update information. + /// + public static PartnerNamespace BeginUpdate(this IPartnerNamespacesOperations operations, string resourceGroupName, string partnerNamespaceName, PartnerNamespaceUpdateParameters partnerNamespaceUpdateParameters) + { + return operations.BeginUpdateAsync(resourceGroupName, partnerNamespaceName, partnerNamespaceUpdateParameters).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. + /// + /// + /// Partner namespace update information. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this IPartnerNamespacesOperations operations, string resourceGroupName, string partnerNamespaceName, PartnerNamespaceUpdateParameters partnerNamespaceUpdateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, partnerNamespaceName, partnerNamespaceUpdateParameters, 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 0000000000000..ad88b6a5e4fba --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerRegistrationsOperations.cs @@ -0,0 +1,1731 @@ +// +// 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. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string partnerRegistrationName, PartnerRegistration partnerRegistrationInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, partnerRegistrationName, partnerRegistrationInfo, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// 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. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string partnerRegistrationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, partnerRegistrationName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// 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. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string partnerRegistrationName, PartnerRegistrationUpdateParameters partnerRegistrationUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, partnerRegistrationName, partnerRegistrationUpdateParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// 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; + } + + /// + /// 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> BeginCreateOrUpdateWithHttpMessagesAsync(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, "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/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 BeginDeleteWithHttpMessagesAsync(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, "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/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> BeginUpdateWithHttpMessagesAsync(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, "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/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 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 0000000000000..224529c133e9c --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerRegistrationsOperationsExtensions.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 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; + } + } + + /// + /// 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 BeginCreateOrUpdate(this IPartnerRegistrationsOperations operations, string resourceGroupName, string partnerRegistrationName, PartnerRegistration partnerRegistrationInfo) + { + return operations.BeginCreateOrUpdateAsync(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 BeginCreateOrUpdateAsync(this IPartnerRegistrationsOperations operations, string resourceGroupName, string partnerRegistrationName, PartnerRegistration partnerRegistrationInfo, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(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 BeginDelete(this IPartnerRegistrationsOperations operations, string resourceGroupName, string partnerRegistrationName) + { + operations.BeginDeleteAsync(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 BeginDeleteAsync(this IPartnerRegistrationsOperations operations, string resourceGroupName, string partnerRegistrationName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(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 BeginUpdate(this IPartnerRegistrationsOperations operations, string resourceGroupName, string partnerRegistrationName, PartnerRegistrationUpdateParameters partnerRegistrationUpdateParameters) + { + return operations.BeginUpdateAsync(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 BeginUpdateAsync(this IPartnerRegistrationsOperations operations, string resourceGroupName, string partnerRegistrationName, PartnerRegistrationUpdateParameters partnerRegistrationUpdateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(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 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 0000000000000..e6fc66ab7dbed --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerTopicEventSubscriptionsOperations.cs @@ -0,0 +1,1840 @@ +// +// 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 properties of 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 existing 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 an existing 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 != 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 an event subscription of a partner topic. + /// + /// + /// Delete an existing 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 an existing 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 0000000000000..6c8a424c3ce93 --- /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 properties of 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 properties of 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 existing 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 existing 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 an existing 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 an existing 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 existing 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 existing 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 an existing 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 an existing 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 0000000000000..190ef0b06bf65 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerTopicsOperations.cs @@ -0,0 +1,2073 @@ +// +// 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; + } + + /// + /// Create a partner topic. + /// + /// + /// Asynchronously creates a new partner topic with the specified parameters. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the partner topic. + /// + /// + /// Partner 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> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string partnerTopicName, PartnerTopic partnerTopicInfo, 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 (partnerTopicInfo == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerTopicInfo"); + } + if (partnerTopicInfo != null) + { + partnerTopicInfo.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("partnerTopicName", partnerTopicName); + tracingParameters.Add("partnerTopicInfo", partnerTopicInfo); + 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/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("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(partnerTopicInfo != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(partnerTopicInfo, 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 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. + /// + /// + /// PartnerTopic 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 partnerTopicName, PartnerTopicUpdateParameters partnerTopicUpdateParameters, 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 (partnerTopicUpdateParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "partnerTopicUpdateParameters"); + } + 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("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 0000000000000..d57ffd4e25010 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PartnerTopicsOperationsExtensions.cs @@ -0,0 +1,563 @@ +// +// 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 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; + } + } + + /// + /// Create a partner topic. + /// + /// + /// Asynchronously creates a new 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. + /// + /// + /// Partner Topic information. + /// + public static PartnerTopic CreateOrUpdate(this IPartnerTopicsOperations operations, string resourceGroupName, string partnerTopicName, PartnerTopic partnerTopicInfo) + { + return operations.CreateOrUpdateAsync(resourceGroupName, partnerTopicName, partnerTopicInfo).GetAwaiter().GetResult(); + } + + /// + /// Create a partner topic. + /// + /// + /// Asynchronously creates a new 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. + /// + /// + /// Partner Topic information. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IPartnerTopicsOperations operations, string resourceGroupName, string partnerTopicName, PartnerTopic partnerTopicInfo, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, partnerTopicName, partnerTopicInfo, 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. + /// + /// + /// PartnerTopic update information. + /// + public static PartnerTopic Update(this IPartnerTopicsOperations operations, string resourceGroupName, string partnerTopicName, PartnerTopicUpdateParameters partnerTopicUpdateParameters) + { + return operations.UpdateAsync(resourceGroupName, partnerTopicName, partnerTopicUpdateParameters).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. + /// + /// + /// PartnerTopic update information. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IPartnerTopicsOperations operations, string resourceGroupName, string partnerTopicName, PartnerTopicUpdateParameters partnerTopicUpdateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, partnerTopicName, partnerTopicUpdateParameters, 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/PrivateEndpointConnectionsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PrivateEndpointConnectionsOperations.cs index 9d16493c4754e..112746dc2a773 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PrivateEndpointConnectionsOperations.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PrivateEndpointConnectionsOperations.cs @@ -54,18 +54,20 @@ internal PrivateEndpointConnectionsOperations(EventGridManagementClient client) /// Get a specific private endpoint connection. /// /// - /// Get a specific private endpoint connection under a topic or domain. + /// Get a specific private endpoint connection under a topic, domain, or + /// partner namespace. /// /// /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. Possible values include: 'topics', 'domains' + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. Possible values include: 'topics', + /// 'domains', 'partnerNamespaces' /// /// - /// The name of the parent resource (namely, either, the topic name or domain - /// name). + /// The name of the parent resource (namely, either, the topic name, domain + /// name, or partner namespace name). /// /// /// The name of the private endpoint connection connection. @@ -136,7 +138,7 @@ internal PrivateEndpointConnectionsOperations(EventGridManagementClient client) var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}").ToString(); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{parentType}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(parentType, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{parentType}", System.Uri.EscapeDataString(parentType)); _url = _url.Replace("{parentName}", System.Uri.EscapeDataString(parentName)); _url = _url.Replace("{privateEndpointConnectionName}", System.Uri.EscapeDataString(privateEndpointConnectionName)); List _queryParameters = new List(); @@ -273,18 +275,20 @@ internal PrivateEndpointConnectionsOperations(EventGridManagementClient client) /// Update a specific private endpoint connection. /// /// - /// Update a specific private endpoint connection under a topic or domain. + /// Update a specific private endpoint connection under a topic, domain or + /// partner namespace. /// /// /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. Possible values include: 'topics', 'domains' + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. Possible values include: 'topics', + /// 'domains', 'partnerNamespaces' /// /// - /// The name of the parent resource (namely, either, the topic name or domain - /// name). + /// The name of the parent resource (namely, either, the topic name, domain + /// name, or partner namespace name). /// /// /// The name of the private endpoint connection connection. @@ -309,18 +313,20 @@ internal PrivateEndpointConnectionsOperations(EventGridManagementClient client) /// Delete a specific private endpoint connection. /// /// - /// Delete a specific private endpoint connection under a topic or domain. + /// Delete a specific private endpoint connection under a topic, domain, or + /// partner namespace. /// /// /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. Possible values include: 'topics', 'domains' + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. Possible values include: 'topics', + /// 'domains', 'partnerNamespaces' /// /// - /// The name of the parent resource (namely, either, the topic name or domain - /// name). + /// The name of the parent resource (namely, either, the topic name, domain + /// name, or partner namespace name). /// /// /// The name of the private endpoint connection connection. @@ -342,18 +348,20 @@ internal PrivateEndpointConnectionsOperations(EventGridManagementClient client) /// Lists all private endpoint connections under a resource. /// /// - /// Get all private endpoint connections under a topic or domain. + /// Get all private endpoint connections under a topic, domain, or partner + /// namespace. /// /// /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. Possible values include: 'topics', 'domains' + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. Possible values include: 'topics', + /// 'domains', 'partnerNamespaces' /// /// - /// The name of the parent resource (namely, either, the topic name or domain - /// name). + /// The name of the parent resource (namely, either, the topic name, domain + /// name, or partner namespace name). /// /// /// The query used to filter the search results using OData syntax. Filtering @@ -432,7 +440,7 @@ internal PrivateEndpointConnectionsOperations(EventGridManagementClient client) var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections").ToString(); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{parentType}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(parentType, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{parentType}", System.Uri.EscapeDataString(parentType)); _url = _url.Replace("{parentName}", System.Uri.EscapeDataString(parentName)); List _queryParameters = new List(); if (Client.ApiVersion != null) @@ -576,18 +584,20 @@ internal PrivateEndpointConnectionsOperations(EventGridManagementClient client) /// Update a specific private endpoint connection. /// /// - /// Update a specific private endpoint connection under a topic or domain. + /// Update a specific private endpoint connection under a topic, domain or + /// partner namespace. /// /// /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. Possible values include: 'topics', 'domains' + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. Possible values include: 'topics', + /// 'domains', 'partnerNamespaces' /// /// - /// The name of the parent resource (namely, either, the topic name or domain - /// name). + /// The name of the parent resource (namely, either, the topic name, domain + /// name, or partner namespace name). /// /// /// The name of the private endpoint connection connection. @@ -666,7 +676,7 @@ internal PrivateEndpointConnectionsOperations(EventGridManagementClient client) var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}").ToString(); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{parentType}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(parentType, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{parentType}", System.Uri.EscapeDataString(parentType)); _url = _url.Replace("{parentName}", System.Uri.EscapeDataString(parentName)); _url = _url.Replace("{privateEndpointConnectionName}", System.Uri.EscapeDataString(privateEndpointConnectionName)); List _queryParameters = new List(); @@ -827,18 +837,20 @@ internal PrivateEndpointConnectionsOperations(EventGridManagementClient client) /// Delete a specific private endpoint connection. /// /// - /// Delete a specific private endpoint connection under a topic or domain. + /// Delete a specific private endpoint connection under a topic, domain, or + /// partner namespace. /// /// /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. Possible values include: 'topics', 'domains' + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. Possible values include: 'topics', + /// 'domains', 'partnerNamespaces' /// /// - /// The name of the parent resource (namely, either, the topic name or domain - /// name). + /// The name of the parent resource (namely, either, the topic name, domain + /// name, or partner namespace name). /// /// /// The name of the private endpoint connection connection. @@ -906,7 +918,7 @@ internal PrivateEndpointConnectionsOperations(EventGridManagementClient client) var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}").ToString(); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{parentType}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(parentType, Client.SerializationSettings).Trim('"'))); + _url = _url.Replace("{parentType}", System.Uri.EscapeDataString(parentType)); _url = _url.Replace("{parentName}", System.Uri.EscapeDataString(parentName)); _url = _url.Replace("{privateEndpointConnectionName}", System.Uri.EscapeDataString(privateEndpointConnectionName)); List _queryParameters = new List(); @@ -1025,7 +1037,8 @@ internal PrivateEndpointConnectionsOperations(EventGridManagementClient client) /// Lists all private endpoint connections under a resource. /// /// - /// Get all private endpoint connections under a topic or domain. + /// Get all private endpoint connections under a topic, domain, or partner + /// namespace. /// /// /// The NextLink from the previous successful call to List operation. diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PrivateEndpointConnectionsOperationsExtensions.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PrivateEndpointConnectionsOperationsExtensions.cs index 106b2b0a0a5ca..b085446e6d026 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PrivateEndpointConnectionsOperationsExtensions.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PrivateEndpointConnectionsOperationsExtensions.cs @@ -25,7 +25,8 @@ public static partial class PrivateEndpointConnectionsOperationsExtensions /// Get a specific private endpoint connection. /// /// - /// Get a specific private endpoint connection under a topic or domain. + /// Get a specific private endpoint connection under a topic, domain, or + /// partner namespace. /// /// /// The operations group for this extension method. @@ -34,12 +35,13 @@ public static partial class PrivateEndpointConnectionsOperationsExtensions /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. Possible values include: 'topics', 'domains' + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. Possible values include: 'topics', + /// 'domains', 'partnerNamespaces' /// /// - /// The name of the parent resource (namely, either, the topic name or domain - /// name). + /// The name of the parent resource (namely, either, the topic name, domain + /// name, or partner namespace name). /// /// /// The name of the private endpoint connection connection. @@ -53,7 +55,8 @@ public static PrivateEndpointConnection Get(this IPrivateEndpointConnectionsOper /// Get a specific private endpoint connection. /// /// - /// Get a specific private endpoint connection under a topic or domain. + /// Get a specific private endpoint connection under a topic, domain, or + /// partner namespace. /// /// /// The operations group for this extension method. @@ -62,12 +65,13 @@ public static PrivateEndpointConnection Get(this IPrivateEndpointConnectionsOper /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. Possible values include: 'topics', 'domains' + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. Possible values include: 'topics', + /// 'domains', 'partnerNamespaces' /// /// - /// The name of the parent resource (namely, either, the topic name or domain - /// name). + /// The name of the parent resource (namely, either, the topic name, domain + /// name, or partner namespace name). /// /// /// The name of the private endpoint connection connection. @@ -87,7 +91,8 @@ public static PrivateEndpointConnection Get(this IPrivateEndpointConnectionsOper /// Update a specific private endpoint connection. /// /// - /// Update a specific private endpoint connection under a topic or domain. + /// Update a specific private endpoint connection under a topic, domain or + /// partner namespace. /// /// /// The operations group for this extension method. @@ -96,12 +101,13 @@ public static PrivateEndpointConnection Get(this IPrivateEndpointConnectionsOper /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. Possible values include: 'topics', 'domains' + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. Possible values include: 'topics', + /// 'domains', 'partnerNamespaces' /// /// - /// The name of the parent resource (namely, either, the topic name or domain - /// name). + /// The name of the parent resource (namely, either, the topic name, domain + /// name, or partner namespace name). /// /// /// The name of the private endpoint connection connection. @@ -118,7 +124,8 @@ public static PrivateEndpointConnection Update(this IPrivateEndpointConnectionsO /// Update a specific private endpoint connection. /// /// - /// Update a specific private endpoint connection under a topic or domain. + /// Update a specific private endpoint connection under a topic, domain or + /// partner namespace. /// /// /// The operations group for this extension method. @@ -127,12 +134,13 @@ public static PrivateEndpointConnection Update(this IPrivateEndpointConnectionsO /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. Possible values include: 'topics', 'domains' + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. Possible values include: 'topics', + /// 'domains', 'partnerNamespaces' /// /// - /// The name of the parent resource (namely, either, the topic name or domain - /// name). + /// The name of the parent resource (namely, either, the topic name, domain + /// name, or partner namespace name). /// /// /// The name of the private endpoint connection connection. @@ -155,7 +163,8 @@ public static PrivateEndpointConnection Update(this IPrivateEndpointConnectionsO /// Delete a specific private endpoint connection. /// /// - /// Delete a specific private endpoint connection under a topic or domain. + /// Delete a specific private endpoint connection under a topic, domain, or + /// partner namespace. /// /// /// The operations group for this extension method. @@ -164,12 +173,13 @@ public static PrivateEndpointConnection Update(this IPrivateEndpointConnectionsO /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. Possible values include: 'topics', 'domains' + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. Possible values include: 'topics', + /// 'domains', 'partnerNamespaces' /// /// - /// The name of the parent resource (namely, either, the topic name or domain - /// name). + /// The name of the parent resource (namely, either, the topic name, domain + /// name, or partner namespace name). /// /// /// The name of the private endpoint connection connection. @@ -183,7 +193,8 @@ public static void Delete(this IPrivateEndpointConnectionsOperations operations, /// Delete a specific private endpoint connection. /// /// - /// Delete a specific private endpoint connection under a topic or domain. + /// Delete a specific private endpoint connection under a topic, domain, or + /// partner namespace. /// /// /// The operations group for this extension method. @@ -192,12 +203,13 @@ public static void Delete(this IPrivateEndpointConnectionsOperations operations, /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. Possible values include: 'topics', 'domains' + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. Possible values include: 'topics', + /// 'domains', 'partnerNamespaces' /// /// - /// The name of the parent resource (namely, either, the topic name or domain - /// name). + /// The name of the parent resource (namely, either, the topic name, domain + /// name, or partner namespace name). /// /// /// The name of the private endpoint connection connection. @@ -214,7 +226,8 @@ public static void Delete(this IPrivateEndpointConnectionsOperations operations, /// Lists all private endpoint connections under a resource. /// /// - /// Get all private endpoint connections under a topic or domain. + /// Get all private endpoint connections under a topic, domain, or partner + /// namespace. /// /// /// The operations group for this extension method. @@ -223,12 +236,13 @@ public static void Delete(this IPrivateEndpointConnectionsOperations operations, /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. Possible values include: 'topics', 'domains' + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. Possible values include: 'topics', + /// 'domains', 'partnerNamespaces' /// /// - /// The name of the parent resource (namely, either, the topic name or domain - /// name). + /// The name of the parent resource (namely, either, the topic name, domain + /// name, or partner namespace name). /// /// /// The query used to filter the search results using OData syntax. Filtering @@ -253,7 +267,8 @@ public static void Delete(this IPrivateEndpointConnectionsOperations operations, /// Lists all private endpoint connections under a resource. /// /// - /// Get all private endpoint connections under a topic or domain. + /// Get all private endpoint connections under a topic, domain, or partner + /// namespace. /// /// /// The operations group for this extension method. @@ -262,12 +277,13 @@ public static void Delete(this IPrivateEndpointConnectionsOperations operations, /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. Possible values include: 'topics', 'domains' + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. Possible values include: 'topics', + /// 'domains', 'partnerNamespaces' /// /// - /// The name of the parent resource (namely, either, the topic name or domain - /// name). + /// The name of the parent resource (namely, either, the topic name, domain + /// name, or partner namespace name). /// /// /// The query used to filter the search results using OData syntax. Filtering @@ -298,7 +314,8 @@ public static void Delete(this IPrivateEndpointConnectionsOperations operations, /// Update a specific private endpoint connection. /// /// - /// Update a specific private endpoint connection under a topic or domain. + /// Update a specific private endpoint connection under a topic, domain or + /// partner namespace. /// /// /// The operations group for this extension method. @@ -307,12 +324,13 @@ public static void Delete(this IPrivateEndpointConnectionsOperations operations, /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. Possible values include: 'topics', 'domains' + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. Possible values include: 'topics', + /// 'domains', 'partnerNamespaces' /// /// - /// The name of the parent resource (namely, either, the topic name or domain - /// name). + /// The name of the parent resource (namely, either, the topic name, domain + /// name, or partner namespace name). /// /// /// The name of the private endpoint connection connection. @@ -329,7 +347,8 @@ public static PrivateEndpointConnection BeginUpdate(this IPrivateEndpointConnect /// Update a specific private endpoint connection. /// /// - /// Update a specific private endpoint connection under a topic or domain. + /// Update a specific private endpoint connection under a topic, domain or + /// partner namespace. /// /// /// The operations group for this extension method. @@ -338,12 +357,13 @@ public static PrivateEndpointConnection BeginUpdate(this IPrivateEndpointConnect /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. Possible values include: 'topics', 'domains' + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. Possible values include: 'topics', + /// 'domains', 'partnerNamespaces' /// /// - /// The name of the parent resource (namely, either, the topic name or domain - /// name). + /// The name of the parent resource (namely, either, the topic name, domain + /// name, or partner namespace name). /// /// /// The name of the private endpoint connection connection. @@ -366,7 +386,8 @@ public static PrivateEndpointConnection BeginUpdate(this IPrivateEndpointConnect /// Delete a specific private endpoint connection. /// /// - /// Delete a specific private endpoint connection under a topic or domain. + /// Delete a specific private endpoint connection under a topic, domain, or + /// partner namespace. /// /// /// The operations group for this extension method. @@ -375,12 +396,13 @@ public static PrivateEndpointConnection BeginUpdate(this IPrivateEndpointConnect /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. Possible values include: 'topics', 'domains' + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. Possible values include: 'topics', + /// 'domains', 'partnerNamespaces' /// /// - /// The name of the parent resource (namely, either, the topic name or domain - /// name). + /// The name of the parent resource (namely, either, the topic name, domain + /// name, or partner namespace name). /// /// /// The name of the private endpoint connection connection. @@ -394,7 +416,8 @@ public static void BeginDelete(this IPrivateEndpointConnectionsOperations operat /// Delete a specific private endpoint connection. /// /// - /// Delete a specific private endpoint connection under a topic or domain. + /// Delete a specific private endpoint connection under a topic, domain, or + /// partner namespace. /// /// /// The operations group for this extension method. @@ -403,12 +426,13 @@ public static void BeginDelete(this IPrivateEndpointConnectionsOperations operat /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. Possible values include: 'topics', 'domains' + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. Possible values include: 'topics', + /// 'domains', 'partnerNamespaces' /// /// - /// The name of the parent resource (namely, either, the topic name or domain - /// name). + /// The name of the parent resource (namely, either, the topic name, domain + /// name, or partner namespace name). /// /// /// The name of the private endpoint connection connection. @@ -425,7 +449,8 @@ public static void BeginDelete(this IPrivateEndpointConnectionsOperations operat /// Lists all private endpoint connections under a resource. /// /// - /// Get all private endpoint connections under a topic or domain. + /// Get all private endpoint connections under a topic, domain, or partner + /// namespace. /// /// /// The operations group for this extension method. @@ -442,7 +467,8 @@ public static IPage ListByResourceNext(this IPrivateE /// Lists all private endpoint connections under a resource. /// /// - /// Get all private endpoint connections under a topic or domain. + /// Get all private endpoint connections under a topic, domain, or partner + /// namespace. /// /// /// The operations group for this extension method. diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PrivateLinkResourcesOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PrivateLinkResourcesOperations.cs index 880aa91fd5ff3..f1dbcf71ab6fb 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PrivateLinkResourcesOperations.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PrivateLinkResourcesOperations.cs @@ -60,12 +60,12 @@ internal PrivateLinkResourcesOperations(EventGridManagementClient client) /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. /// /// - /// The name of the parent resource (namely, either, the topic name or domain - /// name). + /// The name of the parent resource (namely, either, the topic name, domain + /// name, or partner namespace name). /// /// /// The name of private link resource. @@ -270,21 +270,23 @@ internal PrivateLinkResourcesOperations(EventGridManagementClient client) } /// - /// List private link resources under specific topic or domain. + /// List private link resources under specific topic, domain, or partner + /// namespace. /// /// - /// List all the private link resources under a topic or domain. + /// List all the private link resources under a topic, domain, or partner + /// namespace. /// /// /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. /// /// - /// The name of the parent resource (namely, either, the topic name or domain - /// name). + /// The name of the parent resource (namely, either, the topic name, domain + /// name, or partner namespace name). /// /// /// The query used to filter the search results using OData syntax. Filtering @@ -504,10 +506,12 @@ internal PrivateLinkResourcesOperations(EventGridManagementClient client) } /// - /// List private link resources under specific topic or domain. + /// List private link resources under specific topic, domain, or partner + /// namespace. /// /// - /// List all the private link resources under a topic or domain. + /// List all the private link resources under a topic, domain, or partner + /// namespace. /// /// /// The NextLink from the previous successful call to List operation. diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PrivateLinkResourcesOperationsExtensions.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PrivateLinkResourcesOperationsExtensions.cs index b5cc7825cb1e0..c20ae9d788630 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PrivateLinkResourcesOperationsExtensions.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/PrivateLinkResourcesOperationsExtensions.cs @@ -34,12 +34,12 @@ public static partial class PrivateLinkResourcesOperationsExtensions /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. /// /// - /// The name of the parent resource (namely, either, the topic name or domain - /// name). + /// The name of the parent resource (namely, either, the topic name, domain + /// name, or partner namespace name). /// /// /// The name of private link resource. @@ -62,12 +62,12 @@ public static PrivateLinkResource Get(this IPrivateLinkResourcesOperations opera /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. /// /// - /// The name of the parent resource (namely, either, the topic name or domain - /// name). + /// The name of the parent resource (namely, either, the topic name, domain + /// name, or partner namespace name). /// /// /// The name of private link resource. @@ -84,10 +84,12 @@ public static PrivateLinkResource Get(this IPrivateLinkResourcesOperations opera } /// - /// List private link resources under specific topic or domain. + /// List private link resources under specific topic, domain, or partner + /// namespace. /// /// - /// List all the private link resources under a topic or domain. + /// List all the private link resources under a topic, domain, or partner + /// namespace. /// /// /// The operations group for this extension method. @@ -96,12 +98,12 @@ public static PrivateLinkResource Get(this IPrivateLinkResourcesOperations opera /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. /// /// - /// The name of the parent resource (namely, either, the topic name or domain - /// name). + /// The name of the parent resource (namely, either, the topic name, domain + /// name, or partner namespace name). /// /// /// The query used to filter the search results using OData syntax. Filtering @@ -123,10 +125,12 @@ public static PrivateLinkResource Get(this IPrivateLinkResourcesOperations opera } /// - /// List private link resources under specific topic or domain. + /// List private link resources under specific topic, domain, or partner + /// namespace. /// /// - /// List all the private link resources under a topic or domain. + /// List all the private link resources under a topic, domain, or partner + /// namespace. /// /// /// The operations group for this extension method. @@ -135,12 +139,12 @@ public static PrivateLinkResource Get(this IPrivateLinkResourcesOperations opera /// The name of the resource group within the user's subscription. /// /// - /// The type of the parent resource. This can be either \'topics\' or - /// \'domains\'. + /// The type of the parent resource. This can be either \'topics\', + /// \'domains\', or \'partnerNamespaces\'. /// /// - /// The name of the parent resource (namely, either, the topic name or domain - /// name). + /// The name of the parent resource (namely, either, the topic name, domain + /// name, or partner namespace name). /// /// /// The query used to filter the search results using OData syntax. Filtering @@ -168,10 +172,12 @@ public static PrivateLinkResource Get(this IPrivateLinkResourcesOperations opera } /// - /// List private link resources under specific topic or domain. + /// List private link resources under specific topic, domain, or partner + /// namespace. /// /// - /// List all the private link resources under a topic or domain. + /// List all the private link resources under a topic, domain, or partner + /// namespace. /// /// /// The operations group for this extension method. @@ -185,10 +191,12 @@ public static IPage ListByResourceNext(this IPrivateLinkRes } /// - /// List private link resources under specific topic or domain. + /// List private link resources under specific topic, domain, or partner + /// namespace. /// /// - /// List all the private link resources under a topic or domain. + /// List all the private link resources under a topic, domain, or partner + /// namespace. /// /// /// The operations group for this extension method. 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 557f81a2d8a72..a6cd11f652609 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,30 +19,31 @@ public static IEnumerable> ApiInfo_EventGridManage { return new Tuple[] { - new Tuple("EventGrid", "DomainTopics", "2021-12-01"), - new Tuple("EventGrid", "Domains", "2021-12-01"), - new Tuple("EventGrid", "EventSubscriptions", "2021-12-01"), - new Tuple("EventGrid", "ExtensionTopics", "2021-12-01"), - new Tuple("EventGrid", "Operations", "2021-12-01"), - new Tuple("EventGrid", "PrivateEndpointConnections", "2021-12-01"), - new Tuple("EventGrid", "PrivateLinkResources", "2021-12-01"), - new Tuple("EventGrid", "SystemTopicEventSubscriptions", "2021-12-01"), - new Tuple("EventGrid", "SystemTopics", "2021-12-01"), - new Tuple("EventGrid", "TopicTypes", "2021-12-01"), - new Tuple("EventGrid", "Topics", "2021-12-01"), + new Tuple("EventGrid", "Channels", "2021-10-15-preview"), + new Tuple("EventGrid", "DomainEventSubscriptions", "2021-10-15-preview"), + new Tuple("EventGrid", "DomainTopicEventSubscriptions", "2021-10-15-preview"), + new Tuple("EventGrid", "DomainTopics", "2021-10-15-preview"), + new Tuple("EventGrid", "Domains", "2021-10-15-preview"), + new Tuple("EventGrid", "EventChannels", "2021-10-15-preview"), + new Tuple("EventGrid", "EventSubscriptions", "2021-10-15-preview"), + new Tuple("EventGrid", "ExtensionTopics", "2021-10-15-preview"), + new Tuple("EventGrid", "Operations", "2021-10-15-preview"), + new Tuple("EventGrid", "PartnerConfigurations", "2021-10-15-preview"), + new Tuple("EventGrid", "PartnerDestinations", "2021-10-15-preview"), + new Tuple("EventGrid", "PartnerNamespaces", "2021-10-15-preview"), + new Tuple("EventGrid", "PartnerRegistrations", "2021-10-15-preview"), + new Tuple("EventGrid", "PartnerTopicEventSubscriptions", "2021-10-15-preview"), + new Tuple("EventGrid", "PartnerTopics", "2021-10-15-preview"), + new Tuple("EventGrid", "PrivateEndpointConnections", "2021-10-15-preview"), + new Tuple("EventGrid", "PrivateLinkResources", "2021-10-15-preview"), + new Tuple("EventGrid", "SystemTopicEventSubscriptions", "2021-10-15-preview"), + new Tuple("EventGrid", "SystemTopics", "2021-10-15-preview"), + new Tuple("EventGrid", "TopicEventSubscriptions", "2021-10-15-preview"), + new Tuple("EventGrid", "TopicTypes", "2021-10-15-preview"), + new Tuple("EventGrid", "Topics", "2021-10-15-preview"), + new Tuple("EventGrid", "VerifiedPartners", "2021-10-15-preview"), }.AsEnumerable(); } } - // BEGIN: Code Generation Metadata Section - public static readonly String AutoRestVersion = "v2"; - public static readonly String AutoRestBootStrapperVersion = "autorest@3.4.1"; - public static readonly String AutoRestCmdExecuted = "cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/main/specification/eventgrid/resource-manager/readme.md --csharp --version=v2 --reflect-api-versions --csharp-sdks-folder=D:\\repos\\public_sdk\\azure-sdk-for-net\\sdk"; - public static readonly String GithubForkName = "Azure"; - public static readonly String GithubBranchName = "main"; - public static readonly String GithubCommidId = "84c09261f588a7ad29cfb4b46ad7f038f7254275"; - 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 index e0189270e1c0b..5a8d01a569035 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/SystemTopicEventSubscriptionsOperations.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/SystemTopicEventSubscriptionsOperations.cs @@ -299,7 +299,7 @@ internal SystemTopicEventSubscriptionsOperations(EventGridManagementClient clien /// Delete an event subscription of a system topic. /// /// - /// Delete an event subscription of a system topic. + /// Delete an existing event subscription of a system topic. /// /// /// The name of the resource group within the user's subscription. @@ -329,7 +329,7 @@ internal SystemTopicEventSubscriptionsOperations(EventGridManagementClient clien /// Update event subscription of a system topic. /// /// - /// Update event subscription of a system topic. + /// Update an existing event subscription of a system topic. /// /// /// The name of the resource group within the user's subscription. @@ -1231,7 +1231,7 @@ internal SystemTopicEventSubscriptionsOperations(EventGridManagementClient clien /// Delete an event subscription of a system topic. /// /// - /// Delete an event subscription of a system topic. + /// Delete an existing event subscription of a system topic. /// /// /// The name of the resource group within the user's subscription. @@ -1420,7 +1420,7 @@ internal SystemTopicEventSubscriptionsOperations(EventGridManagementClient clien /// Update event subscription of a system topic. /// /// - /// Update event subscription of a system topic. + /// Update an existing event subscription of a system topic. /// /// /// The name of the resource group within the user's subscription. diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/SystemTopicEventSubscriptionsOperationsExtensions.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/SystemTopicEventSubscriptionsOperationsExtensions.cs index e0cd40093816a..54e6593f8874c 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/SystemTopicEventSubscriptionsOperationsExtensions.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/SystemTopicEventSubscriptionsOperationsExtensions.cs @@ -147,7 +147,7 @@ public static EventSubscription CreateOrUpdate(this ISystemTopicEventSubscriptio /// Delete an event subscription of a system topic. /// /// - /// Delete an event subscription of a system topic. + /// Delete an existing event subscription of a system topic. /// /// /// The operations group for this extension method. @@ -172,7 +172,7 @@ public static void Delete(this ISystemTopicEventSubscriptionsOperations operatio /// Delete an event subscription of a system topic. /// /// - /// Delete an event subscription of a system topic. + /// Delete an existing event subscription of a system topic. /// /// /// The operations group for this extension method. @@ -200,7 +200,7 @@ public static void Delete(this ISystemTopicEventSubscriptionsOperations operatio /// Update event subscription of a system topic. /// /// - /// Update event subscription of a system topic. + /// Update an existing event subscription of a system topic. /// /// /// The operations group for this extension method. @@ -228,7 +228,7 @@ public static EventSubscription Update(this ISystemTopicEventSubscriptionsOperat /// Update event subscription of a system topic. /// /// - /// Update event subscription of a system topic. + /// Update an existing event subscription of a system topic. /// /// /// The operations group for this extension method. @@ -514,7 +514,7 @@ public static EventSubscription BeginCreateOrUpdate(this ISystemTopicEventSubscr /// Delete an event subscription of a system topic. /// /// - /// Delete an event subscription of a system topic. + /// Delete an existing event subscription of a system topic. /// /// /// The operations group for this extension method. @@ -539,7 +539,7 @@ public static void BeginDelete(this ISystemTopicEventSubscriptionsOperations ope /// Delete an event subscription of a system topic. /// /// - /// Delete an event subscription of a system topic. + /// Delete an existing event subscription of a system topic. /// /// /// The operations group for this extension method. @@ -567,7 +567,7 @@ public static void BeginDelete(this ISystemTopicEventSubscriptionsOperations ope /// Update event subscription of a system topic. /// /// - /// Update event subscription of a system topic. + /// Update an existing event subscription of a system topic. /// /// /// The operations group for this extension method. @@ -595,7 +595,7 @@ public static EventSubscription BeginUpdate(this ISystemTopicEventSubscriptionsO /// Update event subscription of a system topic. /// /// - /// Update event subscription of a system topic. + /// Update an existing event subscription of a system topic. /// /// /// The operations group for this extension method. diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/TopicEventSubscriptionsOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/TopicEventSubscriptionsOperations.cs new file mode 100644 index 0000000000000..75623377112c3 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/TopicEventSubscriptionsOperations.cs @@ -0,0 +1,1630 @@ +// +// 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; + + /// + /// TopicEventSubscriptionsOperations operations. + /// + internal partial class TopicEventSubscriptionsOperations : IServiceOperations, ITopicEventSubscriptionsOperations + { + /// + /// Initializes a new instance of the TopicEventSubscriptionsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal TopicEventSubscriptionsOperations(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 topic. + /// + /// + /// Get properties of an event subscription of a 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 topicName, 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 (topicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "topicName"); + } + 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("topicName", topicName); + 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/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}").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("{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 to a topic. + /// + /// + /// Asynchronously creates a new event subscription or updates an existing + /// event subscription. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain 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 topicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, topicName, eventSubscriptionName, eventSubscriptionInfo, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Delete an event subscription for a topic. + /// + /// + /// Delete an existing event subscription for a topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the topic. + /// + /// + /// Name of the event subscription to be deleted. 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 topicName, string eventSubscriptionName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, topicName, eventSubscriptionName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Update an event subscription for a topic. + /// + /// + /// Update an existing event subscription for a topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the event subscription to be updated. + /// + /// + /// Updated event subscription information. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> UpdateWithHttpMessagesAsync(string resourceGroupName, string topicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginUpdateWithHttpMessagesAsync(resourceGroupName, topicName, eventSubscriptionName, eventSubscriptionUpdateParameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get full URL of an event subscription for topic. + /// + /// + /// Get the full endpoint URL for an event subscription for topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain 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> GetFullUrlWithHttpMessagesAsync(string resourceGroupName, string topicName, 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 (topicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "topicName"); + } + 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("topicName", topicName); + 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/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl").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("{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 all event subscriptions for a specific topic. + /// + /// + /// List all event subscriptions that have been created for a specific topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the 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>> ListWithHttpMessagesAsync(string resourceGroupName, string topicName, 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 (topicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "topicName"); + } + 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("topicName", topicName); + 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("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions").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)); + 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; + } + + /// + /// Get delivery attributes for an event subscription for topic. + /// + /// + /// Get all delivery attributes for an event subscription for topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain 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 resourceGroupName, string topicName, 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 (topicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "topicName"); + } + 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("topicName", topicName); + 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/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes").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("{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 to a topic. + /// + /// + /// Asynchronously creates a new event subscription or updates an existing + /// event subscription. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain 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 topicName, 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 (topicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "topicName"); + } + 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("topicName", topicName); + 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/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}").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("{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 != 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 an event subscription for a topic. + /// + /// + /// Delete an existing event subscription for a topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the topic. + /// + /// + /// Name of the event subscription to be deleted. 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 topicName, 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 (topicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "topicName"); + } + 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("topicName", topicName); + 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/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}").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("{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 an event subscription for a topic. + /// + /// + /// Update an existing event subscription for a topic. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the event subscription to be updated. + /// + /// + /// 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 topicName, 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 (topicName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "topicName"); + } + 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("topicName", topicName); + 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/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}").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("{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; + } + + } +} diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/TopicEventSubscriptionsOperationsExtensions.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/TopicEventSubscriptionsOperationsExtensions.cs new file mode 100644 index 0000000000000..e77845c49f694 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/TopicEventSubscriptionsOperationsExtensions.cs @@ -0,0 +1,587 @@ +// +// 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 TopicEventSubscriptionsOperations. + /// + public static partial class TopicEventSubscriptionsOperationsExtensions + { + /// + /// Get an event subscription of a topic. + /// + /// + /// Get properties of an event subscription of a 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 ITopicEventSubscriptionsOperations operations, string resourceGroupName, string topicName, string eventSubscriptionName) + { + return operations.GetAsync(resourceGroupName, topicName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Get an event subscription of a topic. + /// + /// + /// Get properties of an event subscription of a 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 ITopicEventSubscriptionsOperations operations, string resourceGroupName, string topicName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, topicName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an event subscription to a topic. + /// + /// + /// Asynchronously creates a new event subscription or updates an existing + /// event subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain 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 ITopicEventSubscriptionsOperations operations, string resourceGroupName, string topicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo) + { + return operations.CreateOrUpdateAsync(resourceGroupName, topicName, eventSubscriptionName, eventSubscriptionInfo).GetAwaiter().GetResult(); + } + + /// + /// Create or update an event subscription to a topic. + /// + /// + /// Asynchronously creates a new event subscription or updates an existing + /// event subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain 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 ITopicEventSubscriptionsOperations operations, string resourceGroupName, string topicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, topicName, eventSubscriptionName, eventSubscriptionInfo, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete an event subscription for a topic. + /// + /// + /// Delete an existing event subscription 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. + /// + /// + /// Name of the event subscription to be deleted. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + public static void Delete(this ITopicEventSubscriptionsOperations operations, string resourceGroupName, string topicName, string eventSubscriptionName) + { + operations.DeleteAsync(resourceGroupName, topicName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Delete an event subscription for a topic. + /// + /// + /// Delete an existing event subscription 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. + /// + /// + /// Name of the event subscription to be deleted. 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 ITopicEventSubscriptionsOperations operations, string resourceGroupName, string topicName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, topicName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update an event subscription for a topic. + /// + /// + /// Update an existing event subscription for a topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the event subscription to be updated. + /// + /// + /// Updated event subscription information. + /// + public static EventSubscription Update(this ITopicEventSubscriptionsOperations operations, string resourceGroupName, string topicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters) + { + return operations.UpdateAsync(resourceGroupName, topicName, eventSubscriptionName, eventSubscriptionUpdateParameters).GetAwaiter().GetResult(); + } + + /// + /// Update an event subscription for a topic. + /// + /// + /// Update an existing event subscription for a topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the event subscription to be updated. + /// + /// + /// Updated event subscription information. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this ITopicEventSubscriptionsOperations operations, string resourceGroupName, string topicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, topicName, eventSubscriptionName, eventSubscriptionUpdateParameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get full URL of an event subscription for topic. + /// + /// + /// Get the full endpoint URL for an event subscription for topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain topic. + /// + /// + /// Name of the event subscription. + /// + public static EventSubscriptionFullUrl GetFullUrl(this ITopicEventSubscriptionsOperations operations, string resourceGroupName, string topicName, string eventSubscriptionName) + { + return operations.GetFullUrlAsync(resourceGroupName, topicName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Get full URL of an event subscription for topic. + /// + /// + /// Get the full endpoint URL for an event subscription for topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain topic. + /// + /// + /// Name of the event subscription. + /// + /// + /// The cancellation token. + /// + public static async Task GetFullUrlAsync(this ITopicEventSubscriptionsOperations operations, string resourceGroupName, string topicName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetFullUrlWithHttpMessagesAsync(resourceGroupName, topicName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all event subscriptions for a specific topic. + /// + /// + /// List all event subscriptions that have been created for a specific topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the topic. + /// + public static IEnumerable List(this ITopicEventSubscriptionsOperations operations, string resourceGroupName, string topicName) + { + return operations.ListAsync(resourceGroupName, topicName).GetAwaiter().GetResult(); + } + + /// + /// List all event subscriptions for a specific topic. + /// + /// + /// List all event subscriptions that have been created for a specific topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the topic. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this ITopicEventSubscriptionsOperations operations, string resourceGroupName, string topicName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, topicName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get delivery attributes for an event subscription for topic. + /// + /// + /// Get all delivery attributes for an event subscription for topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain topic. + /// + /// + /// Name of the event subscription. + /// + public static DeliveryAttributeListResult GetDeliveryAttributes(this ITopicEventSubscriptionsOperations operations, string resourceGroupName, string topicName, string eventSubscriptionName) + { + return operations.GetDeliveryAttributesAsync(resourceGroupName, topicName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Get delivery attributes for an event subscription for topic. + /// + /// + /// Get all delivery attributes for an event subscription for topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain topic. + /// + /// + /// Name of the event subscription. + /// + /// + /// The cancellation token. + /// + public static async Task GetDeliveryAttributesAsync(this ITopicEventSubscriptionsOperations operations, string resourceGroupName, string topicName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetDeliveryAttributesWithHttpMessagesAsync(resourceGroupName, topicName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update an event subscription to a topic. + /// + /// + /// Asynchronously creates a new event subscription or updates an existing + /// event subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain 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 ITopicEventSubscriptionsOperations operations, string resourceGroupName, string topicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, topicName, eventSubscriptionName, eventSubscriptionInfo).GetAwaiter().GetResult(); + } + + /// + /// Create or update an event subscription to a topic. + /// + /// + /// Asynchronously creates a new event subscription or updates an existing + /// event subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain 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 ITopicEventSubscriptionsOperations operations, string resourceGroupName, string topicName, string eventSubscriptionName, EventSubscription eventSubscriptionInfo, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, topicName, eventSubscriptionName, eventSubscriptionInfo, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete an event subscription for a topic. + /// + /// + /// Delete an existing event subscription 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. + /// + /// + /// Name of the event subscription to be deleted. Event subscription names must + /// be between 3 and 100 characters in length and use alphanumeric letters + /// only. + /// + public static void BeginDelete(this ITopicEventSubscriptionsOperations operations, string resourceGroupName, string topicName, string eventSubscriptionName) + { + operations.BeginDeleteAsync(resourceGroupName, topicName, eventSubscriptionName).GetAwaiter().GetResult(); + } + + /// + /// Delete an event subscription for a topic. + /// + /// + /// Delete an existing event subscription 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. + /// + /// + /// Name of the event subscription to be deleted. 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 ITopicEventSubscriptionsOperations operations, string resourceGroupName, string topicName, string eventSubscriptionName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, topicName, eventSubscriptionName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Update an event subscription for a topic. + /// + /// + /// Update an existing event subscription for a topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the event subscription to be updated. + /// + /// + /// Updated event subscription information. + /// + public static EventSubscription BeginUpdate(this ITopicEventSubscriptionsOperations operations, string resourceGroupName, string topicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters) + { + return operations.BeginUpdateAsync(resourceGroupName, topicName, eventSubscriptionName, eventSubscriptionUpdateParameters).GetAwaiter().GetResult(); + } + + /// + /// Update an event subscription for a topic. + /// + /// + /// Update an existing event subscription for a topic. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group within the user's subscription. + /// + /// + /// Name of the domain. + /// + /// + /// Name of the event subscription to be updated. + /// + /// + /// Updated event subscription information. + /// + /// + /// The cancellation token. + /// + public static async Task BeginUpdateAsync(this ITopicEventSubscriptionsOperations operations, string resourceGroupName, string topicName, string eventSubscriptionName, EventSubscriptionUpdateParameters eventSubscriptionUpdateParameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, topicName, eventSubscriptionName, eventSubscriptionUpdateParameters, 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 e6b9178720310..6c5757f820f06 100644 --- a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/TopicsOperations.cs +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/TopicsOperations.cs @@ -1952,7 +1952,7 @@ internal TopicsOperations(EventGridManagementClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 200) + if ((int)_statusCode != 200 && (int)_statusCode != 202) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try diff --git a/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/VerifiedPartnersOperations.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/VerifiedPartnersOperations.cs new file mode 100644 index 0000000000000..3e87de872f057 --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/VerifiedPartnersOperations.cs @@ -0,0 +1,615 @@ +// +// 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; + + /// + /// VerifiedPartnersOperations operations. + /// + internal partial class VerifiedPartnersOperations : IServiceOperations, IVerifiedPartnersOperations + { + /// + /// Initializes a new instance of the VerifiedPartnersOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal VerifiedPartnersOperations(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 verified partner. + /// + /// + /// Get properties of a verified partner. + /// + /// + /// Name of the verified partner. + /// + /// + /// 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 verifiedPartnerName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (verifiedPartnerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "verifiedPartnerName"); + } + 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("verifiedPartnerName", verifiedPartnerName); + 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("/") ? "" : "/")), "providers/Microsoft.EventGrid/verifiedPartners/{verifiedPartnerName}").ToString(); + _url = _url.Replace("{verifiedPartnerName}", System.Uri.EscapeDataString(verifiedPartnerName)); + 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 all verified partners. + /// + /// + /// Get a list of all verified partners. + /// + /// + /// 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>> ListWithHttpMessagesAsync(string filter = default(string), int? top = default(int?), 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("filter", filter); + tracingParameters.Add("top", top); + 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/verifiedPartners").ToString(); + 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 verified partners. + /// + /// + /// Get a list of all verified partners. + /// + /// + /// 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>> ListNextWithHttpMessagesAsync(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, "ListNext", 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/VerifiedPartnersOperationsExtensions.cs b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/VerifiedPartnersOperationsExtensions.cs new file mode 100644 index 0000000000000..f4b40f7557dde --- /dev/null +++ b/sdk/eventgrid/Microsoft.Azure.Management.EventGrid/src/Generated/VerifiedPartnersOperationsExtensions.cs @@ -0,0 +1,167 @@ +// +// 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 VerifiedPartnersOperations. + /// + public static partial class VerifiedPartnersOperationsExtensions + { + /// + /// Get a verified partner. + /// + /// + /// Get properties of a verified partner. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the verified partner. + /// + public static VerifiedPartner Get(this IVerifiedPartnersOperations operations, string verifiedPartnerName) + { + return operations.GetAsync(verifiedPartnerName).GetAwaiter().GetResult(); + } + + /// + /// Get a verified partner. + /// + /// + /// Get properties of a verified partner. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Name of the verified partner. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IVerifiedPartnersOperations operations, string verifiedPartnerName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(verifiedPartnerName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all verified partners. + /// + /// + /// Get a list of all verified partners. + /// + /// + /// 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 List(this IVerifiedPartnersOperations operations, string filter = default(string), int? top = default(int?)) + { + return operations.ListAsync(filter, top).GetAwaiter().GetResult(); + } + + /// + /// List all verified partners. + /// + /// + /// Get a list of all verified partners. + /// + /// + /// 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> ListAsync(this IVerifiedPartnersOperations operations, string filter = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(filter, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all verified partners. + /// + /// + /// Get a list of all verified partners. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IVerifiedPartnersOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List all verified partners. + /// + /// + /// Get a list of all verified partners. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IVerifiedPartnersOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +}