kagglesdk 0.1.0__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.
- kagglesdk/__init__.py +6 -0
- kagglesdk/admin/__init__.py +0 -0
- kagglesdk/admin/services/__init__.py +0 -0
- kagglesdk/admin/services/inbox_file_service.py +22 -0
- kagglesdk/admin/types/__init__.py +0 -0
- kagglesdk/admin/types/inbox_file_service.py +74 -0
- kagglesdk/blobs/__init__.py +0 -0
- kagglesdk/blobs/services/__init__.py +0 -0
- kagglesdk/blobs/services/blob_api_service.py +25 -0
- kagglesdk/blobs/types/__init__.py +0 -0
- kagglesdk/blobs/types/blob_api_service.py +177 -0
- kagglesdk/common/__init__.py +0 -0
- kagglesdk/common/types/__init__.py +0 -0
- kagglesdk/common/types/file_download.py +102 -0
- kagglesdk/common/types/http_redirect.py +105 -0
- kagglesdk/community/__init__.py +0 -0
- kagglesdk/community/types/__init__.py +0 -0
- kagglesdk/community/types/content_enums.py +44 -0
- kagglesdk/competitions/__init__.py +0 -0
- kagglesdk/competitions/services/__init__.py +0 -0
- kagglesdk/competitions/services/competition_api_service.py +141 -0
- kagglesdk/competitions/types/__init__.py +0 -0
- kagglesdk/competitions/types/competition.py +14 -0
- kagglesdk/competitions/types/competition_api_service.py +2205 -0
- kagglesdk/competitions/types/competition_enums.py +53 -0
- kagglesdk/competitions/types/search_competitions.py +27 -0
- kagglesdk/competitions/types/submission_status.py +9 -0
- kagglesdk/datasets/__init__.py +0 -0
- kagglesdk/datasets/services/__init__.py +0 -0
- kagglesdk/datasets/services/dataset_api_service.py +170 -0
- kagglesdk/datasets/types/__init__.py +0 -0
- kagglesdk/datasets/types/dataset_api_service.py +2829 -0
- kagglesdk/datasets/types/dataset_enums.py +90 -0
- kagglesdk/datasets/types/dataset_types.py +646 -0
- kagglesdk/datasets/types/search_datasets.py +6 -0
- kagglesdk/discussions/__init__.py +0 -0
- kagglesdk/discussions/types/__init__.py +0 -0
- kagglesdk/discussions/types/search_discussions.py +94 -0
- kagglesdk/discussions/types/writeup_enums.py +11 -0
- kagglesdk/education/__init__.py +0 -0
- kagglesdk/education/services/__init__.py +0 -0
- kagglesdk/education/services/education_api_service.py +19 -0
- kagglesdk/education/types/__init__.py +0 -0
- kagglesdk/education/types/education_api_service.py +248 -0
- kagglesdk/education/types/education_service.py +139 -0
- kagglesdk/kaggle_client.py +85 -0
- kagglesdk/kaggle_creds.py +148 -0
- kagglesdk/kaggle_env.py +93 -0
- kagglesdk/kaggle_http_client.py +253 -0
- kagglesdk/kaggle_oauth.py +200 -0
- kagglesdk/kaggle_object.py +346 -0
- kagglesdk/kernels/__init__.py +0 -0
- kagglesdk/kernels/services/__init__.py +0 -0
- kagglesdk/kernels/services/kernels_api_service.py +121 -0
- kagglesdk/kernels/types/__init__.py +0 -0
- kagglesdk/kernels/types/kernels_api_service.py +2153 -0
- kagglesdk/kernels/types/kernels_enums.py +39 -0
- kagglesdk/kernels/types/search_kernels.py +6 -0
- kagglesdk/models/__init__.py +0 -0
- kagglesdk/models/services/__init__.py +0 -0
- kagglesdk/models/services/model_api_service.py +256 -0
- kagglesdk/models/services/model_service.py +19 -0
- kagglesdk/models/types/__init__.py +0 -0
- kagglesdk/models/types/model_api_service.py +3751 -0
- kagglesdk/models/types/model_enums.py +60 -0
- kagglesdk/models/types/model_service.py +275 -0
- kagglesdk/models/types/model_types.py +304 -0
- kagglesdk/models/types/search_models.py +8 -0
- kagglesdk/search/__init__.py +0 -0
- kagglesdk/search/services/__init__.py +0 -0
- kagglesdk/search/services/search_api_service.py +19 -0
- kagglesdk/search/types/__init__.py +0 -0
- kagglesdk/search/types/search_api_service.py +2434 -0
- kagglesdk/search/types/search_content_shared.py +50 -0
- kagglesdk/search/types/search_enums.py +44 -0
- kagglesdk/security/__init__.py +0 -0
- kagglesdk/security/services/__init__.py +0 -0
- kagglesdk/security/services/oauth_service.py +44 -0
- kagglesdk/security/types/__init__.py +0 -0
- kagglesdk/security/types/authentication.py +171 -0
- kagglesdk/security/types/oauth_service.py +591 -0
- kagglesdk/test/__init__.py +0 -0
- kagglesdk/test/test_client.py +41 -0
- kagglesdk/users/__init__.py +0 -0
- kagglesdk/users/services/__init__.py +0 -0
- kagglesdk/users/services/account_service.py +31 -0
- kagglesdk/users/types/__init__.py +0 -0
- kagglesdk/users/types/account_service.py +305 -0
- kagglesdk/users/types/progression_service.py +9 -0
- kagglesdk/users/types/search_users.py +23 -0
- kagglesdk/users/types/users_enums.py +22 -0
- kagglesdk-0.1.0.dist-info/METADATA +222 -0
- kagglesdk-0.1.0.dist-info/RECORD +95 -0
- kagglesdk-0.1.0.dist-info/WHEEL +4 -0
- kagglesdk-0.1.0.dist-info/licenses/LICENSE +201 -0
kagglesdk/__init__.py
ADDED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from kagglesdk.admin.types.inbox_file_service import CreateInboxFileRequest, CreateInboxFileResponse
|
|
2
|
+
from kagglesdk.kaggle_http_client import KaggleHttpClient
|
|
3
|
+
|
|
4
|
+
class InboxFileClient(object):
|
|
5
|
+
"""File drop/pickup functionality."""
|
|
6
|
+
|
|
7
|
+
def __init__(self, client: KaggleHttpClient):
|
|
8
|
+
self._client = client
|
|
9
|
+
|
|
10
|
+
def create_inbox_file(self, request: CreateInboxFileRequest = None) -> CreateInboxFileResponse:
|
|
11
|
+
r"""
|
|
12
|
+
Creates (aka 'drops') a new file into the inbox.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
request (CreateInboxFileRequest):
|
|
16
|
+
The request object; initialized to empty instance if not specified.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
if request is None:
|
|
20
|
+
request = CreateInboxFileRequest()
|
|
21
|
+
|
|
22
|
+
return self._client.call("admin.InboxFileService", "CreateInboxFile", request, CreateInboxFileResponse)
|
|
File without changes
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
from kagglesdk.kaggle_object import *
|
|
2
|
+
|
|
3
|
+
class CreateInboxFileRequest(KaggleObject):
|
|
4
|
+
r"""
|
|
5
|
+
Attributes:
|
|
6
|
+
virtual_directory (str)
|
|
7
|
+
Directory name used for tagging the uploaded file.
|
|
8
|
+
blob_file_token (str)
|
|
9
|
+
Token representing the uploaded file.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
def __init__(self):
|
|
13
|
+
self._virtual_directory = ""
|
|
14
|
+
self._blob_file_token = ""
|
|
15
|
+
self._freeze()
|
|
16
|
+
|
|
17
|
+
@property
|
|
18
|
+
def virtual_directory(self) -> str:
|
|
19
|
+
"""Directory name used for tagging the uploaded file."""
|
|
20
|
+
return self._virtual_directory
|
|
21
|
+
|
|
22
|
+
@virtual_directory.setter
|
|
23
|
+
def virtual_directory(self, virtual_directory: str):
|
|
24
|
+
if virtual_directory is None:
|
|
25
|
+
del self.virtual_directory
|
|
26
|
+
return
|
|
27
|
+
if not isinstance(virtual_directory, str):
|
|
28
|
+
raise TypeError('virtual_directory must be of type str')
|
|
29
|
+
self._virtual_directory = virtual_directory
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def blob_file_token(self) -> str:
|
|
33
|
+
"""Token representing the uploaded file."""
|
|
34
|
+
return self._blob_file_token
|
|
35
|
+
|
|
36
|
+
@blob_file_token.setter
|
|
37
|
+
def blob_file_token(self, blob_file_token: str):
|
|
38
|
+
if blob_file_token is None:
|
|
39
|
+
del self.blob_file_token
|
|
40
|
+
return
|
|
41
|
+
if not isinstance(blob_file_token, str):
|
|
42
|
+
raise TypeError('blob_file_token must be of type str')
|
|
43
|
+
self._blob_file_token = blob_file_token
|
|
44
|
+
|
|
45
|
+
def endpoint(self):
|
|
46
|
+
path = '/api/v1/inbox/files/create'
|
|
47
|
+
return path.format_map(self.to_field_map(self))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@staticmethod
|
|
51
|
+
def method():
|
|
52
|
+
return 'POST'
|
|
53
|
+
|
|
54
|
+
@staticmethod
|
|
55
|
+
def body_fields():
|
|
56
|
+
return '*'
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class CreateInboxFileResponse(KaggleObject):
|
|
60
|
+
r"""
|
|
61
|
+
NOTE: This is sent to non-admins, so we're intentionally *NOT* sending back
|
|
62
|
+
the full InboxFile (with its URL for a direct download).
|
|
63
|
+
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
pass
|
|
67
|
+
|
|
68
|
+
CreateInboxFileRequest._fields = [
|
|
69
|
+
FieldMetadata("virtualDirectory", "virtual_directory", "_virtual_directory", str, "", PredefinedSerializer()),
|
|
70
|
+
FieldMetadata("blobFileToken", "blob_file_token", "_blob_file_token", str, "", PredefinedSerializer()),
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
CreateInboxFileResponse._fields = []
|
|
74
|
+
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from kagglesdk.blobs.types.blob_api_service import ApiStartBlobUploadRequest, ApiStartBlobUploadResponse
|
|
2
|
+
from kagglesdk.kaggle_http_client import KaggleHttpClient
|
|
3
|
+
|
|
4
|
+
class BlobApiClient(object):
|
|
5
|
+
r"""
|
|
6
|
+
Binary Large OBject (BLOB) service used for uploading files to Google Cloud
|
|
7
|
+
Storage (GCS).
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
def __init__(self, client: KaggleHttpClient):
|
|
11
|
+
self._client = client
|
|
12
|
+
|
|
13
|
+
def start_blob_upload(self, request: ApiStartBlobUploadRequest = None) -> ApiStartBlobUploadResponse:
|
|
14
|
+
r"""
|
|
15
|
+
Starts a blob upload (i.e. reserves a spot for the upload on GCS).
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
request (ApiStartBlobUploadRequest):
|
|
19
|
+
The request object; initialized to empty instance if not specified.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
if request is None:
|
|
23
|
+
request = ApiStartBlobUploadRequest()
|
|
24
|
+
|
|
25
|
+
return self._client.call("blobs.BlobApiService", "StartBlobUpload", request, ApiStartBlobUploadResponse)
|
|
File without changes
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import enum
|
|
2
|
+
from kagglesdk.kaggle_object import *
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
class ApiBlobType(enum.Enum):
|
|
6
|
+
API_BLOB_TYPE_UNSPECIFIED = 0
|
|
7
|
+
DATASET = 1
|
|
8
|
+
MODEL = 2
|
|
9
|
+
INBOX = 3
|
|
10
|
+
|
|
11
|
+
class ApiStartBlobUploadRequest(KaggleObject):
|
|
12
|
+
r"""
|
|
13
|
+
Attributes:
|
|
14
|
+
type (ApiBlobType)
|
|
15
|
+
The type of the blob.
|
|
16
|
+
name (str)
|
|
17
|
+
Name (e.g. file name) of the blob.
|
|
18
|
+
content_type (str)
|
|
19
|
+
Content/MIME type (e.g. 'text/plain').
|
|
20
|
+
content_length (int)
|
|
21
|
+
Size in bytes of the blob.
|
|
22
|
+
last_modified_epoch_seconds (int)
|
|
23
|
+
Optional user-reported time when the blob was last updated/modified.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
def __init__(self):
|
|
27
|
+
self._type = ApiBlobType.API_BLOB_TYPE_UNSPECIFIED
|
|
28
|
+
self._name = ""
|
|
29
|
+
self._content_type = None
|
|
30
|
+
self._content_length = 0
|
|
31
|
+
self._last_modified_epoch_seconds = None
|
|
32
|
+
self._freeze()
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
def type(self) -> 'ApiBlobType':
|
|
36
|
+
"""The type of the blob."""
|
|
37
|
+
return self._type
|
|
38
|
+
|
|
39
|
+
@type.setter
|
|
40
|
+
def type(self, type: 'ApiBlobType'):
|
|
41
|
+
if type is None:
|
|
42
|
+
del self.type
|
|
43
|
+
return
|
|
44
|
+
if not isinstance(type, ApiBlobType):
|
|
45
|
+
raise TypeError('type must be of type ApiBlobType')
|
|
46
|
+
self._type = type
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def name(self) -> str:
|
|
50
|
+
"""Name (e.g. file name) of the blob."""
|
|
51
|
+
return self._name
|
|
52
|
+
|
|
53
|
+
@name.setter
|
|
54
|
+
def name(self, name: str):
|
|
55
|
+
if name is None:
|
|
56
|
+
del self.name
|
|
57
|
+
return
|
|
58
|
+
if not isinstance(name, str):
|
|
59
|
+
raise TypeError('name must be of type str')
|
|
60
|
+
self._name = name
|
|
61
|
+
|
|
62
|
+
@property
|
|
63
|
+
def content_type(self) -> str:
|
|
64
|
+
"""Content/MIME type (e.g. 'text/plain')."""
|
|
65
|
+
return self._content_type or ""
|
|
66
|
+
|
|
67
|
+
@content_type.setter
|
|
68
|
+
def content_type(self, content_type: Optional[str]):
|
|
69
|
+
if content_type is None:
|
|
70
|
+
del self.content_type
|
|
71
|
+
return
|
|
72
|
+
if not isinstance(content_type, str):
|
|
73
|
+
raise TypeError('content_type must be of type str')
|
|
74
|
+
self._content_type = content_type
|
|
75
|
+
|
|
76
|
+
@property
|
|
77
|
+
def content_length(self) -> int:
|
|
78
|
+
"""Size in bytes of the blob."""
|
|
79
|
+
return self._content_length
|
|
80
|
+
|
|
81
|
+
@content_length.setter
|
|
82
|
+
def content_length(self, content_length: int):
|
|
83
|
+
if content_length is None:
|
|
84
|
+
del self.content_length
|
|
85
|
+
return
|
|
86
|
+
if not isinstance(content_length, int):
|
|
87
|
+
raise TypeError('content_length must be of type int')
|
|
88
|
+
self._content_length = content_length
|
|
89
|
+
|
|
90
|
+
@property
|
|
91
|
+
def last_modified_epoch_seconds(self) -> int:
|
|
92
|
+
"""Optional user-reported time when the blob was last updated/modified."""
|
|
93
|
+
return self._last_modified_epoch_seconds or 0
|
|
94
|
+
|
|
95
|
+
@last_modified_epoch_seconds.setter
|
|
96
|
+
def last_modified_epoch_seconds(self, last_modified_epoch_seconds: Optional[int]):
|
|
97
|
+
if last_modified_epoch_seconds is None:
|
|
98
|
+
del self.last_modified_epoch_seconds
|
|
99
|
+
return
|
|
100
|
+
if not isinstance(last_modified_epoch_seconds, int):
|
|
101
|
+
raise TypeError('last_modified_epoch_seconds must be of type int')
|
|
102
|
+
self._last_modified_epoch_seconds = last_modified_epoch_seconds
|
|
103
|
+
|
|
104
|
+
def endpoint(self):
|
|
105
|
+
path = '/api/v1/blobs/upload'
|
|
106
|
+
return path.format_map(self.to_field_map(self))
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
@staticmethod
|
|
110
|
+
def method():
|
|
111
|
+
return 'POST'
|
|
112
|
+
|
|
113
|
+
@staticmethod
|
|
114
|
+
def body_fields():
|
|
115
|
+
return '*'
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class ApiStartBlobUploadResponse(KaggleObject):
|
|
119
|
+
r"""
|
|
120
|
+
Attributes:
|
|
121
|
+
token (str)
|
|
122
|
+
Opaque string token used to reference the new blob/file.
|
|
123
|
+
create_url (str)
|
|
124
|
+
URL to use to start the upload.
|
|
125
|
+
"""
|
|
126
|
+
|
|
127
|
+
def __init__(self):
|
|
128
|
+
self._token = ""
|
|
129
|
+
self._create_url = ""
|
|
130
|
+
self._freeze()
|
|
131
|
+
|
|
132
|
+
@property
|
|
133
|
+
def token(self) -> str:
|
|
134
|
+
"""Opaque string token used to reference the new blob/file."""
|
|
135
|
+
return self._token
|
|
136
|
+
|
|
137
|
+
@token.setter
|
|
138
|
+
def token(self, token: str):
|
|
139
|
+
if token is None:
|
|
140
|
+
del self.token
|
|
141
|
+
return
|
|
142
|
+
if not isinstance(token, str):
|
|
143
|
+
raise TypeError('token must be of type str')
|
|
144
|
+
self._token = token
|
|
145
|
+
|
|
146
|
+
@property
|
|
147
|
+
def create_url(self) -> str:
|
|
148
|
+
"""URL to use to start the upload."""
|
|
149
|
+
return self._create_url
|
|
150
|
+
|
|
151
|
+
@create_url.setter
|
|
152
|
+
def create_url(self, create_url: str):
|
|
153
|
+
if create_url is None:
|
|
154
|
+
del self.create_url
|
|
155
|
+
return
|
|
156
|
+
if not isinstance(create_url, str):
|
|
157
|
+
raise TypeError('create_url must be of type str')
|
|
158
|
+
self._create_url = create_url
|
|
159
|
+
|
|
160
|
+
@property
|
|
161
|
+
def createUrl(self):
|
|
162
|
+
return self.create_url
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
ApiStartBlobUploadRequest._fields = [
|
|
166
|
+
FieldMetadata("type", "type", "_type", ApiBlobType, ApiBlobType.API_BLOB_TYPE_UNSPECIFIED, EnumSerializer()),
|
|
167
|
+
FieldMetadata("name", "name", "_name", str, "", PredefinedSerializer()),
|
|
168
|
+
FieldMetadata("contentType", "content_type", "_content_type", str, None, PredefinedSerializer(), optional=True),
|
|
169
|
+
FieldMetadata("contentLength", "content_length", "_content_length", int, 0, PredefinedSerializer()),
|
|
170
|
+
FieldMetadata("lastModifiedEpochSeconds", "last_modified_epoch_seconds", "_last_modified_epoch_seconds", int, None, PredefinedSerializer(), optional=True),
|
|
171
|
+
]
|
|
172
|
+
|
|
173
|
+
ApiStartBlobUploadResponse._fields = [
|
|
174
|
+
FieldMetadata("token", "token", "_token", str, "", PredefinedSerializer()),
|
|
175
|
+
FieldMetadata("createUrl", "create_url", "_create_url", str, "", PredefinedSerializer()),
|
|
176
|
+
]
|
|
177
|
+
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
from kagglesdk.kaggle_object import *
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
class FileDownload(KaggleObject):
|
|
5
|
+
r"""
|
|
6
|
+
Standard response object representing a file download.
|
|
7
|
+
See http://go/kaggle-proto-handler-file-downloads
|
|
8
|
+
Some field names/descriptions borrowed from
|
|
9
|
+
google3/gdata/rosy/proto/data.proto
|
|
10
|
+
|
|
11
|
+
Attributes:
|
|
12
|
+
content_type (str)
|
|
13
|
+
MIME type of the data
|
|
14
|
+
TODO(aip.dev/143): (-- api-linter: core::0143::standardized-codes=disabled
|
|
15
|
+
--)
|
|
16
|
+
file_name (str)
|
|
17
|
+
Original file name
|
|
18
|
+
token (str)
|
|
19
|
+
A unique fingerprint for the file/media data
|
|
20
|
+
content_length (int)
|
|
21
|
+
Size of the data, in bytes (if known)
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
def __init__(self):
|
|
25
|
+
self._content_type = ""
|
|
26
|
+
self._file_name = ""
|
|
27
|
+
self._token = ""
|
|
28
|
+
self._content_length = None
|
|
29
|
+
self._freeze()
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def content_type(self) -> str:
|
|
33
|
+
r"""
|
|
34
|
+
MIME type of the data
|
|
35
|
+
TODO(aip.dev/143): (-- api-linter: core::0143::standardized-codes=disabled
|
|
36
|
+
--)
|
|
37
|
+
"""
|
|
38
|
+
return self._content_type
|
|
39
|
+
|
|
40
|
+
@content_type.setter
|
|
41
|
+
def content_type(self, content_type: str):
|
|
42
|
+
if content_type is None:
|
|
43
|
+
del self.content_type
|
|
44
|
+
return
|
|
45
|
+
if not isinstance(content_type, str):
|
|
46
|
+
raise TypeError('content_type must be of type str')
|
|
47
|
+
self._content_type = content_type
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
def file_name(self) -> str:
|
|
51
|
+
"""Original file name"""
|
|
52
|
+
return self._file_name
|
|
53
|
+
|
|
54
|
+
@file_name.setter
|
|
55
|
+
def file_name(self, file_name: str):
|
|
56
|
+
if file_name is None:
|
|
57
|
+
del self.file_name
|
|
58
|
+
return
|
|
59
|
+
if not isinstance(file_name, str):
|
|
60
|
+
raise TypeError('file_name must be of type str')
|
|
61
|
+
self._file_name = file_name
|
|
62
|
+
|
|
63
|
+
@property
|
|
64
|
+
def token(self) -> str:
|
|
65
|
+
"""A unique fingerprint for the file/media data"""
|
|
66
|
+
return self._token
|
|
67
|
+
|
|
68
|
+
@token.setter
|
|
69
|
+
def token(self, token: str):
|
|
70
|
+
if token is None:
|
|
71
|
+
del self.token
|
|
72
|
+
return
|
|
73
|
+
if not isinstance(token, str):
|
|
74
|
+
raise TypeError('token must be of type str')
|
|
75
|
+
self._token = token
|
|
76
|
+
|
|
77
|
+
@property
|
|
78
|
+
def content_length(self) -> int:
|
|
79
|
+
"""Size of the data, in bytes (if known)"""
|
|
80
|
+
return self._content_length or 0
|
|
81
|
+
|
|
82
|
+
@content_length.setter
|
|
83
|
+
def content_length(self, content_length: Optional[int]):
|
|
84
|
+
if content_length is None:
|
|
85
|
+
del self.content_length
|
|
86
|
+
return
|
|
87
|
+
if not isinstance(content_length, int):
|
|
88
|
+
raise TypeError('content_length must be of type int')
|
|
89
|
+
self._content_length = content_length
|
|
90
|
+
|
|
91
|
+
@classmethod
|
|
92
|
+
def prepare_from(cls, http_response):
|
|
93
|
+
return http_response
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
FileDownload._fields = [
|
|
97
|
+
FieldMetadata("contentType", "content_type", "_content_type", str, "", PredefinedSerializer()),
|
|
98
|
+
FieldMetadata("fileName", "file_name", "_file_name", str, "", PredefinedSerializer()),
|
|
99
|
+
FieldMetadata("token", "token", "_token", str, "", PredefinedSerializer()),
|
|
100
|
+
FieldMetadata("contentLength", "content_length", "_content_length", int, None, PredefinedSerializer(), optional=True),
|
|
101
|
+
]
|
|
102
|
+
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
from datetime import timedelta
|
|
2
|
+
from kagglesdk.kaggle_object import *
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
class HttpRedirect(KaggleObject):
|
|
6
|
+
r"""
|
|
7
|
+
Represents an HTTP redirect (e.g. 301 or 302) response.
|
|
8
|
+
Patterned after ASP.NET MVC's RedirectResult.
|
|
9
|
+
|
|
10
|
+
Attributes:
|
|
11
|
+
url (str)
|
|
12
|
+
Destination URL for the redirect.
|
|
13
|
+
permanent (bool)
|
|
14
|
+
Should it be an HTTP 301 (permanent) redirect or just temporary (HTTP
|
|
15
|
+
302)?.
|
|
16
|
+
bypass_encoding (bool)
|
|
17
|
+
When `true`, the `url` is already encoded, so bypass `UriHelper.Encode`.
|
|
18
|
+
Otherwise, invoke `UriHelper.Encode` on the `url` before returning to the
|
|
19
|
+
client.
|
|
20
|
+
expiry (timedelta)
|
|
21
|
+
Specifies how long the redirected url can be cached.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
def __init__(self):
|
|
25
|
+
self._url = ""
|
|
26
|
+
self._permanent = False
|
|
27
|
+
self._bypass_encoding = None
|
|
28
|
+
self._expiry = None
|
|
29
|
+
self._freeze()
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def url(self) -> str:
|
|
33
|
+
"""Destination URL for the redirect."""
|
|
34
|
+
return self._url
|
|
35
|
+
|
|
36
|
+
@url.setter
|
|
37
|
+
def url(self, url: str):
|
|
38
|
+
if url is None:
|
|
39
|
+
del self.url
|
|
40
|
+
return
|
|
41
|
+
if not isinstance(url, str):
|
|
42
|
+
raise TypeError('url must be of type str')
|
|
43
|
+
self._url = url
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def permanent(self) -> bool:
|
|
47
|
+
r"""
|
|
48
|
+
Should it be an HTTP 301 (permanent) redirect or just temporary (HTTP
|
|
49
|
+
302)?.
|
|
50
|
+
"""
|
|
51
|
+
return self._permanent
|
|
52
|
+
|
|
53
|
+
@permanent.setter
|
|
54
|
+
def permanent(self, permanent: bool):
|
|
55
|
+
if permanent is None:
|
|
56
|
+
del self.permanent
|
|
57
|
+
return
|
|
58
|
+
if not isinstance(permanent, bool):
|
|
59
|
+
raise TypeError('permanent must be of type bool')
|
|
60
|
+
self._permanent = permanent
|
|
61
|
+
|
|
62
|
+
@property
|
|
63
|
+
def bypass_encoding(self) -> bool:
|
|
64
|
+
r"""
|
|
65
|
+
When `true`, the `url` is already encoded, so bypass `UriHelper.Encode`.
|
|
66
|
+
Otherwise, invoke `UriHelper.Encode` on the `url` before returning to the
|
|
67
|
+
client.
|
|
68
|
+
"""
|
|
69
|
+
return self._bypass_encoding or False
|
|
70
|
+
|
|
71
|
+
@bypass_encoding.setter
|
|
72
|
+
def bypass_encoding(self, bypass_encoding: Optional[bool]):
|
|
73
|
+
if bypass_encoding is None:
|
|
74
|
+
del self.bypass_encoding
|
|
75
|
+
return
|
|
76
|
+
if not isinstance(bypass_encoding, bool):
|
|
77
|
+
raise TypeError('bypass_encoding must be of type bool')
|
|
78
|
+
self._bypass_encoding = bypass_encoding
|
|
79
|
+
|
|
80
|
+
@property
|
|
81
|
+
def expiry(self) -> timedelta:
|
|
82
|
+
"""Specifies how long the redirected url can be cached."""
|
|
83
|
+
return self._expiry
|
|
84
|
+
|
|
85
|
+
@expiry.setter
|
|
86
|
+
def expiry(self, expiry: timedelta):
|
|
87
|
+
if expiry is None:
|
|
88
|
+
del self.expiry
|
|
89
|
+
return
|
|
90
|
+
if not isinstance(expiry, timedelta):
|
|
91
|
+
raise TypeError('expiry must be of type timedelta')
|
|
92
|
+
self._expiry = expiry
|
|
93
|
+
|
|
94
|
+
@classmethod
|
|
95
|
+
def prepare_from(cls, http_response):
|
|
96
|
+
return http_response
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
HttpRedirect._fields = [
|
|
100
|
+
FieldMetadata("url", "url", "_url", str, "", PredefinedSerializer()),
|
|
101
|
+
FieldMetadata("permanent", "permanent", "_permanent", bool, False, PredefinedSerializer()),
|
|
102
|
+
FieldMetadata("bypassEncoding", "bypass_encoding", "_bypass_encoding", bool, None, PredefinedSerializer(), optional=True),
|
|
103
|
+
FieldMetadata("expiry", "expiry", "_expiry", timedelta, None, TimeDeltaSerializer()),
|
|
104
|
+
]
|
|
105
|
+
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import enum
|
|
2
|
+
|
|
3
|
+
class ContentState(enum.Enum):
|
|
4
|
+
"""Keep synced with /Kaggle.Sdk/cloud/kaggle/moderation/sor.proto"""
|
|
5
|
+
CONTENT_STATE_UNSPECIFIED = 0
|
|
6
|
+
PENDING_CLASSIFICATION = 1
|
|
7
|
+
r"""
|
|
8
|
+
Awaiting abuse classification. This exists as a non-visible state prior to
|
|
9
|
+
classification.
|
|
10
|
+
"""
|
|
11
|
+
PUBLISHED = 2
|
|
12
|
+
r"""
|
|
13
|
+
Publicly viewable, although access may be restricted outside of its content
|
|
14
|
+
state.
|
|
15
|
+
"""
|
|
16
|
+
TEMPORARILY_QUARANTINED = 3
|
|
17
|
+
r"""
|
|
18
|
+
Quarantined by an admin or by the system. This means that the content is
|
|
19
|
+
only visible to the user and admins, however users are able to toggle their
|
|
20
|
+
content out of this state.
|
|
21
|
+
"""
|
|
22
|
+
PERMANENTLY_QUARANTINED = 4
|
|
23
|
+
r"""
|
|
24
|
+
Quarantined by an admin or by the system, the user cannot toggle their
|
|
25
|
+
content's state back to public.
|
|
26
|
+
"""
|
|
27
|
+
USER_DELETED = 5
|
|
28
|
+
"""Deleted by the user."""
|
|
29
|
+
SYSTEM_DELETED = 6
|
|
30
|
+
"""Deleted by an admin or by a system account."""
|
|
31
|
+
PENDING_PERMANENT_DELETE = 7
|
|
32
|
+
"""Awaiting hard deletion."""
|
|
33
|
+
DRAFT = 8
|
|
34
|
+
r"""
|
|
35
|
+
Initial state of entity that has never been previously published.
|
|
36
|
+
Unable to return back to Draft state once published.
|
|
37
|
+
State flow chart example: http://screen/8vDypV7HPeuHBFK
|
|
38
|
+
"""
|
|
39
|
+
UNPUBLISHED = 9
|
|
40
|
+
r"""
|
|
41
|
+
Intermediate stage that has either been upgraded from the Draft state or
|
|
42
|
+
downgraded from the Published state.
|
|
43
|
+
"""
|
|
44
|
+
|
|
File without changes
|
|
File without changes
|