From f0852a79501eb5c4baa95ebb1dcfa5aaae0b9e77 Mon Sep 17 00:00:00 2001 From: SDK Automation Date: Thu, 7 May 2020 18:15:33 +0000 Subject: [PATCH] Generated from 436daeb838eccf0784ee4298fe86842090e643c8 Fix ErrorResponse data model --- .../src/Generated/IPeeringManagementClient.cs | 5 + .../Generated/IReceivedRoutesOperations.cs | 94 ++++ .../src/Generated/Models/ContactDetail.cs | 5 +- .../src/Generated/Models/ErrorDetail.cs | 59 +++ .../src/Generated/Models/ErrorResponse.cs | 22 +- .../Generated/Models/PeeringReceivedRoute.cs | 105 ++++ .../src/Generated/Models/Role.cs | 1 + .../src/Generated/PeeringManagementClient.cs | 8 +- .../src/Generated/ReceivedRoutesOperations.cs | 457 ++++++++++++++++++ .../ReceivedRoutesOperationsExtensions.cs | 137 ++++++ .../SdkInfo_PeeringManagementClient.cs | 27 +- 11 files changed, 890 insertions(+), 30 deletions(-) create mode 100644 sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/IReceivedRoutesOperations.cs create mode 100644 sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/Models/ErrorDetail.cs create mode 100644 sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/Models/PeeringReceivedRoute.cs create mode 100644 sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/ReceivedRoutesOperations.cs create mode 100644 sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/ReceivedRoutesOperationsExtensions.cs diff --git a/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/IPeeringManagementClient.cs b/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/IPeeringManagementClient.cs index 6806b2086259..3173c1e01ce7 100644 --- a/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/IPeeringManagementClient.cs +++ b/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/IPeeringManagementClient.cs @@ -108,6 +108,11 @@ public partial interface IPeeringManagementClient : System.IDisposable /// IPeeringsOperations Peerings { get; } + /// + /// Gets the IReceivedRoutesOperations. + /// + IReceivedRoutesOperations ReceivedRoutes { get; } + /// /// Gets the IPeeringServiceCountriesOperations. /// diff --git a/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/IReceivedRoutesOperations.cs b/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/IReceivedRoutesOperations.cs new file mode 100644 index 000000000000..50db37dd0096 --- /dev/null +++ b/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/IReceivedRoutesOperations.cs @@ -0,0 +1,94 @@ +// +// 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.Peering +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ReceivedRoutesOperations operations. + /// + public partial interface IReceivedRoutesOperations + { + /// + /// Lists the prefixes received over the specified peering under the + /// given subscription and resource group. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the peering. + /// + /// + /// The optional prefix that can be used to filter the routes. + /// + /// + /// The optional AS path that can be used to filter the routes. + /// + /// + /// The optional origin AS validation state that can be used to filter + /// the routes. + /// + /// + /// The optional RPKI validation state that can be used to filter the + /// routes. + /// + /// + /// The optional page continuation token that is used in the event of + /// paginated result. + /// + /// + /// 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>> ListByPeeringWithHttpMessagesAsync(string resourceGroupName, string peeringName, string prefix = default(string), string asPath = default(string), string originAsValidationState = default(string), string rpkiValidationState = default(string), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Lists the prefixes received over the specified peering under the + /// given subscription and 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>> ListByPeeringNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/Models/ContactDetail.cs b/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/Models/ContactDetail.cs index 8a6012947f3c..a447da04339f 100644 --- a/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/Models/ContactDetail.cs +++ b/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/Models/ContactDetail.cs @@ -30,7 +30,8 @@ public ContactDetail() /// Initializes a new instance of the ContactDetail class. /// /// The role of the contact. Possible values - /// include: 'Noc', 'Policy', 'Technical', 'Service', 'Other' + /// include: 'Noc', 'Policy', 'Technical', 'Service', 'Escalation', + /// 'Other' /// The e-mail address of the contact. /// The phone number of the contact. public ContactDetail(string role = default(string), string email = default(string), string phone = default(string)) @@ -48,7 +49,7 @@ public ContactDetail() /// /// Gets or sets the role of the contact. Possible values include: - /// 'Noc', 'Policy', 'Technical', 'Service', 'Other' + /// 'Noc', 'Policy', 'Technical', 'Service', 'Escalation', 'Other' /// [JsonProperty(PropertyName = "role")] public string Role { get; set; } diff --git a/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/Models/ErrorDetail.cs b/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/Models/ErrorDetail.cs new file mode 100644 index 000000000000..7c8959b022f4 --- /dev/null +++ b/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/Models/ErrorDetail.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.Peering.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The error detail that describes why an operation has failed. + /// + public partial class ErrorDetail + { + /// + /// Initializes a new instance of the ErrorDetail class. + /// + public ErrorDetail() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorDetail class. + /// + /// The error code. + /// The error message. + public ErrorDetail(string code = default(string), string message = default(string)) + { + Code = code; + Message = message; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the error code. + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; private set; } + + /// + /// Gets the error message. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; private set; } + + } +} diff --git a/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/Models/ErrorResponse.cs b/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/Models/ErrorResponse.cs index 8754219779a5..9f7587d62b06 100644 --- a/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/Models/ErrorResponse.cs +++ b/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/Models/ErrorResponse.cs @@ -29,12 +29,11 @@ public ErrorResponse() /// /// Initializes a new instance of the ErrorResponse class. /// - /// The error code. - /// The error message. - public ErrorResponse(string code = default(string), string message = default(string)) + /// The error detail that describes why an + /// operation has failed. + public ErrorResponse(ErrorDetail error = default(ErrorDetail)) { - Code = code; - Message = message; + Error = error; CustomInit(); } @@ -44,16 +43,11 @@ public ErrorResponse() partial void CustomInit(); /// - /// Gets the error code. + /// Gets or sets the error detail that describes why an operation has + /// failed. /// - [JsonProperty(PropertyName = "code")] - public string Code { get; private set; } - - /// - /// Gets the error message. - /// - [JsonProperty(PropertyName = "message")] - public string Message { get; private set; } + [JsonProperty(PropertyName = "error")] + public ErrorDetail Error { get; set; } } } diff --git a/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/Models/PeeringReceivedRoute.cs b/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/Models/PeeringReceivedRoute.cs new file mode 100644 index 000000000000..b8a6d368079a --- /dev/null +++ b/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/Models/PeeringReceivedRoute.cs @@ -0,0 +1,105 @@ +// +// 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.Peering.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The properties that define a received route. + /// + public partial class PeeringReceivedRoute + { + /// + /// Initializes a new instance of the PeeringReceivedRoute class. + /// + public PeeringReceivedRoute() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PeeringReceivedRoute class. + /// + /// The prefix. + /// The next hop for the prefix. + /// The AS path for the prefix. + /// The origin AS change + /// information for the prefix. + /// The RPKI validation state for the + /// prefix and origin AS that's listed in the AS path. + /// The authority which holds the Route + /// Origin Authorization record for the prefix, if any. + /// The received timestamp associated + /// with the prefix. + public PeeringReceivedRoute(string prefix = default(string), string nextHop = default(string), string asPath = default(string), string originAsValidationState = default(string), string rpkiValidationState = default(string), string trustAnchor = default(string), string receivedTimestamp = default(string)) + { + Prefix = prefix; + NextHop = nextHop; + AsPath = asPath; + OriginAsValidationState = originAsValidationState; + RpkiValidationState = rpkiValidationState; + TrustAnchor = trustAnchor; + ReceivedTimestamp = receivedTimestamp; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the prefix. + /// + [JsonProperty(PropertyName = "prefix")] + public string Prefix { get; private set; } + + /// + /// Gets the next hop for the prefix. + /// + [JsonProperty(PropertyName = "nextHop")] + public string NextHop { get; private set; } + + /// + /// Gets the AS path for the prefix. + /// + [JsonProperty(PropertyName = "asPath")] + public string AsPath { get; private set; } + + /// + /// Gets the origin AS change information for the prefix. + /// + [JsonProperty(PropertyName = "originAsValidationState")] + public string OriginAsValidationState { get; private set; } + + /// + /// Gets the RPKI validation state for the prefix and origin AS that's + /// listed in the AS path. + /// + [JsonProperty(PropertyName = "rpkiValidationState")] + public string RpkiValidationState { get; private set; } + + /// + /// Gets the authority which holds the Route Origin Authorization + /// record for the prefix, if any. + /// + [JsonProperty(PropertyName = "trustAnchor")] + public string TrustAnchor { get; private set; } + + /// + /// Gets the received timestamp associated with the prefix. + /// + [JsonProperty(PropertyName = "receivedTimestamp")] + public string ReceivedTimestamp { get; private set; } + + } +} diff --git a/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/Models/Role.cs b/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/Models/Role.cs index 848060abffd7..0906c21aefc0 100644 --- a/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/Models/Role.cs +++ b/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/Models/Role.cs @@ -20,6 +20,7 @@ public static class Role public const string Policy = "Policy"; public const string Technical = "Technical"; public const string Service = "Service"; + public const string Escalation = "Escalation"; public const string Other = "Other"; } } diff --git a/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/PeeringManagementClient.cs b/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/PeeringManagementClient.cs index 7e4737c6b86f..10f6b0b6c775 100644 --- a/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/PeeringManagementClient.cs +++ b/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/PeeringManagementClient.cs @@ -111,6 +111,11 @@ public partial class PeeringManagementClient : ServiceClient public virtual IPeeringsOperations Peerings { get; private set; } + /// + /// Gets the IReceivedRoutesOperations. + /// + public virtual IReceivedRoutesOperations ReceivedRoutes { get; private set; } + /// /// Gets the IPeeringServiceCountriesOperations. /// @@ -384,13 +389,14 @@ private void Initialize() RegisteredAsns = new RegisteredAsnsOperations(this); RegisteredPrefixes = new RegisteredPrefixesOperations(this); Peerings = new PeeringsOperations(this); + ReceivedRoutes = new ReceivedRoutesOperations(this); PeeringServiceCountries = new PeeringServiceCountriesOperations(this); PeeringServiceLocations = new PeeringServiceLocationsOperations(this); Prefixes = new PrefixesOperations(this); PeeringServiceProviders = new PeeringServiceProvidersOperations(this); PeeringServices = new PeeringServicesOperations(this); BaseUri = new System.Uri("https://management.azure.com"); - ApiVersion = "2020-01-01-preview"; + ApiVersion = "2020-04-01"; AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; diff --git a/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/ReceivedRoutesOperations.cs b/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/ReceivedRoutesOperations.cs new file mode 100644 index 000000000000..f455bc8fbc60 --- /dev/null +++ b/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/ReceivedRoutesOperations.cs @@ -0,0 +1,457 @@ +// +// 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.Peering +{ + 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; + + /// + /// ReceivedRoutesOperations operations. + /// + internal partial class ReceivedRoutesOperations : IServiceOperations, IReceivedRoutesOperations + { + /// + /// Initializes a new instance of the ReceivedRoutesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ReceivedRoutesOperations(PeeringManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the PeeringManagementClient + /// + public PeeringManagementClient Client { get; private set; } + + /// + /// Lists the prefixes received over the specified peering under the given + /// subscription and resource group. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the peering. + /// + /// + /// The optional prefix that can be used to filter the routes. + /// + /// + /// The optional AS path that can be used to filter the routes. + /// + /// + /// The optional origin AS validation state that can be used to filter the + /// routes. + /// + /// + /// The optional RPKI validation state that can be used to filter the routes. + /// + /// + /// The optional page continuation token that is used in the event of paginated + /// result. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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>> ListByPeeringWithHttpMessagesAsync(string resourceGroupName, string peeringName, string prefix = default(string), string asPath = default(string), string originAsValidationState = default(string), string rpkiValidationState = default(string), string skipToken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (peeringName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "peeringName"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("peeringName", peeringName); + tracingParameters.Add("prefix", prefix); + tracingParameters.Add("asPath", asPath); + tracingParameters.Add("originAsValidationState", originAsValidationState); + tracingParameters.Add("rpkiValidationState", rpkiValidationState); + tracingParameters.Add("skipToken", skipToken); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByPeering", 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.Peering/peerings/{peeringName}/receivedRoutes").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{peeringName}", System.Uri.EscapeDataString(peeringName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (prefix != null) + { + _queryParameters.Add(string.Format("prefix={0}", System.Uri.EscapeDataString(prefix))); + } + if (asPath != null) + { + _queryParameters.Add(string.Format("asPath={0}", System.Uri.EscapeDataString(asPath))); + } + if (originAsValidationState != null) + { + _queryParameters.Add(string.Format("originAsValidationState={0}", System.Uri.EscapeDataString(originAsValidationState))); + } + if (rpkiValidationState != null) + { + _queryParameters.Add(string.Format("rpkiValidationState={0}", System.Uri.EscapeDataString(rpkiValidationState))); + } + if (skipToken != null) + { + _queryParameters.Add(string.Format("$skipToken={0}", System.Uri.EscapeDataString(skipToken))); + } + 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new 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; + } + + /// + /// Lists the prefixes received over the specified peering under the given + /// subscription and 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>> ListByPeeringNextWithHttpMessagesAsync(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, "ListByPeeringNext", 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new 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/peering/Microsoft.Azure.Management.Peering/src/Generated/ReceivedRoutesOperationsExtensions.cs b/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/ReceivedRoutesOperationsExtensions.cs new file mode 100644 index 000000000000..7c835fdcc4ef --- /dev/null +++ b/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/ReceivedRoutesOperationsExtensions.cs @@ -0,0 +1,137 @@ +// +// 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.Peering +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ReceivedRoutesOperations. + /// + public static partial class ReceivedRoutesOperationsExtensions + { + /// + /// Lists the prefixes received over the specified peering under the given + /// subscription and resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the peering. + /// + /// + /// The optional prefix that can be used to filter the routes. + /// + /// + /// The optional AS path that can be used to filter the routes. + /// + /// + /// The optional origin AS validation state that can be used to filter the + /// routes. + /// + /// + /// The optional RPKI validation state that can be used to filter the routes. + /// + /// + /// The optional page continuation token that is used in the event of paginated + /// result. + /// + public static IPage ListByPeering(this IReceivedRoutesOperations operations, string resourceGroupName, string peeringName, string prefix = default(string), string asPath = default(string), string originAsValidationState = default(string), string rpkiValidationState = default(string), string skipToken = default(string)) + { + return operations.ListByPeeringAsync(resourceGroupName, peeringName, prefix, asPath, originAsValidationState, rpkiValidationState, skipToken).GetAwaiter().GetResult(); + } + + /// + /// Lists the prefixes received over the specified peering under the given + /// subscription and resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the peering. + /// + /// + /// The optional prefix that can be used to filter the routes. + /// + /// + /// The optional AS path that can be used to filter the routes. + /// + /// + /// The optional origin AS validation state that can be used to filter the + /// routes. + /// + /// + /// The optional RPKI validation state that can be used to filter the routes. + /// + /// + /// The optional page continuation token that is used in the event of paginated + /// result. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByPeeringAsync(this IReceivedRoutesOperations operations, string resourceGroupName, string peeringName, string prefix = default(string), string asPath = default(string), string originAsValidationState = default(string), string rpkiValidationState = default(string), string skipToken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByPeeringWithHttpMessagesAsync(resourceGroupName, peeringName, prefix, asPath, originAsValidationState, rpkiValidationState, skipToken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Lists the prefixes received over the specified peering under the given + /// subscription and resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByPeeringNext(this IReceivedRoutesOperations operations, string nextPageLink) + { + return operations.ListByPeeringNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists the prefixes received over the specified peering under the given + /// subscription and 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> ListByPeeringNextAsync(this IReceivedRoutesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByPeeringNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/SdkInfo_PeeringManagementClient.cs b/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/SdkInfo_PeeringManagementClient.cs index a5fdbbbf0e5b..1a39846e3cea 100644 --- a/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/SdkInfo_PeeringManagementClient.cs +++ b/sdk/peering/Microsoft.Azure.Management.Peering/src/Generated/SdkInfo_PeeringManagementClient.cs @@ -19,19 +19,20 @@ public static IEnumerable> ApiInfo_PeeringManageme { return new Tuple[] { - new Tuple("Peering", "CheckServiceProviderAvailability", "2020-01-01-preview"), - new Tuple("Peering", "LegacyPeerings", "2020-01-01-preview"), - new Tuple("Peering", "Operations", "2020-01-01-preview"), - new Tuple("Peering", "PeerAsns", "2020-01-01-preview"), - new Tuple("Peering", "PeeringLocations", "2020-01-01-preview"), - new Tuple("Peering", "PeeringServiceCountries", "2020-01-01-preview"), - new Tuple("Peering", "PeeringServiceLocations", "2020-01-01-preview"), - new Tuple("Peering", "PeeringServiceProviders", "2020-01-01-preview"), - new Tuple("Peering", "PeeringServices", "2020-01-01-preview"), - new Tuple("Peering", "Peerings", "2020-01-01-preview"), - new Tuple("Peering", "Prefixes", "2020-01-01-preview"), - new Tuple("Peering", "RegisteredAsns", "2020-01-01-preview"), - new Tuple("Peering", "RegisteredPrefixes", "2020-01-01-preview"), + new Tuple("Peering", "CheckServiceProviderAvailability", "2020-04-01"), + new Tuple("Peering", "LegacyPeerings", "2020-04-01"), + new Tuple("Peering", "Operations", "2020-04-01"), + new Tuple("Peering", "PeerAsns", "2020-04-01"), + new Tuple("Peering", "PeeringLocations", "2020-04-01"), + new Tuple("Peering", "PeeringServiceCountries", "2020-04-01"), + new Tuple("Peering", "PeeringServiceLocations", "2020-04-01"), + new Tuple("Peering", "PeeringServiceProviders", "2020-04-01"), + new Tuple("Peering", "PeeringServices", "2020-04-01"), + new Tuple("Peering", "Peerings", "2020-04-01"), + new Tuple("Peering", "Prefixes", "2020-04-01"), + new Tuple("Peering", "ReceivedRoutes", "2020-04-01"), + new Tuple("Peering", "RegisteredAsns", "2020-04-01"), + new Tuple("Peering", "RegisteredPrefixes", "2020-04-01"), }.AsEnumerable(); } }