files-com 1.6.14__py3-none-any.whl → 1.6.16__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of files-com might be problematic. Click here for more details.

@@ -0,0 +1,110 @@
1
+ import builtins # noqa: F401
2
+ from files_sdk.api import Api # noqa: F401
3
+ from files_sdk.list_obj import ListObj
4
+ from files_sdk.error import ( # noqa: F401
5
+ InvalidParameterError,
6
+ MissingParameterError,
7
+ NotImplementedError,
8
+ )
9
+
10
+
11
+ class SyncRun:
12
+ default_attributes = {
13
+ "id": None, # int64 - SyncRun ID
14
+ "sync_id": None, # int64 - ID of the Sync this run belongs to
15
+ "site_id": None, # int64 - Site ID
16
+ "status": None, # string - Status of the sync run (success, failure, partial_failure, in_progress, skipped)
17
+ "remote_server_type": None, # string - Type of remote server used, if any
18
+ "body": None, # string - Log or summary body for this run
19
+ "event_errors": None, # array(array) - Array of errors encountered during the run
20
+ "bytes_synced": None, # int64 - Total bytes synced in this run
21
+ "compared_files": None, # int64 - Number of files compared
22
+ "compared_folders": None, # int64 - Number of folders compared
23
+ "errored_files": None, # int64 - Number of files that errored
24
+ "successful_files": None, # int64 - Number of files successfully synced
25
+ "runtime": None, # float - Total runtime in seconds
26
+ "s3_body_path": None, # string - S3 path to the main log file
27
+ "s3_internal_body_path": None, # string - S3 path to the internal log file
28
+ "completed_at": None, # date-time - When this run was completed
29
+ "notified": None, # boolean - Whether notifications were sent for this run
30
+ "created_at": None, # date-time - When this run was created
31
+ "updated_at": None, # date-time - When this run was last updated
32
+ }
33
+
34
+ def __init__(self, attributes=None, options=None):
35
+ if not isinstance(attributes, dict):
36
+ attributes = {}
37
+ if not isinstance(options, dict):
38
+ options = {}
39
+ self.set_attributes(attributes)
40
+ self.options = options
41
+
42
+ def set_attributes(self, attributes):
43
+ for attribute, default_value in SyncRun.default_attributes.items():
44
+ setattr(self, attribute, attributes.get(attribute, default_value))
45
+
46
+ def get_attributes(self):
47
+ return {
48
+ k: getattr(self, k, None)
49
+ for k in SyncRun.default_attributes
50
+ if getattr(self, k, None) is not None
51
+ }
52
+
53
+
54
+ # Parameters:
55
+ # user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
56
+ # cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
57
+ # per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
58
+ # sort_by - object - If set, sort records by the specified field in either `asc` or `desc` direction. Valid fields are `sync_id`, `created_at` or `status`.
59
+ # filter - object - If set, return records where the specified field is equal to the supplied value. Valid fields are `status` and `sync_id`. Valid field combinations are `[ sync_id, status ]`.
60
+ # sync_id (required) - int64 - ID of the Sync this run belongs to
61
+ def list(params=None, options=None):
62
+ if not isinstance(params, dict):
63
+ params = {}
64
+ if not isinstance(options, dict):
65
+ options = {}
66
+ if "user_id" in params and not isinstance(params["user_id"], int):
67
+ raise InvalidParameterError("Bad parameter: user_id must be an int")
68
+ if "cursor" in params and not isinstance(params["cursor"], str):
69
+ raise InvalidParameterError("Bad parameter: cursor must be an str")
70
+ if "per_page" in params and not isinstance(params["per_page"], int):
71
+ raise InvalidParameterError("Bad parameter: per_page must be an int")
72
+ if "sort_by" in params and not isinstance(params["sort_by"], dict):
73
+ raise InvalidParameterError("Bad parameter: sort_by must be an dict")
74
+ if "filter" in params and not isinstance(params["filter"], dict):
75
+ raise InvalidParameterError("Bad parameter: filter must be an dict")
76
+ if "sync_id" in params and not isinstance(params["sync_id"], int):
77
+ raise InvalidParameterError("Bad parameter: sync_id must be an int")
78
+ if "sync_id" not in params:
79
+ raise MissingParameterError("Parameter missing: sync_id")
80
+ return ListObj(SyncRun, "GET", "/sync_runs", params, options)
81
+
82
+
83
+ def all(params=None, options=None):
84
+ list(params, options)
85
+
86
+
87
+ # Parameters:
88
+ # id (required) - int64 - Sync Run ID.
89
+ def find(id, params=None, options=None):
90
+ if not isinstance(params, dict):
91
+ params = {}
92
+ if not isinstance(options, dict):
93
+ options = {}
94
+ params["id"] = id
95
+ if "id" in params and not isinstance(params["id"], int):
96
+ raise InvalidParameterError("Bad parameter: id must be an int")
97
+ if "id" not in params:
98
+ raise MissingParameterError("Parameter missing: id")
99
+ response, options = Api.send_request(
100
+ "GET", "/sync_runs/{id}".format(id=params["id"]), params, options
101
+ )
102
+ return SyncRun(response.data, options)
103
+
104
+
105
+ def get(id, params=None, options=None):
106
+ find(id, params, options)
107
+
108
+
109
+ def new(*args, **kwargs):
110
+ return SyncRun(*args, **kwargs)