public virtual ManagementGroupDeleteOperation Delete(bool waitForCompletion, string cacheControl = null, CancellationToken cancellationToken = default) { using var scope = _managementGroupClientDiagnostics.CreateScope("ManagementGroup.Delete"); scope.Start(); try { var response = _managementGroupRestClient.Delete(Id.Name, cacheControl, cancellationToken); var operation = new ManagementGroupDeleteOperation(_managementGroupClientDiagnostics, Pipeline, _managementGroupRestClient.CreateDeleteRequest(Id.Name, cacheControl).Request, response); if (waitForCompletion) { operation.WaitForCompletionResponse(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
/// <summary> /// Delete management group. /// If a management group contains child resources, the request will fail. /// . /// </summary> /// <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="waitForCompletion"> Waits for the completion of the long running operations. </param> /// <param name="cancellationToken"> The cancellation token to use. </param> public async virtual Task <ManagementGroupDeleteOperation> DeleteAsync(string cacheControl = null, bool waitForCompletion = true, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("ManagementGroup.Delete"); scope.Start(); try { var originalResponse = await _restClient.DeleteAsync(Id.Name, cacheControl, cancellationToken).ConfigureAwait(false); var operation = new ManagementGroupDeleteOperation(_clientDiagnostics, Pipeline, _restClient.CreateDeleteRequest(Id.Name, cacheControl).Request, originalResponse); if (waitForCompletion) { await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }