-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCheckBody.java
More file actions
350 lines (287 loc) · 9.4 KB
/
CheckBody.java
File metadata and controls
350 lines (287 loc) · 9.4 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
/*
* Permify API
* Permify is an open source authorization service for creating fine-grained and scalable authorization systems.
*
* The version of the OpenAPI document: v1.4.3
* Contact: hello@permify.co
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package co.permify.sdk.model;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.StringJoiner;
import java.util.Objects;
import java.util.Map;
import java.util.HashMap;
import co.permify.sdk.model.Argument;
import co.permify.sdk.model.Context;
import co.permify.sdk.model.Entity;
import co.permify.sdk.model.PermissionCheckRequestMetadata;
import co.permify.sdk.model.Subject;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
/**
* PermissionCheckRequest is the request message for the Check method in the Permission service.
*/
@JsonPropertyOrder({
CheckBody.JSON_PROPERTY_METADATA,
CheckBody.JSON_PROPERTY_ENTITY,
CheckBody.JSON_PROPERTY_PERMISSION,
CheckBody.JSON_PROPERTY_SUBJECT,
CheckBody.JSON_PROPERTY_CONTEXT,
CheckBody.JSON_PROPERTY_ARGUMENTS
})
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class CheckBody {
public static final String JSON_PROPERTY_METADATA = "metadata";
private PermissionCheckRequestMetadata metadata;
public static final String JSON_PROPERTY_ENTITY = "entity";
private Entity entity;
public static final String JSON_PROPERTY_PERMISSION = "permission";
private String permission;
public static final String JSON_PROPERTY_SUBJECT = "subject";
private Subject subject;
public static final String JSON_PROPERTY_CONTEXT = "context";
private Context context;
public static final String JSON_PROPERTY_ARGUMENTS = "arguments";
private List<Argument> arguments;
public CheckBody() {
}
public CheckBody metadata(PermissionCheckRequestMetadata metadata) {
this.metadata = metadata;
return this;
}
/**
* Get metadata
* @return metadata
**/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_METADATA)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public PermissionCheckRequestMetadata getMetadata() {
return metadata;
}
@JsonProperty(JSON_PROPERTY_METADATA)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setMetadata(PermissionCheckRequestMetadata metadata) {
this.metadata = metadata;
}
public CheckBody entity(Entity entity) {
this.entity = entity;
return this;
}
/**
* Get entity
* @return entity
**/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_ENTITY)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Entity getEntity() {
return entity;
}
@JsonProperty(JSON_PROPERTY_ENTITY)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setEntity(Entity entity) {
this.entity = entity;
}
public CheckBody permission(String permission) {
this.permission = permission;
return this;
}
/**
* The action the user wants to perform on the resource
* @return permission
**/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_PERMISSION)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getPermission() {
return permission;
}
@JsonProperty(JSON_PROPERTY_PERMISSION)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setPermission(String permission) {
this.permission = permission;
}
public CheckBody subject(Subject subject) {
this.subject = subject;
return this;
}
/**
* Get subject
* @return subject
**/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_SUBJECT)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Subject getSubject() {
return subject;
}
@JsonProperty(JSON_PROPERTY_SUBJECT)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setSubject(Subject subject) {
this.subject = subject;
}
public CheckBody context(Context context) {
this.context = context;
return this;
}
/**
* Get context
* @return context
**/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_CONTEXT)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Context getContext() {
return context;
}
@JsonProperty(JSON_PROPERTY_CONTEXT)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setContext(Context context) {
this.context = context;
}
public CheckBody arguments(List<Argument> arguments) {
this.arguments = arguments;
return this;
}
public CheckBody addArgumentsItem(Argument argumentsItem) {
if (this.arguments == null) {
this.arguments = new ArrayList<>();
}
this.arguments.add(argumentsItem);
return this;
}
/**
* Additional arguments associated with this request.
* @return arguments
**/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_ARGUMENTS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List<Argument> getArguments() {
return arguments;
}
@JsonProperty(JSON_PROPERTY_ARGUMENTS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setArguments(List<Argument> arguments) {
this.arguments = arguments;
}
/**
* Return true if this CheckBody object is equal to o.
*/
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CheckBody checkBody = (CheckBody) o;
return Objects.equals(this.metadata, checkBody.metadata) &&
Objects.equals(this.entity, checkBody.entity) &&
Objects.equals(this.permission, checkBody.permission) &&
Objects.equals(this.subject, checkBody.subject) &&
Objects.equals(this.context, checkBody.context) &&
Objects.equals(this.arguments, checkBody.arguments);
}
@Override
public int hashCode() {
return Objects.hash(metadata, entity, permission, subject, context, arguments);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class CheckBody {\n");
sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n");
sb.append(" entity: ").append(toIndentedString(entity)).append("\n");
sb.append(" permission: ").append(toIndentedString(permission)).append("\n");
sb.append(" subject: ").append(toIndentedString(subject)).append("\n");
sb.append(" context: ").append(toIndentedString(context)).append("\n");
sb.append(" arguments: ").append(toIndentedString(arguments)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
/**
* Convert the instance into URL query string.
*
* @return URL query string
*/
public String toUrlQueryString() {
return toUrlQueryString(null);
}
/**
* Convert the instance into URL query string.
*
* @param prefix prefix of the query string
* @return URL query string
*/
public String toUrlQueryString(String prefix) {
String suffix = "";
String containerSuffix = "";
String containerPrefix = "";
if (prefix == null) {
// style=form, explode=true, e.g. /pet?name=cat&type=manx
prefix = "";
} else {
// deepObject style e.g. /pet?id[name]=cat&id[type]=manx
prefix = prefix + "[";
suffix = "]";
containerSuffix = "]";
containerPrefix = "[";
}
StringJoiner joiner = new StringJoiner("&");
// add `metadata` to the URL query string
if (getMetadata() != null) {
joiner.add(getMetadata().toUrlQueryString(prefix + "metadata" + suffix));
}
// add `entity` to the URL query string
if (getEntity() != null) {
joiner.add(getEntity().toUrlQueryString(prefix + "entity" + suffix));
}
// add `permission` to the URL query string
if (getPermission() != null) {
joiner.add(String.format("%spermission%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPermission()), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
// add `subject` to the URL query string
if (getSubject() != null) {
joiner.add(getSubject().toUrlQueryString(prefix + "subject" + suffix));
}
// add `context` to the URL query string
if (getContext() != null) {
joiner.add(getContext().toUrlQueryString(prefix + "context" + suffix));
}
// add `arguments` to the URL query string
if (getArguments() != null) {
for (int i = 0; i < getArguments().size(); i++) {
if (getArguments().get(i) != null) {
joiner.add(getArguments().get(i).toUrlQueryString(String.format("%sarguments%s%s", prefix, suffix,
"".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix))));
}
}
}
return joiner.toString();
}
}