github.com/Files-com/files-sdk-go/v2@v2.1.2/externalevent.go (about) 1 package files_sdk 2 3 import ( 4 "encoding/json" 5 "time" 6 7 lib "github.com/Files-com/files-sdk-go/v2/lib" 8 ) 9 10 type ExternalEvent struct { 11 Id int64 `json:"id,omitempty" path:"id,omitempty" url:"id,omitempty"` 12 EventType string `json:"event_type,omitempty" path:"event_type,omitempty" url:"event_type,omitempty"` 13 Status string `json:"status,omitempty" path:"status,omitempty" url:"status,omitempty"` 14 Body string `json:"body,omitempty" path:"body,omitempty" url:"body,omitempty"` 15 CreatedAt *time.Time `json:"created_at,omitempty" path:"created_at,omitempty" url:"created_at,omitempty"` 16 BodyUrl string `json:"body_url,omitempty" path:"body_url,omitempty" url:"body_url,omitempty"` 17 FolderBehaviorId int64 `json:"folder_behavior_id,omitempty" path:"folder_behavior_id,omitempty" url:"folder_behavior_id,omitempty"` 18 SuccessfulFiles int64 `json:"successful_files,omitempty" path:"successful_files,omitempty" url:"successful_files,omitempty"` 19 ErroredFiles int64 `json:"errored_files,omitempty" path:"errored_files,omitempty" url:"errored_files,omitempty"` 20 BytesSynced int64 `json:"bytes_synced,omitempty" path:"bytes_synced,omitempty" url:"bytes_synced,omitempty"` 21 RemoteServerType string `json:"remote_server_type,omitempty" path:"remote_server_type,omitempty" url:"remote_server_type,omitempty"` 22 } 23 24 func (e ExternalEvent) Identifier() interface{} { 25 return e.Id 26 } 27 28 type ExternalEventCollection []ExternalEvent 29 30 type ExternalEventStatusEnum string 31 32 func (u ExternalEventStatusEnum) String() string { 33 return string(u) 34 } 35 36 func (u ExternalEventStatusEnum) Enum() map[string]ExternalEventStatusEnum { 37 return map[string]ExternalEventStatusEnum{ 38 "success": ExternalEventStatusEnum("success"), 39 "failure": ExternalEventStatusEnum("failure"), 40 "partial_failure": ExternalEventStatusEnum("partial_failure"), 41 "in_progress": ExternalEventStatusEnum("in_progress"), 42 "skipped": ExternalEventStatusEnum("skipped"), 43 } 44 } 45 46 type ExternalEventListParams struct { 47 SortBy map[string]interface{} `url:"sort_by,omitempty" required:"false" json:"sort_by,omitempty" path:"sort_by"` 48 Filter ExternalEvent `url:"filter,omitempty" required:"false" json:"filter,omitempty" path:"filter"` 49 FilterGt map[string]interface{} `url:"filter_gt,omitempty" required:"false" json:"filter_gt,omitempty" path:"filter_gt"` 50 FilterGteq map[string]interface{} `url:"filter_gteq,omitempty" required:"false" json:"filter_gteq,omitempty" path:"filter_gteq"` 51 FilterPrefix map[string]interface{} `url:"filter_prefix,omitempty" required:"false" json:"filter_prefix,omitempty" path:"filter_prefix"` 52 FilterLt map[string]interface{} `url:"filter_lt,omitempty" required:"false" json:"filter_lt,omitempty" path:"filter_lt"` 53 FilterLteq map[string]interface{} `url:"filter_lteq,omitempty" required:"false" json:"filter_lteq,omitempty" path:"filter_lteq"` 54 ListParams 55 } 56 57 type ExternalEventFindParams struct { 58 Id int64 `url:"-,omitempty" required:"false" json:"-,omitempty" path:"id"` 59 } 60 61 type ExternalEventCreateParams struct { 62 Status ExternalEventStatusEnum `url:"status,omitempty" required:"true" json:"status,omitempty" path:"status"` 63 Body string `url:"body,omitempty" required:"true" json:"body,omitempty" path:"body"` 64 } 65 66 func (e *ExternalEvent) UnmarshalJSON(data []byte) error { 67 type externalEvent ExternalEvent 68 var v externalEvent 69 if err := json.Unmarshal(data, &v); err != nil { 70 return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, map[string]interface{}{}) 71 } 72 73 *e = ExternalEvent(v) 74 return nil 75 } 76 77 func (e *ExternalEventCollection) UnmarshalJSON(data []byte) error { 78 type externalEvents ExternalEventCollection 79 var v externalEvents 80 if err := json.Unmarshal(data, &v); err != nil { 81 return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, []map[string]interface{}{}) 82 } 83 84 *e = ExternalEventCollection(v) 85 return nil 86 } 87 88 func (e *ExternalEventCollection) ToSlice() *[]interface{} { 89 ret := make([]interface{}, len(*e)) 90 for i, v := range *e { 91 ret[i] = v 92 } 93 94 return &ret 95 }