/// <summary> /// The process record method. /// </summary> protected override void ProcessRecord() { try { var cloneServerType = new CloneServerType() { id = Server.id, imageName = Name, description = Description, clusterId = ClusterId, guestOsCustomization = GuestOsCustomization.HasValue?GuestOsCustomization.Value:true, guestOsCustomizationSpecified = GuestOsCustomization.HasValue }; var status = Connection.ApiClient.ServerManagement.Server.CloneServer(cloneServerType).Result; if (status != null) { WriteDebug( string.Format( "{0} resulted in {1} ({2}): {3}", status.operation, status.error, status.responseCode, status.message)); } } catch (AggregateException ae) { ae.Handle( e => { if (e is ComputeApiException) { WriteError(new ErrorRecord(e, "-2", ErrorCategory.InvalidOperation, Connection)); } else { ThrowTerminatingError(new ErrorRecord(e, "-1", ErrorCategory.ConnectionError, Connection)); } return(true); }); } base.ProcessRecord(); }
/// <summary> /// Clone journal /// </summary> /// <param name="cloneServerType">Clone Server type.</param> /// <returns>The <see cref="ResponseType"/></returns> public async Task <ResponseType> CloneServer(CloneServerType cloneServerType) { return(await _apiClient.PostAsync <CloneServerType, ResponseType>(ApiUris.CloneServer(_apiClient.OrganizationId), cloneServerType)); }