From deffc57f4dbe153d5a2060a2cbeafc9d9941046c Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 8 Dec 2021 04:46:31 +0000 Subject: [PATCH] CodeGen from PR 16973 in Azure/azure-rest-api-specs Merge 1ce8948d9a38b427668a1a82031d35b5ae2aca8c into d90729bbada2b4f784f2737ab4b4e39693a7aab8 --- .../src/Generated/IResourceGraphClient.cs | 14 ++ .../Models/AuthorizationScopeFilter.cs | 72 +++++++ .../src/Generated/Models/Column.cs | 5 +- .../src/Generated/Models/ColumnDataType.cs | 8 +- .../src/Generated/Models/DateTimeInterval.cs | 81 ++++++++ .../Generated/Models/QueryRequestOptions.cs | 17 +- .../Models/ResourcesHistoryRequest.cs | 95 +++++++++ .../Models/ResourcesHistoryRequestOptions.cs | 125 ++++++++++++ .../src/Generated/ResourceGraphClient.cs | 188 +++++++++++++++++- .../ResourceGraphClientExtensions.cs | 34 ++++ .../Generated/SdkInfo_ResourceGraphClient.cs | 16 +- 11 files changed, 637 insertions(+), 18 deletions(-) create mode 100644 sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/AuthorizationScopeFilter.cs create mode 100644 sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/DateTimeInterval.cs create mode 100644 sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/ResourcesHistoryRequest.cs create mode 100644 sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/ResourcesHistoryRequestOptions.cs diff --git a/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/IResourceGraphClient.cs b/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/IResourceGraphClient.cs index 13b63ca9df67..6b169c3dce8f 100644 --- a/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/IResourceGraphClient.cs +++ b/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/IResourceGraphClient.cs @@ -88,5 +88,19 @@ public partial interface IResourceGraphClient : System.IDisposable /// Task> ResourcesWithHttpMessagesAsync(QueryRequest query, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all snapshots of a resource for a given time interval. + /// + /// + /// Request specifying the query and its options. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> ResourcesHistoryWithHttpMessagesAsync(ResourcesHistoryRequest request, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } } diff --git a/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/AuthorizationScopeFilter.cs b/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/AuthorizationScopeFilter.cs new file mode 100644 index 000000000000..1f5ff6edf380 --- /dev/null +++ b/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/AuthorizationScopeFilter.cs @@ -0,0 +1,72 @@ +// +// 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.ResourceGraph.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for AuthorizationScopeFilter. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum AuthorizationScopeFilter + { + [EnumMember(Value = "AtScopeAndBelow")] + AtScopeAndBelow, + [EnumMember(Value = "AtScopeAndAbove")] + AtScopeAndAbove, + [EnumMember(Value = "AtScopeExact")] + AtScopeExact, + [EnumMember(Value = "AtScopeAboveAndBelow")] + AtScopeAboveAndBelow + } + internal static class AuthorizationScopeFilterEnumExtension + { + internal static string ToSerializedValue(this AuthorizationScopeFilter? value) + { + return value == null ? null : ((AuthorizationScopeFilter)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this AuthorizationScopeFilter value) + { + switch( value ) + { + case AuthorizationScopeFilter.AtScopeAndBelow: + return "AtScopeAndBelow"; + case AuthorizationScopeFilter.AtScopeAndAbove: + return "AtScopeAndAbove"; + case AuthorizationScopeFilter.AtScopeExact: + return "AtScopeExact"; + case AuthorizationScopeFilter.AtScopeAboveAndBelow: + return "AtScopeAboveAndBelow"; + } + return null; + } + + internal static AuthorizationScopeFilter? ParseAuthorizationScopeFilter(this string value) + { + switch( value ) + { + case "AtScopeAndBelow": + return AuthorizationScopeFilter.AtScopeAndBelow; + case "AtScopeAndAbove": + return AuthorizationScopeFilter.AtScopeAndAbove; + case "AtScopeExact": + return AuthorizationScopeFilter.AtScopeExact; + case "AtScopeAboveAndBelow": + return AuthorizationScopeFilter.AtScopeAboveAndBelow; + } + return null; + } + } +} diff --git a/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/Column.cs b/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/Column.cs index 5500c708a9d9..547a2ffa311d 100644 --- a/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/Column.cs +++ b/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/Column.cs @@ -32,7 +32,8 @@ public Column() /// /// Column name. /// Column data type. Possible values include: - /// 'string', 'integer', 'number', 'boolean', 'object' + /// 'string', 'integer', 'number', 'boolean', 'object', + /// 'datetime' public Column(string name, ColumnDataType type) { Name = name; @@ -53,7 +54,7 @@ public Column(string name, ColumnDataType type) /// /// Gets or sets column data type. Possible values include: 'string', - /// 'integer', 'number', 'boolean', 'object' + /// 'integer', 'number', 'boolean', 'object', 'datetime' /// [JsonProperty(PropertyName = "type")] public ColumnDataType Type { get; set; } diff --git a/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/ColumnDataType.cs b/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/ColumnDataType.cs index 27c17bfb7ba0..8ec13323404e 100644 --- a/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/ColumnDataType.cs +++ b/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/ColumnDataType.cs @@ -30,7 +30,9 @@ public enum ColumnDataType [EnumMember(Value = "boolean")] Boolean, [EnumMember(Value = "object")] - Object + Object, + [EnumMember(Value = "datetime")] + Datetime } internal static class ColumnDataTypeEnumExtension { @@ -53,6 +55,8 @@ internal static string ToSerializedValue(this ColumnDataType value) return "boolean"; case ColumnDataType.Object: return "object"; + case ColumnDataType.Datetime: + return "datetime"; } return null; } @@ -71,6 +75,8 @@ internal static string ToSerializedValue(this ColumnDataType value) return ColumnDataType.Boolean; case "object": return ColumnDataType.Object; + case "datetime": + return ColumnDataType.Datetime; } return null; } diff --git a/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/DateTimeInterval.cs b/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/DateTimeInterval.cs new file mode 100644 index 000000000000..d9afca89cddf --- /dev/null +++ b/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/DateTimeInterval.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.ResourceGraph.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// An interval in time specifying the date and time for the inclusive + /// start and exclusive end, i.e. `[start, end)`. + /// + public partial class DateTimeInterval + { + /// + /// Initializes a new instance of the DateTimeInterval class. + /// + public DateTimeInterval() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DateTimeInterval class. + /// + /// A datetime indicating the inclusive/closed + /// start of the time interval, i.e. `[`**`start`**`, end)`. Specifying + /// a `start` that occurs chronologically after `end` will result in an + /// error. + /// A datetime indicating the exclusive/open end of + /// the time interval, i.e. `[start, `**`end`**`)`. Specifying an `end` + /// that occurs chronologically before `start` will result in an + /// error. + public DateTimeInterval(System.DateTime start, System.DateTime end) + { + Start = start; + End = end; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets a datetime indicating the inclusive/closed start of + /// the time interval, i.e. `[`**`start`**`, end)`. Specifying a + /// `start` that occurs chronologically after `end` will result in an + /// error. + /// + [JsonProperty(PropertyName = "start")] + public System.DateTime Start { get; set; } + + /// + /// Gets or sets a datetime indicating the exclusive/open end of the + /// time interval, i.e. `[start, `**`end`**`)`. Specifying an `end` + /// that occurs chronologically before `start` will result in an error. + /// + [JsonProperty(PropertyName = "end")] + public System.DateTime End { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + //Nothing to validate + } + } +} diff --git a/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/QueryRequestOptions.cs b/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/QueryRequestOptions.cs index c55742769b43..411096cb3438 100644 --- a/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/QueryRequestOptions.cs +++ b/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/QueryRequestOptions.cs @@ -45,13 +45,19 @@ public QueryRequestOptions() /// management group level queries to decide whether to allow partial /// scopes for result in case the number of subscriptions exceed /// allowed limits. - public QueryRequestOptions(string skipToken = default(string), int? top = default(int?), int? skip = default(int?), ResultFormat? resultFormat = default(ResultFormat?), bool? allowPartialScopes = default(bool?)) + /// Defines what level of + /// authorization resources should be returned based on the which + /// subscriptions and management groups are passed as scopes. Possible + /// values include: 'AtScopeAndBelow', 'AtScopeAndAbove', + /// 'AtScopeExact', 'AtScopeAboveAndBelow' + public QueryRequestOptions(string skipToken = default(string), int? top = default(int?), int? skip = default(int?), ResultFormat? resultFormat = default(ResultFormat?), bool? allowPartialScopes = default(bool?), AuthorizationScopeFilter? authorizationScopeFilter = default(AuthorizationScopeFilter?)) { SkipToken = skipToken; Top = top; Skip = skip; ResultFormat = resultFormat; AllowPartialScopes = allowPartialScopes; + AuthorizationScopeFilter = authorizationScopeFilter; CustomInit(); } @@ -98,6 +104,15 @@ public QueryRequestOptions() [JsonProperty(PropertyName = "allowPartialScopes")] public bool? AllowPartialScopes { get; set; } + /// + /// Gets or sets defines what level of authorization resources should + /// be returned based on the which subscriptions and management groups + /// are passed as scopes. Possible values include: 'AtScopeAndBelow', + /// 'AtScopeAndAbove', 'AtScopeExact', 'AtScopeAboveAndBelow' + /// + [JsonProperty(PropertyName = "authorizationScopeFilter")] + public AuthorizationScopeFilter? AuthorizationScopeFilter { get; set; } + /// /// Validate the object. /// diff --git a/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/ResourcesHistoryRequest.cs b/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/ResourcesHistoryRequest.cs new file mode 100644 index 000000000000..2467479d2669 --- /dev/null +++ b/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/ResourcesHistoryRequest.cs @@ -0,0 +1,95 @@ +// +// 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.ResourceGraph.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Describes a history request to be executed. + /// + public partial class ResourcesHistoryRequest + { + /// + /// Initializes a new instance of the ResourcesHistoryRequest class. + /// + public ResourcesHistoryRequest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourcesHistoryRequest class. + /// + /// Azure subscriptions against which to + /// execute the query. + /// The resources query. + /// The history request evaluation + /// options + /// Azure management groups against + /// which to execute the query. Example: [ 'mg1', 'mg2' ] + public ResourcesHistoryRequest(IList subscriptions = default(IList), string query = default(string), ResourcesHistoryRequestOptions options = default(ResourcesHistoryRequestOptions), IList managementGroups = default(IList)) + { + Subscriptions = subscriptions; + Query = query; + Options = options; + ManagementGroups = managementGroups; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets azure subscriptions against which to execute the + /// query. + /// + [JsonProperty(PropertyName = "subscriptions")] + public IList Subscriptions { get; set; } + + /// + /// Gets or sets the resources query. + /// + [JsonProperty(PropertyName = "query")] + public string Query { get; set; } + + /// + /// Gets or sets the history request evaluation options + /// + [JsonProperty(PropertyName = "options")] + public ResourcesHistoryRequestOptions Options { get; set; } + + /// + /// Gets or sets azure management groups against which to execute the + /// query. Example: [ 'mg1', 'mg2' ] + /// + [JsonProperty(PropertyName = "managementGroups")] + public IList ManagementGroups { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Options != null) + { + Options.Validate(); + } + } + } +} diff --git a/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/ResourcesHistoryRequestOptions.cs b/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/ResourcesHistoryRequestOptions.cs new file mode 100644 index 000000000000..b3f5752f823e --- /dev/null +++ b/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/Models/ResourcesHistoryRequestOptions.cs @@ -0,0 +1,125 @@ +// +// 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.ResourceGraph.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The options for history request evaluation + /// + public partial class ResourcesHistoryRequestOptions + { + /// + /// Initializes a new instance of the ResourcesHistoryRequestOptions + /// class. + /// + public ResourcesHistoryRequestOptions() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourcesHistoryRequestOptions + /// class. + /// + /// The time interval used to fetch + /// history. + /// The maximum number of rows that the query should + /// return. Overrides the page size when ```$skipToken``` property is + /// present. + /// The number of rows to skip from the beginning of + /// the results. Overrides the next page offset when ```$skipToken``` + /// property is present. + /// Continuation token for pagination, + /// capturing the next page size and offset, as well as the context of + /// the query. + /// Defines in which format query result + /// returned. Possible values include: 'table', 'objectArray' + public ResourcesHistoryRequestOptions(DateTimeInterval interval = default(DateTimeInterval), int? top = default(int?), int? skip = default(int?), string skipToken = default(string), ResultFormat? resultFormat = default(ResultFormat?)) + { + Interval = interval; + Top = top; + Skip = skip; + SkipToken = skipToken; + ResultFormat = resultFormat; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the time interval used to fetch history. + /// + [JsonProperty(PropertyName = "interval")] + public DateTimeInterval Interval { get; set; } + + /// + /// Gets or sets the maximum number of rows that the query should + /// return. Overrides the page size when ```$skipToken``` property is + /// present. + /// + [JsonProperty(PropertyName = "$top")] + public int? Top { get; set; } + + /// + /// Gets or sets the number of rows to skip from the beginning of the + /// results. Overrides the next page offset when ```$skipToken``` + /// property is present. + /// + [JsonProperty(PropertyName = "$skip")] + public int? Skip { get; set; } + + /// + /// Gets or sets continuation token for pagination, capturing the next + /// page size and offset, as well as the context of the query. + /// + [JsonProperty(PropertyName = "$skipToken")] + public string SkipToken { get; set; } + + /// + /// Gets or sets defines in which format query result returned. + /// Possible values include: 'table', 'objectArray' + /// + [JsonProperty(PropertyName = "resultFormat")] + public ResultFormat? ResultFormat { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Interval != null) + { + Interval.Validate(); + } + if (Top > 1000) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "Top", 1000); + } + if (Top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Top", 1); + } + if (Skip < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Skip", 0); + } + } + } +} diff --git a/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/ResourceGraphClient.cs b/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/ResourceGraphClient.cs index f230d8267d40..a62f4720b3dd 100644 --- a/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/ResourceGraphClient.cs +++ b/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/ResourceGraphClient.cs @@ -319,7 +319,7 @@ private void Initialize() { Operations = new Operations(this); BaseUri = new System.Uri("https://management.azure.com"); - ApiVersion = "2021-03-01"; + ApiVersion = "2021-06-01-preview"; AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; @@ -541,5 +541,191 @@ private void Initialize() return _result; } + /// + /// List all snapshots of a resource for a given time interval. + /// + /// + /// Request specifying the query and its options. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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> ResourcesHistoryWithHttpMessagesAsync(ResourcesHistoryRequest request, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (request == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "request"); + } + if (request != null) + { + request.Validate(); + } + if (ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("request", request); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ResourcesHistory", tracingParameters); + } + // Construct URL + var _baseUrl = BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.ResourceGraph/resourcesHistory").ToString(); + List _queryParameters = new List(); + if (ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(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 (GenerateClientRequestId != null && GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", 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(request != null) + { + _requestContent = SafeJsonConvert.SerializeObject(request, 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 (Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new 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 = SafeJsonConvert.DeserializeObject(_responseContent, 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/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/ResourceGraphClientExtensions.cs b/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/ResourceGraphClientExtensions.cs index d2cfe98f861f..51cedb81ae9d 100644 --- a/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/ResourceGraphClientExtensions.cs +++ b/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/ResourceGraphClientExtensions.cs @@ -59,5 +59,39 @@ public static QueryResponse Resources(this IResourceGraphClient operations, Quer } } + /// + /// List all snapshots of a resource for a given time interval. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Request specifying the query and its options. + /// + public static object ResourcesHistory(this IResourceGraphClient operations, ResourcesHistoryRequest request) + { + return operations.ResourcesHistoryAsync(request).GetAwaiter().GetResult(); + } + + /// + /// List all snapshots of a resource for a given time interval. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Request specifying the query and its options. + /// + /// + /// The cancellation token. + /// + public static async Task ResourcesHistoryAsync(this IResourceGraphClient operations, ResourcesHistoryRequest request, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ResourcesHistoryWithHttpMessagesAsync(request, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + } } diff --git a/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/SdkInfo_ResourceGraphClient.cs b/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/SdkInfo_ResourceGraphClient.cs index 5b24d34b6292..80a841ddf080 100644 --- a/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/SdkInfo_ResourceGraphClient.cs +++ b/sdk/resourcegraph/Microsoft.Azure.Management.ResourceGraph/src/Generated/SdkInfo_ResourceGraphClient.cs @@ -19,21 +19,11 @@ public static IEnumerable> ApiInfo_ResourceGraphCl { return new Tuple[] { - new Tuple("ResourceGraph", "Operations", "2021-03-01"), - new Tuple("ResourceGraph", "Resources", "2021-03-01"), + new Tuple("ResourceGraph", "Operations", "2021-06-01-preview"), + new Tuple("ResourceGraph", "Resources", "2021-06-01-preview"), + new Tuple("ResourceGraph", "ResourcesHistory", "2021-06-01-preview"), }.AsEnumerable(); } } - // BEGIN: Code Generation Metadata Section - public static readonly String AutoRestVersion = "v2"; - public static readonly String AutoRestBootStrapperVersion = "autorest@2.0.4413"; - public static readonly String AutoRestCmdExecuted = "cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/resourcegraph/resource-manager/readme.md --csharp --version=v2 --reflect-api-versions --csharp-sdks-folder=C:\\Graph\\azure-sdk-for-net\\sdk"; - public static readonly String GithubForkName = "Azure"; - public static readonly String GithubBranchName = "master"; - public static readonly String GithubCommidId = "413612b5f24da120e83eac227264f2e0b262ed8a"; - public static readonly String CodeGenerationErrors = ""; - public static readonly String GithubRepoName = "azure-rest-api-specs"; - // END: Code Generation Metadata Section } } -