/// <summary> /// Creates a waiter using the provided configuration. /// </summary> /// <param name="request">Request to send.</param> /// <param name="config">Wait Configuration</param> /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param> /// <returns>a new Oci.common.Waiter instance</returns> public Waiter <GetTypeRequest, GetTypeResponse> ForType(GetTypeRequest request, WaiterConfiguration config, params LifecycleState[] targetStates) { var agent = new WaiterAgent <GetTypeRequest, GetTypeResponse>( request, request => client.GetType(request), response => targetStates.Contains(response.Type.LifecycleState.Value), targetStates.Contains(LifecycleState.Deleted) ); return(new Waiter <GetTypeRequest, GetTypeResponse>(config, agent)); }
public GetTypeResponse GetType(GetTypeRequest request) { try { var type = DataContext.Types.First(x => x.Id == request.Id); var response = type.MapTo <GetTypeResponse>(); return(response); } catch (System.InvalidOperationException x) { return(new GetTypeResponse { IsSuccess = false, Message = x.Message }); } }
private void HandleOutput(GetTypeRequest request) { var waiterConfig = new WaiterConfiguration { MaxAttempts = MaxWaitAttempts, GetNextDelayInSeconds = (_) => WaitIntervalSeconds }; switch (ParameterSetName) { case LifecycleStateParamSet: response = client.Waiters.ForType(request, waiterConfig, WaitForLifecycleState).Execute(); break; case Default: response = client.GetType(request).GetAwaiter().GetResult(); break; } WriteOutput(response, response.Type); }
protected override void ProcessRecord() { base.ProcessRecord(); GetTypeRequest request; try { request = new GetTypeRequest { CatalogId = CatalogId, TypeKey = TypeKey, Fields = Fields, OpcRequestId = OpcRequestId }; HandleOutput(request); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
protected override void ProcessRecord() { base.ProcessRecord(); GetTypeRequest request; try { request = new GetTypeRequest { RegistryId = RegistryId, TypeKey = TypeKey, OpcRequestId = OpcRequestId, Fields = Fields }; response = client.GetType(request).GetAwaiter().GetResult(); WriteOutput(response, response.Type); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
/// <summary> /// Creates a waiter using default wait configuration. /// </summary> /// <param name="request">Request to send.</param> /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param> /// <returns>a new Oci.common.Waiter instance</returns> public Waiter <GetTypeRequest, GetTypeResponse> ForType(GetTypeRequest request, params LifecycleState[] targetStates) { return(this.ForType(request, WaiterConfiguration.DefaultWaiterConfiguration, targetStates)); }