示例#1
0
        public async Task <CreateManagementGroupResponse> CreateManagementGroupAsync(CreateManagementGroupRequest request)
        {
            AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
            CreateManagementGroupHeaders headers = new CreateManagementGroupHeaders();

            return(await CreateManagementGroupWithOptionsAsync(request, headers, runtime));
        }
示例#2
0
        public CreateManagementGroupResponse CreateManagementGroup(CreateManagementGroupRequest request)
        {
            AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
            CreateManagementGroupHeaders headers = new CreateManagementGroupHeaders();

            return(CreateManagementGroupWithOptions(request, headers, runtime));
        }
        public override void ExecuteCmdlet()
        {
            try
            {
                if (ParameterSetName.Equals(Constants.ParameterSetNames.ParentGroupParameterSet))
                {
                    ParentId = ParentObject.Id;
                }

                if (ShouldProcess(
                        string.Format(Resource.NewManagementGroupShouldProcessTarget, GroupName),
                        string.Format(Resource.NewManagementGroupShouldProcessAction, GroupName)))
                {
                    PreregisterSubscription();

                    CreateManagementGroupRequest createGroupRequest = new CreateManagementGroupRequest(
                        id: Constants.GroupUrlPrefix + GroupName, type: Constants.GroupType, name: GroupName,
                        displayName: DisplayName,
                        details: new CreateManagementGroupDetails()
                    {
                        Parent = new CreateParentGroupInfo()
                        {
                            Id = ParentId
                        }
                    });

                    var response = (ManagementGroup)ManagementGroupsApiClient.ManagementGroups.CreateOrUpdate(GroupName, createGroupRequest);
                    WriteObject(new PSManagementGroup(response));
                }
            }
            catch (ErrorResponseException ex)
            {
                Utility.HandleErrorResponseException(ex);
            }
        }
示例#4
0
        public CreateManagementGroupResponse CreateManagementGroupWithOptions(CreateManagementGroupRequest request, CreateManagementGroupHeaders headers, AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime)
        {
            AlibabaCloud.TeaUtil.Common.ValidateModel(request);
            Dictionary <string, object> body = new Dictionary <string, object>()
            {
            };

            if (!AlibabaCloud.TeaUtil.Common.IsUnset(request.GroupName))
            {
                body["groupName"] = request.GroupName;
            }
            if (!AlibabaCloud.TeaUtil.Common.IsUnset(request.Members))
            {
                body["members"] = request.Members;
            }
            if (!AlibabaCloud.TeaUtil.Common.IsUnset(request.Scope.ToMap()))
            {
                body["scope"] = request.Scope;
            }
            if (!AlibabaCloud.TeaUtil.Common.IsUnset(request.ResourceIds))
            {
                body["resourceIds"] = request.ResourceIds;
            }
            Dictionary <string, string> realHeaders = new Dictionary <string, string>()
            {
            };

            if (!AlibabaCloud.TeaUtil.Common.IsUnset(headers.CommonHeaders))
            {
                realHeaders = headers.CommonHeaders;
            }
            if (!AlibabaCloud.TeaUtil.Common.IsUnset(headers.XAcsDingtalkAccessToken))
            {
                realHeaders["x-acs-dingtalk-access-token"] = headers.XAcsDingtalkAccessToken;
            }
            AlibabaCloud.OpenApiClient.Models.OpenApiRequest req = new AlibabaCloud.OpenApiClient.Models.OpenApiRequest
            {
                Headers = realHeaders,
                Body    = AlibabaCloud.OpenApiUtil.Client.ParseToMap(body),
            };
            return(TeaModel.ToObject <CreateManagementGroupResponse>(DoROARequest("CreateManagementGroup", "contact_1.0", "HTTP", "POST", "AK", "/v1.0/contact/managementGroups", "json", req, runtime)));
        }
