diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/IOperations.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/IOperations.cs new file mode 100644 index 000000000000..930030652e3b --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/IOperations.cs @@ -0,0 +1,37 @@ +// 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 +{ + using Microsoft.Rest.Azure; + using Models; + + /// + /// Operations operations. + /// + public partial interface IOperations + { + /// + /// Lists all of the available REST API operations. + /// + /// + /// Lists all of the available REST API operations. + /// + /// + /// 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 + /// + System.Threading.Tasks.Task>> ListWithHttpMessagesAsync(System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/IResourceGraphClient.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/IResourceGraphClient.cs new file mode 100644 index 000000000000..96c199d53c02 --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/IResourceGraphClient.cs @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.ResourceGraph +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + + /// + /// Azure Resource Graph API Reference + /// + public partial interface IResourceGraphClient : System.IDisposable + { + /// + /// The base URI of the service. + /// + System.Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + + /// + /// Gets or sets json deserialization settings. + /// + Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + + /// + /// Credentials needed for the client to connect to Azure. + /// + Microsoft.Rest.ServiceClientCredentials Credentials { get;} + + + /// + /// The API version to use for this operation. + /// + string ApiVersion { get;} + + + /// + /// The preferred language for the response. + /// + string AcceptLanguage { get; set;} + + + /// + /// The retry timeout in seconds for Long Running Operations. Default + /// /// value is 30. + /// + int? LongRunningOperationRetryTimeout { get; set;} + + + /// + /// Whether a unique x-ms-client-request-id should be generated. When + /// /// set to true a unique x-ms-client-request-id value is generated and + /// /// included in each request. Default is true. + /// + bool? GenerateClientRequestId { get; set;} + + + /// + /// Gets the IOperations + /// + IOperations Operations { get; } + + /// + /// Queries the resources managed by Azure Resource Manager for scopes + /// specified in the request. + /// + /// + /// Queries the resources managed by Azure Resource Manager for scopes + /// specified in the request. + /// + /// + /// Request specifying query and its options. + /// + /// + /// 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 + /// + System.Threading.Tasks.Task> ResourcesWithHttpMessagesAsync(QueryRequest query, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/Column.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/Column.cs new file mode 100644 index 000000000000..c19954900aac --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/Column.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.ResourceGraph.Models +{ + using System.Linq; + + /// + /// Query result column descriptor. + /// + public partial class Column + { + /// + /// Initializes a new instance of the Column class. + /// + public Column() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Column class. + /// + + /// Column name. + /// + + /// Column data type. + /// Possible values include: 'string', 'integer', 'number', 'boolean', 'object' + public Column(string name, ColumnDataType type) + + { + this.Name = name; + this.Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets column name. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "name")] + public string Name {get; set; } + + /// + /// Gets or sets column data type. Possible values include: 'string', 'integer', 'number', 'boolean', 'object' + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "type")] + public ColumnDataType Type {get; set; } + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (this.Name == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Name"); + } + + + } + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/ColumnDataType.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/ColumnDataType.cs new file mode 100644 index 000000000000..e800dc9f41df --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/ColumnDataType.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.ResourceGraph.Models +{ + + /// + /// Defines values for ColumnDataType. + /// + + + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum ColumnDataType + { + [System.Runtime.Serialization.EnumMember(Value = "string")] + String, + [System.Runtime.Serialization.EnumMember(Value = "integer")] + Integer, + [System.Runtime.Serialization.EnumMember(Value = "number")] + Number, + [System.Runtime.Serialization.EnumMember(Value = "boolean")] + Boolean, + [System.Runtime.Serialization.EnumMember(Value = "object")] + Object + } + internal static class ColumnDataTypeEnumExtension + { + internal static string ToSerializedValue(this ColumnDataType? value) + { + return value == null ? null : ((ColumnDataType)value).ToSerializedValue(); + } + internal static string ToSerializedValue(this ColumnDataType value) + { + switch( value ) + { + case ColumnDataType.String: + return "string"; + case ColumnDataType.Integer: + return "integer"; + case ColumnDataType.Number: + return "number"; + case ColumnDataType.Boolean: + return "boolean"; + case ColumnDataType.Object: + return "object"; + } + return null; + } + internal static ColumnDataType? ParseColumnDataType(this string value) + { + switch( value ) + { + case "string": + return ColumnDataType.String; + case "integer": + return ColumnDataType.Integer; + case "number": + return ColumnDataType.Number; + case "boolean": + return ColumnDataType.Boolean; + case "object": + return ColumnDataType.Object; + } + return null; + } + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/Error.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/Error.cs new file mode 100644 index 000000000000..0d0de33f3eb7 --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/Error.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.ResourceGraph.Models +{ + using System.Linq; + + /// + /// Error details. + /// + /// + /// Error details. + /// + public partial class Error + { + /// + /// Initializes a new instance of the Error class. + /// + public Error() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Error class. + /// + + /// Error code identifying the specific error. + /// + + /// A human readable error message. + /// + + /// Error details + /// + public Error(string code, string message, System.Collections.Generic.IList details = default(System.Collections.Generic.IList)) + + { + this.Code = code; + this.Message = message; + this.Details = details; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets error code identifying the specific error. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "code")] + public string Code {get; set; } + + /// + /// Gets or sets a human readable error message. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "message")] + public string Message {get; set; } + + /// + /// Gets or sets error details + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "details")] + public System.Collections.Generic.IList Details {get; set; } + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (this.Code == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Code"); + } + if (this.Message == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Message"); + } + + + if (this.Details != null) + { + foreach (var element in this.Details) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/ErrorDetails.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/ErrorDetails.cs new file mode 100644 index 000000000000..9b770f899c72 --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/ErrorDetails.cs @@ -0,0 +1,91 @@ +// 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 System.Linq; + + /// + /// Error details. + /// + /// + /// Error details. + /// + public partial class ErrorDetails + { + /// + /// Initializes a new instance of the ErrorDetails class. + /// + public ErrorDetails() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorDetails class. + /// + + /// Error details. + /// + + /// Error code identifying the specific error. + /// + + /// A human readable error message. + /// + public ErrorDetails(string code, string message, System.Collections.Generic.IDictionary additionalProperties = default(System.Collections.Generic.IDictionary)) + + { + this.AdditionalProperties = additionalProperties; + this.Code = code; + this.Message = message; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets error details. + /// + [Newtonsoft.Json.JsonExtensionData] + public System.Collections.Generic.IDictionary AdditionalProperties {get; set; } + + /// + /// Gets or sets error code identifying the specific error. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "code")] + public string Code {get; set; } + + /// + /// Gets or sets a human readable error message. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "message")] + public string Message {get; set; } + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (this.Code == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Code"); + } + if (this.Message == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Message"); + } + + + + } + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/ErrorResponse.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/ErrorResponse.cs new file mode 100644 index 000000000000..6e2748c892c0 --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/ErrorResponse.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.ResourceGraph.Models +{ + using System.Linq; + + /// + /// An error response from the API. + /// + /// + /// An error response from the API. + /// + public partial class ErrorResponse + { + /// + /// Initializes a new instance of the ErrorResponse class. + /// + public ErrorResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorResponse class. + /// + + /// Error information. + /// + public ErrorResponse(Error error) + + { + this.Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets error information. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "error")] + public Error Error {get; set; } + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (this.Error == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Error"); + } + if (this.Error != null) + { + this.Error.Validate(); + } + } + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/ErrorResponseException.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/ErrorResponseException.cs new file mode 100644 index 000000000000..ac2b6328e53a --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/ErrorResponseException.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +namespace Microsoft.Azure.Management.ResourceGraph.Models +{ + + /// + /// Exception thrown for an invalid response with ErrorResponse information. + /// + public partial class ErrorResponseException : Microsoft.Rest.RestException + { + /// + /// Gets information about the associated HTTP request. + /// + public Microsoft.Rest.HttpRequestMessageWrapper Request { get; set; } + + /// + /// Gets information about the associated HTTP response. + /// + public Microsoft.Rest.HttpResponseMessageWrapper Response { get; set; } + + /// + /// Gets or sets the body object. + /// + public ErrorResponse Body { get; set; } + + /// + /// Initializes a new instance of the ErrorResponseException class. + /// + public ErrorResponseException() + { + } + + /// + /// Initializes a new instance of the ErrorResponse class. + /// + /// The exception message. + public ErrorResponseException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the ErrorResponse class. + /// + /// The exception message. + /// Inner exception. + public ErrorResponseException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/Facet.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/Facet.cs new file mode 100644 index 000000000000..b5390968a317 --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/Facet.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.ResourceGraph.Models +{ + using System.Linq; + + /// + /// A facet containing additional statistics on the response of a query. Can be + /// either FacetResult or FacetError. + /// + [Newtonsoft.Json.JsonObject("Facet")] + public partial class Facet + { + /// + /// Initializes a new instance of the Facet class. + /// + public Facet() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Facet class. + /// + + /// Facet expression, same as in the corresponding facet request. + /// + public Facet(string expression) + + { + this.Expression = expression; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets facet expression, same as in the corresponding facet request. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "expression")] + public string Expression {get; set; } + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (this.Expression == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Expression"); + } + + } + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/FacetError.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/FacetError.cs new file mode 100644 index 000000000000..ab72c12b58c5 --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/FacetError.cs @@ -0,0 +1,77 @@ +// 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 System.Linq; + + /// + /// A facet whose execution resulted in an error. + /// + [Newtonsoft.Json.JsonObject("FacetError")] + public partial class FacetError : Facet + { + /// + /// Initializes a new instance of the FacetError class. + /// + public FacetError() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the FacetError class. + /// + + /// Facet expression, same as in the corresponding facet request. + /// + + /// An array containing detected facet errors with details. + /// + public FacetError(string expression, System.Collections.Generic.IList errors) + + : base(expression) + { + this.Errors = errors; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets an array containing detected facet errors with details. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "errors")] + public System.Collections.Generic.IList Errors {get; set; } + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (this.Errors == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Errors"); + } + if (this.Errors != null) + { + foreach (var element in this.Errors) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/FacetRequest.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/FacetRequest.cs new file mode 100644 index 000000000000..f9bcbd1b17c4 --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/FacetRequest.cs @@ -0,0 +1,76 @@ +// 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 System.Linq; + + /// + /// A request to compute additional statistics (facets) over the query results. + /// + public partial class FacetRequest + { + /// + /// Initializes a new instance of the FacetRequest class. + /// + public FacetRequest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the FacetRequest class. + /// + + /// The column or list of columns to summarize by + /// + + /// The options for facet evaluation + /// + public FacetRequest(string expression, FacetRequestOptions options = default(FacetRequestOptions)) + + { + this.Expression = expression; + this.Options = options; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets the column or list of columns to summarize by + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "expression")] + public string Expression {get; set; } + + /// + /// Gets or sets the options for facet evaluation + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "options")] + public FacetRequestOptions Options {get; set; } + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (this.Expression == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Expression"); + } + + if (this.Options != null) + { + this.Options.Validate(); + } + } + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/FacetRequestOptions.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/FacetRequestOptions.cs new file mode 100644 index 000000000000..35a8d1e0110e --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/FacetRequestOptions.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.ResourceGraph.Models +{ + using System.Linq; + + /// + /// The options for facet evaluation + /// + public partial class FacetRequestOptions + { + /// + /// Initializes a new instance of the FacetRequestOptions class. + /// + public FacetRequestOptions() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the FacetRequestOptions class. + /// + + /// The column name or query expression to sort on. Defaults to count if not + /// present. + /// + + /// The sorting order by the selected column (count by default). + /// Possible values include: 'asc', 'desc' + + /// Specifies the filter condition for the 'where' clause which will be run on + /// main query's result, just before the actual faceting. + /// + + /// The maximum number of facet rows that should be returned. + /// + public FacetRequestOptions(string sortBy = default(string), FacetSortOrder? sortOrder = default(FacetSortOrder?), string filter = default(string), int? top = default(int?)) + + { + this.SortBy = sortBy; + this.SortOrder = sortOrder; + this.Filter = filter; + this.Top = top; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets the column name or query expression to sort on. Defaults to + /// count if not present. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "sortBy")] + public string SortBy {get; set; } + + /// + /// Gets or sets the sorting order by the selected column (count by default). Possible values include: 'asc', 'desc' + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "sortOrder")] + public FacetSortOrder? SortOrder {get; set; } + + /// + /// Gets or sets specifies the filter condition for the 'where' clause which + /// will be run on main query's result, just before the actual faceting. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "filter")] + public string Filter {get; set; } + + /// + /// Gets or sets the maximum number of facet rows that should be returned. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "$top")] + public int? Top {get; set; } + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + + + + if (this.Top != null) + { + if (this.Top > 1000) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.InclusiveMaximum, "Top", 1000); + } + if (this.Top < 1) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.InclusiveMinimum, "Top", 1); + } + } + } + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/FacetResult.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/FacetResult.cs new file mode 100644 index 000000000000..cfc97bf8983a --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/FacetResult.cs @@ -0,0 +1,91 @@ +// 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 System.Linq; + + /// + /// Successfully executed facet containing additional statistics on the + /// response of a query. + /// + [Newtonsoft.Json.JsonObject("FacetResult")] + public partial class FacetResult : Facet + { + /// + /// Initializes a new instance of the FacetResult class. + /// + public FacetResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the FacetResult class. + /// + + /// Facet expression, same as in the corresponding facet request. + /// + + /// Number of total records in the facet results. + /// + + /// Number of records returned in the facet response. + /// + + /// A JObject array or Table containing the desired facets. Only present if the + /// facet is valid. + /// + public FacetResult(string expression, long totalRecords, int count, object data) + + : base(expression) + { + this.TotalRecords = totalRecords; + this.Count = count; + this.Data = data; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets number of total records in the facet results. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "totalRecords")] + public long TotalRecords {get; set; } + + /// + /// Gets or sets number of records returned in the facet response. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "count")] + public int Count {get; set; } + + /// + /// Gets or sets a JObject array or Table containing the desired facets. Only + /// present if the facet is valid. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "data")] + public object Data {get; set; } + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (this.Data == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Data"); + } + + } + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/FacetSortOrder.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/FacetSortOrder.cs new file mode 100644 index 000000000000..c245ef7f4ef8 --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/FacetSortOrder.cs @@ -0,0 +1,51 @@ +// 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 +{ + + /// + /// Defines values for FacetSortOrder. + /// + + + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum FacetSortOrder + { + [System.Runtime.Serialization.EnumMember(Value = "asc")] + Asc, + [System.Runtime.Serialization.EnumMember(Value = "desc")] + Desc + } + internal static class FacetSortOrderEnumExtension + { + internal static string ToSerializedValue(this FacetSortOrder? value) + { + return value == null ? null : ((FacetSortOrder)value).ToSerializedValue(); + } + internal static string ToSerializedValue(this FacetSortOrder value) + { + switch( value ) + { + case FacetSortOrder.Asc: + return "asc"; + case FacetSortOrder.Desc: + return "desc"; + } + return null; + } + internal static FacetSortOrder? ParseFacetSortOrder(this string value) + { + switch( value ) + { + case "asc": + return FacetSortOrder.Asc; + case "desc": + return FacetSortOrder.Desc; + } + return null; + } + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/Operation.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/Operation.cs new file mode 100644 index 000000000000..6dcae4de6c43 --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/Operation.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.ResourceGraph.Models +{ + using System.Linq; + + /// + /// Resource Graph REST API operation definition. + /// + public partial class Operation + { + /// + /// Initializes a new instance of the Operation class. + /// + public Operation() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Operation class. + /// + + /// Operation name: {provider}/{resource}/{operation} + /// + + /// Display metadata associated with the operation. + /// + + /// The origin of operations. + /// + public Operation(string name = default(string), OperationDisplay display = default(OperationDisplay), string origin = default(string)) + + { + this.Name = name; + this.Display = display; + this.Origin = origin; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets operation name: {provider}/{resource}/{operation} + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "name")] + public string Name {get; set; } + + /// + /// Gets or sets display metadata associated with the operation. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "display")] + public OperationDisplay Display {get; set; } + + /// + /// Gets or sets the origin of operations. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "origin")] + public string Origin {get; set; } + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/OperationDisplay.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/OperationDisplay.cs new file mode 100644 index 000000000000..e08d95048b40 --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/OperationDisplay.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.ResourceGraph.Models +{ + using System.Linq; + + /// + /// Display metadata associated with the operation. + /// + public partial class OperationDisplay + { + /// + /// Initializes a new instance of the OperationDisplay class. + /// + public OperationDisplay() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationDisplay class. + /// + + /// Service provider: Microsoft Resource Graph. + /// + + /// Resource on which the operation is performed etc. + /// + + /// Type of operation: get, read, delete, etc. + /// + + /// Description for the operation. + /// + public OperationDisplay(string provider = default(string), string resource = default(string), string operation = default(string), string description = default(string)) + + { + this.Provider = provider; + this.Resource = resource; + this.Operation = operation; + this.Description = description; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets service provider: Microsoft Resource Graph. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "provider")] + public string Provider {get; set; } + + /// + /// Gets or sets resource on which the operation is performed etc. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "resource")] + public string Resource {get; set; } + + /// + /// Gets or sets type of operation: get, read, delete, etc. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "operation")] + public string Operation {get; set; } + + /// + /// Gets or sets description for the operation. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "description")] + public string Description {get; set; } + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/Page.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/Page.cs new file mode 100644 index 000000000000..d7a56b5b76bc --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/Page.cs @@ -0,0 +1,43 @@ +// 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 +{ + + /// + /// Defines a page in Azure responses. + /// + /// Type of the page content items + [Newtonsoft.Json.JsonObject] + public class Page : Microsoft.Rest.Azure.IPage + { + /// + /// Gets the link to the next page. + /// + [Newtonsoft.Json.JsonProperty("")] + public System.String NextPageLink { get; private set; } + + [Newtonsoft.Json.JsonProperty("value")] + private System.Collections.Generic.IList Items{ get; set; } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + public System.Collections.Generic.IEnumerator GetEnumerator() + { + return (Items == null) ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/QueryRequest.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/QueryRequest.cs new file mode 100644 index 000000000000..8791a3d58fee --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/QueryRequest.cs @@ -0,0 +1,121 @@ +// 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 System.Linq; + + /// + /// Describes a query to be executed. + /// + public partial class QueryRequest + { + /// + /// Initializes a new instance of the QueryRequest class. + /// + public QueryRequest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the QueryRequest class. + /// + + /// Azure subscriptions against which to execute the query. + /// + + /// Azure management groups against which to execute the query. Example: [ + /// 'mg1', 'mg2' ] + /// + + /// The resources query. + /// + + /// The query evaluation options + /// + + /// An array of facet requests to be computed against the query result. + /// + public QueryRequest(string query, System.Collections.Generic.IList subscriptions = default(System.Collections.Generic.IList), System.Collections.Generic.IList managementGroups = default(System.Collections.Generic.IList), QueryRequestOptions options = default(QueryRequestOptions), System.Collections.Generic.IList facets = default(System.Collections.Generic.IList)) + + { + this.Subscriptions = subscriptions; + this.ManagementGroups = managementGroups; + this.Query = query; + this.Options = options; + this.Facets = facets; + 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. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "subscriptions")] + public System.Collections.Generic.IList Subscriptions {get; set; } + + /// + /// Gets or sets azure management groups against which to execute the query. + /// Example: [ 'mg1', 'mg2' ] + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "managementGroups")] + public System.Collections.Generic.IList ManagementGroups {get; set; } + + /// + /// Gets or sets the resources query. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "query")] + public string Query {get; set; } + + /// + /// Gets or sets the query evaluation options + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "options")] + public QueryRequestOptions Options {get; set; } + + /// + /// Gets or sets an array of facet requests to be computed against the query + /// result. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "facets")] + public System.Collections.Generic.IList Facets {get; set; } + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (this.Query == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Query"); + } + + + + if (this.Options != null) + { + this.Options.Validate(); + } + if (this.Facets != null) + { + foreach (var element in this.Facets) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/QueryRequestOptions.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/QueryRequestOptions.cs new file mode 100644 index 000000000000..bee4e8f08cee --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/QueryRequestOptions.cs @@ -0,0 +1,127 @@ +// 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 System.Linq; + + /// + /// The options for query evaluation + /// + public partial class QueryRequestOptions + { + /// + /// Initializes a new instance of the QueryRequestOptions class. + /// + public QueryRequestOptions() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the QueryRequestOptions class. + /// + + /// Continuation token for pagination, capturing the next page size and offset, + /// as well as the context of the query. + /// + + /// 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. + /// + + /// Defines in which format query result returned. + /// Possible values include: 'table', 'objectArray' + + /// Only applicable for tenant and 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?)) + + { + this.SkipToken = skipToken; + this.Top = top; + this.Skip = skip; + this.ResultFormat = resultFormat; + this.AllowPartialScopes = allowPartialScopes; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets continuation token for pagination, capturing the next page + /// size and offset, as well as the context of the query. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "$skipToken")] + public string SkipToken {get; set; } + + /// + /// Gets or sets the maximum number of rows that the query should return. + /// Overrides the page size when ```$skipToken``` property is present. + /// + [Newtonsoft.Json.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. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "$skip")] + public int? Skip {get; set; } + + /// + /// Gets or sets defines in which format query result returned. Possible values include: 'table', 'objectArray' + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "resultFormat")] + public ResultFormat? ResultFormat {get; set; } + + /// + /// Gets or sets only applicable for tenant and management group level queries + /// to decide whether to allow partial scopes for result in case the number of + /// subscriptions exceed allowed limits. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "allowPartialScopes")] + public bool? AllowPartialScopes {get; set; } + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + + if (this.Top != null) + { + if (this.Top > 1000) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.InclusiveMaximum, "Top", 1000); + } + if (this.Top < 1) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.InclusiveMinimum, "Top", 1); + } + } + if (this.Skip != null) + { + if (this.Skip < 0) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.InclusiveMinimum, "Skip", 0); + } + } + + } + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/QueryResponse.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/QueryResponse.cs new file mode 100644 index 000000000000..e9d3e1414870 --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/QueryResponse.cs @@ -0,0 +1,130 @@ +// 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 System.Linq; + + /// + /// Query result. + /// + public partial class QueryResponse + { + /// + /// Initializes a new instance of the QueryResponse class. + /// + public QueryResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the QueryResponse class. + /// + + /// Number of total records matching the query. + /// + + /// Number of records returned in the current response. In the case of paging, + /// this is the number of records in the current page. + /// + + /// Indicates whether the query results are truncated. + /// Possible values include: 'true', 'false' + + /// When present, the value can be passed to a subsequent query call (together + /// with the same query and scopes used in the current request) to retrieve the + /// next page of data. + /// + + /// Query output in JObject array or Table format. + /// + + /// Query facets. + /// + public QueryResponse(long totalRecords, long count, ResultTruncated resultTruncated, object data, string skipToken = default(string), System.Collections.Generic.IList facets = default(System.Collections.Generic.IList)) + + { + this.TotalRecords = totalRecords; + this.Count = count; + this.ResultTruncated = resultTruncated; + this.SkipToken = skipToken; + this.Data = data; + this.Facets = facets; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets number of total records matching the query. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "totalRecords")] + public long TotalRecords {get; set; } + + /// + /// Gets or sets number of records returned in the current response. In the + /// case of paging, this is the number of records in the current page. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "count")] + public long Count {get; set; } + + /// + /// Gets or sets indicates whether the query results are truncated. Possible values include: 'true', 'false' + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "resultTruncated")] + public ResultTruncated ResultTruncated {get; set; } + + /// + /// Gets or sets when present, the value can be passed to a subsequent query + /// call (together with the same query and scopes used in the current request) + /// to retrieve the next page of data. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "$skipToken")] + public string SkipToken {get; set; } + + /// + /// Gets or sets query output in JObject array or Table format. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "data")] + public object Data {get; set; } + + /// + /// Gets or sets query facets. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "facets")] + public System.Collections.Generic.IList Facets {get; set; } + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (this.Data == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Data"); + } + + + + if (this.Facets != null) + { + foreach (var element in this.Facets) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/ResultFormat.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/ResultFormat.cs new file mode 100644 index 000000000000..add39bc7bc7a --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/ResultFormat.cs @@ -0,0 +1,51 @@ +// 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 +{ + + /// + /// Defines values for ResultFormat. + /// + + + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum ResultFormat + { + [System.Runtime.Serialization.EnumMember(Value = "table")] + Table, + [System.Runtime.Serialization.EnumMember(Value = "objectArray")] + ObjectArray + } + internal static class ResultFormatEnumExtension + { + internal static string ToSerializedValue(this ResultFormat? value) + { + return value == null ? null : ((ResultFormat)value).ToSerializedValue(); + } + internal static string ToSerializedValue(this ResultFormat value) + { + switch( value ) + { + case ResultFormat.Table: + return "table"; + case ResultFormat.ObjectArray: + return "objectArray"; + } + return null; + } + internal static ResultFormat? ParseResultFormat(this string value) + { + switch( value ) + { + case "table": + return ResultFormat.Table; + case "objectArray": + return ResultFormat.ObjectArray; + } + return null; + } + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/ResultTruncated.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/ResultTruncated.cs new file mode 100644 index 000000000000..20bb12e694a4 --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/ResultTruncated.cs @@ -0,0 +1,51 @@ +// 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 +{ + + /// + /// Defines values for ResultTruncated. + /// + + + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum ResultTruncated + { + [System.Runtime.Serialization.EnumMember(Value = "true")] + True, + [System.Runtime.Serialization.EnumMember(Value = "false")] + False + } + internal static class ResultTruncatedEnumExtension + { + internal static string ToSerializedValue(this ResultTruncated? value) + { + return value == null ? null : ((ResultTruncated)value).ToSerializedValue(); + } + internal static string ToSerializedValue(this ResultTruncated value) + { + switch( value ) + { + case ResultTruncated.True: + return "true"; + case ResultTruncated.False: + return "false"; + } + return null; + } + internal static ResultTruncated? ParseResultTruncated(this string value) + { + switch( value ) + { + case "true": + return ResultTruncated.True; + case "false": + return ResultTruncated.False; + } + return null; + } + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/Table.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/Table.cs new file mode 100644 index 000000000000..fb21632f1876 --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Models/Table.cs @@ -0,0 +1,86 @@ +// 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 System.Linq; + + /// + /// Query output in tabular format. + /// + public partial class Table + { + /// + /// Initializes a new instance of the Table class. + /// + public Table() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Table class. + /// + + /// Query result column descriptors. + /// + + /// Query result rows. + /// + public Table(System.Collections.Generic.IList columns, System.Collections.Generic.IList> rows) + + { + this.Columns = columns; + this.Rows = rows; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + + /// + /// Gets or sets query result column descriptors. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "columns")] + public System.Collections.Generic.IList Columns {get; set; } + + /// + /// Gets or sets query result rows. + /// + [Newtonsoft.Json.JsonProperty(PropertyName = "rows")] + public System.Collections.Generic.IList> Rows {get; set; } + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (this.Columns == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Columns"); + } + if (this.Rows == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "Rows"); + } + if (this.Columns != null) + { + foreach (var element in this.Columns) + { + if (element != null) + { + element.Validate(); + } + } + } + + } + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Operations.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Operations.cs new file mode 100644 index 000000000000..fb3dd20aac30 --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/Operations.cs @@ -0,0 +1,224 @@ +// 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 +{ + using System.Linq; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + + /// + /// Operations operations. + /// + internal partial class Operations : Microsoft.Rest.IServiceOperations, IOperations + { + /// + /// Initializes a new instance of the Operations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal Operations (ResourceGraphClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + this.Client = client; + } + + /// + /// Gets a reference to the ResourceGraphClient + /// + public ResourceGraphClient Client { get; private set; } + + /// + /// Lists all of the available REST API operations. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation 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 System.Threading.Tasks.Task>> ListWithHttpMessagesAsync(System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + + + + if (this.Client.ApiVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + + var _baseUrl = this.Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.ResourceGraph/operations").ToString(); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (this.Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(this.Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.Client.GenerateClientRequestId != null && this.Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.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 (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.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 = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.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 = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, this.Client.DeserializationSettings); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/OperationsExtensions.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/OperationsExtensions.cs new file mode 100644 index 000000000000..c94a7e7fe9fa --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/OperationsExtensions.cs @@ -0,0 +1,43 @@ +// 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 +{ + using Microsoft.Rest.Azure; + using Models; + + /// + /// Extension methods for Operations + /// + public static partial class OperationsExtensions + { + /// + /// Lists all of the available REST API operations. + /// + /// + /// The operations group for this extension method. + /// + public static System.Collections.Generic.IEnumerable List(this IOperations operations) + { + return ((IOperations)operations).ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Lists all of the available REST API operations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task> ListAsync(this IOperations operations, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + } +} diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/ResourceGraphClient.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/ResourceGraphClient.cs new file mode 100644 index 000000000000..caa39b6f3707 --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/ResourceGraphClient.cs @@ -0,0 +1,535 @@ +// 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 +{ + using System.Linq; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + + /// + /// Azure Resource Graph API Reference + /// + public partial class ResourceGraphClient : Microsoft.Rest.ServiceClient, IResourceGraphClient, IAzureClient + { + /// + /// The base URI of the service. + /// + public System.Uri BaseUri { get; set; } + /// + /// Gets or sets json serialization settings. + /// + public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + /// + /// Gets or sets json deserialization settings. + /// + public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + /// + /// Credentials needed for the client to connect to Azure. + /// + public Microsoft.Rest.ServiceClientCredentials Credentials { get; private set; } + + /// + /// The API version to use for this operation. + /// + public string ApiVersion { get; private set; } + + /// + /// The preferred language for the response. + /// + public string AcceptLanguage { get; set;} + + /// + /// The retry timeout in seconds for Long Running Operations. Default + /// /// value is 30. + /// + public int? LongRunningOperationRetryTimeout { get; set;} + + /// + /// Whether a unique x-ms-client-request-id should be generated. When + /// /// set to true a unique x-ms-client-request-id value is generated and + /// /// included in each request. Default is true. + /// + public bool? GenerateClientRequestId { get; set;} + + /// + /// Gets the IOperations + /// + public virtual IOperations Operations { get; private set; } + /// + /// Initializes a new instance of the ResourceGraphClient class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling ResourceGraphClient.Dispose(). False: will not dispose provided httpClient + protected ResourceGraphClient(System.Net.Http.HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + this.Initialize(); + } + /// + /// Initializes a new instance of the ResourceGraphClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected ResourceGraphClient(params System.Net.Http.DelegatingHandler[] handlers) : base(handlers) + { + this.Initialize(); + } + /// + /// Initializes a new instance of the ResourceGraphClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected ResourceGraphClient(System.Net.Http.HttpClientHandler rootHandler, params System.Net.Http.DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + this.Initialize(); + } + /// + /// Initializes a new instance of the ResourceGraphClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + protected ResourceGraphClient(System.Uri baseUri, params System.Net.Http.DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + this.BaseUri = baseUri; + } + /// + /// Initializes a new instance of the ResourceGraphClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + protected ResourceGraphClient(System.Uri baseUri, System.Net.Http.HttpClientHandler rootHandler, params System.Net.Http.DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + + this.BaseUri = baseUri; + } + /// + /// Initializes a new instance of the ResourceGraphClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public ResourceGraphClient(Microsoft.Rest.ServiceClientCredentials credentials, params System.Net.Http.DelegatingHandler[] handlers) : this(handlers) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + this.Credentials = credentials; + if (this.Credentials != null) + { + this.Credentials.InitializeServiceClient(this); + } + + } + /// + /// Initializes a new instance of the ResourceGraphClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling ResourceGraphClient.Dispose(). False: will not dispose provided httpClient + /// + /// Thrown when a required parameter is null + /// + public ResourceGraphClient(Microsoft.Rest.ServiceClientCredentials credentials, System.Net.Http.HttpClient httpClient, bool disposeHttpClient) : this(httpClient, disposeHttpClient) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + this.Credentials = credentials; + if (this.Credentials != null) + { + this.Credentials.InitializeServiceClient(this); + } + + } + /// + /// Initializes a new instance of the ResourceGraphClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public ResourceGraphClient(Microsoft.Rest.ServiceClientCredentials credentials, System.Net.Http.HttpClientHandler rootHandler, params System.Net.Http.DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + this.Credentials = credentials; + if (this.Credentials != null) + { + this.Credentials.InitializeServiceClient(this); + } + + } + /// + /// Initializes a new instance of the ResourceGraphClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public ResourceGraphClient(System.Uri baseUri, Microsoft.Rest.ServiceClientCredentials credentials, params System.Net.Http.DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + this.BaseUri = baseUri; + this.Credentials = credentials; + if (this.Credentials != null) + { + this.Credentials.InitializeServiceClient(this); + } + + } + /// + /// Initializes a new instance of the ResourceGraphClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Thrown when a required parameter is null + /// + public ResourceGraphClient(System.Uri baseUri, Microsoft.Rest.ServiceClientCredentials credentials, System.Net.Http.HttpClientHandler rootHandler, params System.Net.Http.DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + this.BaseUri = baseUri; + this.Credentials = credentials; + if (this.Credentials != null) + { + this.Credentials.InitializeServiceClient(this); + } + + } + /// + /// An optional partial-method to perform custom initialization. + /// + partial void CustomInitialize(); + + /// + /// Initializes client properties. + /// + private void Initialize() + { + this.Operations = new Operations(this); + this.BaseUri = new System.Uri("https://management.azure.com"); + this.ApiVersion = "2021-03-01"; + this.AcceptLanguage = "en-US"; + this.LongRunningOperationRetryTimeout = 30; + this.GenerateClientRequestId = true; + SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + { + Formatting = Newtonsoft.Json.Formatting.Indented, + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new Microsoft.Rest.Serialization.ReadOnlyJsonContractResolver(), + Converters = new System.Collections.Generic.List + { + new Microsoft.Rest.Serialization.Iso8601TimeSpanConverter() + } + }; + DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new Microsoft.Rest.Serialization.ReadOnlyJsonContractResolver(), + Converters = new System.Collections.Generic.List + { + new Microsoft.Rest.Serialization.Iso8601TimeSpanConverter() + } + }; + SerializationSettings.Converters.Add(new Microsoft.Rest.Serialization.PolymorphicSerializeJsonConverter("resultType")); + DeserializationSettings.Converters.Add(new Microsoft.Rest.Serialization.PolymorphicDeserializeJsonConverter("resultType")); + CustomInitialize(); + DeserializationSettings.Converters.Add(new Microsoft.Rest.Azure.CloudErrorJsonConverter()); + } + /// + /// Queries the resources managed by Azure Resource Manager for scopes + /// specified in the request. + /// + /// + /// Request specifying 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 System.Threading.Tasks.Task> ResourcesWithHttpMessagesAsync(QueryRequest query, System.Collections.Generic.Dictionary> customHeaders = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + + + + if (query == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "query"); + } + if (query != null) + { + query.Validate(); + } + if (this.ApiVersion == null) + { + throw new Microsoft.Rest.ValidationException(Microsoft.Rest.ValidationRules.CannotBeNull, "this.ApiVersion"); + } + + // Tracing + bool _shouldTrace = Microsoft.Rest.ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = Microsoft.Rest.ServiceClientTracing.NextInvocationId.ToString(); + System.Collections.Generic.Dictionary tracingParameters = new System.Collections.Generic.Dictionary(); + + tracingParameters.Add("query", query); + + tracingParameters.Add("cancellationToken", cancellationToken); + Microsoft.Rest.ServiceClientTracing.Enter(_invocationId, this, "Resources", tracingParameters); + } + // Construct URL + + var _baseUrl = this.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.ResourceGraph/resources").ToString(); + + System.Collections.Generic.List _queryParameters = new System.Collections.Generic.List(); + if (this.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(this.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new System.Net.Http.HttpRequestMessage(); + System.Net.Http.HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (this.GenerateClientRequestId != null && this.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (this.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", this.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(query != null) + { + _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(query, this.SerializationSettings); + _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (this.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await this.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + + System.Net.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 = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (Newtonsoft.Json.JsonException) + { + // Ignore the exception + } + ex.Request = new Microsoft.Rest.HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new Microsoft.Rest.HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new Microsoft.Rest.Azure.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 = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, this.DeserializationSettings); + } + catch (Newtonsoft.Json.JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new Microsoft.Rest.SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + Microsoft.Rest.ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + + + + + + } + } +} \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/ResourceGraphClientExtensions.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/ResourceGraphClientExtensions.cs new file mode 100644 index 000000000000..d8df874ae58f --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Generated/ResourceGraphClientExtensions.cs @@ -0,0 +1,45 @@ +// 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 +{ + using Microsoft.Rest.Azure; + using Models; + + /// + /// Extension methods for ResourceGraphClient + /// + public static partial class ResourceGraphClientExtensions + { + /// + /// Queries the resources managed by Azure Resource Manager for scopes + /// specified in the request. + /// + /// + /// The operations group for this extension method. + /// + public static QueryResponse Resources(this IResourceGraphClient operations, QueryRequest query) + { + return ((IResourceGraphClient)operations).ResourcesAsync(query).GetAwaiter().GetResult(); + } + + /// + /// Queries the resources managed by Azure Resource Manager for scopes + /// specified in the request. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async System.Threading.Tasks.Task ResourcesAsync(this IResourceGraphClient operations, QueryRequest query, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + using (var _result = await operations.ResourcesWithHttpMessagesAsync(query, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + } +} diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/Properties/AssemblyInfo.cs b/src/ResourceGraph/ResourceGraph.Management.Sdk/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..9a9c20efe019 --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/Properties/AssemblyInfo.cs @@ -0,0 +1,29 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Microsoft Azure Powershell - Resource Graph Management SDK")] +[assembly: AssemblyCompany(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCompany)] +[assembly: AssemblyProduct(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyProduct)] +[assembly: AssemblyCopyright(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCopyright)] + +[assembly: ComVisible(false)] +[assembly: CLSCompliant(false)] + +[assembly: AssemblyVersion("2.1.0.0")] +[assembly: AssemblyFileVersion("2.1.0.0")] \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/README.md b/src/ResourceGraph/ResourceGraph.Management.Sdk/README.md new file mode 100644 index 000000000000..30254b0196d2 --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/README.md @@ -0,0 +1,62 @@ +# Overall +This directory contains management plane service clients of Az.Storage module. + +## Run Generation +In this directory, run AutoRest: +``` +autorest --reset +autorest --use:@autorest/powershell@4.x +``` + +### AutoRest Configuration +> see https://aka.ms/autorest +``` yaml +isSdkGenerator: true +powershell: true +clear-output-folder: true +reflect-api-versions: true +openapi-type: arm +azure-arm: true +license-header: MICROSOFT_MIT_NO_VERSION +payload-flattening-threshold: 0 +title: ResourceGraphClient +``` +### Validations + +Run validations when `--validate` is specified on command line + +``` yaml $(validate) +azure-validator: true +semantic-validator: true +model-validator: true +message-format: json +``` + + +### +``` yaml +commit: 413612b5f24da120e83eac227264f2e0b262ed8a +input-file: + - https://github.com/Azure/azure-rest-api-specs/blob/$(commit)/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/stable/2021-03-01/resourcegraph.json + +output-folder: Generated + +namespace: Microsoft.Azure.Management.ResourceGraph + +directive: + - suppress: ListInOperationName + from: resourcegraph.json + where: '$.paths["/providers/Microsoft.ResourceGraph/resourceChanges"].post.operationId' + reason: |- + 1. Is this rule applicable? R1003 ListInOperationName says: "Per ARM SDK guidelines, each 'GET' operation on a resource should have "list" in the name...". However, this is POST, not GET. + + 2. If the rule is applicable anyway, how should we fix it? Renaming it to ResourceChanges_List causes another warning: + "OperationId should contain the verb: 'resourcechanges' in:'ResourceChanges_List'. Consider updating the operationId" + Renaming it to ResourceChanges_ListResourceChanges causes yet another warning: + "Per the Noun_Verb convention for Operation Ids, the noun 'ResourceChanges' should not appear after the underscore." + Renaming it to ResourceChanges_Listresourcechanges seems to get rid of warnings, but the result looks very strange. + - suppress: EnumInsteadOfBoolean + where: $.definitions.ResourceChangesRequestParameters.properties.fetchPropertyChanges + from: resourcegraph.json + reason: This is a clear scenario for a boolean and will not have more than 2 values in the future. +``` \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Management.Sdk/ResourceGraph.Management.Sdk.csproj b/src/ResourceGraph/ResourceGraph.Management.Sdk/ResourceGraph.Management.Sdk.csproj new file mode 100644 index 000000000000..f02c5513bcb3 --- /dev/null +++ b/src/ResourceGraph/ResourceGraph.Management.Sdk/ResourceGraph.Management.Sdk.csproj @@ -0,0 +1,13 @@ + + + ResourceGraph + + + + netstandard2.0 + Microsoft.Azure.PowerShell.ResourceGraph.Management.Sdk + Microsoft.Azure.Management.ResourceGraph + $(NoWarn);CS0108;CS1573 + + + \ No newline at end of file diff --git a/src/ResourceGraph/ResourceGraph.Test/ResourceGraph.Test.csproj b/src/ResourceGraph/ResourceGraph.Test/ResourceGraph.Test.csproj index 1651f84553ac..10ce161d9be0 100644 --- a/src/ResourceGraph/ResourceGraph.Test/ResourceGraph.Test.csproj +++ b/src/ResourceGraph/ResourceGraph.Test/ResourceGraph.Test.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/ResourceGraph/ResourceGraph.sln b/src/ResourceGraph/ResourceGraph.sln index b57241fbf711..2e3c59b9c247 100644 --- a/src/ResourceGraph/ResourceGraph.sln +++ b/src/ResourceGraph/ResourceGraph.sln @@ -5,36 +5,35 @@ VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Accounts", "Accounts", "{B0B443FB-0C5A-4E37-8782-4DDF8C46CABE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Accounts", "..\Accounts\Accounts\Accounts.csproj", "{7F9C97D1-77FE-42AF-B92B-BA01F329C2BF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Accounts", "..\Accounts\Accounts\Accounts.csproj", "{7F9C97D1-77FE-42AF-B92B-BA01F329C2BF}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssemblyLoading", "..\Accounts\AssemblyLoading\AssemblyLoading.csproj", "{3F270F0A-D94E-421C-8339-C55FA3111A13}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssemblyLoading", "..\Accounts\AssemblyLoading\AssemblyLoading.csproj", "{3F270F0A-D94E-421C-8339-C55FA3111A13}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Authentication.ResourceManager", "..\Accounts\Authentication.ResourceManager\Authentication.ResourceManager.csproj", "{7627CD36-FF92-4BCB-B8E9-6A8F40BF7E78}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Authentication.ResourceManager", "..\Accounts\Authentication.ResourceManager\Authentication.ResourceManager.csproj", "{7627CD36-FF92-4BCB-B8E9-6A8F40BF7E78}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Authentication", "..\Accounts\Authentication\Authentication.csproj", "{0BA5EF1E-0393-4252-BDDC-239CC601B710}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Authentication", "..\Accounts\Authentication\Authentication.csproj", "{0BA5EF1E-0393-4252-BDDC-239CC601B710}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AuthenticationAssemblyLoadContext", "..\Accounts\AuthenticationAssemblyLoadContext\AuthenticationAssemblyLoadContext.csproj", "{54F93BDF-C4B8-4861-B1BB-B0307D2AEE16}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AuthenticationAssemblyLoadContext", "..\Accounts\AuthenticationAssemblyLoadContext\AuthenticationAssemblyLoadContext.csproj", "{54F93BDF-C4B8-4861-B1BB-B0307D2AEE16}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Authenticators", "..\Accounts\Authenticators\Authenticators.csproj", "{0EAADCB8-1F3C-4802-8AD8-D78F57CFFC86}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Authenticators", "..\Accounts\Authenticators\Authenticators.csproj", "{0EAADCB8-1F3C-4802-8AD8-D78F57CFFC86}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Az.ResourceGraph", "ResourceGraph.Autorest\Az.ResourceGraph.csproj", "{2A437352-76D2-480A-81FB-3F1B955C0401}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Az.ResourceGraph", "ResourceGraph.Autorest\Az.ResourceGraph.csproj", "{2A437352-76D2-480A-81FB-3F1B955C0401}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{984FDC49-E443-4705-BC90-2C20622D4083}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceGraph.Test", "ResourceGraph.Test\ResourceGraph.Test.csproj", "{FE441B52-EC18-4E9F-B026-EB3E52F57877}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ResourceGraph.Test", "ResourceGraph.Test\ResourceGraph.Test.csproj", "{FE441B52-EC18-4E9F-B026-EB3E52F57877}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceGraph", "ResourceGraph\ResourceGraph.csproj", "{DA0A68FF-2803-40B9-A59B-CDD4CA164707}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ResourceGraph", "ResourceGraph\ResourceGraph.csproj", "{DA0A68FF-2803-40B9-A59B-CDD4CA164707}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestFx", "..\..\tools\TestFx\TestFx.csproj", "{4C4B627A-4C87-4011-B6E8-8511315EE915}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestFx", "..\..\tools\TestFx\TestFx.csproj", "{4C4B627A-4C87-4011-B6E8-8511315EE915}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ResourceGraph.Management.Sdk", "ResourceGraph.Management.Sdk\ResourceGraph.Management.Sdk.csproj", "{21C663FD-ABAA-48A5-A566-CE45ABE6CE06}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {7F9C97D1-77FE-42AF-B92B-BA01F329C2BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7F9C97D1-77FE-42AF-B92B-BA01F329C2BF}.Debug|Any CPU.Build.0 = Debug|Any CPU @@ -76,6 +75,13 @@ Global {4C4B627A-4C87-4011-B6E8-8511315EE915}.Debug|Any CPU.Build.0 = Debug|Any CPU {4C4B627A-4C87-4011-B6E8-8511315EE915}.Release|Any CPU.ActiveCfg = Release|Any CPU {4C4B627A-4C87-4011-B6E8-8511315EE915}.Release|Any CPU.Build.0 = Release|Any CPU + {21C663FD-ABAA-48A5-A566-CE45ABE6CE06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {21C663FD-ABAA-48A5-A566-CE45ABE6CE06}.Debug|Any CPU.Build.0 = Debug|Any CPU + {21C663FD-ABAA-48A5-A566-CE45ABE6CE06}.Release|Any CPU.ActiveCfg = Release|Any CPU + {21C663FD-ABAA-48A5-A566-CE45ABE6CE06}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {7F9C97D1-77FE-42AF-B92B-BA01F329C2BF} = {B0B443FB-0C5A-4E37-8782-4DDF8C46CABE} diff --git a/src/ResourceGraph/ResourceGraph/Az.ResourceGraph.psd1 b/src/ResourceGraph/ResourceGraph/Az.ResourceGraph.psd1 index d877efa839f3..62b7b2bae2d6 100644 --- a/src/ResourceGraph/ResourceGraph/Az.ResourceGraph.psd1 +++ b/src/ResourceGraph/ResourceGraph/Az.ResourceGraph.psd1 @@ -56,7 +56,7 @@ DotNetFrameworkVersion = '4.7.2' RequiredModules = @(@{ModuleName = 'Az.Accounts'; ModuleVersion = '3.0.0'; }) # Assemblies that must be loaded prior to importing this module -RequiredAssemblies = 'Microsoft.Azure.Management.ResourceGraph.dll', +RequiredAssemblies = 'Microsoft.Azure.PowerShell.ResourceGraph.Management.Sdk.dll', 'ResourceGraph.Autorest/bin/Az.ResourceGraph.private.dll' # Script files (.ps1) that are run in the caller's environment prior to importing this module. diff --git a/src/ResourceGraph/ResourceGraph/ChangeLog.md b/src/ResourceGraph/ResourceGraph/ChangeLog.md index 762a34a59eb1..b38101e28ced 100644 --- a/src/ResourceGraph/ResourceGraph/ChangeLog.md +++ b/src/ResourceGraph/ResourceGraph/ChangeLog.md @@ -18,6 +18,9 @@ - Additional information about change #1 --> ## Upcoming Release +* Migrated ResourceGraph SDK to generated SDK + - Removed "Microsoft.Azure.Management.ResourceGraph" Version "2.1.0" PackageReference + - Added ResourceGraph.Management.Sdk ProjectReference ## Version 1.0.0 * General availability for module Az.ResourceGraph diff --git a/src/ResourceGraph/ResourceGraph/ResourceGraph.csproj b/src/ResourceGraph/ResourceGraph/ResourceGraph.csproj index 0f0d3f5959d4..aa24bd2ec37c 100644 --- a/src/ResourceGraph/ResourceGraph/ResourceGraph.csproj +++ b/src/ResourceGraph/ResourceGraph/ResourceGraph.csproj @@ -11,10 +11,10 @@ $(LegacyAssemblyPrefix)$(PsModuleName) + + - + - -