diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/EntitiesOperations.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/EntitiesOperations.cs new file mode 100644 index 000000000000..650a58113aa9 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/EntitiesOperations.cs @@ -0,0 +1,519 @@ +// +// 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.ManagementGroups +{ + 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; + + /// + /// EntitiesOperations operations. + /// + internal partial class EntitiesOperations : IServiceOperations, IEntitiesOperations + { + /// + /// Initializes a new instance of the EntitiesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal EntitiesOperations(ManagementGroupsAPIClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ManagementGroupsAPIClient + /// + public ManagementGroupsAPIClient Client { get; private set; } + + /// + /// List all entities (Management Groups, Subscriptions, etc.) for the + /// authenticated user. + /// + /// + /// + /// Page continuation token is only used if a previous operation returned a + /// partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a token parameter that specifies a starting + /// point to use for subsequent calls. + /// + /// + /// Number of entities to skip over when retrieving results. Passing this in + /// will override $skipToken. + /// + /// + /// Number of elements to return when retrieving results. Passing this in will + /// override $skipToken. + /// + /// + /// This parameter specifies the fields to include in the response. Can include + /// any combination of + /// Name,DisplayName,Type,ParentDisplayNameChain,ParentChain, e.g. + /// '$select=Name,DisplayName,Type,ParentDisplayNameChain,ParentNameChain'. + /// When specified the $select parameter can override select in $skipToken. + /// + /// + /// The $search parameter is used in conjunction with the $filter parameter to + /// return three different outputs depending on the parameter passed in. + /// With $search=AllowedParents the API will return the entity info of all + /// groups that the requested entity will be able to reparent to as determined + /// by the user's permissions. + /// With $search=AllowedChildren the API will return the entity info of all + /// entities that can be added as children of the requested entity. + /// With $search=ParentAndFirstLevelChildren the API will return the parent and + /// first level of children that the user has either direct access to or + /// indirect access via one of their descendants. + /// With $search=ParentOnly the API will return only the group if the user has + /// access to at least one of the descendants of the group. + /// With $search=ChildrenOnly the API will return only the first level of + /// children of the group entity info specified in $filter. The user must have + /// direct access to the children entities or one of it's descendants for it to + /// show up in the results. Possible values include: 'AllowedParents', + /// 'AllowedChildren', 'ParentAndFirstLevelChildren', 'ParentOnly', + /// 'ChildrenOnly' + /// + /// + /// The filter parameter allows you to filter on the the name or display name + /// fields. You can check for equality on the name field (e.g. name eq + /// '{entityName}') and you can check for substrings on either the name or + /// display name fields(e.g. contains(name, '{substringToSearch}'), + /// contains(displayName, '{substringToSearch')). Note that the '{entityName}' + /// and '{substringToSearch}' fields are checked case insensitively. + /// + /// + /// The view parameter allows clients to filter the type of data that is + /// returned by the getEntities call. Possible values include: 'FullHierarchy', + /// 'GroupsOnly', 'SubscriptionsOnly', 'Audit' + /// + /// + /// A filter which allows the get entities call to focus on a particular group + /// (i.e. "$filter=name eq 'groupName'") + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(string skiptoken = default(string), int? skip = default(int?), int? top = default(int?), string select = default(string), string search = default(string), string filter = default(string), string view = default(string), string groupName = default(string), string cacheControl = "no-cache", 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("skiptoken", skiptoken); + tracingParameters.Add("skip", skip); + tracingParameters.Add("top", top); + tracingParameters.Add("select", select); + tracingParameters.Add("search", search); + tracingParameters.Add("filter", filter); + tracingParameters.Add("view", view); + tracingParameters.Add("groupName", groupName); + tracingParameters.Add("cacheControl", cacheControl); + 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.Management/getEntities").ToString(); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (skiptoken != null) + { + _queryParameters.Add(string.Format("$skiptoken={0}", System.Uri.EscapeDataString(skiptoken))); + } + if (skip != null) + { + _queryParameters.Add(string.Format("$skip={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(skip, Client.SerializationSettings).Trim('"')))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (select != null) + { + _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(select))); + } + if (search != null) + { + _queryParameters.Add(string.Format("$search={0}", System.Uri.EscapeDataString(search))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (view != null) + { + _queryParameters.Add(string.Format("$view={0}", System.Uri.EscapeDataString(view))); + } + if (groupName != null) + { + _queryParameters.Add(string.Format("groupName={0}", System.Uri.EscapeDataString(groupName))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (cacheControl != null) + { + if (_httpRequest.Headers.Contains("Cache-Control")) + { + _httpRequest.Headers.Remove("Cache-Control"); + } + _httpRequest.Headers.TryAddWithoutValidation("Cache-Control", cacheControl); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List all entities (Management Groups, Subscriptions, etc.) for the + /// authenticated user. + /// + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cacheControl", cacheControl); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (cacheControl != null) + { + if (_httpRequest.Headers.Contains("Cache-Control")) + { + _httpRequest.Headers.Remove("Cache-Control"); + } + _httpRequest.Headers.TryAddWithoutValidation("Cache-Control", cacheControl); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/EntitiesOperationsExtensions.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/EntitiesOperationsExtensions.cs new file mode 100644 index 000000000000..db9a26c9d364 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/EntitiesOperationsExtensions.cs @@ -0,0 +1,229 @@ +// +// 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.ManagementGroups +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for EntitiesOperations. + /// + public static partial class EntitiesOperationsExtensions + { + /// + /// List all entities (Management Groups, Subscriptions, etc.) for the + /// authenticated user. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Page continuation token is only used if a previous operation returned a + /// partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a token parameter that specifies a starting + /// point to use for subsequent calls. + /// + /// + /// Number of entities to skip over when retrieving results. Passing this in + /// will override $skipToken. + /// + /// + /// Number of elements to return when retrieving results. Passing this in will + /// override $skipToken. + /// + /// + /// This parameter specifies the fields to include in the response. Can include + /// any combination of + /// Name,DisplayName,Type,ParentDisplayNameChain,ParentChain, e.g. + /// '$select=Name,DisplayName,Type,ParentDisplayNameChain,ParentNameChain'. + /// When specified the $select parameter can override select in $skipToken. + /// + /// + /// The $search parameter is used in conjunction with the $filter parameter to + /// return three different outputs depending on the parameter passed in. + /// With $search=AllowedParents the API will return the entity info of all + /// groups that the requested entity will be able to reparent to as determined + /// by the user's permissions. + /// With $search=AllowedChildren the API will return the entity info of all + /// entities that can be added as children of the requested entity. + /// With $search=ParentAndFirstLevelChildren the API will return the parent and + /// first level of children that the user has either direct access to or + /// indirect access via one of their descendants. + /// With $search=ParentOnly the API will return only the group if the user has + /// access to at least one of the descendants of the group. + /// With $search=ChildrenOnly the API will return only the first level of + /// children of the group entity info specified in $filter. The user must have + /// direct access to the children entities or one of it's descendants for it to + /// show up in the results. Possible values include: 'AllowedParents', + /// 'AllowedChildren', 'ParentAndFirstLevelChildren', 'ParentOnly', + /// 'ChildrenOnly' + /// + /// + /// The filter parameter allows you to filter on the the name or display name + /// fields. You can check for equality on the name field (e.g. name eq + /// '{entityName}') and you can check for substrings on either the name or + /// display name fields(e.g. contains(name, '{substringToSearch}'), + /// contains(displayName, '{substringToSearch')). Note that the '{entityName}' + /// and '{substringToSearch}' fields are checked case insensitively. + /// + /// + /// The view parameter allows clients to filter the type of data that is + /// returned by the getEntities call. Possible values include: 'FullHierarchy', + /// 'GroupsOnly', 'SubscriptionsOnly', 'Audit' + /// + /// + /// A filter which allows the get entities call to focus on a particular group + /// (i.e. "$filter=name eq 'groupName'") + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + public static IPage List(this IEntitiesOperations operations, string skiptoken = default(string), int? skip = default(int?), int? top = default(int?), string select = default(string), string search = default(string), string filter = default(string), string view = default(string), string groupName = default(string), string cacheControl = "no-cache") + { + return operations.ListAsync(skiptoken, skip, top, select, search, filter, view, groupName, cacheControl).GetAwaiter().GetResult(); + } + + /// + /// List all entities (Management Groups, Subscriptions, etc.) for the + /// authenticated user. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Page continuation token is only used if a previous operation returned a + /// partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a token parameter that specifies a starting + /// point to use for subsequent calls. + /// + /// + /// Number of entities to skip over when retrieving results. Passing this in + /// will override $skipToken. + /// + /// + /// Number of elements to return when retrieving results. Passing this in will + /// override $skipToken. + /// + /// + /// This parameter specifies the fields to include in the response. Can include + /// any combination of + /// Name,DisplayName,Type,ParentDisplayNameChain,ParentChain, e.g. + /// '$select=Name,DisplayName,Type,ParentDisplayNameChain,ParentNameChain'. + /// When specified the $select parameter can override select in $skipToken. + /// + /// + /// The $search parameter is used in conjunction with the $filter parameter to + /// return three different outputs depending on the parameter passed in. + /// With $search=AllowedParents the API will return the entity info of all + /// groups that the requested entity will be able to reparent to as determined + /// by the user's permissions. + /// With $search=AllowedChildren the API will return the entity info of all + /// entities that can be added as children of the requested entity. + /// With $search=ParentAndFirstLevelChildren the API will return the parent and + /// first level of children that the user has either direct access to or + /// indirect access via one of their descendants. + /// With $search=ParentOnly the API will return only the group if the user has + /// access to at least one of the descendants of the group. + /// With $search=ChildrenOnly the API will return only the first level of + /// children of the group entity info specified in $filter. The user must have + /// direct access to the children entities or one of it's descendants for it to + /// show up in the results. Possible values include: 'AllowedParents', + /// 'AllowedChildren', 'ParentAndFirstLevelChildren', 'ParentOnly', + /// 'ChildrenOnly' + /// + /// + /// The filter parameter allows you to filter on the the name or display name + /// fields. You can check for equality on the name field (e.g. name eq + /// '{entityName}') and you can check for substrings on either the name or + /// display name fields(e.g. contains(name, '{substringToSearch}'), + /// contains(displayName, '{substringToSearch')). Note that the '{entityName}' + /// and '{substringToSearch}' fields are checked case insensitively. + /// + /// + /// The view parameter allows clients to filter the type of data that is + /// returned by the getEntities call. Possible values include: 'FullHierarchy', + /// 'GroupsOnly', 'SubscriptionsOnly', 'Audit' + /// + /// + /// A filter which allows the get entities call to focus on a particular group + /// (i.e. "$filter=name eq 'groupName'") + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IEntitiesOperations operations, string skiptoken = default(string), int? skip = default(int?), int? top = default(int?), string select = default(string), string search = default(string), string filter = default(string), string view = default(string), string groupName = default(string), string cacheControl = "no-cache", CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(skiptoken, skip, top, select, search, filter, view, groupName, cacheControl, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all entities (Management Groups, Subscriptions, etc.) for the + /// authenticated user. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + public static IPage ListNext(this IEntitiesOperations operations, string nextPageLink, string cacheControl = "no-cache") + { + return operations.ListNextAsync(nextPageLink, cacheControl).GetAwaiter().GetResult(); + } + + /// + /// List all entities (Management Groups, Subscriptions, etc.) for the + /// authenticated user. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IEntitiesOperations operations, string nextPageLink, string cacheControl = "no-cache", CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, cacheControl, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/HierarchySettingsOperations.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/HierarchySettingsOperations.cs new file mode 100644 index 000000000000..87e4392eb9cd --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/HierarchySettingsOperations.cs @@ -0,0 +1,954 @@ +// +// 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.ManagementGroups +{ + 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; + + /// + /// HierarchySettingsOperations operations. + /// + internal partial class HierarchySettingsOperations : IServiceOperations, IHierarchySettingsOperations + { + /// + /// Initializes a new instance of the HierarchySettingsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal HierarchySettingsOperations(ManagementGroupsAPIClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ManagementGroupsAPIClient + /// + public ManagementGroupsAPIClient Client { get; private set; } + + /// + /// Gets all the hierarchy settings defined at the Management Group level. + /// Settings can only be set on the root Management Group of the hierarchy. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> ListWithHttpMessagesAsync(string groupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + 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("groupId", groupId); + 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.Management/managementGroups/{groupId}/settings").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets the hierarchy settings defined at the Management Group level. Settings + /// can only be set on the root Management Group of the hierarchy. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string groupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + 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("groupId", groupId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/settings/default").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + 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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Creates or updates the hierarchy settings defined at the Management Group + /// level. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Tenant level settings request parameter. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string groupId, CreateOrUpdateSettingsRequest createTenantSettingsRequest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (createTenantSettingsRequest == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "createTenantSettingsRequest"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("groupId", groupId); + tracingParameters.Add("createTenantSettingsRequest", createTenantSettingsRequest); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/settings/default").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(createTenantSettingsRequest != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(createTenantSettingsRequest, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Updates the hierarchy settings defined at the Management Group level. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Tenant level settings request parameter. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> UpdateWithHttpMessagesAsync(string groupId, CreateOrUpdateSettingsRequest createTenantSettingsRequest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (createTenantSettingsRequest == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "createTenantSettingsRequest"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("groupId", groupId); + tracingParameters.Add("createTenantSettingsRequest", createTenantSettingsRequest); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/settings/default").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(createTenantSettingsRequest != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(createTenantSettingsRequest, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes the hierarchy settings defined at the Management Group level. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task DeleteWithHttpMessagesAsync(string groupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + 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("groupId", groupId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/settings/default").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/HierarchySettingsOperationsExtensions.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/HierarchySettingsOperationsExtensions.cs new file mode 100644 index 000000000000..42af29051f8d --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/HierarchySettingsOperationsExtensions.cs @@ -0,0 +1,220 @@ +// +// 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.ManagementGroups +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for HierarchySettingsOperations. + /// + public static partial class HierarchySettingsOperationsExtensions + { + /// + /// Gets all the hierarchy settings defined at the Management Group level. + /// Settings can only be set on the root Management Group of the hierarchy. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + public static HierarchySettingsList List(this IHierarchySettingsOperations operations, string groupId) + { + return operations.ListAsync(groupId).GetAwaiter().GetResult(); + } + + /// + /// Gets all the hierarchy settings defined at the Management Group level. + /// Settings can only be set on the root Management Group of the hierarchy. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this IHierarchySettingsOperations operations, string groupId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(groupId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the hierarchy settings defined at the Management Group level. Settings + /// can only be set on the root Management Group of the hierarchy. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + public static HierarchySettings Get(this IHierarchySettingsOperations operations, string groupId) + { + return operations.GetAsync(groupId).GetAwaiter().GetResult(); + } + + /// + /// Gets the hierarchy settings defined at the Management Group level. Settings + /// can only be set on the root Management Group of the hierarchy. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IHierarchySettingsOperations operations, string groupId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(groupId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Creates or updates the hierarchy settings defined at the Management Group + /// level. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// Tenant level settings request parameter. + /// + public static HierarchySettings CreateOrUpdate(this IHierarchySettingsOperations operations, string groupId, CreateOrUpdateSettingsRequest createTenantSettingsRequest) + { + return operations.CreateOrUpdateAsync(groupId, createTenantSettingsRequest).GetAwaiter().GetResult(); + } + + /// + /// Creates or updates the hierarchy settings defined at the Management Group + /// level. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// Tenant level settings request parameter. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IHierarchySettingsOperations operations, string groupId, CreateOrUpdateSettingsRequest createTenantSettingsRequest, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(groupId, createTenantSettingsRequest, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Updates the hierarchy settings defined at the Management Group level. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// Tenant level settings request parameter. + /// + public static HierarchySettings Update(this IHierarchySettingsOperations operations, string groupId, CreateOrUpdateSettingsRequest createTenantSettingsRequest) + { + return operations.UpdateAsync(groupId, createTenantSettingsRequest).GetAwaiter().GetResult(); + } + + /// + /// Updates the hierarchy settings defined at the Management Group level. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// Tenant level settings request parameter. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IHierarchySettingsOperations operations, string groupId, CreateOrUpdateSettingsRequest createTenantSettingsRequest, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(groupId, createTenantSettingsRequest, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes the hierarchy settings defined at the Management Group level. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + public static void Delete(this IHierarchySettingsOperations operations, string groupId) + { + operations.DeleteAsync(groupId).GetAwaiter().GetResult(); + } + + /// + /// Deletes the hierarchy settings defined at the Management Group level. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IHierarchySettingsOperations operations, string groupId, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(groupId, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/IEntitiesOperations.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/IEntitiesOperations.cs new file mode 100644 index 000000000000..7fd99fd62139 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/IEntitiesOperations.cs @@ -0,0 +1,142 @@ +// +// 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.ManagementGroups +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// EntitiesOperations operations. + /// + public partial interface IEntitiesOperations + { + /// + /// List all entities (Management Groups, Subscriptions, etc.) for the + /// authenticated user. + /// + /// + /// + /// Page continuation token is only used if a previous operation + /// returned a partial result. + /// If a previous response contains a nextLink element, the value of + /// the nextLink element will include a token parameter that specifies + /// a starting point to use for subsequent calls. + /// + /// + /// Number of entities to skip over when retrieving results. Passing + /// this in will override $skipToken. + /// + /// + /// Number of elements to return when retrieving results. Passing this + /// in will override $skipToken. + /// + /// + /// This parameter specifies the fields to include in the response. Can + /// include any combination of + /// Name,DisplayName,Type,ParentDisplayNameChain,ParentChain, e.g. + /// '$select=Name,DisplayName,Type,ParentDisplayNameChain,ParentNameChain'. + /// When specified the $select parameter can override select in + /// $skipToken. + /// + /// + /// The $search parameter is used in conjunction with the $filter + /// parameter to return three different outputs depending on the + /// parameter passed in. + /// With $search=AllowedParents the API will return the entity info of + /// all groups that the requested entity will be able to reparent to as + /// determined by the user's permissions. + /// With $search=AllowedChildren the API will return the entity info of + /// all entities that can be added as children of the requested entity. + /// With $search=ParentAndFirstLevelChildren the API will return the + /// parent and first level of children that the user has either direct + /// access to or indirect access via one of their descendants. + /// With $search=ParentOnly the API will return only the group if the + /// user has access to at least one of the descendants of the group. + /// With $search=ChildrenOnly the API will return only the first level + /// of children of the group entity info specified in $filter. The + /// user must have direct access to the children entities or one of + /// it's descendants for it to show up in the results. Possible values + /// include: 'AllowedParents', 'AllowedChildren', + /// 'ParentAndFirstLevelChildren', 'ParentOnly', 'ChildrenOnly' + /// + /// + /// The filter parameter allows you to filter on the the name or + /// display name fields. You can check for equality on the name field + /// (e.g. name eq '{entityName}') and you can check for substrings on + /// either the name or display name fields(e.g. contains(name, + /// '{substringToSearch}'), contains(displayName, + /// '{substringToSearch')). Note that the '{entityName}' and + /// '{substringToSearch}' fields are checked case insensitively. + /// + /// + /// The view parameter allows clients to filter the type of data that + /// is returned by the getEntities call. Possible values include: + /// 'FullHierarchy', 'GroupsOnly', 'SubscriptionsOnly', 'Audit' + /// + /// + /// A filter which allows the get entities call to focus on a + /// particular group (i.e. "$filter=name eq 'groupName'") + /// + /// + /// Indicates whether the request should utilize any caches. Populate + /// the header with 'no-cache' value to bypass existing caches. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(string skiptoken = default(string), int? skip = default(int?), int? top = default(int?), string select = default(string), string search = default(string), string filter = default(string), string view = default(string), string groupName = default(string), string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all entities (Management Groups, Subscriptions, etc.) for the + /// authenticated user. + /// + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Indicates whether the request should utilize any caches. Populate + /// the header with 'no-cache' value to bypass existing caches. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/IHierarchySettingsOperations.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/IHierarchySettingsOperations.cs new file mode 100644 index 000000000000..e0e0d8aec67d --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/IHierarchySettingsOperations.cs @@ -0,0 +1,152 @@ +// +// 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.ManagementGroups +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// HierarchySettingsOperations operations. + /// + public partial interface IHierarchySettingsOperations + { + /// + /// Gets all the hierarchy settings defined at the Management Group + /// level. Settings can only be set on the root Management Group of the + /// hierarchy. + /// + /// + /// + /// Management Group ID. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ListWithHttpMessagesAsync(string groupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the hierarchy settings defined at the Management Group level. + /// Settings can only be set on the root Management Group of the + /// hierarchy. + /// + /// + /// + /// Management Group ID. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string groupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Creates or updates the hierarchy settings defined at the Management + /// Group level. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Tenant level settings request parameter. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string groupId, CreateOrUpdateSettingsRequest createTenantSettingsRequest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Updates the hierarchy settings defined at the Management Group + /// level. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Tenant level settings request parameter. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string groupId, CreateOrUpdateSettingsRequest createTenantSettingsRequest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes the hierarchy settings defined at the Management Group + /// level. + /// + /// + /// + /// Management Group ID. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string groupId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/IManagementGroupSubscriptionsOperations.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/IManagementGroupSubscriptionsOperations.cs new file mode 100644 index 000000000000..c5e62d32cab8 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/IManagementGroupSubscriptionsOperations.cs @@ -0,0 +1,170 @@ +// +// 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.ManagementGroups +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ManagementGroupSubscriptionsOperations operations. + /// + public partial interface IManagementGroupSubscriptionsOperations + { + /// + /// Associates existing subscription with the management group. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Subscription ID. + /// + /// + /// Indicates whether the request should utilize any caches. Populate + /// the header with 'no-cache' value to bypass existing caches. + /// + /// + /// 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> CreateWithHttpMessagesAsync(string groupId, string subscriptionId, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// De-associates subscription from the management group. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Subscription ID. + /// + /// + /// Indicates whether the request should utilize any caches. Populate + /// the header with 'no-cache' value to bypass existing caches. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string groupId, string subscriptionId, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves details about given subscription which is associated with + /// the management group. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Subscription ID. + /// + /// + /// Indicates whether the request should utilize any caches. Populate + /// the header with 'no-cache' value to bypass existing caches. + /// + /// + /// 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> GetSubscriptionWithHttpMessagesAsync(string groupId, string subscriptionId, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves details about all subscriptions which are associated with + /// the management group. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Page continuation token is only used if a previous operation + /// returned a partial result. + /// If a previous response contains a nextLink element, the value of + /// the nextLink element will include a token parameter that specifies + /// a starting point to use for subsequent calls. + /// + /// + /// 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>> GetSubscriptionsUnderManagementGroupWithHttpMessagesAsync(string groupId, string skiptoken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Retrieves details about all subscriptions which are associated with + /// the management group. + /// + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> GetSubscriptionsUnderManagementGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/IManagementGroupsAPIClient.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/IManagementGroupsAPIClient.cs new file mode 100644 index 000000000000..405cfa35bd60 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/IManagementGroupsAPIClient.cs @@ -0,0 +1,138 @@ +// +// 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.ManagementGroups +{ + 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; + + /// + /// The Azure Management Groups API enables consolidation of multiple + /// subscriptions/resources into an organizational hierarchy and centrally + /// manage access control, policies, alerting and reporting for those + /// resources. + /// + /// + public partial interface IManagementGroupsAPIClient : 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; } + + /// + /// Version of the API to be used with the client request. The current + /// version is 2018-01-01-preview. + /// + 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 IManagementGroupsOperations. + /// + IManagementGroupsOperations ManagementGroups { get; } + + /// + /// Gets the IManagementGroupSubscriptionsOperations. + /// + IManagementGroupSubscriptionsOperations ManagementGroupSubscriptions { get; } + + /// + /// Gets the IHierarchySettingsOperations. + /// + IHierarchySettingsOperations HierarchySettings { get; } + + /// + /// Gets the IOperations. + /// + IOperations Operations { get; } + + /// + /// Gets the IEntitiesOperations. + /// + IEntitiesOperations Entities { get; } + + /// + /// Checks if the specified management group name is valid and unique + /// + /// + /// Management group name availability check parameters. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> CheckNameAvailabilityWithHttpMessagesAsync(CheckNameAvailabilityRequest checkNameAvailabilityRequest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Starts backfilling subscriptions for the Tenant. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> StartTenantBackfillWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + /// Gets tenant backfill status + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task> TenantBackfillStatusWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/IManagementGroupsOperations.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/IManagementGroupsOperations.cs new file mode 100644 index 000000000000..d2da55a2934b --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/IManagementGroupsOperations.cs @@ -0,0 +1,339 @@ +// +// 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.ManagementGroups +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ManagementGroupsOperations operations. + /// + public partial interface IManagementGroupsOperations + { + /// + /// List management groups for the authenticated user. + /// + /// + /// + /// Indicates whether the request should utilize any caches. Populate + /// the header with 'no-cache' value to bypass existing caches. + /// + /// + /// Page continuation token is only used if a previous operation + /// returned a partial result. + /// If a previous response contains a nextLink element, the value of + /// the nextLink element will include a token parameter that specifies + /// a starting point to use for subsequent calls. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(string cacheControl = "no-cache", string skiptoken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get the details of the management group. + /// + /// + /// + /// Management Group ID. + /// + /// + /// The $expand=children query string parameter allows clients to + /// request inclusion of children in the response payload. + /// $expand=path includes the path from the root group to the current + /// group. $expand=ancestors includes the ancestor Ids of the current + /// group. Possible values include: 'children', 'path', 'ancestors' + /// + /// + /// The $recurse=true query string parameter allows clients to request + /// inclusion of entire hierarchy in the response payload. Note that + /// $expand=children must be passed up if $recurse is set to true. + /// + /// + /// A filter which allows the exclusion of subscriptions from results + /// (i.e. '$filter=children.childType ne Subscription') + /// + /// + /// Indicates whether the request should utilize any caches. Populate + /// the header with 'no-cache' value to bypass existing caches. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string groupId, string expand = default(string), bool? recurse = default(bool?), string filter = default(string), string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update a management group. + /// If a management group is already created and a subsequent create + /// request is issued with different properties, the management group + /// properties will be updated. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Management group creation parameters. + /// + /// + /// Indicates whether the request should utilize any caches. Populate + /// the header with 'no-cache' value to bypass existing caches. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string groupId, CreateManagementGroupRequest createManagementGroupRequest, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Update a management group. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Management group patch parameters. + /// + /// + /// Indicates whether the request should utilize any caches. Populate + /// the header with 'no-cache' value to bypass existing caches. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> UpdateWithHttpMessagesAsync(string groupId, PatchManagementGroupRequest patchGroupRequest, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete management group. + /// If a management group contains child resources, the request will + /// fail. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Indicates whether the request should utilize any caches. Populate + /// the header with 'no-cache' value to bypass existing caches. + /// + /// + /// 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> DeleteWithHttpMessagesAsync(string groupId, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all entities that descend from a management group. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Page continuation token is only used if a previous operation + /// returned a partial result. + /// If a previous response contains a nextLink element, the value of + /// the nextLink element will include a token parameter that specifies + /// a starting point to use for subsequent calls. + /// + /// + /// Number of elements to return when retrieving results. Passing this + /// in will override $skipToken. + /// + /// + /// 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>> GetDescendantsWithHttpMessagesAsync(string groupId, string skiptoken = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update a management group. + /// If a management group is already created and a subsequent create + /// request is issued with different properties, the management group + /// properties will be updated. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Management group creation parameters. + /// + /// + /// Indicates whether the request should utilize any caches. Populate + /// the header with 'no-cache' value to bypass existing caches. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateOrUpdateWithHttpMessagesAsync(string groupId, CreateManagementGroupRequest createManagementGroupRequest, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete management group. + /// If a management group contains child resources, the request will + /// fail. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Indicates whether the request should utilize any caches. Populate + /// the header with 'no-cache' value to bypass existing caches. + /// + /// + /// 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> BeginDeleteWithHttpMessagesAsync(string groupId, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List management groups for the authenticated user. + /// + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Indicates whether the request should utilize any caches. Populate + /// the header with 'no-cache' value to bypass existing caches. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List all entities that descend from a management group. + /// + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> GetDescendantsNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/IOperations.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/IOperations.cs new file mode 100644 index 000000000000..eaeea1579ebf --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/IOperations.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.ManagementGroups +{ + 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 Management 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)); + /// + /// Lists all of the available Management REST API operations. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/ManagementGroupSubscriptionsOperations.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/ManagementGroupSubscriptionsOperations.cs new file mode 100644 index 000000000000..19fdfd801e4d --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/ManagementGroupSubscriptionsOperations.cs @@ -0,0 +1,995 @@ +// +// 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.ManagementGroups +{ + 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; + + /// + /// ManagementGroupSubscriptionsOperations operations. + /// + internal partial class ManagementGroupSubscriptionsOperations : IServiceOperations, IManagementGroupSubscriptionsOperations + { + /// + /// Initializes a new instance of the ManagementGroupSubscriptionsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ManagementGroupSubscriptionsOperations(ManagementGroupsAPIClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ManagementGroupsAPIClient + /// + public ManagementGroupsAPIClient Client { get; private set; } + + /// + /// Associates existing subscription with the management group. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Subscription ID. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// 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> CreateWithHttpMessagesAsync(string groupId, string subscriptionId, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("groupId", groupId); + tracingParameters.Add("subscriptionId", subscriptionId); + tracingParameters.Add("cacheControl", cacheControl); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (cacheControl != null) + { + if (_httpRequest.Headers.Contains("Cache-Control")) + { + _httpRequest.Headers.Remove("Cache-Control"); + } + _httpRequest.Headers.TryAddWithoutValidation("Cache-Control", cacheControl); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// De-associates subscription from the management group. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Subscription ID. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task DeleteWithHttpMessagesAsync(string groupId, string subscriptionId, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("groupId", groupId); + tracingParameters.Add("subscriptionId", subscriptionId); + tracingParameters.Add("cacheControl", cacheControl); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (cacheControl != null) + { + if (_httpRequest.Headers.Contains("Cache-Control")) + { + _httpRequest.Headers.Remove("Cache-Control"); + } + _httpRequest.Headers.TryAddWithoutValidation("Cache-Control", cacheControl); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Retrieves details about given subscription which is associated with the + /// management group. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Subscription ID. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// 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> GetSubscriptionWithHttpMessagesAsync(string groupId, string subscriptionId, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("groupId", groupId); + tracingParameters.Add("subscriptionId", subscriptionId); + tracingParameters.Add("cacheControl", cacheControl); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetSubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); + 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 (cacheControl != null) + { + if (_httpRequest.Headers.Contains("Cache-Control")) + { + _httpRequest.Headers.Remove("Cache-Control"); + } + _httpRequest.Headers.TryAddWithoutValidation("Cache-Control", cacheControl); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Retrieves details about all subscriptions which are associated with the + /// management group. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Page continuation token is only used if a previous operation returned a + /// partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a token parameter that specifies a starting + /// point to use for subsequent calls. + /// + /// + /// 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>> GetSubscriptionsUnderManagementGroupWithHttpMessagesAsync(string groupId, string skiptoken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + 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("groupId", groupId); + tracingParameters.Add("skiptoken", skiptoken); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetSubscriptionsUnderManagementGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/subscriptions").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (skiptoken != null) + { + _queryParameters.Add(string.Format("$skiptoken={0}", System.Uri.EscapeDataString(skiptoken))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Retrieves details about all subscriptions which are associated with the + /// management group. + /// + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> GetSubscriptionsUnderManagementGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetSubscriptionsUnderManagementGroupNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/ManagementGroupSubscriptionsOperationsExtensions.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/ManagementGroupSubscriptionsOperationsExtensions.cs new file mode 100644 index 000000000000..ba2841129489 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/ManagementGroupSubscriptionsOperationsExtensions.cs @@ -0,0 +1,264 @@ +// +// 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.ManagementGroups +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ManagementGroupSubscriptionsOperations. + /// + public static partial class ManagementGroupSubscriptionsOperationsExtensions + { + /// + /// Associates existing subscription with the management group. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// Subscription ID. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + public static SubscriptionUnderManagementGroup Create(this IManagementGroupSubscriptionsOperations operations, string groupId, string subscriptionId, string cacheControl = "no-cache") + { + return operations.CreateAsync(groupId, subscriptionId, cacheControl).GetAwaiter().GetResult(); + } + + /// + /// Associates existing subscription with the management group. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// Subscription ID. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// The cancellation token. + /// + public static async Task CreateAsync(this IManagementGroupSubscriptionsOperations operations, string groupId, string subscriptionId, string cacheControl = "no-cache", CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateWithHttpMessagesAsync(groupId, subscriptionId, cacheControl, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// De-associates subscription from the management group. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// Subscription ID. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + public static void Delete(this IManagementGroupSubscriptionsOperations operations, string groupId, string subscriptionId, string cacheControl = "no-cache") + { + operations.DeleteAsync(groupId, subscriptionId, cacheControl).GetAwaiter().GetResult(); + } + + /// + /// De-associates subscription from the management group. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// Subscription ID. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IManagementGroupSubscriptionsOperations operations, string groupId, string subscriptionId, string cacheControl = "no-cache", CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(groupId, subscriptionId, cacheControl, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Retrieves details about given subscription which is associated with the + /// management group. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// Subscription ID. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + public static SubscriptionUnderManagementGroup GetSubscription(this IManagementGroupSubscriptionsOperations operations, string groupId, string subscriptionId, string cacheControl = "no-cache") + { + return operations.GetSubscriptionAsync(groupId, subscriptionId, cacheControl).GetAwaiter().GetResult(); + } + + /// + /// Retrieves details about given subscription which is associated with the + /// management group. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// Subscription ID. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// The cancellation token. + /// + public static async Task GetSubscriptionAsync(this IManagementGroupSubscriptionsOperations operations, string groupId, string subscriptionId, string cacheControl = "no-cache", CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetSubscriptionWithHttpMessagesAsync(groupId, subscriptionId, cacheControl, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves details about all subscriptions which are associated with the + /// management group. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// Page continuation token is only used if a previous operation returned a + /// partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a token parameter that specifies a starting + /// point to use for subsequent calls. + /// + public static IPage GetSubscriptionsUnderManagementGroup(this IManagementGroupSubscriptionsOperations operations, string groupId, string skiptoken = default(string)) + { + return operations.GetSubscriptionsUnderManagementGroupAsync(groupId, skiptoken).GetAwaiter().GetResult(); + } + + /// + /// Retrieves details about all subscriptions which are associated with the + /// management group. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// Page continuation token is only used if a previous operation returned a + /// partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a token parameter that specifies a starting + /// point to use for subsequent calls. + /// + /// + /// The cancellation token. + /// + public static async Task> GetSubscriptionsUnderManagementGroupAsync(this IManagementGroupSubscriptionsOperations operations, string groupId, string skiptoken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetSubscriptionsUnderManagementGroupWithHttpMessagesAsync(groupId, skiptoken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Retrieves details about all subscriptions which are associated with the + /// management group. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage GetSubscriptionsUnderManagementGroupNext(this IManagementGroupSubscriptionsOperations operations, string nextPageLink) + { + return operations.GetSubscriptionsUnderManagementGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Retrieves details about all subscriptions which are associated with the + /// management group. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> GetSubscriptionsUnderManagementGroupNextAsync(this IManagementGroupSubscriptionsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetSubscriptionsUnderManagementGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/ManagementGroupsAPIClient.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/ManagementGroupsAPIClient.cs new file mode 100644 index 000000000000..9ae2df5a9a72 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/ManagementGroupsAPIClient.cs @@ -0,0 +1,904 @@ +// +// 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.ManagementGroups +{ + 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; + + /// + /// The Azure Management Groups API enables consolidation of multiple + /// subscriptions/resources into an organizational hierarchy and centrally + /// manage access control, policies, alerting and reporting for those + /// resources. + /// + /// + public partial class ManagementGroupsAPIClient : ServiceClient, IManagementGroupsAPIClient, 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; } + + /// + /// Version of the API to be used with the client request. The current version + /// is 2018-01-01-preview. + /// + 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 IManagementGroupsOperations. + /// + public virtual IManagementGroupsOperations ManagementGroups { get; private set; } + + /// + /// Gets the IManagementGroupSubscriptionsOperations. + /// + public virtual IManagementGroupSubscriptionsOperations ManagementGroupSubscriptions { get; private set; } + + /// + /// Gets the IHierarchySettingsOperations. + /// + public virtual IHierarchySettingsOperations HierarchySettings { get; private set; } + + /// + /// Gets the IOperations. + /// + public virtual IOperations Operations { get; private set; } + + /// + /// Gets the IEntitiesOperations. + /// + public virtual IEntitiesOperations Entities { get; private set; } + + /// + /// Initializes a new instance of the ManagementGroupsAPIClient class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling ManagementGroupsAPIClient.Dispose(). False: will not dispose provided httpClient + protected ManagementGroupsAPIClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + Initialize(); + } + + /// + /// Initializes a new instance of the ManagementGroupsAPIClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected ManagementGroupsAPIClient(params DelegatingHandler[] handlers) : base(handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the ManagementGroupsAPIClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected ManagementGroupsAPIClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the ManagementGroupsAPIClient 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 ManagementGroupsAPIClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the ManagementGroupsAPIClient 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 ManagementGroupsAPIClient(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 ManagementGroupsAPIClient 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 ManagementGroupsAPIClient(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 ManagementGroupsAPIClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling ManagementGroupsAPIClient.Dispose(). False: will not dispose provided httpClient + /// + /// Thrown when a required parameter is null + /// + public ManagementGroupsAPIClient(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 ManagementGroupsAPIClient 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 ManagementGroupsAPIClient(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 ManagementGroupsAPIClient 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 ManagementGroupsAPIClient(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 ManagementGroupsAPIClient 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 ManagementGroupsAPIClient(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() + { + ManagementGroups = new ManagementGroupsOperations(this); + ManagementGroupSubscriptions = new ManagementGroupSubscriptionsOperations(this); + HierarchySettings = new HierarchySettingsOperations(this); + Operations = new Operations(this); + Entities = new EntitiesOperations(this); + BaseUri = new System.Uri("https://management.azure.com"); + ApiVersion = "2023-04-01"; + 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() + } + }; + SerializationSettings.Converters.Add(new TransformationJsonConverter()); + 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() + } + }; + CustomInitialize(); + DeserializationSettings.Converters.Add(new TransformationJsonConverter()); + DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); + } + /// + /// Checks if the specified management group name is valid and unique + /// + /// + /// Management group name availability check parameters. + /// + /// + /// 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> CheckNameAvailabilityWithHttpMessagesAsync(CheckNameAvailabilityRequest checkNameAvailabilityRequest, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion"); + } + if (checkNameAvailabilityRequest == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "checkNameAvailabilityRequest"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("checkNameAvailabilityRequest", checkNameAvailabilityRequest); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CheckNameAvailability", tracingParameters); + } + // Construct URL + var _baseUrl = BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/checkNameAvailability").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(checkNameAvailabilityRequest != null) + { + _requestContent = SafeJsonConvert.SerializeObject(checkNameAvailabilityRequest, 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; + } + + /// + /// Starts backfilling subscriptions for the Tenant. + /// + /// + /// 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> StartTenantBackfillWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "StartTenantBackfill", tracingParameters); + } + // Construct URL + var _baseUrl = BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/startTenantBackfill").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; + // 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; + } + + /// + /// Gets tenant backfill status + /// + /// + /// 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> TenantBackfillStatusWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "TenantBackfillStatus", tracingParameters); + } + // Construct URL + var _baseUrl = BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/tenantBackfillStatus").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; + // Set Credentials + if (Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/ManagementGroupsAPIClientExtensions.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/ManagementGroupsAPIClientExtensions.cs new file mode 100644 index 000000000000..e62b112a40fa --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/ManagementGroupsAPIClientExtensions.cs @@ -0,0 +1,115 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ManagementGroups +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ManagementGroupsAPIClient. + /// + public static partial class ManagementGroupsAPIClientExtensions + { + /// + /// Checks if the specified management group name is valid and unique + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management group name availability check parameters. + /// + public static CheckNameAvailabilityResult CheckNameAvailability(this IManagementGroupsAPIClient operations, CheckNameAvailabilityRequest checkNameAvailabilityRequest) + { + return operations.CheckNameAvailabilityAsync(checkNameAvailabilityRequest).GetAwaiter().GetResult(); + } + + /// + /// Checks if the specified management group name is valid and unique + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management group name availability check parameters. + /// + /// + /// The cancellation token. + /// + public static async Task CheckNameAvailabilityAsync(this IManagementGroupsAPIClient operations, CheckNameAvailabilityRequest checkNameAvailabilityRequest, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CheckNameAvailabilityWithHttpMessagesAsync(checkNameAvailabilityRequest, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Starts backfilling subscriptions for the Tenant. + /// + /// + /// The operations group for this extension method. + /// + public static TenantBackfillStatusResult StartTenantBackfill(this IManagementGroupsAPIClient operations) + { + return operations.StartTenantBackfillAsync().GetAwaiter().GetResult(); + } + + /// + /// Starts backfilling subscriptions for the Tenant. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task StartTenantBackfillAsync(this IManagementGroupsAPIClient operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.StartTenantBackfillWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets tenant backfill status + /// + /// + /// The operations group for this extension method. + /// + public static TenantBackfillStatusResult TenantBackfillStatus(this IManagementGroupsAPIClient operations) + { + return operations.TenantBackfillStatusAsync().GetAwaiter().GetResult(); + } + + /// + /// Gets tenant backfill status + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task TenantBackfillStatusAsync(this IManagementGroupsAPIClient operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.TenantBackfillStatusWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/ManagementGroupsOperations.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/ManagementGroupsOperations.cs new file mode 100644 index 000000000000..c78527167915 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/ManagementGroupsOperations.cs @@ -0,0 +1,1724 @@ +// +// 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.ManagementGroups +{ + 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; + + /// + /// ManagementGroupsOperations operations. + /// + internal partial class ManagementGroupsOperations : IServiceOperations, IManagementGroupsOperations + { + /// + /// Initializes a new instance of the ManagementGroupsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ManagementGroupsOperations(ManagementGroupsAPIClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ManagementGroupsAPIClient + /// + public ManagementGroupsAPIClient Client { get; private set; } + + /// + /// List management groups for the authenticated user. + /// + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// Page continuation token is only used if a previous operation returned a + /// partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a token parameter that specifies a starting + /// point to use for subsequent calls. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(string cacheControl = "no-cache", string skiptoken = default(string), 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("cacheControl", cacheControl); + tracingParameters.Add("skiptoken", skiptoken); + 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.Management/managementGroups").ToString(); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (skiptoken != null) + { + _queryParameters.Add(string.Format("$skiptoken={0}", System.Uri.EscapeDataString(skiptoken))); + } + 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 (cacheControl != null) + { + if (_httpRequest.Headers.Contains("Cache-Control")) + { + _httpRequest.Headers.Remove("Cache-Control"); + } + _httpRequest.Headers.TryAddWithoutValidation("Cache-Control", cacheControl); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get the details of the management group. + /// + /// + /// + /// Management Group ID. + /// + /// + /// The $expand=children query string parameter allows clients to request + /// inclusion of children in the response payload. $expand=path includes the + /// path from the root group to the current group. $expand=ancestors includes + /// the ancestor Ids of the current group. Possible values include: 'children', + /// 'path', 'ancestors' + /// + /// + /// The $recurse=true query string parameter allows clients to request + /// inclusion of entire hierarchy in the response payload. Note that + /// $expand=children must be passed up if $recurse is set to true. + /// + /// + /// A filter which allows the exclusion of subscriptions from results (i.e. + /// '$filter=children.childType ne Subscription') + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string groupId, string expand = default(string), bool? recurse = default(bool?), string filter = default(string), string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + 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("groupId", groupId); + tracingParameters.Add("expand", expand); + tracingParameters.Add("recurse", recurse); + tracingParameters.Add("filter", filter); + tracingParameters.Add("cacheControl", cacheControl); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + if (recurse != null) + { + _queryParameters.Add(string.Format("$recurse={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(recurse, Client.SerializationSettings).Trim('"')))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + 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 (cacheControl != null) + { + if (_httpRequest.Headers.Contains("Cache-Control")) + { + _httpRequest.Headers.Remove("Cache-Control"); + } + _httpRequest.Headers.TryAddWithoutValidation("Cache-Control", cacheControl); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update a management group. + /// If a management group is already created and a subsequent create request is + /// issued with different properties, the management group properties will be + /// updated. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Management group creation parameters. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string groupId, CreateManagementGroupRequest createManagementGroupRequest, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(groupId, createManagementGroupRequest, cacheControl, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Update a management group. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Management group patch parameters. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> UpdateWithHttpMessagesAsync(string groupId, PatchManagementGroupRequest patchGroupRequest, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (patchGroupRequest == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "patchGroupRequest"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("groupId", groupId); + tracingParameters.Add("cacheControl", cacheControl); + tracingParameters.Add("patchGroupRequest", patchGroupRequest); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PATCH"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (cacheControl != null) + { + if (_httpRequest.Headers.Contains("Cache-Control")) + { + _httpRequest.Headers.Remove("Cache-Control"); + } + _httpRequest.Headers.TryAddWithoutValidation("Cache-Control", cacheControl); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(patchGroupRequest != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(patchGroupRequest, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete management group. + /// If a management group contains child resources, the request will fail. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> DeleteWithHttpMessagesAsync(string groupId, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(groupId, cacheControl, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// List all entities that descend from a management group. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Page continuation token is only used if a previous operation returned a + /// partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a token parameter that specifies a starting + /// point to use for subsequent calls. + /// + /// + /// Number of elements to return when retrieving results. Passing this in will + /// override $skipToken. + /// + /// + /// 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>> GetDescendantsWithHttpMessagesAsync(string groupId, string skiptoken = default(string), int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + 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("groupId", groupId); + tracingParameters.Add("skiptoken", skiptoken); + tracingParameters.Add("top", top); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetDescendants", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/descendants").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (skiptoken != null) + { + _queryParameters.Add(string.Format("$skiptoken={0}", System.Uri.EscapeDataString(skiptoken))); + } + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update a management group. + /// If a management group is already created and a subsequent create request is + /// issued with different properties, the management group properties will be + /// updated. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Management group creation parameters. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string groupId, CreateManagementGroupRequest createManagementGroupRequest, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (createManagementGroupRequest == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "createManagementGroupRequest"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("groupId", groupId); + tracingParameters.Add("cacheControl", cacheControl); + tracingParameters.Add("createManagementGroupRequest", createManagementGroupRequest); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (cacheControl != null) + { + if (_httpRequest.Headers.Contains("Cache-Control")) + { + _httpRequest.Headers.Remove("Cache-Control"); + } + _httpRequest.Headers.TryAddWithoutValidation("Cache-Control", cacheControl); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(createManagementGroupRequest != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(createManagementGroupRequest, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 202) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 202) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete management group. + /// If a management group contains child resources, the request will fail. + /// + /// + /// + /// Management Group ID. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// 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> BeginDeleteWithHttpMessagesAsync(string groupId, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + 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("groupId", groupId); + tracingParameters.Add("cacheControl", cacheControl); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (cacheControl != null) + { + if (_httpRequest.Headers.Contains("Cache-Control")) + { + _httpRequest.Headers.Remove("Cache-Control"); + } + _httpRequest.Headers.TryAddWithoutValidation("Cache-Control", cacheControl); + } + 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 != 202 && (int)_statusCode != 204) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 202) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + try + { + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the headers.", _httpResponse.GetHeadersAsJson().ToString(), ex); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List management groups for the authenticated user. + /// + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cacheControl", cacheControl); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (cacheControl != null) + { + if (_httpRequest.Headers.Contains("Cache-Control")) + { + _httpRequest.Headers.Remove("Cache-Control"); + } + _httpRequest.Headers.TryAddWithoutValidation("Cache-Control", cacheControl); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List all entities that descend from a management group. + /// + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> GetDescendantsNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetDescendantsNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/ManagementGroupsOperationsExtensions.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/ManagementGroupsOperationsExtensions.cs new file mode 100644 index 000000000000..56b483e9ef07 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/ManagementGroupsOperationsExtensions.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.ManagementGroups +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ManagementGroupsOperations. + /// + public static partial class ManagementGroupsOperationsExtensions + { + /// + /// List management groups for the authenticated user. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// Page continuation token is only used if a previous operation returned a + /// partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a token parameter that specifies a starting + /// point to use for subsequent calls. + /// + public static IPage List(this IManagementGroupsOperations operations, string cacheControl = "no-cache", string skiptoken = default(string)) + { + return operations.ListAsync(cacheControl, skiptoken).GetAwaiter().GetResult(); + } + + /// + /// List management groups for the authenticated user. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// Page continuation token is only used if a previous operation returned a + /// partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a token parameter that specifies a starting + /// point to use for subsequent calls. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IManagementGroupsOperations operations, string cacheControl = "no-cache", string skiptoken = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(cacheControl, skiptoken, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get the details of the management group. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// The $expand=children query string parameter allows clients to request + /// inclusion of children in the response payload. $expand=path includes the + /// path from the root group to the current group. $expand=ancestors includes + /// the ancestor Ids of the current group. Possible values include: 'children', + /// 'path', 'ancestors' + /// + /// + /// The $recurse=true query string parameter allows clients to request + /// inclusion of entire hierarchy in the response payload. Note that + /// $expand=children must be passed up if $recurse is set to true. + /// + /// + /// A filter which allows the exclusion of subscriptions from results (i.e. + /// '$filter=children.childType ne Subscription') + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + public static ManagementGroup Get(this IManagementGroupsOperations operations, string groupId, string expand = default(string), bool? recurse = default(bool?), string filter = default(string), string cacheControl = "no-cache") + { + return operations.GetAsync(groupId, expand, recurse, filter, cacheControl).GetAwaiter().GetResult(); + } + + /// + /// Get the details of the management group. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// The $expand=children query string parameter allows clients to request + /// inclusion of children in the response payload. $expand=path includes the + /// path from the root group to the current group. $expand=ancestors includes + /// the ancestor Ids of the current group. Possible values include: 'children', + /// 'path', 'ancestors' + /// + /// + /// The $recurse=true query string parameter allows clients to request + /// inclusion of entire hierarchy in the response payload. Note that + /// $expand=children must be passed up if $recurse is set to true. + /// + /// + /// A filter which allows the exclusion of subscriptions from results (i.e. + /// '$filter=children.childType ne Subscription') + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IManagementGroupsOperations operations, string groupId, string expand = default(string), bool? recurse = default(bool?), string filter = default(string), string cacheControl = "no-cache", CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(groupId, expand, recurse, filter, cacheControl, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update a management group. + /// If a management group is already created and a subsequent create request is + /// issued with different properties, the management group properties will be + /// updated. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// Management group creation parameters. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + public static object CreateOrUpdate(this IManagementGroupsOperations operations, string groupId, CreateManagementGroupRequest createManagementGroupRequest, string cacheControl = "no-cache") + { + return operations.CreateOrUpdateAsync(groupId, createManagementGroupRequest, cacheControl).GetAwaiter().GetResult(); + } + + /// + /// Create or update a management group. + /// If a management group is already created and a subsequent create request is + /// issued with different properties, the management group properties will be + /// updated. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// Management group creation parameters. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IManagementGroupsOperations operations, string groupId, CreateManagementGroupRequest createManagementGroupRequest, string cacheControl = "no-cache", CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(groupId, createManagementGroupRequest, cacheControl, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Update a management group. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// Management group patch parameters. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + public static ManagementGroup Update(this IManagementGroupsOperations operations, string groupId, PatchManagementGroupRequest patchGroupRequest, string cacheControl = "no-cache") + { + return operations.UpdateAsync(groupId, patchGroupRequest, cacheControl).GetAwaiter().GetResult(); + } + + /// + /// Update a management group. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// Management group patch parameters. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IManagementGroupsOperations operations, string groupId, PatchManagementGroupRequest patchGroupRequest, string cacheControl = "no-cache", CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(groupId, patchGroupRequest, cacheControl, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete management group. + /// If a management group contains child resources, the request will fail. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + public static AzureAsyncOperationResults Delete(this IManagementGroupsOperations operations, string groupId, string cacheControl = "no-cache") + { + return operations.DeleteAsync(groupId, cacheControl).GetAwaiter().GetResult(); + } + + /// + /// Delete management group. + /// If a management group contains child resources, the request will fail. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IManagementGroupsOperations operations, string groupId, string cacheControl = "no-cache", CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.DeleteWithHttpMessagesAsync(groupId, cacheControl, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all entities that descend from a management group. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// Page continuation token is only used if a previous operation returned a + /// partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a token parameter that specifies a starting + /// point to use for subsequent calls. + /// + /// + /// Number of elements to return when retrieving results. Passing this in will + /// override $skipToken. + /// + public static IPage GetDescendants(this IManagementGroupsOperations operations, string groupId, string skiptoken = default(string), int? top = default(int?)) + { + return operations.GetDescendantsAsync(groupId, skiptoken, top).GetAwaiter().GetResult(); + } + + /// + /// List all entities that descend from a management group. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// Page continuation token is only used if a previous operation returned a + /// partial result. + /// If a previous response contains a nextLink element, the value of the + /// nextLink element will include a token parameter that specifies a starting + /// point to use for subsequent calls. + /// + /// + /// Number of elements to return when retrieving results. Passing this in will + /// override $skipToken. + /// + /// + /// The cancellation token. + /// + public static async Task> GetDescendantsAsync(this IManagementGroupsOperations operations, string groupId, string skiptoken = default(string), int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetDescendantsWithHttpMessagesAsync(groupId, skiptoken, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update a management group. + /// If a management group is already created and a subsequent create request is + /// issued with different properties, the management group properties will be + /// updated. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// Management group creation parameters. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + public static object BeginCreateOrUpdate(this IManagementGroupsOperations operations, string groupId, CreateManagementGroupRequest createManagementGroupRequest, string cacheControl = "no-cache") + { + return operations.BeginCreateOrUpdateAsync(groupId, createManagementGroupRequest, cacheControl).GetAwaiter().GetResult(); + } + + /// + /// Create or update a management group. + /// If a management group is already created and a subsequent create request is + /// issued with different properties, the management group properties will be + /// updated. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// Management group creation parameters. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IManagementGroupsOperations operations, string groupId, CreateManagementGroupRequest createManagementGroupRequest, string cacheControl = "no-cache", CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(groupId, createManagementGroupRequest, cacheControl, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete management group. + /// If a management group contains child resources, the request will fail. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + public static AzureAsyncOperationResults BeginDelete(this IManagementGroupsOperations operations, string groupId, string cacheControl = "no-cache") + { + return operations.BeginDeleteAsync(groupId, cacheControl).GetAwaiter().GetResult(); + } + + /// + /// Delete management group. + /// If a management group contains child resources, the request will fail. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// Management Group ID. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IManagementGroupsOperations operations, string groupId, string cacheControl = "no-cache", CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginDeleteWithHttpMessagesAsync(groupId, cacheControl, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List management groups for the authenticated user. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + public static IPage ListNext(this IManagementGroupsOperations operations, string nextPageLink, string cacheControl = "no-cache") + { + return operations.ListNextAsync(nextPageLink, cacheControl).GetAwaiter().GetResult(); + } + + /// + /// List management groups for the authenticated user. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Indicates whether the request should utilize any caches. Populate the + /// header with 'no-cache' value to bypass existing caches. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IManagementGroupsOperations operations, string nextPageLink, string cacheControl = "no-cache", CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, cacheControl, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List all entities that descend from a management group. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage GetDescendantsNext(this IManagementGroupsOperations operations, string nextPageLink) + { + return operations.GetDescendantsNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List all entities that descend from a management group. + /// + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> GetDescendantsNextAsync(this IManagementGroupsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetDescendantsNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/AzureAsyncOperationResults.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/AzureAsyncOperationResults.cs new file mode 100644 index 000000000000..193272ebfb6c --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/AzureAsyncOperationResults.cs @@ -0,0 +1,108 @@ +// +// 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.ManagementGroups.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The results of Azure-AsyncOperation. + /// + [Rest.Serialization.JsonTransformation] + public partial class AzureAsyncOperationResults + { + /// + /// Initializes a new instance of the AzureAsyncOperationResults class. + /// + public AzureAsyncOperationResults() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AzureAsyncOperationResults class. + /// + /// The fully qualified ID for the management group. + /// For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// The type of the resource. For example, + /// Microsoft.Management/managementGroups + /// The name of the management group. For example, + /// 00000000-0000-0000-0000-000000000000 + /// The current status of the asynchronous + /// operation performed . For example, Running, Succeeded, + /// Failed + /// The AAD Tenant ID associated with the + /// management group. For example, + /// 00000000-0000-0000-0000-000000000000 + /// The friendly name of the management + /// group. + public AzureAsyncOperationResults(string id = default(string), string type = default(string), string name = default(string), string status = default(string), string tenantId = default(string), string displayName = default(string)) + { + Id = id; + Type = type; + Name = name; + Status = status; + TenantId = tenantId; + DisplayName = displayName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the fully qualified ID for the management group. For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the type of the resource. For example, + /// Microsoft.Management/managementGroups + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets the name of the management group. For example, + /// 00000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the current status of the asynchronous operation performed . + /// For example, Running, Succeeded, Failed + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; private set; } + + /// + /// Gets or sets the AAD Tenant ID associated with the management + /// group. For example, 00000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "properties.tenantId")] + public string TenantId { get; set; } + + /// + /// Gets or sets the friendly name of the management group. + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/CheckNameAvailabilityRequest.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/CheckNameAvailabilityRequest.cs new file mode 100644 index 000000000000..dbd68cd3e4ce --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/CheckNameAvailabilityRequest.cs @@ -0,0 +1,65 @@ +// +// 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.ManagementGroups.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Management group name availability check parameters. + /// + public partial class CheckNameAvailabilityRequest + { + /// + /// Initializes a new instance of the CheckNameAvailabilityRequest + /// class. + /// + public CheckNameAvailabilityRequest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CheckNameAvailabilityRequest + /// class. + /// + /// the name to check for availability + /// fully qualified resource type which includes + /// provider namespace. Possible values include: + /// 'Microsoft.Management/managementGroups' + public CheckNameAvailabilityRequest(string name = default(string), Type? type = default(Type?)) + { + Name = name; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name to check for availability + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets fully qualified resource type which includes provider + /// namespace. Possible values include: + /// 'Microsoft.Management/managementGroups' + /// + [JsonProperty(PropertyName = "type")] + public Type? Type { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/CheckNameAvailabilityResult.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/CheckNameAvailabilityResult.cs new file mode 100644 index 000000000000..fdc50861b128 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/CheckNameAvailabilityResult.cs @@ -0,0 +1,91 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ManagementGroups.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Describes the result of the request to check management group name + /// availability. + /// + public partial class CheckNameAvailabilityResult + { + /// + /// Initializes a new instance of the CheckNameAvailabilityResult + /// class. + /// + public CheckNameAvailabilityResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CheckNameAvailabilityResult + /// class. + /// + /// Required. True indicates name is valid + /// and available. False indicates the name is invalid, unavailable, or + /// both. + /// Required if nameAvailable == false. Invalid + /// indicates the name provided does not match the resource provider's + /// naming requirements (incorrect length, unsupported characters, + /// etc.) AlreadyExists indicates that the name is already in use and + /// is therefore unavailable. Possible values include: 'Invalid', + /// 'AlreadyExists' + /// Required if nameAvailable == false. + /// Localized. If reason == invalid, provide the user with the reason + /// why the given name is invalid, and provide the resource naming + /// requirements so that the user can select a valid name. If reason == + /// AlreadyExists, explain that is already in use, and direct them to + /// select a different name. + public CheckNameAvailabilityResult(bool? nameAvailable = default(bool?), Reason? reason = default(Reason?), string message = default(string)) + { + NameAvailable = nameAvailable; + Reason = reason; + Message = message; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets required. True indicates name is valid and available. False + /// indicates the name is invalid, unavailable, or both. + /// + [JsonProperty(PropertyName = "nameAvailable")] + public bool? NameAvailable { get; private set; } + + /// + /// Gets required if nameAvailable == false. Invalid indicates the name + /// provided does not match the resource provider's naming requirements + /// (incorrect length, unsupported characters, etc.) AlreadyExists + /// indicates that the name is already in use and is therefore + /// unavailable. Possible values include: 'Invalid', 'AlreadyExists' + /// + [JsonProperty(PropertyName = "reason")] + public Reason? Reason { get; private set; } + + /// + /// Gets required if nameAvailable == false. Localized. If reason == + /// invalid, provide the user with the reason why the given name is + /// invalid, and provide the resource naming requirements so that the + /// user can select a valid name. If reason == AlreadyExists, explain + /// that is already in use, and direct them to select a different name. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; private set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/CreateManagementGroupChildInfo.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/CreateManagementGroupChildInfo.cs new file mode 100644 index 000000000000..b64df7bdfc96 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/CreateManagementGroupChildInfo.cs @@ -0,0 +1,97 @@ +// +// 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.ManagementGroups.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The child information of a management group used during creation. + /// + public partial class CreateManagementGroupChildInfo + { + /// + /// Initializes a new instance of the CreateManagementGroupChildInfo + /// class. + /// + public CreateManagementGroupChildInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CreateManagementGroupChildInfo + /// class. + /// + /// The type of child resource. + /// The fully qualified ID for the child resource + /// (management group or subscription). For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// The name of the child entity. + /// The friendly name of the child + /// resource. + /// The list of children. + public CreateManagementGroupChildInfo(ManagementGroupChildType? type = default(ManagementGroupChildType?), string id = default(string), string name = default(string), string displayName = default(string), IList children = default(IList)) + { + Type = type; + Id = id; + Name = name; + DisplayName = displayName; + Children = children; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the type of child resource. + /// + /// + /// The fully qualified resource type which includes provider namespace + /// (e.g. Microsoft.Management/managementGroups). Possible values + /// include: 'Microsoft.Management/managementGroups', '/subscriptions' + /// + [JsonProperty(PropertyName = "type")] + public ManagementGroupChildType? Type { get; private set; } + + /// + /// Gets the fully qualified ID for the child resource (management + /// group or subscription). For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the name of the child entity. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the friendly name of the child resource. + /// + [JsonProperty(PropertyName = "displayName")] + public string DisplayName { get; private set; } + + /// + /// Gets the list of children. + /// + [JsonProperty(PropertyName = "children")] + public IList Children { get; private set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/CreateManagementGroupDetails.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/CreateManagementGroupDetails.cs new file mode 100644 index 000000000000..efd948d4ecc3 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/CreateManagementGroupDetails.cs @@ -0,0 +1,80 @@ +// +// 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.ManagementGroups.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The details of a management group used during creation. + /// + public partial class CreateManagementGroupDetails + { + /// + /// Initializes a new instance of the CreateManagementGroupDetails + /// class. + /// + public CreateManagementGroupDetails() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CreateManagementGroupDetails + /// class. + /// + /// The version number of the object. + /// The date and time when this object was + /// last updated. + /// The identity of the principal or process + /// that updated the object. + /// Parent + public CreateManagementGroupDetails(double? version = default(double?), System.DateTime? updatedTime = default(System.DateTime?), string updatedBy = default(string), CreateParentGroupInfo parent = default(CreateParentGroupInfo)) + { + Version = version; + UpdatedTime = updatedTime; + UpdatedBy = updatedBy; + Parent = parent; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the version number of the object. + /// + [JsonProperty(PropertyName = "version")] + public double? Version { get; private set; } + + /// + /// Gets the date and time when this object was last updated. + /// + [JsonProperty(PropertyName = "updatedTime")] + public System.DateTime? UpdatedTime { get; private set; } + + /// + /// Gets the identity of the principal or process that updated the + /// object. + /// + [JsonProperty(PropertyName = "updatedBy")] + public string UpdatedBy { get; private set; } + + /// + /// Gets or sets parent + /// + [JsonProperty(PropertyName = "parent")] + public CreateParentGroupInfo Parent { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/CreateManagementGroupRequest.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/CreateManagementGroupRequest.cs new file mode 100644 index 000000000000..ac4942b13a04 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/CreateManagementGroupRequest.cs @@ -0,0 +1,120 @@ +// +// 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.ManagementGroups.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Management group creation parameters. + /// + [Rest.Serialization.JsonTransformation] + public partial class CreateManagementGroupRequest : IResource + { + /// + /// Initializes a new instance of the CreateManagementGroupRequest + /// class. + /// + public CreateManagementGroupRequest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CreateManagementGroupRequest + /// class. + /// + /// The fully qualified ID for the management group. + /// For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// The type of the resource. For example, + /// Microsoft.Management/managementGroups + /// The name of the management group. For example, + /// 00000000-0000-0000-0000-000000000000 + /// The AAD Tenant ID associated with the + /// management group. For example, + /// 00000000-0000-0000-0000-000000000000 + /// The friendly name of the management + /// group. If no value is passed then this field will be set to the + /// groupId. + /// Details + /// The list of children. + public CreateManagementGroupRequest(string id = default(string), string type = default(string), string name = default(string), string tenantId = default(string), string displayName = default(string), CreateManagementGroupDetails details = default(CreateManagementGroupDetails), IList children = default(IList)) + { + Id = id; + Type = type; + Name = name; + TenantId = tenantId; + DisplayName = displayName; + Details = details; + Children = children; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the fully qualified ID for the management group. For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the type of the resource. For example, + /// Microsoft.Management/managementGroups + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets or sets the name of the management group. For example, + /// 00000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets the AAD Tenant ID associated with the management group. For + /// example, 00000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "properties.tenantId")] + public string TenantId { get; private set; } + + /// + /// Gets or sets the friendly name of the management group. If no value + /// is passed then this field will be set to the groupId. + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets details + /// + [JsonProperty(PropertyName = "properties.details")] + public CreateManagementGroupDetails Details { get; set; } + + /// + /// Gets the list of children. + /// + [JsonProperty(PropertyName = "properties.children")] + public IList Children { get; private set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/CreateOrUpdateSettingsRequest.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/CreateOrUpdateSettingsRequest.cs new file mode 100644 index 000000000000..4eadc039c93c --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/CreateOrUpdateSettingsRequest.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.ManagementGroups.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Parameters for creating or updating Management Group settings + /// + [Rest.Serialization.JsonTransformation] + public partial class CreateOrUpdateSettingsRequest : IResource + { + /// + /// Initializes a new instance of the CreateOrUpdateSettingsRequest + /// class. + /// + public CreateOrUpdateSettingsRequest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CreateOrUpdateSettingsRequest + /// class. + /// + /// Indicates + /// whether RBAC access is required upon group creation under the root + /// Management Group. If set to true, user will require + /// Microsoft.Management/managementGroups/write action on the root + /// Management Group scope in order to create new Groups directly under + /// the root. This will prevent new users from creating new Management + /// Groups, unless they are given access. + /// Settings that sets the default + /// Management Group under which new subscriptions get added in this + /// tenant. For example, + /// /providers/Microsoft.Management/managementGroups/defaultGroup + public CreateOrUpdateSettingsRequest(bool? requireAuthorizationForGroupCreation = default(bool?), string defaultManagementGroup = default(string)) + { + RequireAuthorizationForGroupCreation = requireAuthorizationForGroupCreation; + DefaultManagementGroup = defaultManagementGroup; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets indicates whether RBAC access is required upon group + /// creation under the root Management Group. If set to true, user will + /// require Microsoft.Management/managementGroups/write action on the + /// root Management Group scope in order to create new Groups directly + /// under the root. This will prevent new users from creating new + /// Management Groups, unless they are given access. + /// + [JsonProperty(PropertyName = "properties.requireAuthorizationForGroupCreation")] + public bool? RequireAuthorizationForGroupCreation { get; set; } + + /// + /// Gets or sets settings that sets the default Management Group under + /// which new subscriptions get added in this tenant. For example, + /// /providers/Microsoft.Management/managementGroups/defaultGroup + /// + [JsonProperty(PropertyName = "properties.defaultManagementGroup")] + public string DefaultManagementGroup { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/CreateParentGroupInfo.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/CreateParentGroupInfo.cs new file mode 100644 index 000000000000..53fe697eb3ce --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/CreateParentGroupInfo.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.ManagementGroups.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// (Optional) The ID of the parent management group used during creation. + /// + public partial class CreateParentGroupInfo + { + /// + /// Initializes a new instance of the CreateParentGroupInfo class. + /// + public CreateParentGroupInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CreateParentGroupInfo class. + /// + /// The fully qualified ID for the parent management + /// group. For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// The name of the parent management group + /// The friendly name of the parent + /// management group. + public CreateParentGroupInfo(string id = default(string), string name = default(string), string displayName = default(string)) + { + Id = id; + Name = name; + DisplayName = displayName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the fully qualified ID for the parent management + /// group. For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets the name of the parent management group + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the friendly name of the parent management group. + /// + [JsonProperty(PropertyName = "displayName")] + public string DisplayName { get; private set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/DescendantInfo.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/DescendantInfo.cs new file mode 100644 index 000000000000..9daf4ccd201b --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/DescendantInfo.cs @@ -0,0 +1,96 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ManagementGroups.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The descendant. + /// + [Rest.Serialization.JsonTransformation] + public partial class DescendantInfo + { + /// + /// Initializes a new instance of the DescendantInfo class. + /// + public DescendantInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DescendantInfo class. + /// + /// The fully qualified ID for the descendant. For + /// example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// or /subscriptions/0000000-0000-0000-0000-000000000000 + /// The type of the resource. For example, + /// Microsoft.Management/managementGroups or /subscriptions + /// The name of the descendant. For example, + /// 00000000-0000-0000-0000-000000000000 + /// The friendly name of the management + /// group. + /// Parent + public DescendantInfo(string id = default(string), string type = default(string), string name = default(string), string displayName = default(string), DescendantParentGroupInfo parent = default(DescendantParentGroupInfo)) + { + Id = id; + Type = type; + Name = name; + DisplayName = displayName; + Parent = parent; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the fully qualified ID for the descendant. For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// or /subscriptions/0000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the type of the resource. For example, + /// Microsoft.Management/managementGroups or /subscriptions + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets the name of the descendant. For example, + /// 00000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the friendly name of the management group. + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets parent + /// + [JsonProperty(PropertyName = "properties.parent")] + public DescendantParentGroupInfo Parent { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/DescendantParentGroupInfo.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/DescendantParentGroupInfo.cs new file mode 100644 index 000000000000..7988d461e814 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/DescendantParentGroupInfo.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.ManagementGroups.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The ID of the parent management group. + /// + public partial class DescendantParentGroupInfo + { + /// + /// Initializes a new instance of the DescendantParentGroupInfo class. + /// + public DescendantParentGroupInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DescendantParentGroupInfo class. + /// + /// The fully qualified ID for the parent management + /// group. For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + public DescendantParentGroupInfo(string id = default(string)) + { + Id = id; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the fully qualified ID for the parent management + /// group. For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/EntityHierarchyItem.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/EntityHierarchyItem.cs new file mode 100644 index 000000000000..4a429711401e --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/EntityHierarchyItem.cs @@ -0,0 +1,108 @@ +// +// 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.ManagementGroups.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The management group details for the hierarchy view. + /// + [Rest.Serialization.JsonTransformation] + public partial class EntityHierarchyItem : IResource + { + /// + /// Initializes a new instance of the EntityHierarchyItem class. + /// + public EntityHierarchyItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EntityHierarchyItem class. + /// + /// The fully qualified ID for the management group. + /// For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// The type of the resource. For example, + /// Microsoft.Management/managementGroups + /// The name of the management group. For example, + /// 00000000-0000-0000-0000-000000000000 + /// The friendly name of the management + /// group. + /// Permissions + /// The list of children. + public EntityHierarchyItem(string id = default(string), string type = default(string), string name = default(string), string displayName = default(string), Permissions? permissions = default(Permissions?), IList children = default(IList)) + { + Id = id; + Type = type; + Name = name; + DisplayName = displayName; + Permissions = permissions; + Children = children; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the fully qualified ID for the management group. For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the type of the resource. For example, + /// Microsoft.Management/managementGroups + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets the name of the management group. For example, + /// 00000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the friendly name of the management group. + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets permissions + /// + /// + /// Possible values include: 'noaccess', 'view', 'edit', 'delete' + /// + [JsonProperty(PropertyName = "properties.permissions")] + public Permissions? Permissions { get; set; } + + /// + /// Gets or sets the list of children. + /// + [JsonProperty(PropertyName = "properties.children")] + public IList Children { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/EntityInfo.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/EntityInfo.cs new file mode 100644 index 000000000000..e8a1f73965b3 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/EntityInfo.cs @@ -0,0 +1,180 @@ +// +// 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.ManagementGroups.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The entity. + /// + [Rest.Serialization.JsonTransformation] + public partial class EntityInfo + { + /// + /// Initializes a new instance of the EntityInfo class. + /// + public EntityInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EntityInfo class. + /// + /// The fully qualified ID for the entity. For + /// example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// The type of the resource. For example, + /// Microsoft.Management/managementGroups + /// The name of the entity. For example, + /// 00000000-0000-0000-0000-000000000000 + /// The AAD Tenant ID associated with the + /// entity. For example, 00000000-0000-0000-0000-000000000000 + /// The friendly name of the management + /// group. + /// Parent + /// Permissions + /// Inherited Permissions + /// Number of Descendants + /// Number of Children + /// Number of Child Groups + /// The parent display name chain + /// from the root group to the immediate parent + /// The parent name chain from the root + /// group to the immediate parent + public EntityInfo(string id = default(string), string type = default(string), string name = default(string), string tenantId = default(string), string displayName = default(string), EntityParentGroupInfo parent = default(EntityParentGroupInfo), Permissions? permissions = default(Permissions?), Permissions? inheritedPermissions = default(Permissions?), int? numberOfDescendants = default(int?), int? numberOfChildren = default(int?), int? numberOfChildGroups = default(int?), IList parentDisplayNameChain = default(IList), IList parentNameChain = default(IList)) + { + Id = id; + Type = type; + Name = name; + TenantId = tenantId; + DisplayName = displayName; + Parent = parent; + Permissions = permissions; + InheritedPermissions = inheritedPermissions; + NumberOfDescendants = numberOfDescendants; + NumberOfChildren = numberOfChildren; + NumberOfChildGroups = numberOfChildGroups; + ParentDisplayNameChain = parentDisplayNameChain; + ParentNameChain = parentNameChain; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the fully qualified ID for the entity. For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the type of the resource. For example, + /// Microsoft.Management/managementGroups + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets the name of the entity. For example, + /// 00000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the AAD Tenant ID associated with the entity. For + /// example, 00000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "properties.tenantId")] + public string TenantId { get; set; } + + /// + /// Gets or sets the friendly name of the management group. + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets parent + /// + [JsonProperty(PropertyName = "properties.parent")] + public EntityParentGroupInfo Parent { get; set; } + + /// + /// Gets or sets permissions + /// + /// + /// Possible values include: 'noaccess', 'view', 'edit', 'delete' + /// + [JsonProperty(PropertyName = "properties.permissions")] + public Permissions? Permissions { get; set; } + + /// + /// Gets or sets inherited Permissions + /// + /// + /// Possible values include: 'noaccess', 'view', 'edit', 'delete' + /// + [JsonProperty(PropertyName = "properties.inheritedPermissions")] + public Permissions? InheritedPermissions { get; set; } + + /// + /// Gets or sets number of Descendants + /// + [JsonProperty(PropertyName = "properties.numberOfDescendants")] + public int? NumberOfDescendants { get; set; } + + /// + /// Gets or sets number of Children + /// + /// + /// Number of children is the number of Groups and Subscriptions that + /// are exactly one level underneath the current Group. + /// + [JsonProperty(PropertyName = "properties.numberOfChildren")] + public int? NumberOfChildren { get; set; } + + /// + /// Gets or sets number of Child Groups + /// + /// + /// Number of children is the number of Groups that are exactly one + /// level underneath the current Group. + /// + [JsonProperty(PropertyName = "properties.numberOfChildGroups")] + public int? NumberOfChildGroups { get; set; } + + /// + /// Gets or sets the parent display name chain from the root group to + /// the immediate parent + /// + [JsonProperty(PropertyName = "properties.parentDisplayNameChain")] + public IList ParentDisplayNameChain { get; set; } + + /// + /// Gets or sets the parent name chain from the root group to the + /// immediate parent + /// + [JsonProperty(PropertyName = "properties.parentNameChain")] + public IList ParentNameChain { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/EntityParentGroupInfo.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/EntityParentGroupInfo.cs new file mode 100644 index 000000000000..aa62f3c54c87 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/EntityParentGroupInfo.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.ManagementGroups.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// (Optional) The ID of the parent management group. + /// + public partial class EntityParentGroupInfo + { + /// + /// Initializes a new instance of the EntityParentGroupInfo class. + /// + public EntityParentGroupInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EntityParentGroupInfo class. + /// + /// The fully qualified ID for the parent management + /// group. For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + public EntityParentGroupInfo(string id = default(string)) + { + Id = id; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the fully qualified ID for the parent management + /// group. For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/EntitySearchType.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/EntitySearchType.cs new file mode 100644 index 000000000000..590ac38f2ad4 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/EntitySearchType.cs @@ -0,0 +1,25 @@ +// +// 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.ManagementGroups.Models +{ + + /// + /// Defines values for EntitySearchType. + /// + public static class EntitySearchType + { + public const string AllowedParents = "AllowedParents"; + public const string AllowedChildren = "AllowedChildren"; + public const string ParentAndFirstLevelChildren = "ParentAndFirstLevelChildren"; + public const string ParentOnly = "ParentOnly"; + public const string ChildrenOnly = "ChildrenOnly"; + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/EntityViewParameterType.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/EntityViewParameterType.cs new file mode 100644 index 000000000000..3e48c7b616cf --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/EntityViewParameterType.cs @@ -0,0 +1,24 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ManagementGroups.Models +{ + + /// + /// Defines values for EntityViewParameterType. + /// + public static class EntityViewParameterType + { + public const string FullHierarchy = "FullHierarchy"; + public const string GroupsOnly = "GroupsOnly"; + public const string SubscriptionsOnly = "SubscriptionsOnly"; + public const string Audit = "Audit"; + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ErrorDetails.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ErrorDetails.cs new file mode 100644 index 000000000000..41d7c17b749b --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ErrorDetails.cs @@ -0,0 +1,71 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ManagementGroups.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The details of the error. + /// + public partial class ErrorDetails + { + /// + /// Initializes a new instance of the ErrorDetails class. + /// + public ErrorDetails() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorDetails class. + /// + /// One of a server-defined set of error + /// codes. + /// A human-readable representation of the + /// error. + /// A human-readable representation of the + /// error's details. + public ErrorDetails(string code = default(string), string message = default(string), string details = default(string)) + { + Code = code; + Message = message; + Details = details; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets one of a server-defined set of error codes. + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; set; } + + /// + /// Gets or sets a human-readable representation of the error. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + /// + /// Gets or sets a human-readable representation of the error's + /// details. + /// + [JsonProperty(PropertyName = "details")] + public string Details { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ErrorResponse.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ErrorResponse.cs new file mode 100644 index 000000000000..735ee8f44514 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ErrorResponse.cs @@ -0,0 +1,51 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ManagementGroups.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The error object. + /// + public partial class ErrorResponse + { + /// + /// Initializes a new instance of the ErrorResponse class. + /// + public ErrorResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorResponse class. + /// + /// Error + public ErrorResponse(ErrorDetails error = default(ErrorDetails)) + { + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets error + /// + [JsonProperty(PropertyName = "error")] + public ErrorDetails Error { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ErrorResponseException.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ErrorResponseException.cs new file mode 100644 index 000000000000..b843ee906177 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/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.ManagementGroups.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/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/HierarchySettings.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/HierarchySettings.cs new file mode 100644 index 000000000000..0ac33a9cf7e4 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/HierarchySettings.cs @@ -0,0 +1,120 @@ +// +// 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.ManagementGroups.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Settings defined at the Management Group scope. + /// + [Rest.Serialization.JsonTransformation] + public partial class HierarchySettings : IResource + { + /// + /// Initializes a new instance of the HierarchySettings class. + /// + public HierarchySettings() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the HierarchySettings class. + /// + /// The fully qualified ID for the settings object. + /// For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000/settings/default. + /// The type of the resource. For example, + /// Microsoft.Management/managementGroups/settings. + /// The name of the object. In this case, + /// default. + /// The AAD Tenant ID associated with the + /// hierarchy settings. For example, + /// 00000000-0000-0000-0000-000000000000 + /// Indicates + /// whether RBAC access is required upon group creation under the root + /// Management Group. If set to true, user will require + /// Microsoft.Management/managementGroups/write action on the root + /// Management Group scope in order to create new Groups directly under + /// the root. This will prevent new users from creating new Management + /// Groups, unless they are given access. + /// Settings that sets the default + /// Management Group under which new subscriptions get added in this + /// tenant. For example, + /// /providers/Microsoft.Management/managementGroups/defaultGroup + public HierarchySettings(string id = default(string), string type = default(string), string name = default(string), string tenantId = default(string), bool? requireAuthorizationForGroupCreation = default(bool?), string defaultManagementGroup = default(string)) + { + Id = id; + Type = type; + Name = name; + TenantId = tenantId; + RequireAuthorizationForGroupCreation = requireAuthorizationForGroupCreation; + DefaultManagementGroup = defaultManagementGroup; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the fully qualified ID for the settings object. For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000/settings/default. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the type of the resource. For example, + /// Microsoft.Management/managementGroups/settings. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets the name of the object. In this case, default. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the AAD Tenant ID associated with the hierarchy + /// settings. For example, 00000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "properties.tenantId")] + public string TenantId { get; set; } + + /// + /// Gets or sets indicates whether RBAC access is required upon group + /// creation under the root Management Group. If set to true, user will + /// require Microsoft.Management/managementGroups/write action on the + /// root Management Group scope in order to create new Groups directly + /// under the root. This will prevent new users from creating new + /// Management Groups, unless they are given access. + /// + [JsonProperty(PropertyName = "properties.requireAuthorizationForGroupCreation")] + public bool? RequireAuthorizationForGroupCreation { get; set; } + + /// + /// Gets or sets settings that sets the default Management Group under + /// which new subscriptions get added in this tenant. For example, + /// /providers/Microsoft.Management/managementGroups/defaultGroup + /// + [JsonProperty(PropertyName = "properties.defaultManagementGroup")] + public string DefaultManagementGroup { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/HierarchySettingsInfo.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/HierarchySettingsInfo.cs new file mode 100644 index 000000000000..1e2132d057b0 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/HierarchySettingsInfo.cs @@ -0,0 +1,119 @@ +// +// 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.ManagementGroups.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The hierarchy settings resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class HierarchySettingsInfo + { + /// + /// Initializes a new instance of the HierarchySettingsInfo class. + /// + public HierarchySettingsInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the HierarchySettingsInfo class. + /// + /// The fully qualified ID for the settings object. + /// For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000/settings/default. + /// The type of the resource. For example, + /// Microsoft.Management/managementGroups/settings. + /// The name of the object. In this case, + /// default. + /// The AAD Tenant ID associated with the + /// hierarchy settings. For example, + /// 00000000-0000-0000-0000-000000000000 + /// Indicates + /// whether RBAC access is required upon group creation under the root + /// Management Group. If set to true, user will require + /// Microsoft.Management/managementGroups/write action on the root + /// Management Group scope in order to create new Groups directly under + /// the root. This will prevent new users from creating new Management + /// Groups, unless they are given access. + /// Settings that sets the default + /// Management Group under which new subscriptions get added in this + /// tenant. For example, + /// /providers/Microsoft.Management/managementGroups/defaultGroup + public HierarchySettingsInfo(string id = default(string), string type = default(string), string name = default(string), string tenantId = default(string), bool? requireAuthorizationForGroupCreation = default(bool?), string defaultManagementGroup = default(string)) + { + Id = id; + Type = type; + Name = name; + TenantId = tenantId; + RequireAuthorizationForGroupCreation = requireAuthorizationForGroupCreation; + DefaultManagementGroup = defaultManagementGroup; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the fully qualified ID for the settings object. For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000/settings/default. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the type of the resource. For example, + /// Microsoft.Management/managementGroups/settings. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets the name of the object. In this case, default. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the AAD Tenant ID associated with the hierarchy + /// settings. For example, 00000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "properties.tenantId")] + public string TenantId { get; set; } + + /// + /// Gets or sets indicates whether RBAC access is required upon group + /// creation under the root Management Group. If set to true, user will + /// require Microsoft.Management/managementGroups/write action on the + /// root Management Group scope in order to create new Groups directly + /// under the root. This will prevent new users from creating new + /// Management Groups, unless they are given access. + /// + [JsonProperty(PropertyName = "properties.requireAuthorizationForGroupCreation")] + public bool? RequireAuthorizationForGroupCreation { get; set; } + + /// + /// Gets or sets settings that sets the default Management Group under + /// which new subscriptions get added in this tenant. For example, + /// /providers/Microsoft.Management/managementGroups/defaultGroup + /// + [JsonProperty(PropertyName = "properties.defaultManagementGroup")] + public string DefaultManagementGroup { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/HierarchySettingsList.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/HierarchySettingsList.cs new file mode 100644 index 000000000000..0822b412c072 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/HierarchySettingsList.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.ManagementGroups.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Lists all hierarchy settings. + /// + public partial class HierarchySettingsList + { + /// + /// Initializes a new instance of the HierarchySettingsList class. + /// + public HierarchySettingsList() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the HierarchySettingsList class. + /// + /// The list of hierarchy settings. + /// The URL to use for getting the next set of + /// results. + public HierarchySettingsList(IList value = default(IList), string nextLink = default(string)) + { + Value = value; + NextLink = nextLink; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the list of hierarchy settings. + /// + [JsonProperty(PropertyName = "value")] + public IList Value { get; set; } + + /// + /// Gets the URL to use for getting the next set of results. + /// + [JsonProperty(PropertyName = "@nextLink")] + public string NextLink { get; private set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroup.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroup.cs new file mode 100644 index 000000000000..887931a0d79f --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroup.cs @@ -0,0 +1,116 @@ +// +// 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.ManagementGroups.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The management group details. + /// + [Rest.Serialization.JsonTransformation] + public partial class ManagementGroup : IResource + { + /// + /// Initializes a new instance of the ManagementGroup class. + /// + public ManagementGroup() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManagementGroup class. + /// + /// The fully qualified ID for the management group. + /// For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// The type of the resource. For example, + /// Microsoft.Management/managementGroups + /// The name of the management group. For example, + /// 00000000-0000-0000-0000-000000000000 + /// The AAD Tenant ID associated with the + /// management group. For example, + /// 00000000-0000-0000-0000-000000000000 + /// The friendly name of the management + /// group. + /// Details + /// The list of children. + public ManagementGroup(string id = default(string), string type = default(string), string name = default(string), string tenantId = default(string), string displayName = default(string), ManagementGroupDetails details = default(ManagementGroupDetails), IList children = default(IList)) + { + Id = id; + Type = type; + Name = name; + TenantId = tenantId; + DisplayName = displayName; + Details = details; + Children = children; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the fully qualified ID for the management group. For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the type of the resource. For example, + /// Microsoft.Management/managementGroups + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets the name of the management group. For example, + /// 00000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the AAD Tenant ID associated with the management + /// group. For example, 00000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "properties.tenantId")] + public string TenantId { get; set; } + + /// + /// Gets or sets the friendly name of the management group. + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets details + /// + [JsonProperty(PropertyName = "properties.details")] + public ManagementGroupDetails Details { get; set; } + + /// + /// Gets or sets the list of children. + /// + [JsonProperty(PropertyName = "properties.children")] + public IList Children { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroupChildInfo.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroupChildInfo.cs new file mode 100644 index 000000000000..f228d02340fa --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroupChildInfo.cs @@ -0,0 +1,95 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ManagementGroups.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The child information of a management group. + /// + public partial class ManagementGroupChildInfo + { + /// + /// Initializes a new instance of the ManagementGroupChildInfo class. + /// + public ManagementGroupChildInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManagementGroupChildInfo class. + /// + /// The type of child resource. + /// The fully qualified ID for the child resource + /// (management group or subscription). For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// The name of the child entity. + /// The friendly name of the child + /// resource. + /// The list of children. + public ManagementGroupChildInfo(ManagementGroupChildType? type = default(ManagementGroupChildType?), string id = default(string), string name = default(string), string displayName = default(string), IList children = default(IList)) + { + Type = type; + Id = id; + Name = name; + DisplayName = displayName; + Children = children; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the type of child resource. + /// + /// + /// The fully qualified resource type which includes provider namespace + /// (e.g. Microsoft.Management/managementGroups). Possible values + /// include: 'Microsoft.Management/managementGroups', '/subscriptions' + /// + [JsonProperty(PropertyName = "type")] + public ManagementGroupChildType? Type { get; set; } + + /// + /// Gets or sets the fully qualified ID for the child resource + /// (management group or subscription). For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets the name of the child entity. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the friendly name of the child resource. + /// + [JsonProperty(PropertyName = "displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets the list of children. + /// + [JsonProperty(PropertyName = "children")] + public IList Children { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroupChildType.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroupChildType.cs new file mode 100644 index 000000000000..70f73002386c --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroupChildType.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.ManagementGroups.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for ManagementGroupChildType. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum ManagementGroupChildType + { + [EnumMember(Value = "Microsoft.Management/managementGroups")] + MicrosoftManagementManagementGroups, + [EnumMember(Value = "/subscriptions")] + HyphenMinussubscriptions + } + internal static class ManagementGroupChildTypeEnumExtension + { + internal static string ToSerializedValue(this ManagementGroupChildType? value) + { + return value == null ? null : ((ManagementGroupChildType)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this ManagementGroupChildType value) + { + switch( value ) + { + case ManagementGroupChildType.MicrosoftManagementManagementGroups: + return "Microsoft.Management/managementGroups"; + case ManagementGroupChildType.HyphenMinussubscriptions: + return "/subscriptions"; + } + return null; + } + + internal static ManagementGroupChildType? ParseManagementGroupChildType(this string value) + { + switch( value ) + { + case "Microsoft.Management/managementGroups": + return ManagementGroupChildType.MicrosoftManagementManagementGroups; + case "/subscriptions": + return ManagementGroupChildType.HyphenMinussubscriptions; + } + return null; + } + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroupDetails.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroupDetails.cs new file mode 100644 index 000000000000..30276fb88e5f --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroupDetails.cs @@ -0,0 +1,109 @@ +// +// 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.ManagementGroups.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The details of a management group. + /// + public partial class ManagementGroupDetails + { + /// + /// Initializes a new instance of the ManagementGroupDetails class. + /// + public ManagementGroupDetails() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManagementGroupDetails class. + /// + /// The version number of the object. + /// The date and time when this object was + /// last updated. + /// The identity of the principal or process + /// that updated the object. + /// Parent + /// The path from the root to the current + /// group. + /// The ancestors of the + /// management group. + /// The ancestors of the + /// management group displayed in reversed order, from immediate parent + /// to the root. + public ManagementGroupDetails(double? version = default(double?), System.DateTime? updatedTime = default(System.DateTime?), string updatedBy = default(string), ParentGroupInfo parent = default(ParentGroupInfo), IList path = default(IList), IList managementGroupAncestors = default(IList), IList managementGroupAncestorsChain = default(IList)) + { + Version = version; + UpdatedTime = updatedTime; + UpdatedBy = updatedBy; + Parent = parent; + Path = path; + ManagementGroupAncestors = managementGroupAncestors; + ManagementGroupAncestorsChain = managementGroupAncestorsChain; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the version number of the object. + /// + [JsonProperty(PropertyName = "version")] + public double? Version { get; set; } + + /// + /// Gets or sets the date and time when this object was last updated. + /// + [JsonProperty(PropertyName = "updatedTime")] + public System.DateTime? UpdatedTime { get; set; } + + /// + /// Gets or sets the identity of the principal or process that updated + /// the object. + /// + [JsonProperty(PropertyName = "updatedBy")] + public string UpdatedBy { get; set; } + + /// + /// Gets or sets parent + /// + [JsonProperty(PropertyName = "parent")] + public ParentGroupInfo Parent { get; set; } + + /// + /// Gets or sets the path from the root to the current group. + /// + [JsonProperty(PropertyName = "path")] + public IList Path { get; set; } + + /// + /// Gets or sets the ancestors of the management group. + /// + [JsonProperty(PropertyName = "managementGroupAncestors")] + public IList ManagementGroupAncestors { get; set; } + + /// + /// Gets or sets the ancestors of the management group displayed in + /// reversed order, from immediate parent to the root. + /// + [JsonProperty(PropertyName = "managementGroupAncestorsChain")] + public IList ManagementGroupAncestorsChain { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroupExpandType.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroupExpandType.cs new file mode 100644 index 000000000000..1f18a055f2ac --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroupExpandType.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ManagementGroups.Models +{ + + /// + /// Defines values for ManagementGroupExpandType. + /// + public static class ManagementGroupExpandType + { + public const string Children = "children"; + public const string Path = "path"; + public const string Ancestors = "ancestors"; + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroupInfo.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroupInfo.cs new file mode 100644 index 000000000000..a2811f355f50 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroupInfo.cs @@ -0,0 +1,97 @@ +// +// 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.ManagementGroups.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The management group resource. + /// + [Rest.Serialization.JsonTransformation] + public partial class ManagementGroupInfo + { + /// + /// Initializes a new instance of the ManagementGroupInfo class. + /// + public ManagementGroupInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManagementGroupInfo class. + /// + /// The fully qualified ID for the management group. + /// For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// The type of the resource. For example, + /// Microsoft.Management/managementGroups + /// The name of the management group. For example, + /// 00000000-0000-0000-0000-000000000000 + /// The AAD Tenant ID associated with the + /// management group. For example, + /// 00000000-0000-0000-0000-000000000000 + /// The friendly name of the management + /// group. + public ManagementGroupInfo(string id = default(string), string type = default(string), string name = default(string), string tenantId = default(string), string displayName = default(string)) + { + Id = id; + Type = type; + Name = name; + TenantId = tenantId; + DisplayName = displayName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the fully qualified ID for the management group. For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the type of the resource. For example, + /// Microsoft.Management/managementGroups + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets the name of the management group. For example, + /// 00000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the AAD Tenant ID associated with the management + /// group. For example, 00000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "properties.tenantId")] + public string TenantId { get; set; } + + /// + /// Gets or sets the friendly name of the management group. + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroupPathElement.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroupPathElement.cs new file mode 100644 index 000000000000..2b4243c28114 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroupPathElement.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ManagementGroups.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// A path element of a management group ancestors. + /// + public partial class ManagementGroupPathElement + { + /// + /// Initializes a new instance of the ManagementGroupPathElement class. + /// + public ManagementGroupPathElement() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManagementGroupPathElement class. + /// + /// The name of the group. + /// The friendly name of the group. + public ManagementGroupPathElement(string name = default(string), string displayName = default(string)) + { + Name = name; + DisplayName = displayName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the group. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the friendly name of the group. + /// + [JsonProperty(PropertyName = "displayName")] + public string DisplayName { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroupsCreateOrUpdateHeaders.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroupsCreateOrUpdateHeaders.cs new file mode 100644 index 000000000000..75065c9de3ac --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroupsCreateOrUpdateHeaders.cs @@ -0,0 +1,84 @@ +// +// 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.ManagementGroups.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for CreateOrUpdate operation. + /// + public partial class ManagementGroupsCreateOrUpdateHeaders + { + /// + /// Initializes a new instance of the + /// ManagementGroupsCreateOrUpdateHeaders class. + /// + public ManagementGroupsCreateOrUpdateHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// ManagementGroupsCreateOrUpdateHeaders class. + /// + /// URL for determining when an operation has + /// completed. Send a GET request to the URL in Location header. + /// The URI should return a 202 until the operation reaches a terminal + /// state and 200 once it reaches a terminal state. + /// + /// For more info: + /// https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#202-accepted-and-location-headers + /// URL for checking the ongoing + /// status of the operation. + /// To get the status of the asynchronous operation, send a GET request + /// to the URL in Azure-AsyncOperation header value. + /// + /// For more info: + /// https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#asynchronous-operations + public ManagementGroupsCreateOrUpdateHeaders(string location = default(string), string azureAsyncOperation = default(string)) + { + Location = location; + AzureAsyncOperation = azureAsyncOperation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets URL for determining when an operation has completed. + /// Send a GET request to the URL in Location header. + /// The URI should return a 202 until the operation reaches a terminal + /// state and 200 once it reaches a terminal state. + /// + /// For more info: + /// https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#202-accepted-and-location-headers + /// + [JsonProperty(PropertyName = "Location")] + public string Location { get; set; } + + /// + /// Gets or sets URL for checking the ongoing status of the operation. + /// To get the status of the asynchronous operation, send a GET request + /// to the URL in Azure-AsyncOperation header value. + /// + /// For more info: + /// https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#asynchronous-operations + /// + [JsonProperty(PropertyName = "Azure-AsyncOperation")] + public string AzureAsyncOperation { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroupsDeleteHeaders.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroupsDeleteHeaders.cs new file mode 100644 index 000000000000..537e721941e2 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ManagementGroupsDeleteHeaders.cs @@ -0,0 +1,84 @@ +// +// 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.ManagementGroups.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Defines headers for Delete operation. + /// + public partial class ManagementGroupsDeleteHeaders + { + /// + /// Initializes a new instance of the ManagementGroupsDeleteHeaders + /// class. + /// + public ManagementGroupsDeleteHeaders() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ManagementGroupsDeleteHeaders + /// class. + /// + /// URL for determining when an operation has + /// completed. Send a GET request to the URL in Location header. + /// The URI should return a 202 until the operation reaches a terminal + /// state and 200 once it reaches a terminal state. + /// + /// For more info: + /// https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#202-accepted-and-location-headers + /// URL for checking the ongoing + /// status of the operation. + /// To get the status of the asynchronous operation, send a GET request + /// to the URL in Azure-AsyncOperation header value. + /// + /// For more info: + /// https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#asynchronous-operations + public ManagementGroupsDeleteHeaders(string location = default(string), string azureAsyncOperation = default(string)) + { + Location = location; + AzureAsyncOperation = azureAsyncOperation; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets URL for determining when an operation has completed. + /// Send a GET request to the URL in Location header. + /// The URI should return a 202 until the operation reaches a terminal + /// state and 200 once it reaches a terminal state. + /// + /// For more info: + /// https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#202-accepted-and-location-headers + /// + [JsonProperty(PropertyName = "Location")] + public string Location { get; set; } + + /// + /// Gets or sets URL for checking the ongoing status of the operation. + /// To get the status of the asynchronous operation, send a GET request + /// to the URL in Azure-AsyncOperation header value. + /// + /// For more info: + /// https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/Addendum.md#asynchronous-operations + /// + [JsonProperty(PropertyName = "Azure-AsyncOperation")] + public string AzureAsyncOperation { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/Operation.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/Operation.cs new file mode 100644 index 000000000000..746cf92844f9 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/Operation.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.ManagementGroups.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Operation supported by the Microsoft.Management resource provider. + /// + 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 + public Operation(string name = default(string), OperationDisplayProperties display = default(OperationDisplayProperties)) + { + Name = name; + Display = display; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets operation name: {provider}/{resource}/{operation}. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets display + /// + [JsonProperty(PropertyName = "display")] + public OperationDisplayProperties Display { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/OperationDisplayProperties.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/OperationDisplayProperties.cs new file mode 100644 index 000000000000..69f6741878dd --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/OperationDisplayProperties.cs @@ -0,0 +1,77 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ManagementGroups.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The object that represents the operation. + /// + public partial class OperationDisplayProperties + { + /// + /// Initializes a new instance of the OperationDisplayProperties class. + /// + public OperationDisplayProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationDisplayProperties class. + /// + /// The name of the provider. + /// The resource on which the operation is + /// performed. + /// The operation that can be + /// performed. + /// Operation description. + public OperationDisplayProperties(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 the name of the provider. + /// + [JsonProperty(PropertyName = "provider")] + public string Provider { get; private set; } + + /// + /// Gets the resource on which the operation is performed. + /// + [JsonProperty(PropertyName = "resource")] + public string Resource { get; private set; } + + /// + /// Gets the operation that can be performed. + /// + [JsonProperty(PropertyName = "operation")] + public string Operation { get; private set; } + + /// + /// Gets operation description. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; private set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/OperationResults.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/OperationResults.cs new file mode 100644 index 000000000000..68deccf42346 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/OperationResults.cs @@ -0,0 +1,97 @@ +// +// 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.ManagementGroups.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The results of an asynchronous operation. + /// + [Rest.Serialization.JsonTransformation] + public partial class OperationResults + { + /// + /// Initializes a new instance of the OperationResults class. + /// + public OperationResults() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationResults class. + /// + /// The fully qualified ID for the management group. + /// For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// The type of the resource. For example, + /// Microsoft.Management/managementGroups + /// The name of the management group. For example, + /// 00000000-0000-0000-0000-000000000000 + /// The AAD Tenant ID associated with the + /// management group. For example, + /// 00000000-0000-0000-0000-000000000000 + /// The friendly name of the management + /// group. + public OperationResults(string id = default(string), string type = default(string), string name = default(string), string tenantId = default(string), string displayName = default(string)) + { + Id = id; + Type = type; + Name = name; + TenantId = tenantId; + DisplayName = displayName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the fully qualified ID for the management group. For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the type of the resource. For example, + /// Microsoft.Management/managementGroups + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets the name of the management group. For example, + /// 00000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the AAD Tenant ID associated with the management + /// group. For example, 00000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "properties.tenantId")] + public string TenantId { get; set; } + + /// + /// Gets or sets the friendly name of the management group. + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/Page.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/Page.cs new file mode 100644 index 000000000000..2d0baf32b741 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/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.ManagementGroups.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("@nextLink")] + 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/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/Page1.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/Page1.cs new file mode 100644 index 000000000000..a3b5d61d9dcd --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/Page1.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.ManagementGroups.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 Page1 : IPage + { + /// + /// Gets the link to the next page. + /// + [JsonProperty("nextLink")] + 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/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ParentGroupInfo.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ParentGroupInfo.cs new file mode 100644 index 000000000000..cdbe651eebd6 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/ParentGroupInfo.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.ManagementGroups.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// (Optional) The ID of the parent management group. + /// + public partial class ParentGroupInfo + { + /// + /// Initializes a new instance of the ParentGroupInfo class. + /// + public ParentGroupInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ParentGroupInfo class. + /// + /// The fully qualified ID for the parent management + /// group. For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// The name of the parent management group + /// The friendly name of the parent + /// management group. + public ParentGroupInfo(string id = default(string), string name = default(string), string displayName = default(string)) + { + Id = id; + Name = name; + DisplayName = displayName; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the fully qualified ID for the parent management + /// group. For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets the name of the parent management group + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the friendly name of the parent management group. + /// + [JsonProperty(PropertyName = "displayName")] + public string DisplayName { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/PatchManagementGroupRequest.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/PatchManagementGroupRequest.cs new file mode 100644 index 000000000000..8820bac17f01 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/PatchManagementGroupRequest.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. +// +// 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.ManagementGroups.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Management group patch parameters. + /// + public partial class PatchManagementGroupRequest + { + /// + /// Initializes a new instance of the PatchManagementGroupRequest + /// class. + /// + public PatchManagementGroupRequest() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PatchManagementGroupRequest + /// class. + /// + /// The friendly name of the management + /// group. + /// (Optional) The fully qualified ID for + /// the parent management group. For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + public PatchManagementGroupRequest(string displayName = default(string), string parentGroupId = default(string)) + { + DisplayName = displayName; + ParentGroupId = parentGroupId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the friendly name of the management group. + /// + [JsonProperty(PropertyName = "displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets (Optional) The fully qualified ID for the parent + /// management group. For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "parentGroupId")] + public string ParentGroupId { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/Permissions.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/Permissions.cs new file mode 100644 index 000000000000..a858f3bfff5d --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/Permissions.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.ManagementGroups.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for Permissions. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum Permissions + { + [EnumMember(Value = "noaccess")] + Noaccess, + [EnumMember(Value = "view")] + View, + [EnumMember(Value = "edit")] + Edit, + [EnumMember(Value = "delete")] + Delete + } + internal static class PermissionsEnumExtension + { + internal static string ToSerializedValue(this Permissions? value) + { + return value == null ? null : ((Permissions)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this Permissions value) + { + switch( value ) + { + case Permissions.Noaccess: + return "noaccess"; + case Permissions.View: + return "view"; + case Permissions.Edit: + return "edit"; + case Permissions.Delete: + return "delete"; + } + return null; + } + + internal static Permissions? ParsePermissions(this string value) + { + switch( value ) + { + case "noaccess": + return Permissions.Noaccess; + case "view": + return Permissions.View; + case "edit": + return Permissions.Edit; + case "delete": + return Permissions.Delete; + } + return null; + } + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/Reason.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/Reason.cs new file mode 100644 index 000000000000..e65ee4bec69f --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/Reason.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.ManagementGroups.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for Reason. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum Reason + { + [EnumMember(Value = "Invalid")] + Invalid, + [EnumMember(Value = "AlreadyExists")] + AlreadyExists + } + internal static class ReasonEnumExtension + { + internal static string ToSerializedValue(this Reason? value) + { + return value == null ? null : ((Reason)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this Reason value) + { + switch( value ) + { + case Reason.Invalid: + return "Invalid"; + case Reason.AlreadyExists: + return "AlreadyExists"; + } + return null; + } + + internal static Reason? ParseReason(this string value) + { + switch( value ) + { + case "Invalid": + return Reason.Invalid; + case "AlreadyExists": + return Reason.AlreadyExists; + } + return null; + } + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/Status.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/Status.cs new file mode 100644 index 000000000000..66654d1c0f42 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/Status.cs @@ -0,0 +1,84 @@ +// +// 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.ManagementGroups.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for Status. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum Status + { + [EnumMember(Value = "NotStarted")] + NotStarted, + [EnumMember(Value = "NotStartedButGroupsExist")] + NotStartedButGroupsExist, + [EnumMember(Value = "Started")] + Started, + [EnumMember(Value = "Failed")] + Failed, + [EnumMember(Value = "Cancelled")] + Cancelled, + [EnumMember(Value = "Completed")] + Completed + } + internal static class StatusEnumExtension + { + internal static string ToSerializedValue(this Status? value) + { + return value == null ? null : ((Status)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this Status value) + { + switch( value ) + { + case Status.NotStarted: + return "NotStarted"; + case Status.NotStartedButGroupsExist: + return "NotStartedButGroupsExist"; + case Status.Started: + return "Started"; + case Status.Failed: + return "Failed"; + case Status.Cancelled: + return "Cancelled"; + case Status.Completed: + return "Completed"; + } + return null; + } + + internal static Status? ParseStatus(this string value) + { + switch( value ) + { + case "NotStarted": + return Status.NotStarted; + case "NotStartedButGroupsExist": + return Status.NotStartedButGroupsExist; + case "Started": + return Status.Started; + case "Failed": + return Status.Failed; + case "Cancelled": + return Status.Cancelled; + case "Completed": + return Status.Completed; + } + return null; + } + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/SubscriptionUnderManagementGroup.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/SubscriptionUnderManagementGroup.cs new file mode 100644 index 000000000000..96aa616ee933 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/SubscriptionUnderManagementGroup.cs @@ -0,0 +1,116 @@ +// +// 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.ManagementGroups.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The details of subscription under management group. + /// + [Rest.Serialization.JsonTransformation] + public partial class SubscriptionUnderManagementGroup : IResource + { + /// + /// Initializes a new instance of the SubscriptionUnderManagementGroup + /// class. + /// + public SubscriptionUnderManagementGroup() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SubscriptionUnderManagementGroup + /// class. + /// + /// The fully qualified ID for the subscription. For + /// example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000/subscriptions/0000000-0000-0000-0000-000000000001 + /// The type of the resource. For example, + /// Microsoft.Management/managementGroups/subscriptions + /// The stringified id of the subscription. For + /// example, 00000000-0000-0000-0000-000000000000 + /// The AAD Tenant ID associated with the + /// subscription. For example, + /// 00000000-0000-0000-0000-000000000000 + /// The friendly name of the + /// subscription. + /// Parent + /// The state of the subscription. + public SubscriptionUnderManagementGroup(string id = default(string), string type = default(string), string name = default(string), string tenant = default(string), string displayName = default(string), DescendantParentGroupInfo parent = default(DescendantParentGroupInfo), string state = default(string)) + { + Id = id; + Type = type; + Name = name; + Tenant = tenant; + DisplayName = displayName; + Parent = parent; + State = state; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the fully qualified ID for the subscription. For example, + /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000/subscriptions/0000000-0000-0000-0000-000000000001 + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the type of the resource. For example, + /// Microsoft.Management/managementGroups/subscriptions + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets the stringified id of the subscription. For example, + /// 00000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets or sets the AAD Tenant ID associated with the subscription. + /// For example, 00000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "properties.tenant")] + public string Tenant { get; set; } + + /// + /// Gets or sets the friendly name of the subscription. + /// + [JsonProperty(PropertyName = "properties.displayName")] + public string DisplayName { get; set; } + + /// + /// Gets or sets parent + /// + [JsonProperty(PropertyName = "properties.parent")] + public DescendantParentGroupInfo Parent { get; set; } + + /// + /// Gets or sets the state of the subscription. + /// + [JsonProperty(PropertyName = "properties.state")] + public string State { get; set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/TenantBackfillStatusResult.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/TenantBackfillStatusResult.cs new file mode 100644 index 000000000000..6cad104f93b5 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/TenantBackfillStatusResult.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. +// +// 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.ManagementGroups.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The tenant backfill status + /// + public partial class TenantBackfillStatusResult + { + /// + /// Initializes a new instance of the TenantBackfillStatusResult class. + /// + public TenantBackfillStatusResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the TenantBackfillStatusResult class. + /// + /// The AAD Tenant ID associated with the + /// management group. For example, + /// 00000000-0000-0000-0000-000000000000 + /// The status of the Tenant Backfill. Possible + /// values include: 'NotStarted', 'NotStartedButGroupsExist', + /// 'Started', 'Failed', 'Cancelled', 'Completed' + public TenantBackfillStatusResult(string tenantId = default(string), Status? status = default(Status?)) + { + TenantId = tenantId; + Status = status; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the AAD Tenant ID associated with the management group. For + /// example, 00000000-0000-0000-0000-000000000000 + /// + [JsonProperty(PropertyName = "tenantId")] + public string TenantId { get; private set; } + + /// + /// Gets the status of the Tenant Backfill. Possible values include: + /// 'NotStarted', 'NotStartedButGroupsExist', 'Started', 'Failed', + /// 'Cancelled', 'Completed' + /// + [JsonProperty(PropertyName = "status")] + public Status? Status { get; private set; } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/Type.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/Type.cs new file mode 100644 index 000000000000..0f8e0f25a747 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Models/Type.cs @@ -0,0 +1,54 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ManagementGroups.Models +{ + using Newtonsoft.Json; + using Newtonsoft.Json.Converters; + using System.Runtime; + using System.Runtime.Serialization; + + /// + /// Defines values for Type. + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum Type + { + [EnumMember(Value = "Microsoft.Management/managementGroups")] + MicrosoftManagementManagementGroups + } + internal static class TypeEnumExtension + { + internal static string ToSerializedValue(this Type? value) + { + return value == null ? null : ((Type)value).ToSerializedValue(); + } + + internal static string ToSerializedValue(this Type value) + { + switch( value ) + { + case Type.MicrosoftManagementManagementGroups: + return "Microsoft.Management/managementGroups"; + } + return null; + } + + internal static Type? ParseType(this string value) + { + switch( value ) + { + case "Microsoft.Management/managementGroups": + return Type.MicrosoftManagementManagementGroups; + } + return null; + } + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Operations.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Operations.cs new file mode 100644 index 000000000000..78e571efa869 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/Operations.cs @@ -0,0 +1,390 @@ +// +// 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.ManagementGroups +{ + 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(ManagementGroupsAPIClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ManagementGroupsAPIClient + /// + public ManagementGroupsAPIClient Client { get; private set; } + + /// + /// Lists all of the available Management 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.Management/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 ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Lists all of the available Management REST API operations. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/OperationsExtensions.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/OperationsExtensions.cs new file mode 100644 index 000000000000..0a88d0d93627 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/OperationsExtensions.cs @@ -0,0 +1,87 @@ +// +// 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.ManagementGroups +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for Operations. + /// + public static partial class OperationsExtensions + { + /// + /// Lists all of the available Management REST API operations. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Lists all of the available Management 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; + } + } + + /// + /// Lists all of the available Management REST API operations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Lists all of the available Management REST API operations. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/SdkInfo_ManagementGroupsAPI.cs b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/SdkInfo_ManagementGroupsAPI.cs new file mode 100644 index 000000000000..9e3e691b94c3 --- /dev/null +++ b/sdk/managementgroups/Microsoft.Azure.Management.ManagementGroups/src/Generated/SdkInfo_ManagementGroupsAPI.cs @@ -0,0 +1,34 @@ + +// +// 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.ManagementGroups +{ + using System; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_ManagementGroupsAPI + { + get + { + return new Tuple[] + { + new Tuple("Management", "CheckNameAvailability", "2023-04-01"), + new Tuple("Management", "Entities", "2023-04-01"), + new Tuple("Management", "HierarchySettings", "2023-04-01"), + new Tuple("Management", "ManagementGroupSubscriptions", "2023-04-01"), + new Tuple("Management", "ManagementGroups", "2023-04-01"), + new Tuple("Management", "Operations", "2023-04-01"), + new Tuple("Management", "StartTenantBackfill", "2023-04-01"), + new Tuple("Management", "TenantBackfillStatus", "2023-04-01"), + }.AsEnumerable(); + } + } + } +}