/// <summary> /// The process record method. /// </summary> protected override void ProcessRecord() { ResponseType response = null; base.ProcessRecord(); try { var snapshotType = new EnableSnapshotServiceType { serverId = Server.id, servicePlan = ServicePlan, windowId = SnapshotWindowId.ToString(), initiateManualSnapshot = false }; response = Connection.ApiClient.ServerManagement.Server.EnableSnapshotService(snapshotType).Result; } catch (AggregateException ae) { ae.Handle( e => { if (e is ComputeApiException) { WriteError(new ErrorRecord(e, "-2", ErrorCategory.InvalidOperation, Connection)); } else { // if (e is HttpRequestException) ThrowTerminatingError(new ErrorRecord(e, "-1", ErrorCategory.ConnectionError, Connection)); } return(true); }); } WriteObject(response); }
/// <summary> /// Enable snapshot service /// </summary> /// <param name="enableSnapshotServiceType">Enable Snapshot Service Type.</param> /// <returns>The <see cref="ResponseType"/></returns> public async Task <ResponseType> EnableSnapshotService(EnableSnapshotServiceType enableSnapshotServiceType) { return(await _apiClient.PostAsync <EnableSnapshotServiceType, ResponseType>(ApiUris.EnableSnapshotService(_apiClient.OrganizationId), enableSnapshotServiceType)); }