Repository navigation
Expand file tree
/
Copy pathAsyncForwardClient.java
More file actions
181 lines (155 loc) · 5.62 KB
/
Copy pathAsyncForwardClient.java
File metadata and controls
181 lines (155 loc) · 5.62 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
package com.qoder.cloudagents;
import com.qoder.cloudagents.core.*;
import com.qoder.cloudagents.core.internal.ClientEngine;
import com.qoder.cloudagents.errors.ConfigurationException;
import com.qoder.cloudagents.forward.AsyncBatches;
import com.qoder.cloudagents.forward.AsyncChannelPairings;
import com.qoder.cloudagents.forward.AsyncChannels;
import com.qoder.cloudagents.forward.AsyncDrives;
import com.qoder.cloudagents.forward.AsyncEnvironments;
import com.qoder.cloudagents.forward.AsyncFiles;
import com.qoder.cloudagents.forward.AsyncIdentities;
import com.qoder.cloudagents.forward.AsyncMemoryStores;
import com.qoder.cloudagents.forward.AsyncModels;
import com.qoder.cloudagents.forward.AsyncScheduleRuns;
import com.qoder.cloudagents.forward.AsyncSchedules;
import com.qoder.cloudagents.forward.AsyncServiceAccountTokens;
import com.qoder.cloudagents.forward.AsyncSessions;
import com.qoder.cloudagents.forward.AsyncSkills;
import com.qoder.cloudagents.forward.AsyncTemplates;
import com.qoder.cloudagents.forward.AsyncUsage;
import com.qoder.cloudagents.forward.AsyncVaults;
import com.qoder.cloudagents.forward.AsyncWebhooks;
import com.qoder.cloudagents.forward.realtime.AsyncRealtime;
import java.util.Collections;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
/** Native asynchronous Forward client. Build with ForwardClient.builder().buildAsync(). */
public final class AsyncForwardClient implements AutoCloseable {
private final AsyncWebhooks webhooks;
private final AsyncUsage usage;
private final AsyncServiceAccountTokens serviceAccountTokens;
private final AsyncDrives drives;
private final AsyncRealtime realtime;
private final ClientEngine engine;
private final ForwardClient.Builder configuration;
private final boolean ownsEngine;
private final AsyncModels models;
private final AsyncFiles files;
private final AsyncChannelPairings channelPairings;
private final AsyncChannels channels;
private final AsyncBatches batches;
private final AsyncScheduleRuns scheduleRuns;
private final AsyncSchedules schedules;
private final AsyncVaults vaults;
private final AsyncSkills skills;
private final AsyncEnvironments environments;
private final AsyncTemplates templates;
private final AsyncIdentities identities;
private final AsyncSessions sessions;
private final AsyncMemoryStores memoryStores;
AsyncForwardClient(ClientEngine engine, boolean ownsEngine, ForwardClient.Builder configuration) {
this.configuration = configuration;
this.engine = engine;
realtime = new AsyncRealtime(engine);
drives = new AsyncDrives(engine);
serviceAccountTokens = new AsyncServiceAccountTokens(engine);
usage = new AsyncUsage(engine);
webhooks = new AsyncWebhooks(engine);
this.ownsEngine = ownsEngine;
models = new AsyncModels(engine);
files = new AsyncFiles(engine);
channelPairings = new AsyncChannelPairings(engine);
channels = new AsyncChannels(engine);
batches = new AsyncBatches(engine);
scheduleRuns = new AsyncScheduleRuns(engine);
schedules = new AsyncSchedules(engine);
vaults = new AsyncVaults(engine);
skills = new AsyncSkills(engine);
environments = new AsyncEnvironments(engine);
templates = new AsyncTemplates(engine);
identities = new AsyncIdentities(engine);
sessions = new AsyncSessions(engine);
memoryStores = new AsyncMemoryStores(engine);
}
public AsyncWebhooks webhooks() {
return webhooks;
}
public AsyncRealtime realtime() {
return realtime;
}
public AsyncUsage usage() {
return usage;
}
public AsyncServiceAccountTokens serviceAccountTokens() {
return serviceAccountTokens;
}
public AsyncDrives drives() {
return drives;
}
public AsyncModels models() {
return models;
}
public AsyncTemplates templates() {
return templates;
}
public AsyncIdentities identities() {
return identities;
}
public AsyncSessions sessions() {
return sessions;
}
public AsyncMemoryStores memoryStores() {
return memoryStores;
}
public AsyncEnvironments environments() {
return environments;
}
public AsyncFiles files() {
return files;
}
public AsyncSkills skills() {
return skills;
}
public AsyncVaults vaults() {
return vaults;
}
public AsyncSchedules schedules() {
return schedules;
}
public AsyncScheduleRuns scheduleRuns() {
return scheduleRuns;
}
public AsyncBatches batches() {
return batches;
}
public AsyncChannels channels() {
return channels;
}
public AsyncChannelPairings channelPairings() {
return channelPairings;
}
/** Creates an independently owned async client; the original client is unchanged. */
public AsyncForwardClient withOptions(Consumer<ForwardClient.Builder> configure) {
if (configure == null)
throw new ConfigurationException("Configuration callback must not be null");
ForwardClient.Builder copy = configuration.copy();
configure.accept(copy);
return copy.buildAsync();
}
public CompletableFuture<ApiResponse<JsonValue>> request(ApiRequest request) {
return request(request, RequestOptions.DEFAULT);
}
/** The returned future directly owns cancellation of the underlying operation. */
public CompletableFuture<ApiResponse<JsonValue>> request(
ApiRequest request, RequestOptions options) {
if (request == null || options == null)
throw new ConfigurationException("Request and options must not be null");
return engine.request(
request.method(), request.path(), Collections.emptyMap(), request.body(), true, options);
}
@Override
public void close() {
if (ownsEngine) engine.close();
}
}