public override void ExecuteCmdlet() { try { if (ParameterSetName.Equals(Constants.ParameterSetNames.ManagementGroupParameterSet) || ParameterSetName.Equals(Constants.ParameterSetNames.ParentGroupAndManagementGroupParameterSet)) { GroupName = InputObject.Name; } if (ParameterSetName.Equals(Constants.ParameterSetNames.ParentGroupParameterSet) || ParameterSetName.Equals(Constants.ParameterSetNames.ParentGroupAndManagementGroupParameterSet)) { ParentId = ParentObject.Id; } if (ShouldProcess( string.Format(Resource.UpdateManagementGroupShouldProcessTarget, GroupName), string.Format(Resource.UpdateManagementGroupShouldProcessAction, GroupName))) { PreregisterSubscription(); PatchManagementGroupRequest patchGroupRequest = new PatchManagementGroupRequest(DisplayName, ParentId); var response = ManagementGroupsApiClient.ManagementGroups.Update(GroupName, patchGroupRequest); WriteObject(new PSManagementGroup(response)); } } catch (ErrorResponseException ex) { Utility.HandleErrorResponseException(ex); } }
public async Task Update() { ManagementGroup mgmtGroup = await Client.GetManagementGroups().CreateOrUpdateAsync(Recording.GenerateAssetName("mgmt-group-"), new CreateManagementGroupRequest()); PatchManagementGroupRequest patch = new PatchManagementGroupRequest(); patch.DisplayName = "New Display Name"; ManagementGroup patchedMgmtGroup = await mgmtGroup.UpdateAsync(patch); Assert.AreEqual("New Display Name", patchedMgmtGroup.Data.DisplayName); Assert.AreEqual(mgmtGroup.Data.Id, patchedMgmtGroup.Data.Id); Assert.AreEqual(mgmtGroup.Data.Name, patchedMgmtGroup.Data.Name); Assert.AreEqual(mgmtGroup.Data.TenantId, patchedMgmtGroup.Data.TenantId); Assert.AreEqual(mgmtGroup.Data.Type, patchedMgmtGroup.Data.Type); }
/// <summary> /// Update a management group. /// . /// </summary> /// <param name="patchGroupRequest"> Management group patch 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 to use. </param> public virtual Response <ManagementGroup> Update(PatchManagementGroupRequest patchGroupRequest, string cacheControl = null, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("ManagementGroupOperations.Update"); scope.Start(); try { var response = _restClient.Update(Id.Name, patchGroupRequest, cacheControl, cancellationToken); return(Response.FromValue(new ManagementGroup(this, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
/// <summary> /// Update a management group. /// /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='groupId'> /// Management Group ID. /// </param> /// <param name='patchGroupRequest'> /// Management group patch 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 <ManagementGroup> 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); } }
/// <summary> /// Update a management group. /// /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='groupId'> /// Management Group ID. /// </param> /// <param name='patchGroupRequest'> /// Management group patch 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 ManagementGroup Update(this IManagementGroupsOperations operations, string groupId, PatchManagementGroupRequest patchGroupRequest, string cacheControl = "no-cache") { return(operations.UpdateAsync(groupId, patchGroupRequest, cacheControl).GetAwaiter().GetResult()); }