diff --git a/src/SDKs/ResourceGraph/Management/AzSdk.RP.props b/src/SDKs/ResourceGraph/Management/AzSdk.RP.props new file mode 100644 index 000000000000..842a140129b9 --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/AzSdk.RP.props @@ -0,0 +1,7 @@ + + + + ResourceGraph_2018-09-01-preview; + $(PackageTags);$(CommonTags);$(AzureApiTag); + + \ No newline at end of file diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/IOperations.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/IOperations.cs new file mode 100644 index 000000000000..e887be44e664 --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/IOperations.cs @@ -0,0 +1,46 @@ +// +// 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; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Operations operations. + /// + public partial interface IOperations + { + /// + /// 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 + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/IResourceGraphClient.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/IResourceGraphClient.cs new file mode 100644 index 000000000000..fe940384cd33 --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/IResourceGraphClient.cs @@ -0,0 +1,92 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ResourceGraph +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// 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. + /// + JsonSerializerSettings SerializationSettings { get; } + + /// + /// Gets or sets json deserialization settings. + /// + JsonSerializerSettings DeserializationSettings { get; } + + /// + /// Credentials needed for the client to connect to Azure. + /// + ServiceClientCredentials Credentials { get; } + + /// + /// API version. + /// + 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 all + /// subscriptions specified in the request. + /// + /// + /// Request specifying query and its options. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> ResourcesWithHttpMessagesAsync(QueryRequest query, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/Column.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/Column.cs new file mode 100644 index 000000000000..5500c708a9d9 --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/Column.cs @@ -0,0 +1,75 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ResourceGraph.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + 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) + { + Name = name; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets column name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets column data type. Possible values include: 'string', + /// 'integer', 'number', 'boolean', 'object' + /// + [JsonProperty(PropertyName = "type")] + public ColumnDataType Type { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + } + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/ColumnDataType.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/ColumnDataType.cs new file mode 100644 index 000000000000..27c17bfb7ba0 --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/ColumnDataType.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 Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for ColumnDataType. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum ColumnDataType + { + [EnumMember(Value = "string")] + String, + [EnumMember(Value = "integer")] + Integer, + [EnumMember(Value = "number")] + Number, + [EnumMember(Value = "boolean")] + Boolean, + [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; + } + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/Error.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/Error.cs new file mode 100644 index 000000000000..d2219b12995d --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/Error.cs @@ -0,0 +1,101 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ResourceGraph.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Error info. + /// + /// + /// 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, IList details = default(IList)) + { + Code = code; + Message = message; + 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. + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; set; } + + /// + /// Gets or sets a human readable error message. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + /// + /// Gets or sets error details + /// + [JsonProperty(PropertyName = "details")] + public IList Details { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Code == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Code"); + } + if (Message == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Message"); + } + if (Details != null) + { + foreach (var element in Details) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/ErrorDetails.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/ErrorDetails.cs new file mode 100644 index 000000000000..74f6c532f366 --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/ErrorDetails.cs @@ -0,0 +1,90 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ResourceGraph.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// 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 code identifying the specific + /// error. + /// A human readable error message. + /// Unmatched properties from the + /// message are deserialized this collection + public ErrorDetails(string code, string message, IDictionary additionalProperties = default(IDictionary)) + { + AdditionalProperties = additionalProperties; + Code = code; + Message = message; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets unmatched properties from the message are deserialized + /// this collection + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Gets or sets error code identifying the specific error. + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; set; } + + /// + /// Gets or sets a human readable error message. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Code == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Code"); + } + if (Message == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Message"); + } + } + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/ErrorResponse.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/ErrorResponse.cs new file mode 100644 index 000000000000..e6302517d58a --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/ErrorResponse.cs @@ -0,0 +1,72 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ResourceGraph.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Error response. + /// + /// + /// 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) + { + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets error information. + /// + [JsonProperty(PropertyName = "error")] + public Error Error { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Error == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Error"); + } + if (Error != null) + { + Error.Validate(); + } + } + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/ErrorResponseException.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/ErrorResponseException.cs new file mode 100644 index 000000000000..628eb6b70c9f --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/ErrorResponseException.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ResourceGraph.Models +{ + using Microsoft.Rest; + + /// + /// Exception thrown for an invalid response with ErrorResponse + /// information. + /// + public partial class ErrorResponseException : RestException + { + /// + /// Gets information about the associated HTTP request. + /// + public HttpRequestMessageWrapper Request { get; set; } + + /// + /// Gets information about the associated HTTP response. + /// + public 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 ErrorResponseException class. + /// + /// The exception message. + public ErrorResponseException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the ErrorResponseException class. + /// + /// The exception message. + /// Inner exception. + public ErrorResponseException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/Facet.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/Facet.cs new file mode 100644 index 000000000000..ea8af3901958 --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/Facet.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 Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// A facet containing additional statistics on the response of a query. + /// Can be either FacetResult or FacetError. + /// + 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) + { + 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. + /// + [JsonProperty(PropertyName = "expression")] + public string Expression { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Expression == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Expression"); + } + } + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/FacetError.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/FacetError.cs new file mode 100644 index 000000000000..886b24423817 --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/FacetError.cs @@ -0,0 +1,83 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ResourceGraph.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A facet whose execution resulted in an error. + /// + 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, IList errors) + : base(expression) + { + 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. + /// + [JsonProperty(PropertyName = "errors")] + public IList Errors { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (Errors == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Errors"); + } + if (Errors != null) + { + foreach (var element in Errors) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/FacetRequest.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/FacetRequest.cs new file mode 100644 index 000000000000..2a78e731a672 --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/FacetRequest.cs @@ -0,0 +1,79 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ResourceGraph.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + 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)) + { + Expression = expression; + 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 + /// + [JsonProperty(PropertyName = "expression")] + public string Expression { get; set; } + + /// + /// Gets or sets the options for facet evaluation + /// + [JsonProperty(PropertyName = "options")] + public FacetRequestOptions Options { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Expression == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Expression"); + } + if (Options != null) + { + Options.Validate(); + } + } + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/FacetRequestOptions.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/FacetRequestOptions.cs new file mode 100644 index 000000000000..62564cddc6c1 --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/FacetRequestOptions.cs @@ -0,0 +1,81 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ResourceGraph.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + 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 sorting order by the hit count. + /// Possible values include: 'asc', 'desc' + /// The maximum number of facet rows that should be + /// returned. + public FacetRequestOptions(FacetSortOrder? sortOrder = default(FacetSortOrder?), int? top = default(int?)) + { + SortOrder = sortOrder; + Top = top; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the sorting order by the hit count. Possible values + /// include: 'asc', 'desc' + /// + [JsonProperty(PropertyName = "sortOrder")] + public FacetSortOrder? SortOrder { get; set; } + + /// + /// Gets or sets the maximum number of facet rows that should be + /// returned. + /// + [JsonProperty(PropertyName = "$top")] + public int? Top { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Top > 1000) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "Top", 1000); + } + if (Top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Top", 1); + } + } + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/FacetResult.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/FacetResult.cs new file mode 100644 index 000000000000..70c78defe537 --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/FacetResult.cs @@ -0,0 +1,94 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ResourceGraph.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Successfully executed facet containing additional statistics on the + /// response of a query. + /// + 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 table containing the desired facets. Only + /// present if the facet is valid. + public FacetResult(string expression, long totalRecords, int count, Table data) + : base(expression) + { + TotalRecords = totalRecords; + Count = count; + 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. + /// + [JsonProperty(PropertyName = "totalRecords")] + public long TotalRecords { get; set; } + + /// + /// Gets or sets number of records returned in the facet response. + /// + [JsonProperty(PropertyName = "count")] + public int Count { get; set; } + + /// + /// Gets or sets a table containing the desired facets. Only present if + /// the facet is valid. + /// + [JsonProperty(PropertyName = "data")] + public Table Data { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (Data == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Data"); + } + if (Data != null) + { + Data.Validate(); + } + } + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/FacetSortOrder.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/FacetSortOrder.cs new file mode 100644 index 000000000000..4acb5cf0354c --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/FacetSortOrder.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ResourceGraph.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for FacetSortOrder. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum FacetSortOrder + { + [EnumMember(Value = "asc")] + Asc, + [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; + } + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/Operation.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/Operation.cs new file mode 100644 index 000000000000..baa17ec70ecf --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/Operation.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 +{ + using Newtonsoft.Json; + 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)) + { + Name = name; + Display = display; + Origin = origin; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets operation name: {provider}/{resource}/{operation} + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets display metadata associated with the operation. + /// + [JsonProperty(PropertyName = "display")] + public OperationDisplay Display { get; set; } + + /// + /// Gets or sets the origin of operations. + /// + [JsonProperty(PropertyName = "origin")] + public string Origin { get; set; } + + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/OperationDisplay.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/OperationDisplay.cs new file mode 100644 index 000000000000..ac8dedc630c0 --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/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 Newtonsoft.Json; + 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)) + { + Provider = provider; + Resource = resource; + Operation = operation; + Description = description; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets service provider: Microsoft Resource Graph. + /// + [JsonProperty(PropertyName = "provider")] + public string Provider { get; set; } + + /// + /// Gets or sets resource on which the operation is performed etc. + /// + [JsonProperty(PropertyName = "resource")] + public string Resource { get; set; } + + /// + /// Gets or sets type of operation: get, read, delete, etc. + /// + [JsonProperty(PropertyName = "operation")] + public string Operation { get; set; } + + /// + /// Gets or sets description for the operation. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/Page.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/Page.cs new file mode 100644 index 000000000000..a62e35959e9d --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/Page.cs @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ResourceGraph.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + + /// + /// Defines a page in Azure responses. + /// + /// Type of the page content items + [JsonObject] + public class Page : IPage + { + /// + /// Gets the link to the next page. + /// + [JsonProperty("")] + public string NextPageLink { get; private set; } + + [JsonProperty("value")] + private 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 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. + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/QueryRequest.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/QueryRequest.cs new file mode 100644 index 000000000000..a31aafe386ca --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/QueryRequest.cs @@ -0,0 +1,113 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ResourceGraph.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + 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. + /// The resources query. + /// The query evaluation options + /// An array of facet requests to be computed + /// against the query result. + public QueryRequest(IList subscriptions, string query, QueryRequestOptions options = default(QueryRequestOptions), IList facets = default(IList)) + { + Subscriptions = subscriptions; + Query = query; + Options = options; + 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. + /// + [JsonProperty(PropertyName = "subscriptions")] + public IList Subscriptions { get; set; } + + /// + /// Gets or sets the resources query. + /// + [JsonProperty(PropertyName = "query")] + public string Query { get; set; } + + /// + /// Gets or sets the query evaluation options + /// + [JsonProperty(PropertyName = "options")] + public QueryRequestOptions Options { get; set; } + + /// + /// Gets or sets an array of facet requests to be computed against the + /// query result. + /// + [JsonProperty(PropertyName = "facets")] + public IList Facets { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Subscriptions == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Subscriptions"); + } + if (Query == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Query"); + } + if (Options != null) + { + Options.Validate(); + } + if (Facets != null) + { + foreach (var element in Facets) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/QueryRequestOptions.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/QueryRequestOptions.cs new file mode 100644 index 000000000000..cfb9ff8f0cc9 --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/QueryRequestOptions.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 Microsoft.Rest; + using Newtonsoft.Json; + 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. + public QueryRequestOptions(string skipToken = default(string), int? top = default(int?), int? skip = default(int?)) + { + SkipToken = skipToken; + Top = top; + Skip = skip; + 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. + /// + [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. + /// + [JsonProperty(PropertyName = "$top")] + public int? Top { get; set; } + + /// + /// Gets or sets the number of rows to skip from the beginning of the + /// results. Overrides the next page offset when ```$skipToken``` + /// property is present. + /// + [JsonProperty(PropertyName = "$skip")] + public int? Skip { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Top > 1000) + { + throw new ValidationException(ValidationRules.InclusiveMaximum, "Top", 1000); + } + if (Top < 1) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Top", 1); + } + if (Skip < 0) + { + throw new ValidationException(ValidationRules.InclusiveMinimum, "Skip", 0); + } + } + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/QueryResponse.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/QueryResponse.cs new file mode 100644 index 000000000000..9b648c4b757e --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/QueryResponse.cs @@ -0,0 +1,133 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ResourceGraph.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + 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' + /// Query output in tabular format. + /// When present, the value can be passed to a + /// subsequent query call (together with the same query and + /// subscriptions used in the current request) to retrieve the next + /// page of data. + /// Query facets. + public QueryResponse(long totalRecords, long count, ResultTruncated resultTruncated, Table data, string skipToken = default(string), IList facets = default(IList)) + { + TotalRecords = totalRecords; + Count = count; + ResultTruncated = resultTruncated; + SkipToken = skipToken; + Data = data; + 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. + /// + [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. + /// + [JsonProperty(PropertyName = "count")] + public long Count { get; set; } + + /// + /// Gets or sets indicates whether the query results are truncated. + /// Possible values include: 'true', 'false' + /// + [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 subscriptions used in + /// the current request) to retrieve the next page of data. + /// + [JsonProperty(PropertyName = "$skipToken")] + public string SkipToken { get; set; } + + /// + /// Gets or sets query output in tabular format. + /// + [JsonProperty(PropertyName = "data")] + public Table Data { get; set; } + + /// + /// Gets or sets query facets. + /// + [JsonProperty(PropertyName = "facets")] + public IList Facets { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Data == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Data"); + } + if (Data != null) + { + Data.Validate(); + } + if (Facets != null) + { + foreach (var element in Facets) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/ResultTruncated.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/ResultTruncated.cs new file mode 100644 index 000000000000..15c557e9791b --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/ResultTruncated.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ResourceGraph.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for ResultTruncated. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum ResultTruncated + { + [EnumMember(Value = "true")] + True, + [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; + } + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/Table.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/Table.cs new file mode 100644 index 000000000000..d4f1d07403f2 --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Models/Table.cs @@ -0,0 +1,89 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ResourceGraph.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + 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(IList columns, IList> rows) + { + Columns = columns; + Rows = rows; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets query result column descriptors. + /// + [JsonProperty(PropertyName = "columns")] + public IList Columns { get; set; } + + /// + /// Gets or sets query result rows. + /// + [JsonProperty(PropertyName = "rows")] + public IList> Rows { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Columns == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Columns"); + } + if (Rows == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Rows"); + } + if (Columns != null) + { + foreach (var element in Columns) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Operations.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Operations.cs new file mode 100644 index 000000000000..090458295d96 --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/Operations.cs @@ -0,0 +1,227 @@ +// +// 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; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Operations operations. + /// + internal partial class Operations : 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"); + } + 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 Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.ResourceGraph/operations").ToString(); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/OperationsExtensions.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/OperationsExtensions.cs new file mode 100644 index 000000000000..4ecc6547f019 --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/OperationsExtensions.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 +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for Operations. + /// + public static partial class OperationsExtensions + { + /// + /// Lists all of the available REST API operations. + /// + /// + /// The operations group for this extension method. + /// + public static IEnumerable List(this IOperations operations) + { + return 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 Task> ListAsync(this IOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/ResourceGraphClient.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/ResourceGraphClient.cs new file mode 100644 index 000000000000..7f7e15ecf0a9 --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/ResourceGraphClient.cs @@ -0,0 +1,545 @@ +// +// 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 Microsoft.Rest.Serialization; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Azure Resource Graph API Reference + /// + public partial class ResourceGraphClient : ServiceClient, IResourceGraphClient, IAzureClient + { + /// + /// The base URI of the service. + /// + public System.Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + public JsonSerializerSettings SerializationSettings { get; private set; } + + /// + /// Gets or sets json deserialization settings. + /// + public JsonSerializerSettings DeserializationSettings { get; private set; } + + /// + /// Credentials needed for the client to connect to Azure. + /// + public ServiceClientCredentials Credentials { get; private set; } + + /// + /// API version. + /// + 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(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + Initialize(); + } + + /// + /// Initializes a new instance of the ResourceGraphClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected ResourceGraphClient(params DelegatingHandler[] handlers) : base(handlers) + { + 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(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + 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 DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + 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, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + 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(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + 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(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpClient) : this(httpClient, disposeHttpClient) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + 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(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + 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, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + BaseUri = baseUri; + Credentials = credentials; + if (Credentials != null) + { + 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. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public ResourceGraphClient(System.Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + BaseUri = baseUri; + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// An optional partial-method to perform custom initialization. + /// + partial void CustomInitialize(); + /// + /// Initializes client properties. + /// + private void Initialize() + { + Operations = new Operations(this); + BaseUri = new System.Uri("https://management.azure.com"); + ApiVersion = "2018-09-01-preview"; + AcceptLanguage = "en-US"; + LongRunningOperationRetryTimeout = 30; + GenerateClientRequestId = true; + SerializationSettings = new 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 ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + DeserializationSettings = new JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter("resultType")); + DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter("resultType")); + CustomInitialize(); + DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); + } + /// + /// Queries the resources managed by Azure Resource Manager for all + /// subscriptions 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 Task> ResourcesWithHttpMessagesAsync(QueryRequest query, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion"); + } + if (query == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "query"); + } + if (query != null) + { + query.Validate(); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("query", query); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Resources", tracingParameters); + } + // Construct URL + var _baseUrl = BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.ResourceGraph/resources").ToString(); + List _queryParameters = new List(); + if (ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (GenerateClientRequestId != null && GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(query != null) + { + _requestContent = SafeJsonConvert.SerializeObject(query, SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/ResourceGraphClientExtensions.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/ResourceGraphClientExtensions.cs new file mode 100644 index 000000000000..f9b1e8b4e9ca --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/ResourceGraphClientExtensions.cs @@ -0,0 +1,63 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ResourceGraph +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ResourceGraphClient. + /// + public static partial class ResourceGraphClientExtensions + { + /// + /// Queries the resources managed by Azure Resource Manager for all + /// subscriptions specified in the request. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Request specifying query and its options. + /// + public static QueryResponse Resources(this IResourceGraphClient operations, QueryRequest query) + { + return operations.ResourcesAsync(query).GetAwaiter().GetResult(); + } + + /// + /// Queries the resources managed by Azure Resource Manager for all + /// subscriptions specified in the request. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Request specifying query and its options. + /// + /// + /// The cancellation token. + /// + public static async Task ResourcesAsync(this IResourceGraphClient operations, QueryRequest query, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ResourcesWithHttpMessagesAsync(query, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/SdkInfo_ResourceGraphClient.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/SdkInfo_ResourceGraphClient.cs new file mode 100644 index 000000000000..2344c75d535e --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Generated/SdkInfo_ResourceGraphClient.cs @@ -0,0 +1,39 @@ + +// +// 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; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_ResourceGraphClient + { + get + { + return new Tuple[] + { + new Tuple("ResourceGraph", "Operations", "2018-09-01-preview"), + new Tuple("ResourceGraph", "Resources", "2018-09-01-preview"), + }.AsEnumerable(); + } + } + // BEGIN: Code Generation Metadata Section + public static readonly String AutoRestVersion = "latest"; + public static readonly String AutoRestBootStrapperVersion = "autorest@2.0.4283"; + public static readonly String AutoRestCmdExecuted = "cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/resourcegraph/resource-manager/readme.md --csharp --version=latest --reflect-api-versions --csharp-sdks-folder=C:\\git\\azure-sdk-for-net\\src\\SDKs"; + public static readonly String GithubForkName = "Azure"; + public static readonly String GithubBranchName = "master"; + public static readonly String GithubCommidId = "15929694cc9babeb19c0e834f8babe23af323b75"; + public static readonly String CodeGenerationErrors = ""; + public static readonly String GithubRepoName = "azure-rest-api-specs"; + // END: Code Generation Metadata Section + } +} + diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Microsoft.Azure.Management.ResourceGraph.csproj b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Microsoft.Azure.Management.ResourceGraph.csproj new file mode 100644 index 000000000000..07f49e8cec5c --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Microsoft.Azure.Management.ResourceGraph.csproj @@ -0,0 +1,25 @@ + + + + + + + Microsoft.Azure.Management.ResourceGraph + Provides Resource Graph operations for Microsoft Azure. + Microsoft.Azure.Management.ResourceGraph + 0.9.0-preview + Azure;ResourceGraph; + + + + + + net452;netstandard1.4 + + + + + + \ No newline at end of file diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Properties/AssemblyInfo.cs b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..dc51fa45f979 --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System.Reflection; +using System.Resources; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Microsoft Azure Resource Graph Library")] +[assembly: AssemblyDescription("Provides Microsoft Azure Resource Graph operations.")] + +[assembly: AssemblyVersion("0.9.0.0")] +[assembly: AssemblyFileVersion("0.9.0.0")] + +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Microsoft Azure .NET SDK")] +[assembly: AssemblyCopyright("Copyright (c) Microsoft Corporation")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: NeutralResourcesLanguage("en")] diff --git a/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/generate.ps1 b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/generate.ps1 new file mode 100644 index 000000000000..84c1c7fd126f --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/Management.ResourceGraph/generate.ps1 @@ -0,0 +1 @@ +Start-AutoRestCodeGeneration -ResourceProvider "resourcegraph/resource-manager" -AutoRestVersion "latest" diff --git a/src/SDKs/ResourceGraph/Management/ResourceGraph.Tests/Helpers/RecordedDelegatingHandler.cs b/src/SDKs/ResourceGraph/Management/ResourceGraph.Tests/Helpers/RecordedDelegatingHandler.cs new file mode 100644 index 000000000000..b1b4d6658c50 --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/ResourceGraph.Tests/Helpers/RecordedDelegatingHandler.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System; +using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Threading.Tasks; + +namespace Microsoft.Azure.Management.ResourceGraph.Tests.Helpers +{ + public class RecordedDelegatingHandler : DelegatingHandler + { + private readonly HttpResponseMessage _response; + + public RecordedDelegatingHandler() + { + StatusCodeToReturn = HttpStatusCode.OK; + } + + public RecordedDelegatingHandler(HttpResponseMessage response) + { + StatusCodeToReturn = HttpStatusCode.OK; + + _response = response; + if (null == _response.Content) + { + _response.Content = new StringContent(string.Empty); + } + } + + public HttpStatusCode StatusCodeToReturn { get; set; } + + public string Request { get; private set; } + + public HttpRequestHeaders RequestHeaders { get; private set; } + + public HttpContentHeaders ContentHeaders { get; private set; } + + public HttpMethod Method { get; private set; } + + public Uri Uri { get; private set; } + + public bool IsPassThrough { get; set; } + + protected override async Task SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) + { + // Save request + Request = null == request.Content ? string.Empty : await request.Content.ReadAsStringAsync(); + RequestHeaders = request.Headers; + if (null != request.Content) + { + ContentHeaders = request.Content.Headers; + } + Method = request.Method; + Uri = request.RequestUri; + + if (IsPassThrough) + { + return await base.SendAsync(request, cancellationToken); + } + + return _response ?? new HttpResponseMessage(StatusCodeToReturn) { Content = new StringContent("") }; + } + } +} diff --git a/src/SDKs/ResourceGraph/Management/ResourceGraph.Tests/Microsoft.Azure.Management.ResourceGraph.Tests.csproj b/src/SDKs/ResourceGraph/Management/ResourceGraph.Tests/Microsoft.Azure.Management.ResourceGraph.Tests.csproj new file mode 100644 index 000000000000..51efb645e3a2 --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/ResourceGraph.Tests/Microsoft.Azure.Management.ResourceGraph.Tests.csproj @@ -0,0 +1,33 @@ + + + + Microsoft.Azure.Management.ResourceGraph.Tests + 1.0.0 + ResourceGraph.Tests Class Library + Microsoft Corporation + Microsoft.Azure.Management.ResourceGraph.Tests + + + + + + + + + true + + + + + + + + + PreserveNewest + + + + + + + diff --git a/src/SDKs/ResourceGraph/Management/ResourceGraph.Tests/ResourceGraphTests.cs b/src/SDKs/ResourceGraph/Management/ResourceGraph.Tests/ResourceGraphTests.cs new file mode 100644 index 000000000000..ebc9d6e67c18 --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/ResourceGraph.Tests/ResourceGraphTests.cs @@ -0,0 +1,248 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System; +using System.Net; + +using Microsoft.Azure.Management.ResourceGraph.Models; +using Microsoft.Azure.Management.ResourceGraph.Tests.Helpers; +using Microsoft.Azure.Test.HttpRecorder; +using Microsoft.Rest.ClientRuntime.Azure.TestFramework; +using Xunit; + +namespace Microsoft.Azure.Management.ResourceGraph.Tests +{ + using System.Collections.Generic; + + using Newtonsoft.Json.Linq; + + /// + /// ResourceGraph tests + /// + /// + public class ResourceGraphTests : TestBase + { + /// + /// Gets or sets the test environment. + /// + private static TestEnvironment TestEnvironment { get; set; } + + /// + /// Gets the resource graph client. + /// + /// The context. + /// + private static ResourceGraphClient GetResourceGraphClient(MockContext context) + { + if (TestEnvironment == null && HttpMockServer.Mode == HttpRecorderMode.Record) + { + TestEnvironment = TestEnvironmentFactory.GetTestEnvironment(); + } + + var handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK, IsPassThrough = true }; + + var policyInsightsClient = HttpMockServer.Mode == HttpRecorderMode.Record + ? context.GetServiceClient(TestEnvironment, handlers: handler) + : context.GetServiceClient(handlers: handler); + + return policyInsightsClient; + } + + /// + /// Resources basic query test. + /// + [Fact] + public void ResourcesBasicQueryTest() + { + using (var context = MockContext.Start(this.GetType().FullName)) + { + var resourceGraphClient = GetResourceGraphClient(context); + var query = new QueryRequest + { + Subscriptions = new List { "00000000-0000-0000-0000-000000000000" }, + Query = "project id, tags, properties | limit 2" + }; + + var queryResponse = resourceGraphClient.Resources(query); + + // Top-level response fields + Assert.Equal(2, queryResponse.Count); + Assert.Equal(2, queryResponse.TotalRecords); + Assert.Null(queryResponse.SkipToken); + Assert.Equal(ResultTruncated.False, queryResponse.ResultTruncated); + Assert.NotNull(queryResponse.Data); + Assert.NotNull(queryResponse.Facets); + Assert.Empty(queryResponse.Facets); + + // Data columns + Assert.NotNull(queryResponse.Data.Columns); + Assert.Equal(3, queryResponse.Data.Columns.Count); + Assert.NotNull(queryResponse.Data.Columns[0].Name); + Assert.NotNull(queryResponse.Data.Columns[1].Name); + Assert.NotNull(queryResponse.Data.Columns[2].Name); + Assert.Equal(ColumnDataType.String, queryResponse.Data.Columns[0].Type); + Assert.Equal(ColumnDataType.Object, queryResponse.Data.Columns[1].Type); + Assert.Equal(ColumnDataType.Object, queryResponse.Data.Columns[2].Type); + + // Data rows + Assert.NotNull(queryResponse.Data.Rows); + Assert.Equal(2, queryResponse.Data.Rows.Count); + Assert.Equal(3, queryResponse.Data.Rows[0].Count); + Assert.IsType(queryResponse.Data.Rows[0][0]); + Assert.IsType(queryResponse.Data.Rows[0][1]); + Assert.IsType(queryResponse.Data.Rows[0][2]); + } + } + + [Fact] + public void ResourcesQueryOptionsTest() + { + using (var context = MockContext.Start(this.GetType().FullName)) + { + var resourceGraphClient = GetResourceGraphClient(context); + var query = new QueryRequest + { + Subscriptions = new List { "00000000-0000-0000-0000-000000000000" }, + Query = "project id", + Options = new QueryRequestOptions + { + SkipToken = "82aw3vQlArEastJ24LABY8oPgQLesIyAyzYs2g6/aOOOmJHSYFj39fODurJV5e2tTFFebWcfxn7n5edicA8u6HgSJe1GCEk5HjxwLkeJiye2LVZDC7TaValkJbsk9JqY4yv5c7iRiLqgO34RbHEeVfLJpa56u4RZu0K+GpQvnBRPyAhy3KbwhZWpU5Nnqnud2whGb5WKdlL8xF7wnQaUnUN2lns8WwqwM4rc0VK4BbQt/WfWWcYJivSAyB3m4Z5g73df1KiU4C+K8auvUMpLPYVxxnKC/YZz42YslVAWXXUmuGOaM2SfLHRO6o4O9DgXlUgYjeFWqIbAkmMiVEqU", + Top = 4, + Skip = 8 + } + }; + + var queryResponse = resourceGraphClient.Resources(query); + + // Top-level response fields + Assert.Equal(4, queryResponse.Count); + Assert.Equal(743, queryResponse.TotalRecords); + Assert.NotNull(queryResponse.SkipToken); + Assert.Equal(ResultTruncated.False, queryResponse.ResultTruncated); + Assert.NotNull(queryResponse.Data); + Assert.NotNull(queryResponse.Facets); + Assert.Empty(queryResponse.Facets); + + // Data columns + Assert.NotNull(queryResponse.Data.Columns); + Assert.Single(queryResponse.Data.Columns); + Assert.NotNull(queryResponse.Data.Columns[0].Name); + Assert.Equal(ColumnDataType.String, queryResponse.Data.Columns[0].Type); + + // Data rows + Assert.NotNull(queryResponse.Data.Rows); + Assert.Equal(4, queryResponse.Data.Rows.Count); + Assert.Single(queryResponse.Data.Rows[0]); + Assert.IsType(queryResponse.Data.Rows[0][0]); + } + } + + [Fact] + public void ResourcesFacetQueryTest() + { + using (var context = MockContext.Start(this.GetType().FullName)) + { + var resourceGraphClient = GetResourceGraphClient(context); + + var validExpression = "location"; + var invalidExpression = "nonExistingColumn"; + var query = new QueryRequest + { + Subscriptions = new List { "00000000-0000-0000-0000-000000000000" }, + Query = "project id, location | limit 10", + Facets = new List + { + new FacetRequest + { + Expression = validExpression, + Options = new FacetRequestOptions + { + SortOrder = FacetSortOrder.Desc, + Top = 4 + } + }, + new FacetRequest + { + Expression = invalidExpression, + Options = new FacetRequestOptions + { + SortOrder = FacetSortOrder.Desc, + Top = 4 + } + } + } + }; + + var queryResponse = resourceGraphClient.Resources(query); + + // Top-level response fields + Assert.Equal(10, queryResponse.Count); + Assert.Equal(10, queryResponse.TotalRecords); + Assert.Null(queryResponse.SkipToken); + Assert.Equal(ResultTruncated.False, queryResponse.ResultTruncated); + Assert.NotNull(queryResponse.Data); + Assert.NotNull(queryResponse.Facets); + Assert.Equal(2, queryResponse.Facets.Count); + + // Valid facet fields + var validFacet = queryResponse.Facets[0] as FacetResult; + Assert.NotNull(validFacet); + Assert.Equal(validExpression, validFacet.Expression); + Assert.Equal(4, validFacet.TotalRecords); + Assert.Equal(4, validFacet.Count); + + // Valid facet columns + Assert.NotNull(validFacet.Data.Columns); + Assert.Equal(2, validFacet.Data.Columns.Count); + Assert.NotNull(validFacet.Data.Columns[0].Name); + Assert.NotNull(validFacet.Data.Columns[1].Name); + Assert.Equal(ColumnDataType.String, validFacet.Data.Columns[0].Type); + Assert.Equal(ColumnDataType.Integer, validFacet.Data.Columns[1].Type); + + // Valid facet rows + Assert.NotNull(validFacet.Data.Rows); + Assert.Equal(4, validFacet.Data.Rows.Count); + Assert.Equal(2, validFacet.Data.Rows[0].Count); + Assert.IsType(validFacet.Data.Rows[0][0]); + Assert.IsType(validFacet.Data.Rows[0][1]); + + // Invalid facet + var invalidFacet = queryResponse.Facets[1] as FacetError; + Assert.NotNull(invalidFacet); + Assert.Equal(invalidExpression, invalidFacet.Expression); + Assert.NotNull(invalidFacet.Errors); + Assert.InRange(invalidFacet.Errors.Count, 1, int.MaxValue); + Assert.NotNull(invalidFacet.Errors[0].Code); + Assert.NotNull(invalidFacet.Errors[1].Code); + } + } + + [Fact] + public void ResourcesMalformedQueryTest() + { + using (var context = MockContext.Start(this.GetType().FullName)) + { + var resourceGraphClient = GetResourceGraphClient(context); + var query = new QueryRequest + { + Subscriptions = new List { "00000000-0000-0000-0000-000000000000" }, + Query = "project id, location | where where" + }; + + var exception = + Assert.Throws( + () => resourceGraphClient.Resources(query)); + + var error = exception.Body.Error; + Assert.NotNull(error.Code); + Assert.NotNull(error.Message); + Assert.NotNull(error.Details); + Assert.InRange(error.Details.Count, 1, int.MaxValue); + Assert.NotNull(error.Details[0].Code); + Assert.NotNull(error.Details[0].Message); + Assert.NotNull(error.Details[0].AdditionalProperties); + Assert.Equal(4, error.Details[0].AdditionalProperties.Count); + } + } + } +} diff --git a/src/SDKs/ResourceGraph/Management/ResourceGraph.Tests/SessionRecords/Microsoft.Azure.Management.ResourceGraph.Tests.ResourceGraphTests/ResourcesBasicQueryTest.json b/src/SDKs/ResourceGraph/Management/ResourceGraph.Tests/SessionRecords/Microsoft.Azure.Management.ResourceGraph.Tests.ResourceGraphTests/ResourcesBasicQueryTest.json new file mode 100644 index 000000000000..2dc8997ea6ab --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/ResourceGraph.Tests/SessionRecords/Microsoft.Azure.Management.ResourceGraph.Tests.ResourceGraphTests/ResourcesBasicQueryTest.json @@ -0,0 +1,75 @@ +{ + "Entries": [ + { + "RequestUri": "/providers/Microsoft.ResourceGraph/resources?api-version=2018-09-01-preview", + "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VHcmFwaC9yZXNvdXJjZXM/YXBpLXZlcnNpb249MjAxOC0wOS0wMS1wcmV2aWV3", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"subscriptions\": [\r\n \"00000000-0000-0000-0000-000000000000\"\r\n ],\r\n \"query\": \"project id, tags, properties | limit 2\"\r\n}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "d2cbefd0-8265-4e02-bf5f-9229c30e0ca9" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "Microsoft.Azure.Management.ResourceGraph.ResourceGraphClient/1.0.0.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "129" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Fri, 31 Aug 2018 23:24:47 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-HTTPAPI/2.0" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "x-ms-ratelimit-remaining-tenant-writes": [ + "1199" + ], + "x-ms-request-id": [ + "cf5a7008-1435-4b18-9fc6-f4c4e26aa562" + ], + "x-ms-correlation-request-id": [ + "cf5a7008-1435-4b18-9fc6-f4c4e26aa562" + ], + "x-ms-routing-request-id": [ + "WESTUS2:20180831T232447Z:cf5a7008-1435-4b18-9fc6-f4c4e26aa562" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "1679" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\"totalRecords\":2,\"count\":2,\"data\":{\"columns\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"tags\",\"type\":\"object\"},{\"name\":\"properties\",\"type\":\"object\"}],\"rows\":[[\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/zarttest1faaede5-14b9-43b9-8836-3b8df81aa6f2/providers/Microsoft.StreamAnalytics/streamingjobs/zarttest28000000\",{},{\"provisioningState\":\"Succeeded\",\"sku\":{\"name\":\"Standard\"},\"eventsLateArrivalMaxDelayInSeconds\":5,\"createdDate\":\"2018-07-26T01:17:29.3470000Z\",\"compatibilityLevel\":\"1.0\",\"outputErrorPolicy\":\"Stop\",\"dataLocale\":\"en-US\",\"jobState\":\"Created\",\"package\":null,\"jobType\":\"Cloud\",\"jobId\":\"00000000-0000-0000-0000-000000000000\"}],[\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/newzarttestefd4b1a7-6480-40bb-bac5-f23376ebb04d/providers/Microsoft.Storage/storageAccounts/zarttest9b000000\",{},{\"provisioningState\":\"Succeeded\",\"creationTime\":\"2018-08-04T19:23:48.4690000Z\",\"supportsHttpsTrafficOnly\":true,\"trustedDirectories\":[\"72f988bf-86f1-41af-91ab-2d7cd011db47\"],\"primaryEndpoints\":{\"blob\":\"https://zarttest9b000000.blob.core.windows.net/\",\"file\":\"https://zarttest9b000000.file.core.windows.net/\",\"table\":\"https://zarttest9b000000.table.core.windows.net/\",\"queue\":\"https://zarttest9b000000.queue.core.windows.net/\"},\"statusOfPrimary\":\"available\",\"primaryLocation\":\"eastus\",\"networkAcls\":{\"virtualNetworkRules\":[],\"defaultAction\":\"Allow\",\"ipRules\":[],\"bypass\":\"AzureServices\"},\"encryption\":{\"services\":{\"blob\":{\"lastEnabledTime\":\"2018-08-04T19:23:48.5940000Z\",\"enabled\":true},\"file\":{\"lastEnabledTime\":\"2018-08-04T19:23:48.5940000Z\",\"enabled\":true}},\"keySource\":\"Microsoft.Storage\"}}]]},\"facets\":[],\"resultTruncated\":\"false\"}", + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": { + "SubscriptionId": "00000000-0000-0000-0000-000000000000" + } +} \ No newline at end of file diff --git a/src/SDKs/ResourceGraph/Management/ResourceGraph.Tests/SessionRecords/Microsoft.Azure.Management.ResourceGraph.Tests.ResourceGraphTests/ResourcesFacetQueryTest.json b/src/SDKs/ResourceGraph/Management/ResourceGraph.Tests/SessionRecords/Microsoft.Azure.Management.ResourceGraph.Tests.ResourceGraphTests/ResourcesFacetQueryTest.json new file mode 100644 index 000000000000..044a65e0c230 --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/ResourceGraph.Tests/SessionRecords/Microsoft.Azure.Management.ResourceGraph.Tests.ResourceGraphTests/ResourcesFacetQueryTest.json @@ -0,0 +1,75 @@ +{ + "Entries": [ + { + "RequestUri": "/providers/Microsoft.ResourceGraph/resources?api-version=2018-09-01-preview", + "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VHcmFwaC9yZXNvdXJjZXM/YXBpLXZlcnNpb249MjAxOC0wOS0wMS1wcmV2aWV3", + "RequestMethod": "POST", + "RequestBody": "{\"subscriptions\": [\"00000000-0000-0000-0000-000000000000\"], \"query\": \"project id, location | limit 10\", \"facets\": [{\"expression\": \"location\", \"options\": {\"sortOrder\": \"desc\", \"$top\": 4}}, {\"expression\": \"nonExistingColumn\", \"options\": {\"sortOrder\": \"desc\", \"$top\": 4}}]}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "077d2050-2bc1-4be5-a8d0-9001e8a502db" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "Microsoft.Azure.Management.ResourceGraph.ResourceGraphClient/1.0.0.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "403" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Fri, 31 Aug 2018 23:24:55 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-HTTPAPI/2.0" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "x-ms-ratelimit-remaining-tenant-writes": [ + "1199" + ], + "x-ms-request-id": [ + "e9d37026-4efc-4c35-886a-0bc3bbe600ad" + ], + "x-ms-correlation-request-id": [ + "e9d37026-4efc-4c35-886a-0bc3bbe600ad" + ], + "x-ms-routing-request-id": [ + "WESTUS2:20180831T232456Z:e9d37026-4efc-4c35-886a-0bc3bbe600ad" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "2472" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\"totalRecords\":10,\"count\":10,\"data\":{\"columns\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"location\",\"type\":\"string\"}],\"rows\":[[\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/zarttest1f000000-14b9-43b9-8836-3b8df81aa6f2/providers/Microsoft.StreamAnalytics/streamingjobs/zarttest28000000\",\"southcentralus\"],[\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test/providers/Microsoft.Storage/storageAccounts/testsouthcentralus\",\"southcentralus\"],[\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/newzarttest30000000-5d0c-432c-8652-102e3aa336b6/providers/Microsoft.Storage/storageAccounts/zarttest93000000\",\"eastus\"],[\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/backup/providers/Microsoft.ClassicCompute/domainNames/rp-a\",\"westcentralus\"],[\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test/providers/Microsoft.Storage/storageAccounts/test1\",\"southcentralus\"],[\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/k8stest_centralus/providers/Microsoft.Compute/virtualMachines/aks-default-34000000-0/extensions/cse-agent-0\",\"centralus\"],[\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/pere/providers/Microsoft.Network/networkSecurityGroups/shouldFail-nsg\",\"eastus\"],[\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/newzarttestdd000000-bfc5-44f1-b6a9-aabdc7a1e614/providers/Microsoft.Storage/storageAccounts/zarttest43000000\",\"eastus\"],[\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/newzarttest60000000-3713-4c51-9e6b-c96a30f0fbb7/providers/Microsoft.Storage/storageAccounts/zarttestd2000000\",\"eastus\"],[\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ManageRG/providers/Microsoft.EventHub/namespaces/resourceuse\",\"eastus\"]]},\"facets\":[{\"expression\":\"location\",\"totalRecords\":4,\"count\":4,\"data\":{\"columns\":[{\"name\":\"location\",\"type\":\"string\"},{\"name\":\"count\",\"type\":\"integer\"}],\"rows\":[[\"eastus\",5],[\"southcentralus\",3],[\"centralus\",1],[\"westcentralus\",1]]},\"resultType\":\"FacetResult\"},{\"expression\":\"nonExistingColumn\",\"errors\":[{\"code\":\"NoValidColumns\",\"message\":\"No valid columns in facet expression.\"},{\"code\":\"InvalidColumnNames\",\"message\":\"Invalid column names: [nonExistingColumn].\"}],\"resultType\":\"FacetError\"}],\"resultTruncated\":\"false\"}", + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": { + "SubscriptionId": "00000000-0000-0000-0000-000000000000" + } +} \ No newline at end of file diff --git a/src/SDKs/ResourceGraph/Management/ResourceGraph.Tests/SessionRecords/Microsoft.Azure.Management.ResourceGraph.Tests.ResourceGraphTests/ResourcesMalformedQueryTest.json b/src/SDKs/ResourceGraph/Management/ResourceGraph.Tests/SessionRecords/Microsoft.Azure.Management.ResourceGraph.Tests.ResourceGraphTests/ResourcesMalformedQueryTest.json new file mode 100644 index 000000000000..0d1993a0c3c7 --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/ResourceGraph.Tests/SessionRecords/Microsoft.Azure.Management.ResourceGraph.Tests.ResourceGraphTests/ResourcesMalformedQueryTest.json @@ -0,0 +1,75 @@ +{ + "Entries": [ + { + "RequestUri": "/providers/Microsoft.ResourceGraph/resources?api-version=2018-09-01-preview", + "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VHcmFwaC9yZXNvdXJjZXM/YXBpLXZlcnNpb249MjAxOC0wOS0wMS1wcmV2aWV3", + "RequestMethod": "POST", + "RequestBody": "{\"subscriptions\": [\"d0610b27-9663-4c05-89f8-5b4be01e86a5\"], \"query\": \"project id, location | where where\"}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "23f526de-829e-46db-a108-8ab2c2a34d7e" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "Microsoft.Azure.Management.ResourceGraph.ResourceGraphClient/1.0.0.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "125" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Fri, 31 Aug 2018 23:24:52 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-HTTPAPI/2.0" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "x-ms-ratelimit-remaining-tenant-writes": [ + "1199" + ], + "x-ms-request-id": [ + "c213e6d0-e1e0-4e91-8a4e-e1d1843b3bbd" + ], + "x-ms-correlation-request-id": [ + "c213e6d0-e1e0-4e91-8a4e-e1d1843b3bbd" + ], + "x-ms-routing-request-id": [ + "WESTUS2:20180831T232453Z:c213e6d0-e1e0-4e91-8a4e-e1d1843b3bbd" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "232" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\"error\":{\"code\":\"InvalidQuery\",\"message\":\"Query validation error\",\"details\":[{\"code\":\"ParserFailure\",\"message\":\"Parser failure\",\"line\":1,\"characterPositionInLine\":34,\"token\":\"\",\"expectedToken\":\"\u0178\"}]}}", + "StatusCode": 400 + } + ], + "Names": {}, + "Variables": { + "SubscriptionId": "00000000-0000-0000-0000-000000000000" + } +} \ No newline at end of file diff --git a/src/SDKs/ResourceGraph/Management/ResourceGraph.Tests/SessionRecords/Microsoft.Azure.Management.ResourceGraph.Tests.ResourceGraphTests/ResourcesQueryOptionsTest.json b/src/SDKs/ResourceGraph/Management/ResourceGraph.Tests/SessionRecords/Microsoft.Azure.Management.ResourceGraph.Tests.ResourceGraphTests/ResourcesQueryOptionsTest.json new file mode 100644 index 000000000000..5b110f6afc7d --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/ResourceGraph.Tests/SessionRecords/Microsoft.Azure.Management.ResourceGraph.Tests.ResourceGraphTests/ResourcesQueryOptionsTest.json @@ -0,0 +1,75 @@ +{ + "Entries": [ + { + "RequestUri": "/providers/Microsoft.ResourceGraph/resources?api-version=2018-09-01-preview", + "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VHcmFwaC9yZXNvdXJjZXM/YXBpLXZlcnNpb249MjAxOC0wOS0wMS1wcmV2aWV3", + "RequestMethod": "POST", + "RequestBody": "{\"subscriptions\": [\"d0610b27-9663-4c05-89f8-5b4be01e86a5\"], \"query\": \"project id\", \"options\": {\"$skipToken\": \"82aw3vQlArEastJ24LABY8oPgQLesIyAyzYs2g6/aOOOmJHSYFj39fODurJV5e2tTFFebWcfxn7n5edicA8u6HgSJe1GCEk5HjxwLkeJiye2LVZDC7TaValkJbsk9JqY4yv5c7iRiLqgO34RbHEeVfLJpa56u4RZu0K+GpQvnBRPyAhy3KbwhZWpU5Nnqnud2whGb5WKdlL8xF7wnQaUnUN2lns8WwqwM4rc0VK4BbQt/WfWWcYJivSAyB3m4Z5g73df1KiU4C+K8auvUMpLPYVxxnKC/YZz42YslVAWXXUmuGOaM2SfLHRO6o4O9DgXlUgYjeFWqIbAkmMiVEqU\", \"$top\": 4, \"$skip\": 8}}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "a29e441c-d71f-48e5-9988-ff4d9ddc7c99" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26614.01", + "Microsoft.Azure.Management.ResourceGraph.ResourceGraphClient/1.0.0.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "458" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Fri, 31 Aug 2018 23:24:49 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Server": [ + "Microsoft-HTTPAPI/2.0" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "x-ms-ratelimit-remaining-tenant-writes": [ + "1199" + ], + "x-ms-request-id": [ + "e242e4e7-39e0-4c74-85f5-8abb009a2711" + ], + "x-ms-correlation-request-id": [ + "e242e4e7-39e0-4c74-85f5-8abb009a2711" + ], + "x-ms-routing-request-id": [ + "WESTUS2:20180831T232450Z:e242e4e7-39e0-4c74-85f5-8abb009a2711" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "1098" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\"totalRecords\":743,\"count\":4,\"data\":{\"columns\":[{\"name\":\"id\",\"type\":\"string\"}],\"rows\":[[\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/backup/providers/Microsoft.ClassicCompute/domainNames/admin-a\"],[\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/backup/providers/Microsoft.ClassicCompute/domainNames/admin-b\"],[\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/backup/providers/Microsoft.Network/trafficmanagerprofiles/admin\"],[\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/RP/providers/Microsoft.ClassicCompute/domainNames/rp-a\"]]},\"facets\":[],\"resultTruncated\":\"false\",\"$skipToken\":\"ceXHDV/5yajn1stYtSCyQ32ULLF0jGv9oazG14qvdgwdAQNDUPHjt6MIlJZ2Y/K8z7fb+qo9wguegf8QYW0c7rqwtXUghJvKkPBENcn1O17nQxtjXeq6s8sD64D8t5P9NIHntl70D95yuVUjHF6/dsvVK33wKyvORwPTCbZrSj+pfz2yd5spa93izzOu06PcyFvcvCJAzZ5scImnVDqS700hR63izVwyETJtQluoqSPYkhxAOVk/+ThWlN0DKy9OfUE34M9PZSQz2QTWXKpUK1+okRfH/B2RVdXro60ZnNMrdPtglA5w7oEs5Ivq20IE4RtPfg97UEbkfyMP9huC=\"}", + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": { + "SubscriptionId": "00000000-0000-0000-0000-000000000000" + } +} \ No newline at end of file diff --git a/src/SDKs/ResourceGraph/Management/ResourceGraph.sln b/src/SDKs/ResourceGraph/Management/ResourceGraph.sln new file mode 100644 index 000000000000..bb757bbba20e --- /dev/null +++ b/src/SDKs/ResourceGraph/Management/ResourceGraph.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28010.2016 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Management.ResourceGraph", "Management.ResourceGraph\Microsoft.Azure.Management.ResourceGraph.csproj", "{FE7325B2-DE9A-42DC-9279-5F90E7D7C0AF}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Management.ResourceGraph.Tests", "ResourceGraph.Tests\Microsoft.Azure.Management.ResourceGraph.Tests.csproj", "{82256D83-2BE0-4E34-AA1C-F72003CAE48D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FE7325B2-DE9A-42DC-9279-5F90E7D7C0AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FE7325B2-DE9A-42DC-9279-5F90E7D7C0AF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FE7325B2-DE9A-42DC-9279-5F90E7D7C0AF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FE7325B2-DE9A-42DC-9279-5F90E7D7C0AF}.Release|Any CPU.Build.0 = Release|Any CPU + {82256D83-2BE0-4E34-AA1C-F72003CAE48D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {82256D83-2BE0-4E34-AA1C-F72003CAE48D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {82256D83-2BE0-4E34-AA1C-F72003CAE48D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {82256D83-2BE0-4E34-AA1C-F72003CAE48D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2C4C51FE-F0CC-41D9-9B32-A4BD3B8F312B} + EndGlobalSection +EndGlobal diff --git a/src/SDKs/_metadata/resourcegraph_resource-manager.txt b/src/SDKs/_metadata/resourcegraph_resource-manager.txt new file mode 100644 index 000000000000..90ebecf014ec --- /dev/null +++ b/src/SDKs/_metadata/resourcegraph_resource-manager.txt @@ -0,0 +1,14 @@ +Installing AutoRest version: latest +AutoRest installed successfully. +Commencing code generation +Generating CSharp code +Executing AutoRest command +cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/resourcegraph/resource-manager/readme.md --csharp --version=latest --reflect-api-versions --csharp-sdks-folder=C:\git\azure-sdk-for-net\src\SDKs +2018-09-04 23:54:58 UTC +Azure-rest-api-specs repository information +GitHub fork: Azure +Branch: master +Commit: 15929694cc9babeb19c0e834f8babe23af323b75 +AutoRest information +Requested version: latest +Bootstrapper version: autorest@2.0.4283