kaggle 1.8.2__py3-none-any.whl → 1.8.4__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.
- kaggle/__init__.py +1 -1
- kaggle/api/kaggle_api_extended.py +206 -75
- kaggle/cli.py +36 -28
- kaggle/models/upload_file.py +4 -4
- {kaggle-1.8.2.dist-info → kaggle-1.8.4.dist-info}/METADATA +66 -75
- kaggle-1.8.4.dist-info/RECORD +15 -0
- {kaggle-1.8.2.dist-info → kaggle-1.8.4.dist-info}/WHEEL +1 -1
- kaggle/models/api_blob_type.py +0 -4
- kaggle/models/dataset_column.py +0 -228
- kaggle/models/dataset_new_request.py +0 -443
- kaggle/models/dataset_new_version_request.py +0 -319
- kaggle/models/dataset_update_settings_request.py +0 -344
- kaggle/models/kernel_push_request.py +0 -608
- kaggle/models/model_instance_new_version_request.py +0 -145
- kaggle/models/model_instance_update_request.py +0 -451
- kaggle/models/model_new_instance_request.py +0 -552
- kaggle/models/model_new_request.py +0 -329
- kaggle/models/model_update_request.py +0 -300
- kaggle/models/start_blob_upload_request.py +0 -240
- kaggle/models/start_blob_upload_response.py +0 -142
- kaggle-1.8.2.dist-info/RECORD +0 -148
- kagglesdk/LICENSE +0 -201
- kagglesdk/__init__.py +0 -6
- kagglesdk/admin/__init__.py +0 -0
- kagglesdk/admin/services/__init__.py +0 -0
- kagglesdk/admin/services/inbox_file_service.py +0 -22
- kagglesdk/admin/types/__init__.py +0 -0
- kagglesdk/admin/types/inbox_file_service.py +0 -74
- kagglesdk/benchmarks/__init__.py +0 -0
- kagglesdk/benchmarks/services/__init__.py +0 -0
- kagglesdk/benchmarks/services/benchmarks_api_service.py +0 -19
- kagglesdk/benchmarks/types/__init__.py +0 -0
- kagglesdk/benchmarks/types/benchmark_types.py +0 -307
- kagglesdk/benchmarks/types/benchmarks_api_service.py +0 -243
- kagglesdk/blobs/__init__.py +0 -0
- kagglesdk/blobs/services/__init__.py +0 -0
- kagglesdk/blobs/services/blob_api_service.py +0 -25
- kagglesdk/blobs/types/__init__.py +0 -0
- kagglesdk/blobs/types/blob_api_service.py +0 -177
- kagglesdk/common/__init__.py +0 -0
- kagglesdk/common/services/__init__.py +0 -0
- kagglesdk/common/services/operations_service.py +0 -46
- kagglesdk/common/types/__init__.py +0 -0
- kagglesdk/common/types/file_download.py +0 -102
- kagglesdk/common/types/http_redirect.py +0 -105
- kagglesdk/common/types/operations.py +0 -194
- kagglesdk/common/types/operations_service.py +0 -48
- kagglesdk/community/__init__.py +0 -0
- kagglesdk/community/types/__init__.py +0 -0
- kagglesdk/community/types/content_enums.py +0 -44
- kagglesdk/community/types/organization.py +0 -410
- kagglesdk/competitions/__init__.py +0 -0
- kagglesdk/competitions/services/__init__.py +0 -0
- kagglesdk/competitions/services/competition_api_service.py +0 -178
- kagglesdk/competitions/types/__init__.py +0 -0
- kagglesdk/competitions/types/competition.py +0 -14
- kagglesdk/competitions/types/competition_api_service.py +0 -2393
- kagglesdk/competitions/types/competition_enums.py +0 -53
- kagglesdk/competitions/types/search_competitions.py +0 -28
- kagglesdk/competitions/types/submission_status.py +0 -9
- kagglesdk/datasets/__init__.py +0 -0
- kagglesdk/datasets/databundles/__init__.py +0 -0
- kagglesdk/datasets/databundles/types/__init__.py +0 -0
- kagglesdk/datasets/databundles/types/databundle_api_types.py +0 -540
- kagglesdk/datasets/services/__init__.py +0 -0
- kagglesdk/datasets/services/dataset_api_service.py +0 -195
- kagglesdk/datasets/types/__init__.py +0 -0
- kagglesdk/datasets/types/dataset_api_service.py +0 -3047
- kagglesdk/datasets/types/dataset_enums.py +0 -103
- kagglesdk/datasets/types/dataset_service.py +0 -145
- kagglesdk/datasets/types/dataset_types.py +0 -646
- kagglesdk/datasets/types/search_datasets.py +0 -6
- kagglesdk/discussions/__init__.py +0 -0
- kagglesdk/discussions/types/__init__.py +0 -0
- kagglesdk/discussions/types/search_discussions.py +0 -43
- kagglesdk/discussions/types/writeup_enums.py +0 -11
- kagglesdk/education/__init__.py +0 -0
- kagglesdk/education/services/__init__.py +0 -0
- kagglesdk/education/services/education_api_service.py +0 -19
- kagglesdk/education/types/__init__.py +0 -0
- kagglesdk/education/types/education_api_service.py +0 -248
- kagglesdk/education/types/education_service.py +0 -139
- kagglesdk/kaggle_client.py +0 -101
- kagglesdk/kaggle_creds.py +0 -148
- kagglesdk/kaggle_env.py +0 -104
- kagglesdk/kaggle_http_client.py +0 -269
- kagglesdk/kaggle_oauth.py +0 -200
- kagglesdk/kaggle_object.py +0 -344
- kagglesdk/kernels/__init__.py +0 -0
- kagglesdk/kernels/services/__init__.py +0 -0
- kagglesdk/kernels/services/kernels_api_service.py +0 -146
- kagglesdk/kernels/types/__init__.py +0 -0
- kagglesdk/kernels/types/kernels_api_service.py +0 -2451
- kagglesdk/kernels/types/kernels_enums.py +0 -39
- kagglesdk/kernels/types/search_kernels.py +0 -6
- kagglesdk/licenses/__init__.py +0 -0
- kagglesdk/licenses/types/__init__.py +0 -0
- kagglesdk/licenses/types/licenses_types.py +0 -182
- kagglesdk/models/__init__.py +0 -0
- kagglesdk/models/services/__init__.py +0 -0
- kagglesdk/models/services/model_api_service.py +0 -280
- kagglesdk/models/services/model_service.py +0 -19
- kagglesdk/models/types/__init__.py +0 -0
- kagglesdk/models/types/model_api_service.py +0 -4069
- kagglesdk/models/types/model_enums.py +0 -68
- kagglesdk/models/types/model_service.py +0 -275
- kagglesdk/models/types/model_types.py +0 -1338
- kagglesdk/models/types/search_models.py +0 -8
- kagglesdk/search/__init__.py +0 -0
- kagglesdk/search/services/__init__.py +0 -0
- kagglesdk/search/services/search_api_service.py +0 -19
- kagglesdk/search/types/__init__.py +0 -0
- kagglesdk/search/types/search_api_service.py +0 -2435
- kagglesdk/search/types/search_content_shared.py +0 -50
- kagglesdk/search/types/search_enums.py +0 -45
- kagglesdk/search/types/search_service.py +0 -303
- kagglesdk/security/__init__.py +0 -0
- kagglesdk/security/services/__init__.py +0 -0
- kagglesdk/security/services/iam_service.py +0 -31
- kagglesdk/security/services/oauth_service.py +0 -58
- kagglesdk/security/types/__init__.py +0 -0
- kagglesdk/security/types/authentication.py +0 -171
- kagglesdk/security/types/iam_service.py +0 -496
- kagglesdk/security/types/oauth_service.py +0 -1181
- kagglesdk/security/types/roles.py +0 -8
- kagglesdk/security/types/security_types.py +0 -159
- kagglesdk/test/__init__.py +0 -0
- kagglesdk/test/test_client.py +0 -41
- kagglesdk/users/__init__.py +0 -0
- kagglesdk/users/services/__init__.py +0 -0
- kagglesdk/users/services/account_service.py +0 -31
- kagglesdk/users/services/group_api_service.py +0 -31
- kagglesdk/users/types/__init__.py +0 -0
- kagglesdk/users/types/account_service.py +0 -345
- kagglesdk/users/types/group_api_service.py +0 -315
- kagglesdk/users/types/group_types.py +0 -165
- kagglesdk/users/types/groups_enum.py +0 -8
- kagglesdk/users/types/progression_service.py +0 -9
- kagglesdk/users/types/search_users.py +0 -23
- kagglesdk/users/types/user_avatar.py +0 -226
- kagglesdk/users/types/users_enums.py +0 -22
- {kaggle-1.8.2.dist-info → kaggle-1.8.4.dist-info}/entry_points.txt +0 -0
- {kaggle-1.8.2.dist-info → kaggle-1.8.4.dist-info}/licenses/LICENSE.txt +0 -0
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import enum
|
|
2
|
-
from kagglesdk.kaggle_object import *
|
|
3
|
-
from typing import Optional
|
|
4
|
-
|
|
5
|
-
class KaggleResourceType(enum.Enum):
|
|
6
|
-
r"""
|
|
7
|
-
Types of Kaggle resources on which permissions can be defined. Each entry in
|
|
8
|
-
this proto must correspond to a permission block in the Permission enum in
|
|
9
|
-
'permissions.proto'. For example COMPETITIONS_GET permission
|
|
10
|
-
applies to resource of type COMPETITIONS and thus has value of 300 because
|
|
11
|
-
COMPETITIONS_X permissions block start at 3000. The formula
|
|
12
|
-
ValueOfFirstCanonicalPermission / 10. (COMPETITIONS_GET = 3001) / 10 =>
|
|
13
|
-
(COMPETITIONS = 300).
|
|
14
|
-
Please see the documentation of the Permission enum to understand permission
|
|
15
|
-
blocks better.
|
|
16
|
-
"""
|
|
17
|
-
KAGGLE_RESOURCE_TYPE_UNSPECIFIED = 0
|
|
18
|
-
KAGGLE_RESOURCE_TYPE_WILDCARD_ALL = -1
|
|
19
|
-
KAGGLE_RESOURCE_TYPE_USERS = 100
|
|
20
|
-
"""---------- Shared ----------"""
|
|
21
|
-
KAGGLE_RESOURCE_TYPE_USER_ATTRIBUTES = 102
|
|
22
|
-
KAGGLE_RESOURCE_TYPE_ATTRIBUTES = 104
|
|
23
|
-
KAGGLE_RESOURCE_TYPE_ACCESS_TOKENS = 106
|
|
24
|
-
KAGGLE_RESOURCE_TYPE_API_TOKENS = 108
|
|
25
|
-
KAGGLE_RESOURCE_TYPE_SYNCHRONIZED_GROUPS = 110
|
|
26
|
-
KAGGLE_RESOURCE_TYPE_BLOBS = 112
|
|
27
|
-
KAGGLE_RESOURCE_TYPE_LICENSES = 114
|
|
28
|
-
KAGGLE_RESOURCE_TYPE_LICENSE_USER_AGREEMENTS = 116
|
|
29
|
-
KAGGLE_RESOURCE_TYPE_SEARCH_PROXY = 118
|
|
30
|
-
KAGGLE_RESOURCE_TYPE_SECRETS = 120
|
|
31
|
-
KAGGLE_RESOURCE_TYPE_SECRET_ATTACHMENTS = 122
|
|
32
|
-
KAGGLE_RESOURCE_TYPE_TAGS = 124
|
|
33
|
-
KAGGLE_RESOURCE_TYPE_RESOURCES = 130
|
|
34
|
-
KAGGLE_RESOURCE_TYPE_USER_MANAGED_GROUPS = 132
|
|
35
|
-
KAGGLE_RESOURCE_TYPE_USER_MANAGED_GROUP_INVITES = 134
|
|
36
|
-
KAGGLE_RESOURCE_TYPE_USER_MANAGED_GROUP_MEMBERSHIPS = 136
|
|
37
|
-
KAGGLE_RESOURCE_TYPE_OAUTH_CLIENTS = 138
|
|
38
|
-
KAGGLE_RESOURCE_TYPE_RESOURCE_ACCESS_GROUPS = 140
|
|
39
|
-
KAGGLE_RESOURCE_TYPE_OPERATIONS = 142
|
|
40
|
-
KAGGLE_RESOURCE_TYPE_FORUMS = 200
|
|
41
|
-
"""---------- Community ----------"""
|
|
42
|
-
KAGGLE_RESOURCE_TYPE_FORUM_TOPICS = 202
|
|
43
|
-
KAGGLE_RESOURCE_TYPE_FORUM_MESSAGES = 204
|
|
44
|
-
KAGGLE_RESOURCE_TYPE_FORUM_MESSAGE_ATTACHMENTS = 208
|
|
45
|
-
KAGGLE_RESOURCE_TYPE_BADGES = 210
|
|
46
|
-
KAGGLE_RESOURCE_TYPE_USER_BADGES = 212
|
|
47
|
-
KAGGLE_RESOURCE_TYPE_BOOKMARKS = 214
|
|
48
|
-
KAGGLE_RESOURCE_TYPE_COLLECTIONS = 216
|
|
49
|
-
KAGGLE_RESOURCE_TYPE_NUDGES = 218
|
|
50
|
-
KAGGLE_RESOURCE_TYPE_ORGANIZATIONS = 220
|
|
51
|
-
KAGGLE_RESOURCE_TYPE_ORGANIZATION_MEMBERS = 224
|
|
52
|
-
KAGGLE_RESOURCE_TYPE_SUGGESTED_ITEMS = 226
|
|
53
|
-
KAGGLE_RESOURCE_TYPE_WRITE_UPS = 228
|
|
54
|
-
KAGGLE_RESOURCE_TYPE_VOTES = 230
|
|
55
|
-
KAGGLE_RESOURCE_TYPE_OPEN_GRAPH_IMAGE_METADATUM = 232
|
|
56
|
-
KAGGLE_RESOURCE_TYPE_COMPETITIONS = 300
|
|
57
|
-
"""---------- Competitions ----------"""
|
|
58
|
-
KAGGLE_RESOURCE_TYPE_COMPETITION_LEADERBOARDS = 304
|
|
59
|
-
KAGGLE_RESOURCE_TYPE_EPISODES = 306
|
|
60
|
-
KAGGLE_RESOURCE_TYPE_EPISODE_AGENTS = 308
|
|
61
|
-
KAGGLE_RESOURCE_TYPE_EVALUATION_ALGORITHMS = 310
|
|
62
|
-
KAGGLE_RESOURCE_TYPE_HOST_SEGMENTS = 312
|
|
63
|
-
KAGGLE_RESOURCE_TYPE_PAGES = 314
|
|
64
|
-
KAGGLE_RESOURCE_TYPE_SUBMISSIONS = 316
|
|
65
|
-
KAGGLE_RESOURCE_TYPE_SUBMISSION_RESCORES = 318
|
|
66
|
-
KAGGLE_RESOURCE_TYPE_TEAMS = 320
|
|
67
|
-
KAGGLE_RESOURCE_TYPE_TEAM_MERGE_REQUESTS = 322
|
|
68
|
-
KAGGLE_RESOURCE_TYPE_HACKATHON_WRITE_UPS = 324
|
|
69
|
-
KAGGLE_RESOURCE_TYPE_COMPETITION_METRIC_VERSIONS = 326
|
|
70
|
-
KAGGLE_RESOURCE_TYPE_DATASETS = 400
|
|
71
|
-
"""---------- Datasets ----------"""
|
|
72
|
-
KAGGLE_RESOURCE_TYPE_DATASET_VERSIONS = 404
|
|
73
|
-
KAGGLE_RESOURCE_TYPE_DATASET_SUGGESTION_BUNDLES = 406
|
|
74
|
-
KAGGLE_RESOURCE_TYPE_DATABUNDLES = 408
|
|
75
|
-
KAGGLE_RESOURCE_TYPE_DATABUNDLE_VERSIONS = 410
|
|
76
|
-
KAGGLE_RESOURCE_TYPE_DATA_VIEWS = 412
|
|
77
|
-
KAGGLE_RESOURCE_TYPE_KERNELS = 500
|
|
78
|
-
"""---------- Kernels ----------"""
|
|
79
|
-
KAGGLE_RESOURCE_TYPE_KERNEL_SESSIONS = 504
|
|
80
|
-
KAGGLE_RESOURCE_TYPE_KERNEL_SNIPPETS = 508
|
|
81
|
-
KAGGLE_RESOURCE_TYPE_KERNEL_SOURCE_REFERENCES = 510
|
|
82
|
-
KAGGLE_RESOURCE_TYPE_KERNEL_VERSIONS = 512
|
|
83
|
-
KAGGLE_RESOURCE_TYPE_RESOURCE_REFERENCES = 520
|
|
84
|
-
KAGGLE_RESOURCE_TYPE_MODELS = 600
|
|
85
|
-
"""---------- Models ----------"""
|
|
86
|
-
KAGGLE_RESOURCE_TYPE_MODEL_INSTANCES = 608
|
|
87
|
-
KAGGLE_RESOURCE_TYPE_MODEL_INSTANCE_VERSIONS = 610
|
|
88
|
-
KAGGLE_RESOURCE_TYPE_MODEL_VERSIONS = 612
|
|
89
|
-
KAGGLE_RESOURCE_TYPE_GATING_AGREEMENTS = 614
|
|
90
|
-
KAGGLE_RESOURCE_TYPE_GATING_AGREEMENTS_USER_CONSENTS = 616
|
|
91
|
-
KAGGLE_RESOURCE_TYPE_BENCHMARKS = 700
|
|
92
|
-
"""---------- Benchmarks ----------"""
|
|
93
|
-
KAGGLE_RESOURCE_TYPE_BENCHMARK_VERSIONS = 704
|
|
94
|
-
KAGGLE_RESOURCE_TYPE_BENCHMARK_MODELS = 706
|
|
95
|
-
KAGGLE_RESOURCE_TYPE_BENCHMARK_MODEL_VERSIONS = 708
|
|
96
|
-
KAGGLE_RESOURCE_TYPE_BENCHMARK_TASKS = 710
|
|
97
|
-
KAGGLE_RESOURCE_TYPE_BENCHMARK_TASK_VERSIONS = 712
|
|
98
|
-
KAGGLE_RESOURCE_TYPE_BENCHMARK_TASK_RUNS = 714
|
|
99
|
-
|
|
100
|
-
class KaggleResourceId(KaggleObject):
|
|
101
|
-
r"""
|
|
102
|
-
Attributes:
|
|
103
|
-
type (KaggleResourceType)
|
|
104
|
-
id (int)
|
|
105
|
-
hash_link (str)
|
|
106
|
-
"""
|
|
107
|
-
|
|
108
|
-
def __init__(self):
|
|
109
|
-
self._type = KaggleResourceType.KAGGLE_RESOURCE_TYPE_UNSPECIFIED
|
|
110
|
-
self._id = 0
|
|
111
|
-
self._hash_link = None
|
|
112
|
-
self._freeze()
|
|
113
|
-
|
|
114
|
-
@property
|
|
115
|
-
def type(self) -> 'KaggleResourceType':
|
|
116
|
-
return self._type
|
|
117
|
-
|
|
118
|
-
@type.setter
|
|
119
|
-
def type(self, type: 'KaggleResourceType'):
|
|
120
|
-
if type is None:
|
|
121
|
-
del self.type
|
|
122
|
-
return
|
|
123
|
-
if not isinstance(type, KaggleResourceType):
|
|
124
|
-
raise TypeError('type must be of type KaggleResourceType')
|
|
125
|
-
self._type = type
|
|
126
|
-
|
|
127
|
-
@property
|
|
128
|
-
def id(self) -> int:
|
|
129
|
-
return self._id
|
|
130
|
-
|
|
131
|
-
@id.setter
|
|
132
|
-
def id(self, id: int):
|
|
133
|
-
if id is None:
|
|
134
|
-
del self.id
|
|
135
|
-
return
|
|
136
|
-
if not isinstance(id, int):
|
|
137
|
-
raise TypeError('id must be of type int')
|
|
138
|
-
self._id = id
|
|
139
|
-
|
|
140
|
-
@property
|
|
141
|
-
def hash_link(self) -> str:
|
|
142
|
-
return self._hash_link or ""
|
|
143
|
-
|
|
144
|
-
@hash_link.setter
|
|
145
|
-
def hash_link(self, hash_link: Optional[str]):
|
|
146
|
-
if hash_link is None:
|
|
147
|
-
del self.hash_link
|
|
148
|
-
return
|
|
149
|
-
if not isinstance(hash_link, str):
|
|
150
|
-
raise TypeError('hash_link must be of type str')
|
|
151
|
-
self._hash_link = hash_link
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
KaggleResourceId._fields = [
|
|
155
|
-
FieldMetadata("type", "type", "_type", KaggleResourceType, KaggleResourceType.KAGGLE_RESOURCE_TYPE_UNSPECIFIED, EnumSerializer()),
|
|
156
|
-
FieldMetadata("id", "id", "_id", int, 0, PredefinedSerializer()),
|
|
157
|
-
FieldMetadata("hashLink", "hash_link", "_hash_link", str, None, PredefinedSerializer(), optional=True),
|
|
158
|
-
]
|
|
159
|
-
|
kagglesdk/test/__init__.py
DELETED
|
File without changes
|
kagglesdk/test/test_client.py
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
from kagglesdk import kaggle_env
|
|
2
|
-
from kagglesdk import KaggleClient, KaggleEnv
|
|
3
|
-
|
|
4
|
-
# python -m unittest tests.test_authenticate
|
|
5
|
-
|
|
6
|
-
import os
|
|
7
|
-
import unittest
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class TestClient(unittest.TestCase):
|
|
11
|
-
|
|
12
|
-
def setUp(self):
|
|
13
|
-
print("setup class:%s" % self)
|
|
14
|
-
|
|
15
|
-
def tearDown(self):
|
|
16
|
-
print("teardown class:TestStuff")
|
|
17
|
-
|
|
18
|
-
# Environment
|
|
19
|
-
|
|
20
|
-
def test_kaggle_environment(self):
|
|
21
|
-
os.environ["KAGGLE_API_ENVIRONMENT"] = "PROD"
|
|
22
|
-
|
|
23
|
-
env = kaggle_env.get_env()
|
|
24
|
-
self.assertEqual(env, KaggleEnv.PROD)
|
|
25
|
-
|
|
26
|
-
endpoint = kaggle_env.get_endpoint(env)
|
|
27
|
-
self.assertEqual(endpoint, "https://www.kaggle.com")
|
|
28
|
-
|
|
29
|
-
# Client
|
|
30
|
-
|
|
31
|
-
def test_kaggle_client(self):
|
|
32
|
-
client = KaggleClient(env=KaggleEnv.PROD, verbose=False, username="dinosaur", password="xxxxxxxxxxxx")
|
|
33
|
-
|
|
34
|
-
self.assertEqual(client.username, "dinosaur")
|
|
35
|
-
self.assertEqual(client.password, "xxxxxxxxxxxx")
|
|
36
|
-
self.assertEqual(client.http_client()._endpoint, "https://www.kaggle.com")
|
|
37
|
-
self.assertEqual(client.http_client()._verbose, False)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if __name__ == "__main__":
|
|
41
|
-
unittest.main()
|
kagglesdk/users/__init__.py
DELETED
|
File without changes
|
|
File without changes
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
from kagglesdk.kaggle_http_client import KaggleHttpClient
|
|
2
|
-
from kagglesdk.users.types.account_service import ExpireApiTokenRequest, GenerateAccessTokenRequest, GenerateAccessTokenResponse
|
|
3
|
-
|
|
4
|
-
class AccountClient(object):
|
|
5
|
-
|
|
6
|
-
def __init__(self, client: KaggleHttpClient):
|
|
7
|
-
self._client = client
|
|
8
|
-
|
|
9
|
-
def expire_api_token(self, request: ExpireApiTokenRequest = None):
|
|
10
|
-
r"""
|
|
11
|
-
Args:
|
|
12
|
-
request (ExpireApiTokenRequest):
|
|
13
|
-
The request object; initialized to empty instance if not specified.
|
|
14
|
-
"""
|
|
15
|
-
|
|
16
|
-
if request is None:
|
|
17
|
-
request = ExpireApiTokenRequest()
|
|
18
|
-
|
|
19
|
-
self._client.call("users.AccountService", "ExpireApiToken", request, None)
|
|
20
|
-
|
|
21
|
-
def generate_access_token(self, request: GenerateAccessTokenRequest = None) -> GenerateAccessTokenResponse:
|
|
22
|
-
r"""
|
|
23
|
-
Args:
|
|
24
|
-
request (GenerateAccessTokenRequest):
|
|
25
|
-
The request object; initialized to empty instance if not specified.
|
|
26
|
-
"""
|
|
27
|
-
|
|
28
|
-
if request is None:
|
|
29
|
-
request = GenerateAccessTokenRequest()
|
|
30
|
-
|
|
31
|
-
return self._client.call("users.AccountService", "GenerateAccessToken", request, GenerateAccessTokenResponse)
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
from kagglesdk.kaggle_http_client import KaggleHttpClient
|
|
2
|
-
from kagglesdk.users.types.group_api_service import ApiListSynchronizedGroupMembershipsRequest, ApiListSynchronizedGroupMembershipsResponse, ApiListUserManagedGroupMembershipsRequest, ApiListUserManagedGroupMembershipsResponse
|
|
3
|
-
|
|
4
|
-
class GroupApiClient(object):
|
|
5
|
-
|
|
6
|
-
def __init__(self, client: KaggleHttpClient):
|
|
7
|
-
self._client = client
|
|
8
|
-
|
|
9
|
-
def list_user_managed_group_memberships(self, request: ApiListUserManagedGroupMembershipsRequest = None) -> ApiListUserManagedGroupMembershipsResponse:
|
|
10
|
-
r"""
|
|
11
|
-
Args:
|
|
12
|
-
request (ApiListUserManagedGroupMembershipsRequest):
|
|
13
|
-
The request object; initialized to empty instance if not specified.
|
|
14
|
-
"""
|
|
15
|
-
|
|
16
|
-
if request is None:
|
|
17
|
-
request = ApiListUserManagedGroupMembershipsRequest()
|
|
18
|
-
|
|
19
|
-
return self._client.call("users.GroupApiService", "ListUserManagedGroupMemberships", request, ApiListUserManagedGroupMembershipsResponse)
|
|
20
|
-
|
|
21
|
-
def list_synchronized_group_memberships(self, request: ApiListSynchronizedGroupMembershipsRequest = None) -> ApiListSynchronizedGroupMembershipsResponse:
|
|
22
|
-
r"""
|
|
23
|
-
Args:
|
|
24
|
-
request (ApiListSynchronizedGroupMembershipsRequest):
|
|
25
|
-
The request object; initialized to empty instance if not specified.
|
|
26
|
-
"""
|
|
27
|
-
|
|
28
|
-
if request is None:
|
|
29
|
-
request = ApiListSynchronizedGroupMembershipsRequest()
|
|
30
|
-
|
|
31
|
-
return self._client.call("users.GroupApiService", "ListSynchronizedGroupMemberships", request, ApiListSynchronizedGroupMembershipsResponse)
|
|
File without changes
|
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
from datetime import timedelta
|
|
2
|
-
import enum
|
|
3
|
-
from kagglesdk.kaggle_object import *
|
|
4
|
-
from kagglesdk.security.types.authentication import AuthorizationScope
|
|
5
|
-
from typing import Optional, List
|
|
6
|
-
|
|
7
|
-
class ApiVersion(enum.Enum):
|
|
8
|
-
API_VERSION_UNSPECIFIED = 0
|
|
9
|
-
API_VERSION_V1 = 1
|
|
10
|
-
"""Publicly available ('/api/v1' endpoints)."""
|
|
11
|
-
API_VERSION_V2 = 2
|
|
12
|
-
"""Experimental, admin-only, internal ('/api/i' endpoints)."""
|
|
13
|
-
|
|
14
|
-
class AuthorizationContext(KaggleObject):
|
|
15
|
-
r"""
|
|
16
|
-
Attributes:
|
|
17
|
-
kernel_session_id (int)
|
|
18
|
-
If set, access token is restricted to be used only from the specified
|
|
19
|
-
notebook session.
|
|
20
|
-
"""
|
|
21
|
-
|
|
22
|
-
def __init__(self):
|
|
23
|
-
self._kernel_session_id = None
|
|
24
|
-
self._freeze()
|
|
25
|
-
|
|
26
|
-
@property
|
|
27
|
-
def kernel_session_id(self) -> int:
|
|
28
|
-
r"""
|
|
29
|
-
If set, access token is restricted to be used only from the specified
|
|
30
|
-
notebook session.
|
|
31
|
-
"""
|
|
32
|
-
return self._kernel_session_id or 0
|
|
33
|
-
|
|
34
|
-
@kernel_session_id.setter
|
|
35
|
-
def kernel_session_id(self, kernel_session_id: Optional[int]):
|
|
36
|
-
if kernel_session_id is None:
|
|
37
|
-
del self.kernel_session_id
|
|
38
|
-
return
|
|
39
|
-
if not isinstance(kernel_session_id, int):
|
|
40
|
-
raise TypeError('kernel_session_id must be of type int')
|
|
41
|
-
self._kernel_session_id = kernel_session_id
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
class ExpireApiTokenRequest(KaggleObject):
|
|
45
|
-
r"""
|
|
46
|
-
Attributes:
|
|
47
|
-
token_id (int)
|
|
48
|
-
Id of the token.
|
|
49
|
-
token (str)
|
|
50
|
-
Value of the token.
|
|
51
|
-
reason (str)
|
|
52
|
-
Reason why this token is expired.
|
|
53
|
-
"""
|
|
54
|
-
|
|
55
|
-
def __init__(self):
|
|
56
|
-
self._token_id = None
|
|
57
|
-
self._token = None
|
|
58
|
-
self._reason = None
|
|
59
|
-
self._freeze()
|
|
60
|
-
|
|
61
|
-
@property
|
|
62
|
-
def token_id(self) -> int:
|
|
63
|
-
"""Id of the token."""
|
|
64
|
-
return self._token_id or 0
|
|
65
|
-
|
|
66
|
-
@token_id.setter
|
|
67
|
-
def token_id(self, token_id: int):
|
|
68
|
-
if token_id is None:
|
|
69
|
-
del self.token_id
|
|
70
|
-
return
|
|
71
|
-
if not isinstance(token_id, int):
|
|
72
|
-
raise TypeError('token_id must be of type int')
|
|
73
|
-
del self.token
|
|
74
|
-
self._token_id = token_id
|
|
75
|
-
|
|
76
|
-
@property
|
|
77
|
-
def token(self) -> str:
|
|
78
|
-
"""Value of the token."""
|
|
79
|
-
return self._token or ""
|
|
80
|
-
|
|
81
|
-
@token.setter
|
|
82
|
-
def token(self, token: str):
|
|
83
|
-
if token is None:
|
|
84
|
-
del self.token
|
|
85
|
-
return
|
|
86
|
-
if not isinstance(token, str):
|
|
87
|
-
raise TypeError('token must be of type str')
|
|
88
|
-
del self.token_id
|
|
89
|
-
self._token = token
|
|
90
|
-
|
|
91
|
-
@property
|
|
92
|
-
def reason(self) -> str:
|
|
93
|
-
"""Reason why this token is expired."""
|
|
94
|
-
return self._reason or ""
|
|
95
|
-
|
|
96
|
-
@reason.setter
|
|
97
|
-
def reason(self, reason: Optional[str]):
|
|
98
|
-
if reason is None:
|
|
99
|
-
del self.reason
|
|
100
|
-
return
|
|
101
|
-
if not isinstance(reason, str):
|
|
102
|
-
raise TypeError('reason must be of type str')
|
|
103
|
-
self._reason = reason
|
|
104
|
-
|
|
105
|
-
def endpoint(self):
|
|
106
|
-
path = '/api/v1/tokens/revoke'
|
|
107
|
-
return path.format_map(self.to_field_map(self))
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
@staticmethod
|
|
111
|
-
def method():
|
|
112
|
-
return 'POST'
|
|
113
|
-
|
|
114
|
-
@staticmethod
|
|
115
|
-
def body_fields():
|
|
116
|
-
return '*'
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
class GenerateAccessTokenRequest(KaggleObject):
|
|
120
|
-
r"""
|
|
121
|
-
Attributes:
|
|
122
|
-
refresh_token (str)
|
|
123
|
-
Refresh token used to generate a short-lived restricted access token.
|
|
124
|
-
If not specified current user credentials will be used to generate an
|
|
125
|
-
unrestricted access token.
|
|
126
|
-
api_version (ApiVersion)
|
|
127
|
-
Version of the Kaggle API for which this token will be used.
|
|
128
|
-
expiration_duration (timedelta)
|
|
129
|
-
Token expiration.
|
|
130
|
-
authorization_context (AuthorizationContext)
|
|
131
|
-
On which context (such as a Kaggle notebook) this token can be used.
|
|
132
|
-
authorization_scopes (AuthorizationScope)
|
|
133
|
-
Set of scopes to further restrict the token. If 'refresh_token' is
|
|
134
|
-
specified, these should be a subset of the scopes allowed by the
|
|
135
|
-
'refresh_token'.
|
|
136
|
-
"""
|
|
137
|
-
|
|
138
|
-
def __init__(self):
|
|
139
|
-
self._refresh_token = None
|
|
140
|
-
self._api_version = ApiVersion.API_VERSION_UNSPECIFIED
|
|
141
|
-
self._expiration_duration = None
|
|
142
|
-
self._authorization_context = None
|
|
143
|
-
self._authorization_scopes = []
|
|
144
|
-
self._freeze()
|
|
145
|
-
|
|
146
|
-
@property
|
|
147
|
-
def refresh_token(self) -> str:
|
|
148
|
-
r"""
|
|
149
|
-
Refresh token used to generate a short-lived restricted access token.
|
|
150
|
-
If not specified current user credentials will be used to generate an
|
|
151
|
-
unrestricted access token.
|
|
152
|
-
"""
|
|
153
|
-
return self._refresh_token or ""
|
|
154
|
-
|
|
155
|
-
@refresh_token.setter
|
|
156
|
-
def refresh_token(self, refresh_token: Optional[str]):
|
|
157
|
-
if refresh_token is None:
|
|
158
|
-
del self.refresh_token
|
|
159
|
-
return
|
|
160
|
-
if not isinstance(refresh_token, str):
|
|
161
|
-
raise TypeError('refresh_token must be of type str')
|
|
162
|
-
self._refresh_token = refresh_token
|
|
163
|
-
|
|
164
|
-
@property
|
|
165
|
-
def api_version(self) -> 'ApiVersion':
|
|
166
|
-
"""Version of the Kaggle API for which this token will be used."""
|
|
167
|
-
return self._api_version
|
|
168
|
-
|
|
169
|
-
@api_version.setter
|
|
170
|
-
def api_version(self, api_version: 'ApiVersion'):
|
|
171
|
-
if api_version is None:
|
|
172
|
-
del self.api_version
|
|
173
|
-
return
|
|
174
|
-
if not isinstance(api_version, ApiVersion):
|
|
175
|
-
raise TypeError('api_version must be of type ApiVersion')
|
|
176
|
-
self._api_version = api_version
|
|
177
|
-
|
|
178
|
-
@property
|
|
179
|
-
def expiration_duration(self) -> timedelta:
|
|
180
|
-
"""Token expiration."""
|
|
181
|
-
return self._expiration_duration
|
|
182
|
-
|
|
183
|
-
@expiration_duration.setter
|
|
184
|
-
def expiration_duration(self, expiration_duration: timedelta):
|
|
185
|
-
if expiration_duration is None:
|
|
186
|
-
del self.expiration_duration
|
|
187
|
-
return
|
|
188
|
-
if not isinstance(expiration_duration, timedelta):
|
|
189
|
-
raise TypeError('expiration_duration must be of type timedelta')
|
|
190
|
-
self._expiration_duration = expiration_duration
|
|
191
|
-
|
|
192
|
-
@property
|
|
193
|
-
def authorization_context(self) -> Optional['AuthorizationContext']:
|
|
194
|
-
"""On which context (such as a Kaggle notebook) this token can be used."""
|
|
195
|
-
return self._authorization_context
|
|
196
|
-
|
|
197
|
-
@authorization_context.setter
|
|
198
|
-
def authorization_context(self, authorization_context: Optional['AuthorizationContext']):
|
|
199
|
-
if authorization_context is None:
|
|
200
|
-
del self.authorization_context
|
|
201
|
-
return
|
|
202
|
-
if not isinstance(authorization_context, AuthorizationContext):
|
|
203
|
-
raise TypeError('authorization_context must be of type AuthorizationContext')
|
|
204
|
-
self._authorization_context = authorization_context
|
|
205
|
-
|
|
206
|
-
@property
|
|
207
|
-
def authorization_scopes(self) -> Optional[List[Optional['AuthorizationScope']]]:
|
|
208
|
-
r"""
|
|
209
|
-
Set of scopes to further restrict the token. If 'refresh_token' is
|
|
210
|
-
specified, these should be a subset of the scopes allowed by the
|
|
211
|
-
'refresh_token'.
|
|
212
|
-
"""
|
|
213
|
-
return self._authorization_scopes
|
|
214
|
-
|
|
215
|
-
@authorization_scopes.setter
|
|
216
|
-
def authorization_scopes(self, authorization_scopes: Optional[List[Optional['AuthorizationScope']]]):
|
|
217
|
-
if authorization_scopes is None:
|
|
218
|
-
del self.authorization_scopes
|
|
219
|
-
return
|
|
220
|
-
if not isinstance(authorization_scopes, list):
|
|
221
|
-
raise TypeError('authorization_scopes must be of type list')
|
|
222
|
-
if not all([isinstance(t, AuthorizationScope) for t in authorization_scopes]):
|
|
223
|
-
raise TypeError('authorization_scopes must contain only items of type AuthorizationScope')
|
|
224
|
-
self._authorization_scopes = authorization_scopes
|
|
225
|
-
|
|
226
|
-
def endpoint(self):
|
|
227
|
-
path = '/api/v1/access-tokens/generate'
|
|
228
|
-
return path.format_map(self.to_field_map(self))
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
@staticmethod
|
|
232
|
-
def method():
|
|
233
|
-
return 'POST'
|
|
234
|
-
|
|
235
|
-
@staticmethod
|
|
236
|
-
def body_fields():
|
|
237
|
-
return '*'
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
class GenerateAccessTokenResponse(KaggleObject):
|
|
241
|
-
r"""
|
|
242
|
-
Attributes:
|
|
243
|
-
token (str)
|
|
244
|
-
expires_in (int)
|
|
245
|
-
user_name (str)
|
|
246
|
-
user_id (int)
|
|
247
|
-
"""
|
|
248
|
-
|
|
249
|
-
def __init__(self):
|
|
250
|
-
self._token = ""
|
|
251
|
-
self._expires_in = 0
|
|
252
|
-
self._user_name = ""
|
|
253
|
-
self._user_id = 0
|
|
254
|
-
self._freeze()
|
|
255
|
-
|
|
256
|
-
@property
|
|
257
|
-
def token(self) -> str:
|
|
258
|
-
return self._token
|
|
259
|
-
|
|
260
|
-
@token.setter
|
|
261
|
-
def token(self, token: str):
|
|
262
|
-
if token is None:
|
|
263
|
-
del self.token
|
|
264
|
-
return
|
|
265
|
-
if not isinstance(token, str):
|
|
266
|
-
raise TypeError('token must be of type str')
|
|
267
|
-
self._token = token
|
|
268
|
-
|
|
269
|
-
@property
|
|
270
|
-
def expires_in(self) -> int:
|
|
271
|
-
return self._expires_in
|
|
272
|
-
|
|
273
|
-
@expires_in.setter
|
|
274
|
-
def expires_in(self, expires_in: int):
|
|
275
|
-
if expires_in is None:
|
|
276
|
-
del self.expires_in
|
|
277
|
-
return
|
|
278
|
-
if not isinstance(expires_in, int):
|
|
279
|
-
raise TypeError('expires_in must be of type int')
|
|
280
|
-
self._expires_in = expires_in
|
|
281
|
-
|
|
282
|
-
@property
|
|
283
|
-
def user_name(self) -> str:
|
|
284
|
-
return self._user_name
|
|
285
|
-
|
|
286
|
-
@user_name.setter
|
|
287
|
-
def user_name(self, user_name: str):
|
|
288
|
-
if user_name is None:
|
|
289
|
-
del self.user_name
|
|
290
|
-
return
|
|
291
|
-
if not isinstance(user_name, str):
|
|
292
|
-
raise TypeError('user_name must be of type str')
|
|
293
|
-
self._user_name = user_name
|
|
294
|
-
|
|
295
|
-
@property
|
|
296
|
-
def user_id(self) -> int:
|
|
297
|
-
return self._user_id
|
|
298
|
-
|
|
299
|
-
@user_id.setter
|
|
300
|
-
def user_id(self, user_id: int):
|
|
301
|
-
if user_id is None:
|
|
302
|
-
del self.user_id
|
|
303
|
-
return
|
|
304
|
-
if not isinstance(user_id, int):
|
|
305
|
-
raise TypeError('user_id must be of type int')
|
|
306
|
-
self._user_id = user_id
|
|
307
|
-
|
|
308
|
-
@property
|
|
309
|
-
def expiresIn(self):
|
|
310
|
-
return self.expires_in
|
|
311
|
-
|
|
312
|
-
@property
|
|
313
|
-
def userName(self):
|
|
314
|
-
return self.user_name
|
|
315
|
-
|
|
316
|
-
@property
|
|
317
|
-
def userId(self):
|
|
318
|
-
return self.user_id
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
AuthorizationContext._fields = [
|
|
322
|
-
FieldMetadata("kernelSessionId", "kernel_session_id", "_kernel_session_id", int, None, PredefinedSerializer(), optional=True),
|
|
323
|
-
]
|
|
324
|
-
|
|
325
|
-
ExpireApiTokenRequest._fields = [
|
|
326
|
-
FieldMetadata("tokenId", "token_id", "_token_id", int, None, PredefinedSerializer(), optional=True),
|
|
327
|
-
FieldMetadata("token", "token", "_token", str, None, PredefinedSerializer(), optional=True),
|
|
328
|
-
FieldMetadata("reason", "reason", "_reason", str, None, PredefinedSerializer(), optional=True),
|
|
329
|
-
]
|
|
330
|
-
|
|
331
|
-
GenerateAccessTokenRequest._fields = [
|
|
332
|
-
FieldMetadata("refreshToken", "refresh_token", "_refresh_token", str, None, PredefinedSerializer(), optional=True),
|
|
333
|
-
FieldMetadata("apiVersion", "api_version", "_api_version", ApiVersion, ApiVersion.API_VERSION_UNSPECIFIED, EnumSerializer()),
|
|
334
|
-
FieldMetadata("expirationDuration", "expiration_duration", "_expiration_duration", timedelta, None, TimeDeltaSerializer()),
|
|
335
|
-
FieldMetadata("authorizationContext", "authorization_context", "_authorization_context", AuthorizationContext, None, KaggleObjectSerializer()),
|
|
336
|
-
FieldMetadata("authorizationScopes", "authorization_scopes", "_authorization_scopes", AuthorizationScope, [], ListSerializer(KaggleObjectSerializer())),
|
|
337
|
-
]
|
|
338
|
-
|
|
339
|
-
GenerateAccessTokenResponse._fields = [
|
|
340
|
-
FieldMetadata("token", "token", "_token", str, "", PredefinedSerializer()),
|
|
341
|
-
FieldMetadata("expiresIn", "expires_in", "_expires_in", int, 0, PredefinedSerializer()),
|
|
342
|
-
FieldMetadata("userName", "user_name", "_user_name", str, "", PredefinedSerializer()),
|
|
343
|
-
FieldMetadata("userId", "user_id", "_user_id", int, 0, PredefinedSerializer()),
|
|
344
|
-
]
|
|
345
|
-
|