/// <summary> /// The process record method. /// </summary> protected override void ProcessRecord() { ResponseType response = null; base.ProcessRecord(); try { var connectionDetails = new SetConnectivityDetailsType[] { new SetConnectivityDetailsType { id = NicId.ToString(), connected = ConnectionState } }; var connectivityType = new SetNicConnectivityType { Items = connectionDetails, ItemsElementName = new ItemsChoiceType[] { ItemsChoiceType.nic } }; response = Connection.ApiClient.ServerManagement.Server.SetNicConnectivity(connectivityType).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> /// Set Nic Connectivity /// </summary> /// <param name="setNicConnectivityType">Nic Connectivity Type.</param> /// <returns>The <see cref="ResponseType"/></returns> public async Task <ResponseType> SetNicConnectivity(SetNicConnectivityType setNicConnectivityType) { return(await _apiClient.PostAsync <SetNicConnectivityType, ResponseType>(ApiUris.SetNicConnectivity(_apiClient.OrganizationId), setNicConnectivityType)); }