forked from oracle/oci-dotnet-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OdaWaiters.cs
85 lines (78 loc) · 4.43 KB
/
OdaWaiters.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
*/
// NOTE: Code generated by OracleSDKGenerator.
// DO NOT EDIT this file manually.
using System.Linq;
using Oci.Common.Waiters;
using Oci.OdaService.Models;
using Oci.OdaService.Requests;
using Oci.OdaService.Responses;
namespace Oci.OdaService
{
/// <summary>
/// Contains collection of helper methods to produce Oci.Common.Waiters for different resources of Oda.
/// </summary>
public class OdaWaiters
{
private readonly OdaClient client;
public OdaWaiters(OdaClient client)
{
this.client = client;
}
/// <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<GetOdaInstanceRequest, GetOdaInstanceResponse> ForOdaInstance(GetOdaInstanceRequest request, params OdaInstance.LifecycleStateEnum[] targetStates)
{
return this.ForOdaInstance(request, WaiterConfiguration.DefaultWaiterConfiguration, targetStates);
}
/// <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<GetOdaInstanceRequest, GetOdaInstanceResponse> ForOdaInstance(GetOdaInstanceRequest request, WaiterConfiguration config, params OdaInstance.LifecycleStateEnum[] targetStates)
{
var agent = new WaiterAgent<GetOdaInstanceRequest, GetOdaInstanceResponse>(
request,
request => client.GetOdaInstance(request),
response => targetStates.Contains(response.OdaInstance.LifecycleState.Value),
targetStates.Contains(OdaInstance.LifecycleStateEnum.Deleted)
);
return new Waiter<GetOdaInstanceRequest, GetOdaInstanceResponse>(config, agent);
}
/// <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<GetWorkRequestRequest, GetWorkRequestResponse> ForWorkRequest(GetWorkRequestRequest request, params WorkRequest.StatusEnum[] targetStates)
{
return this.ForWorkRequest(request, WaiterConfiguration.DefaultWaiterConfiguration, targetStates);
}
/// <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<GetWorkRequestRequest, GetWorkRequestResponse> ForWorkRequest(GetWorkRequestRequest request, WaiterConfiguration config, params WorkRequest.StatusEnum[] targetStates)
{
var agent = new WaiterAgent<GetWorkRequestRequest, GetWorkRequestResponse>(
request,
request => client.GetWorkRequest(request),
response => targetStates.Contains(response.WorkRequest.Status.Value)
);
return new Waiter<GetWorkRequestRequest, GetWorkRequestResponse>(config, agent);
}
}
}