-
Notifications
You must be signed in to change notification settings - Fork 2
/
task.go
444 lines (395 loc) · 12.9 KB
/
task.go
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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
package shared
import (
"encoding/json"
"fmt"
"github.com/conductorone/conductorone-sdk-go/pkg/utils"
"time"
)
type Actions string
const (
ActionsTaskActionTypeUnspecified Actions = "TASK_ACTION_TYPE_UNSPECIFIED"
ActionsTaskActionTypeClose Actions = "TASK_ACTION_TYPE_CLOSE"
ActionsTaskActionTypeApprove Actions = "TASK_ACTION_TYPE_APPROVE"
ActionsTaskActionTypeDeny Actions = "TASK_ACTION_TYPE_DENY"
ActionsTaskActionTypeComment Actions = "TASK_ACTION_TYPE_COMMENT"
ActionsTaskActionTypeDelete Actions = "TASK_ACTION_TYPE_DELETE"
ActionsTaskActionTypeReassign Actions = "TASK_ACTION_TYPE_REASSIGN"
ActionsTaskActionTypeRestart Actions = "TASK_ACTION_TYPE_RESTART"
ActionsTaskActionTypeSendReminder Actions = "TASK_ACTION_TYPE_SEND_REMINDER"
ActionsTaskActionTypeProvisionComplete Actions = "TASK_ACTION_TYPE_PROVISION_COMPLETE"
ActionsTaskActionTypeProvisionCancelled Actions = "TASK_ACTION_TYPE_PROVISION_CANCELLED"
ActionsTaskActionTypeProvisionErrored Actions = "TASK_ACTION_TYPE_PROVISION_ERRORED"
ActionsTaskActionTypeProvisionAppUserTargetCreated Actions = "TASK_ACTION_TYPE_PROVISION_APP_USER_TARGET_CREATED"
ActionsTaskActionTypeRollbackSkipped Actions = "TASK_ACTION_TYPE_ROLLBACK_SKIPPED"
ActionsTaskActionTypeHardReset Actions = "TASK_ACTION_TYPE_HARD_RESET"
ActionsTaskActionTypeEscalateToEmergencyAccess Actions = "TASK_ACTION_TYPE_ESCALATE_TO_EMERGENCY_ACCESS"
ActionsTaskActionTypeChangePolicy Actions = "TASK_ACTION_TYPE_CHANGE_POLICY"
ActionsTaskActionTypeRecalculateDenialFromBasePolicyDecisions Actions = "TASK_ACTION_TYPE_RECALCULATE_DENIAL_FROM_BASE_POLICY_DECISIONS"
ActionsTaskActionTypeSetInsightsAndRecommendation Actions = "TASK_ACTION_TYPE_SET_INSIGHTS_AND_RECOMMENDATION"
)
func (e Actions) ToPointer() *Actions {
return &e
}
func (e *Actions) UnmarshalJSON(data []byte) error {
var v string
if err := json.Unmarshal(data, &v); err != nil {
return err
}
switch v {
case "TASK_ACTION_TYPE_UNSPECIFIED":
fallthrough
case "TASK_ACTION_TYPE_CLOSE":
fallthrough
case "TASK_ACTION_TYPE_APPROVE":
fallthrough
case "TASK_ACTION_TYPE_DENY":
fallthrough
case "TASK_ACTION_TYPE_COMMENT":
fallthrough
case "TASK_ACTION_TYPE_DELETE":
fallthrough
case "TASK_ACTION_TYPE_REASSIGN":
fallthrough
case "TASK_ACTION_TYPE_RESTART":
fallthrough
case "TASK_ACTION_TYPE_SEND_REMINDER":
fallthrough
case "TASK_ACTION_TYPE_PROVISION_COMPLETE":
fallthrough
case "TASK_ACTION_TYPE_PROVISION_CANCELLED":
fallthrough
case "TASK_ACTION_TYPE_PROVISION_ERRORED":
fallthrough
case "TASK_ACTION_TYPE_PROVISION_APP_USER_TARGET_CREATED":
fallthrough
case "TASK_ACTION_TYPE_ROLLBACK_SKIPPED":
fallthrough
case "TASK_ACTION_TYPE_HARD_RESET":
fallthrough
case "TASK_ACTION_TYPE_ESCALATE_TO_EMERGENCY_ACCESS":
fallthrough
case "TASK_ACTION_TYPE_CHANGE_POLICY":
fallthrough
case "TASK_ACTION_TYPE_RECALCULATE_DENIAL_FROM_BASE_POLICY_DECISIONS":
fallthrough
case "TASK_ACTION_TYPE_SET_INSIGHTS_AND_RECOMMENDATION":
*e = Actions(v)
return nil
default:
return fmt.Errorf("invalid value for Actions: %v", v)
}
}
// Annotations - Contains an arbitrary serialized message along with a @type that describes the type of the serialized message.
type Annotations struct {
// The type of the serialized message.
AtType *string `json:"@type,omitempty"`
AdditionalProperties map[string]interface{} `additionalProperties:"true" json:"-"`
}
func (a Annotations) MarshalJSON() ([]byte, error) {
return utils.MarshalJSON(a, "", false)
}
func (a *Annotations) UnmarshalJSON(data []byte) error {
if err := utils.UnmarshalJSON(data, &a, "", false, false); err != nil {
return err
}
return nil
}
func (o *Annotations) GetAtType() *string {
if o == nil {
return nil
}
return o.AtType
}
func (o *Annotations) GetAdditionalProperties() map[string]interface{} {
if o == nil {
return nil
}
return o.AdditionalProperties
}
// Processing - The processing state of a task as defined by the `processing_enum`
type Processing string
const (
ProcessingTaskProcessingTypeUnspecified Processing = "TASK_PROCESSING_TYPE_UNSPECIFIED"
ProcessingTaskProcessingTypeProcessing Processing = "TASK_PROCESSING_TYPE_PROCESSING"
ProcessingTaskProcessingTypeWaiting Processing = "TASK_PROCESSING_TYPE_WAITING"
ProcessingTaskProcessingTypeDone Processing = "TASK_PROCESSING_TYPE_DONE"
)
func (e Processing) ToPointer() *Processing {
return &e
}
func (e *Processing) UnmarshalJSON(data []byte) error {
var v string
if err := json.Unmarshal(data, &v); err != nil {
return err
}
switch v {
case "TASK_PROCESSING_TYPE_UNSPECIFIED":
fallthrough
case "TASK_PROCESSING_TYPE_PROCESSING":
fallthrough
case "TASK_PROCESSING_TYPE_WAITING":
fallthrough
case "TASK_PROCESSING_TYPE_DONE":
*e = Processing(v)
return nil
default:
return fmt.Errorf("invalid value for Processing: %v", v)
}
}
// Recommendation - The recommendation field.
type Recommendation string
const (
RecommendationInsightRecommendationUnspecified Recommendation = "INSIGHT_RECOMMENDATION_UNSPECIFIED"
RecommendationInsightRecommendationApprove Recommendation = "INSIGHT_RECOMMENDATION_APPROVE"
RecommendationInsightRecommendationDeny Recommendation = "INSIGHT_RECOMMENDATION_DENY"
RecommendationInsightRecommendationReview Recommendation = "INSIGHT_RECOMMENDATION_REVIEW"
)
func (e Recommendation) ToPointer() *Recommendation {
return &e
}
func (e *Recommendation) UnmarshalJSON(data []byte) error {
var v string
if err := json.Unmarshal(data, &v); err != nil {
return err
}
switch v {
case "INSIGHT_RECOMMENDATION_UNSPECIFIED":
fallthrough
case "INSIGHT_RECOMMENDATION_APPROVE":
fallthrough
case "INSIGHT_RECOMMENDATION_DENY":
fallthrough
case "INSIGHT_RECOMMENDATION_REVIEW":
*e = Recommendation(v)
return nil
default:
return fmt.Errorf("invalid value for Recommendation: %v", v)
}
}
// TaskState - The current state of the task as defined by the `state_enum`
type TaskState string
const (
TaskStateTaskStateUnspecified TaskState = "TASK_STATE_UNSPECIFIED"
TaskStateTaskStateOpen TaskState = "TASK_STATE_OPEN"
TaskStateTaskStateClosed TaskState = "TASK_STATE_CLOSED"
)
func (e TaskState) ToPointer() *TaskState {
return &e
}
func (e *TaskState) UnmarshalJSON(data []byte) error {
var v string
if err := json.Unmarshal(data, &v); err != nil {
return err
}
switch v {
case "TASK_STATE_UNSPECIFIED":
fallthrough
case "TASK_STATE_OPEN":
fallthrough
case "TASK_STATE_CLOSED":
*e = TaskState(v)
return nil
default:
return fmt.Errorf("invalid value for TaskState: %v", v)
}
}
// Task - A fully-fleged task object. Includes its policy, references to external apps, its type, its processing history, and more.
type Task struct {
// A policy instance is an object that contains a reference to the policy it was created from, the currently executing step, the next steps, and the history of previously completed steps.
PolicyInstance *PolicyInstance `json:"policy,omitempty"`
// Task Type provides configuration for the type of task: certify, grant, or revoke
//
// This message contains a oneof named task_type. Only a single field of the following list may be set at a time:
// - grant
// - revoke
// - certify
//
TaskType *TaskType `json:"type,omitempty"`
// The actions that can be performed on the task by the current user.
Actions []Actions `json:"actions,omitempty"`
// The ID of the analysis object associated with this task created by an analysis workflow if the analysis feature is enabled for your tenant.
AnalysisID *string `json:"analysisId,omitempty"`
// An array of `google.protobuf.Any` annotations with various base64-encoded data.
Annotations []Annotations `json:"annotations,omitempty"`
// The count of comments.
CommentCount *int `json:"commentCount,omitempty"`
CreatedAt *time.Time `json:"createdAt,omitempty"`
// The ID of the user that is the creator of this task. This may not always match the userId field.
CreatedByUserID *string `json:"createdByUserId,omitempty"`
DeletedAt *time.Time `json:"deletedAt,omitempty"`
// The description of the task. This is also known as justification.
Description *string `json:"description,omitempty"`
// The display name of the task.
DisplayName *string `json:"displayName,omitempty"`
// A field indicating whether this task was created using an emergency access flow, or escalated to emergency access. On task creation, it will also use the app entitlement's emergency policy when possible.
EmergencyAccess *bool `json:"emergencyAccess,omitempty"`
// An array of external references to the task. Historically that has been items like Jira task IDs. This is currently unused, but may come back in the future for integrations.
ExternalRefs []ExternalRef `json:"externalRefs,omitempty"`
// The ID of the task.
ID *string `json:"id,omitempty"`
// The insightIds field.
InsightIds []string `json:"insightIds,omitempty"`
// A human-usable numeric ID of a task which can be included in place of the fully qualified task id in path parmeters (but not search queries).
NumericID *string `json:"numericId,omitempty"`
// The policy generation id refers to the current policy's generation ID. This is changed when the policy is changed on a task.
PolicyGenerationID *string `json:"policyGenerationId,omitempty"`
// The processing state of a task as defined by the `processing_enum`
Processing *Processing `json:"processing,omitempty"`
// The recommendation field.
Recommendation *Recommendation `json:"recommendation,omitempty"`
// The current state of the task as defined by the `state_enum`
State *TaskState `json:"state,omitempty"`
// An array of IDs belonging to Identity Users that are allowed to review this step in a task.
StepApproverIds []string `json:"stepApproverIds,omitempty"`
UpdatedAt *time.Time `json:"updatedAt,omitempty"`
// The ID of the user that is the target of this task. This may be empty if we're targeting a specific app user that has no known identity user.
UserID *string `json:"userId,omitempty"`
}
func (t Task) MarshalJSON() ([]byte, error) {
return utils.MarshalJSON(t, "", false)
}
func (t *Task) UnmarshalJSON(data []byte) error {
if err := utils.UnmarshalJSON(data, &t, "", false, false); err != nil {
return err
}
return nil
}
func (o *Task) GetPolicyInstance() *PolicyInstance {
if o == nil {
return nil
}
return o.PolicyInstance
}
func (o *Task) GetTaskType() *TaskType {
if o == nil {
return nil
}
return o.TaskType
}
func (o *Task) GetActions() []Actions {
if o == nil {
return nil
}
return o.Actions
}
func (o *Task) GetAnalysisID() *string {
if o == nil {
return nil
}
return o.AnalysisID
}
func (o *Task) GetAnnotations() []Annotations {
if o == nil {
return nil
}
return o.Annotations
}
func (o *Task) GetCommentCount() *int {
if o == nil {
return nil
}
return o.CommentCount
}
func (o *Task) GetCreatedAt() *time.Time {
if o == nil {
return nil
}
return o.CreatedAt
}
func (o *Task) GetCreatedByUserID() *string {
if o == nil {
return nil
}
return o.CreatedByUserID
}
func (o *Task) GetDeletedAt() *time.Time {
if o == nil {
return nil
}
return o.DeletedAt
}
func (o *Task) GetDescription() *string {
if o == nil {
return nil
}
return o.Description
}
func (o *Task) GetDisplayName() *string {
if o == nil {
return nil
}
return o.DisplayName
}
func (o *Task) GetEmergencyAccess() *bool {
if o == nil {
return nil
}
return o.EmergencyAccess
}
func (o *Task) GetExternalRefs() []ExternalRef {
if o == nil {
return nil
}
return o.ExternalRefs
}
func (o *Task) GetID() *string {
if o == nil {
return nil
}
return o.ID
}
func (o *Task) GetInsightIds() []string {
if o == nil {
return nil
}
return o.InsightIds
}
func (o *Task) GetNumericID() *string {
if o == nil {
return nil
}
return o.NumericID
}
func (o *Task) GetPolicyGenerationID() *string {
if o == nil {
return nil
}
return o.PolicyGenerationID
}
func (o *Task) GetProcessing() *Processing {
if o == nil {
return nil
}
return o.Processing
}
func (o *Task) GetRecommendation() *Recommendation {
if o == nil {
return nil
}
return o.Recommendation
}
func (o *Task) GetState() *TaskState {
if o == nil {
return nil
}
return o.State
}
func (o *Task) GetStepApproverIds() []string {
if o == nil {
return nil
}
return o.StepApproverIds
}
func (o *Task) GetUpdatedAt() *time.Time {
if o == nil {
return nil
}
return o.UpdatedAt
}
func (o *Task) GetUserID() *string {
if o == nil {
return nil
}
return o.UserID
}