示例#5
0
        /// <summary>
        /// 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.
        /// .
        /// </summary>
        /// <param name="groupId"> Management Group ID. </param>
        /// <param name="createManagementGroupRequest"> Management group creation parameters. </param>
        /// <param name="cacheControl"> Indicates whether the request should utilize any caches. Populate the header with &apos;no-cache&apos; value to bypass existing caches. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="groupId"/> or <paramref name="createManagementGroupRequest"/> is null. </exception>
        public virtual Response <ManagementGroup> CreateOrUpdate(string groupId, CreateManagementGroupRequest createManagementGroupRequest, string cacheControl = null, CancellationToken cancellationToken = default)
        {
            if (groupId == null)
            {
                throw new ArgumentNullException(nameof(groupId));
            }
            if (createManagementGroupRequest == null)
            {
                throw new ArgumentNullException(nameof(createManagementGroupRequest));
            }

            using var scope = _clientDiagnostics.CreateScope("ManagementGroupContainer.CreateOrUpdate");
            scope.Start();
            try
            {
                var operation = StartCreateOrUpdate(groupId, createManagementGroupRequest, cacheControl, cancellationToken);
                return(operation.WaitForCompletion(cancellationToken));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
 /// <summary>
 /// 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.
 ///
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='groupId'>
 /// Management Group ID.
 /// </param>
 /// <param name='createManagementGroupRequest'>
 /// Management group creation parameters.
 /// </param>
 /// <param name='cacheControl'>
 /// Indicates whether the request should utilize any caches. Populate the
 /// header with 'no-cache' value to bypass existing caches.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <object> 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);
     }
 }
 /// <summary>
 /// 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.
 ///
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='groupId'>
 /// Management Group ID.
 /// </param>
 /// <param name='createManagementGroupRequest'>
 /// Management group creation parameters.
 /// </param>
 /// <param name='cacheControl'>
 /// Indicates whether the request should utilize any caches. Populate the
 /// header with 'no-cache' value to bypass existing caches.
 /// </param>
 public static object BeginCreateOrUpdate(this IManagementGroupsOperations operations, string groupId, CreateManagementGroupRequest createManagementGroupRequest, string cacheControl = "no-cache")
 {
     return(operations.BeginCreateOrUpdateAsync(groupId, createManagementGroupRequest, cacheControl).GetAwaiter().GetResult());
 }
示例#8
0
        /// <summary>
        /// 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.
        /// .
        /// </summary>
        /// <param name="groupId"> Management Group ID. </param>
        /// <param name="createManagementGroupRequest"> Management group creation parameters. </param>
        /// <param name="cacheControl"> Indicates whether the request should utilize any caches. Populate the header with &apos;no-cache&apos; value to bypass existing caches. </param>
        /// <param name="cancellationToken"> The cancellation token to use. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="groupId"/> or <paramref name="createManagementGroupRequest"/> is null. </exception>
        public async virtual Task <ManagementGroupsCreateOrUpdateOperation> StartCreateOrUpdateAsync(string groupId, CreateManagementGroupRequest createManagementGroupRequest, string cacheControl = null, CancellationToken cancellationToken = default)
        {
            if (groupId == null)
            {
                throw new ArgumentNullException(nameof(groupId));
            }
            if (createManagementGroupRequest == null)
            {
                throw new ArgumentNullException(nameof(createManagementGroupRequest));
            }

            using var scope = _clientDiagnostics.CreateScope("ManagementGroupContainer.StartCreateOrUpdate");
            scope.Start();
            try
            {
                var originalResponse = await _restClient.CreateOrUpdateAsync(groupId, createManagementGroupRequest, cacheControl, cancellationToken).ConfigureAwait(false);

                return(new ManagementGroupsCreateOrUpdateOperation(this, _clientDiagnostics, Pipeline, _restClient.CreateCreateOrUpdateRequest(groupId, createManagementGroupRequest, cacheControl).Request, originalResponse));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }