kaggle 1.7.4.5__py3-none-any.whl → 1.8.2__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.
Files changed (110) hide show
  1. kaggle/__init__.py +10 -6
  2. kaggle/api/kaggle_api.py +574 -598
  3. kaggle/api/kaggle_api_extended.py +5251 -4769
  4. kaggle/cli.py +1335 -1585
  5. kaggle/models/api_blob_type.py +3 -3
  6. kaggle/models/dataset_column.py +165 -174
  7. kaggle/models/dataset_new_request.py +83 -41
  8. kaggle/models/dataset_new_version_request.py +32 -25
  9. kaggle/models/dataset_update_settings_request.py +35 -27
  10. kaggle/models/kaggle_models_extended.py +169 -172
  11. kaggle/models/kernel_push_request.py +66 -49
  12. kaggle/models/model_instance_new_version_request.py +10 -18
  13. kaggle/models/model_instance_update_request.py +103 -34
  14. kaggle/models/model_new_instance_request.py +138 -41
  15. kaggle/models/model_new_request.py +35 -27
  16. kaggle/models/model_update_request.py +32 -25
  17. kaggle/models/start_blob_upload_request.py +192 -195
  18. kaggle/models/start_blob_upload_response.py +98 -98
  19. kaggle/models/upload_file.py +114 -120
  20. kaggle/test/test_authenticate.py +23 -23
  21. {kaggle-1.7.4.5.dist-info → kaggle-1.8.2.dist-info}/METADATA +12 -15
  22. kaggle-1.8.2.dist-info/RECORD +148 -0
  23. kagglesdk/__init__.py +5 -1
  24. kagglesdk/benchmarks/services/__init__.py +0 -0
  25. kagglesdk/benchmarks/services/benchmarks_api_service.py +19 -0
  26. kagglesdk/benchmarks/types/__init__.py +0 -0
  27. kagglesdk/benchmarks/types/benchmark_types.py +307 -0
  28. kagglesdk/benchmarks/types/benchmarks_api_service.py +243 -0
  29. kagglesdk/blobs/services/blob_api_service.py +1 -1
  30. kagglesdk/blobs/types/blob_api_service.py +2 -2
  31. kagglesdk/common/services/__init__.py +0 -0
  32. kagglesdk/common/services/operations_service.py +46 -0
  33. kagglesdk/common/types/file_download.py +1 -1
  34. kagglesdk/common/types/http_redirect.py +1 -1
  35. kagglesdk/common/types/operations.py +194 -0
  36. kagglesdk/common/types/operations_service.py +48 -0
  37. kagglesdk/community/__init__.py +0 -0
  38. kagglesdk/community/types/__init__.py +0 -0
  39. kagglesdk/community/types/content_enums.py +44 -0
  40. kagglesdk/community/types/organization.py +410 -0
  41. kagglesdk/competitions/services/competition_api_service.py +49 -12
  42. kagglesdk/competitions/types/competition.py +14 -0
  43. kagglesdk/competitions/types/competition_api_service.py +1639 -1275
  44. kagglesdk/competitions/types/search_competitions.py +28 -0
  45. kagglesdk/datasets/databundles/__init__.py +0 -0
  46. kagglesdk/datasets/databundles/types/__init__.py +0 -0
  47. kagglesdk/datasets/databundles/types/databundle_api_types.py +540 -0
  48. kagglesdk/datasets/services/dataset_api_service.py +39 -14
  49. kagglesdk/datasets/types/dataset_api_service.py +554 -300
  50. kagglesdk/datasets/types/dataset_enums.py +21 -0
  51. kagglesdk/datasets/types/dataset_service.py +145 -0
  52. kagglesdk/datasets/types/dataset_types.py +74 -74
  53. kagglesdk/datasets/types/search_datasets.py +6 -0
  54. kagglesdk/discussions/__init__.py +0 -0
  55. kagglesdk/discussions/types/__init__.py +0 -0
  56. kagglesdk/discussions/types/search_discussions.py +43 -0
  57. kagglesdk/discussions/types/writeup_enums.py +11 -0
  58. kagglesdk/education/services/education_api_service.py +1 -1
  59. kagglesdk/education/types/education_api_service.py +1 -1
  60. kagglesdk/kaggle_client.py +46 -23
  61. kagglesdk/kaggle_creds.py +148 -0
  62. kagglesdk/kaggle_env.py +89 -25
  63. kagglesdk/kaggle_http_client.py +224 -306
  64. kagglesdk/kaggle_oauth.py +200 -0
  65. kagglesdk/kaggle_object.py +286 -293
  66. kagglesdk/kernels/services/kernels_api_service.py +46 -9
  67. kagglesdk/kernels/types/kernels_api_service.py +635 -159
  68. kagglesdk/kernels/types/kernels_enums.py +6 -0
  69. kagglesdk/kernels/types/search_kernels.py +6 -0
  70. kagglesdk/licenses/__init__.py +0 -0
  71. kagglesdk/licenses/types/__init__.py +0 -0
  72. kagglesdk/licenses/types/licenses_types.py +182 -0
  73. kagglesdk/models/services/model_api_service.py +41 -17
  74. kagglesdk/models/types/model_api_service.py +987 -637
  75. kagglesdk/models/types/model_enums.py +8 -0
  76. kagglesdk/models/types/model_service.py +71 -71
  77. kagglesdk/models/types/model_types.py +1057 -5
  78. kagglesdk/models/types/search_models.py +8 -0
  79. kagglesdk/search/__init__.py +0 -0
  80. kagglesdk/search/services/__init__.py +0 -0
  81. kagglesdk/search/services/search_api_service.py +19 -0
  82. kagglesdk/search/types/__init__.py +0 -0
  83. kagglesdk/search/types/search_api_service.py +2435 -0
  84. kagglesdk/search/types/search_content_shared.py +50 -0
  85. kagglesdk/search/types/search_enums.py +45 -0
  86. kagglesdk/search/types/search_service.py +303 -0
  87. kagglesdk/security/services/iam_service.py +31 -0
  88. kagglesdk/security/services/oauth_service.py +27 -1
  89. kagglesdk/security/types/authentication.py +63 -63
  90. kagglesdk/security/types/iam_service.py +496 -0
  91. kagglesdk/security/types/oauth_service.py +797 -10
  92. kagglesdk/security/types/roles.py +8 -0
  93. kagglesdk/security/types/security_types.py +159 -0
  94. kagglesdk/test/__init__.py +0 -0
  95. kagglesdk/test/test_client.py +20 -22
  96. kagglesdk/users/services/account_service.py +13 -1
  97. kagglesdk/users/services/group_api_service.py +31 -0
  98. kagglesdk/users/types/account_service.py +169 -28
  99. kagglesdk/users/types/group_api_service.py +315 -0
  100. kagglesdk/users/types/group_types.py +165 -0
  101. kagglesdk/users/types/groups_enum.py +8 -0
  102. kagglesdk/users/types/progression_service.py +9 -0
  103. kagglesdk/users/types/search_users.py +23 -0
  104. kagglesdk/users/types/user_avatar.py +226 -0
  105. kaggle/configuration.py +0 -206
  106. kaggle-1.7.4.5.dist-info/RECORD +0 -98
  107. {kaggle-1.7.4.5.dist-info → kaggle-1.8.2.dist-info}/WHEEL +0 -0
  108. {kaggle-1.7.4.5.dist-info → kaggle-1.8.2.dist-info}/entry_points.txt +0 -0
  109. {kaggle-1.7.4.5.dist-info → kaggle-1.8.2.dist-info}/licenses/LICENSE.txt +0 -0
  110. {kaggle/test → kagglesdk/benchmarks}/__init__.py +0 -0
@@ -1,5 +1,5 @@
1
1
  from kagglesdk.kaggle_object import *
2
- from typing import Optional
2
+ from typing import Optional, List
3
3
 
4
4
  class ExchangeOAuthTokenRequest(KaggleObject):
5
5
  r"""
@@ -13,13 +13,28 @@ class ExchangeOAuthTokenRequest(KaggleObject):
13
13
  code_verifier (str)
14
14
  Original code_verifier (hash of code_challenge) for PKCE protection.
15
15
  grant_type (str)
16
- Must be set to 'authorization_code'.
16
+ Can be 'authorization_code' or 'refresh_token'.
17
+ client_id (str)
18
+ The client id of the OAuth client that initiated this flow.
19
+ redirect_uri (str)
20
+ The redirect URI that was used in the initial authorization request.
21
+ resource (str)
22
+ The 'resource' parameter is not part of the OAuth2 spec, but is sent by
23
+ some clients. We are capturing it here to avoid 'invalid field' errors.
24
+ refresh_token (str)
25
+ This field is used by MCP clients to refresh an access token. The client
26
+ sends a refresh_token to the standard /token endpoint, and this field
27
+ allows the server to correctly deserialize the request.
17
28
  """
18
29
 
19
30
  def __init__(self):
20
- self._code = ""
31
+ self._code = None
21
32
  self._code_verifier = None
22
33
  self._grant_type = ""
34
+ self._client_id = None
35
+ self._redirect_uri = None
36
+ self._resource = None
37
+ self._refresh_token = None
23
38
  self._freeze()
24
39
 
25
40
  @property
@@ -31,10 +46,10 @@ class ExchangeOAuthTokenRequest(KaggleObject):
31
46
  initiator as a query string parameter to their redirect_uri
32
47
  (https://dataverse.org?code=808f9afcabb3489a8b30353a8ae4dc4b)
33
48
  """
34
- return self._code
49
+ return self._code or ""
35
50
 
36
51
  @code.setter
37
- def code(self, code: str):
52
+ def code(self, code: Optional[str]):
38
53
  if code is None:
39
54
  del self.code
40
55
  return
@@ -48,7 +63,7 @@ class ExchangeOAuthTokenRequest(KaggleObject):
48
63
  return self._code_verifier or ""
49
64
 
50
65
  @code_verifier.setter
51
- def code_verifier(self, code_verifier: str):
66
+ def code_verifier(self, code_verifier: Optional[str]):
52
67
  if code_verifier is None:
53
68
  del self.code_verifier
54
69
  return
@@ -58,7 +73,7 @@ class ExchangeOAuthTokenRequest(KaggleObject):
58
73
 
59
74
  @property
60
75
  def grant_type(self) -> str:
61
- """Must be set to 'authorization_code'."""
76
+ """Can be 'authorization_code' or 'refresh_token'."""
62
77
  return self._grant_type
63
78
 
64
79
  @grant_type.setter
@@ -70,6 +85,69 @@ class ExchangeOAuthTokenRequest(KaggleObject):
70
85
  raise TypeError('grant_type must be of type str')
71
86
  self._grant_type = grant_type
72
87
 
88
+ @property
89
+ def client_id(self) -> str:
90
+ """The client id of the OAuth client that initiated this flow."""
91
+ return self._client_id or ""
92
+
93
+ @client_id.setter
94
+ def client_id(self, client_id: Optional[str]):
95
+ if client_id is None:
96
+ del self.client_id
97
+ return
98
+ if not isinstance(client_id, str):
99
+ raise TypeError('client_id must be of type str')
100
+ self._client_id = client_id
101
+
102
+ @property
103
+ def redirect_uri(self) -> str:
104
+ """The redirect URI that was used in the initial authorization request."""
105
+ return self._redirect_uri or ""
106
+
107
+ @redirect_uri.setter
108
+ def redirect_uri(self, redirect_uri: Optional[str]):
109
+ if redirect_uri is None:
110
+ del self.redirect_uri
111
+ return
112
+ if not isinstance(redirect_uri, str):
113
+ raise TypeError('redirect_uri must be of type str')
114
+ self._redirect_uri = redirect_uri
115
+
116
+ @property
117
+ def resource(self) -> str:
118
+ r"""
119
+ The 'resource' parameter is not part of the OAuth2 spec, but is sent by
120
+ some clients. We are capturing it here to avoid 'invalid field' errors.
121
+ """
122
+ return self._resource or ""
123
+
124
+ @resource.setter
125
+ def resource(self, resource: Optional[str]):
126
+ if resource is None:
127
+ del self.resource
128
+ return
129
+ if not isinstance(resource, str):
130
+ raise TypeError('resource must be of type str')
131
+ self._resource = resource
132
+
133
+ @property
134
+ def refresh_token(self) -> str:
135
+ r"""
136
+ This field is used by MCP clients to refresh an access token. The client
137
+ sends a refresh_token to the standard /token endpoint, and this field
138
+ allows the server to correctly deserialize the request.
139
+ """
140
+ return self._refresh_token or ""
141
+
142
+ @refresh_token.setter
143
+ def refresh_token(self, refresh_token: Optional[str]):
144
+ if refresh_token is None:
145
+ del self.refresh_token
146
+ return
147
+ if not isinstance(refresh_token, str):
148
+ raise TypeError('refresh_token must be of type str')
149
+ self._refresh_token = refresh_token
150
+
73
151
  def endpoint(self):
74
152
  path = '/api/v1/oauth2/token'
75
153
  return path.format_map(self.to_field_map(self))
@@ -96,6 +174,12 @@ class ExchangeOAuthTokenResponse(KaggleObject):
96
174
  Type of the token. Set to 'Bearer'.
97
175
  expires_in (int)
98
176
  Lifetime of the access token in seconds.
177
+ username (str)
178
+ Username of the user who authorized/owns this token.
179
+ user_id (int)
180
+ Id the of user who authorized/owns this token.
181
+ scope (str)
182
+ The scope of the access token as a space-delimited list of strings.
99
183
  """
100
184
 
101
185
  def __init__(self):
@@ -103,6 +187,9 @@ class ExchangeOAuthTokenResponse(KaggleObject):
103
187
  self._refresh_token = ""
104
188
  self._token_type = ""
105
189
  self._expires_in = 0
190
+ self._username = ""
191
+ self._user_id = 0
192
+ self._scope = None
106
193
  self._freeze()
107
194
 
108
195
  @property
@@ -164,6 +251,48 @@ class ExchangeOAuthTokenResponse(KaggleObject):
164
251
  raise TypeError('expires_in must be of type int')
165
252
  self._expires_in = expires_in
166
253
 
254
+ @property
255
+ def username(self) -> str:
256
+ """Username of the user who authorized/owns this token."""
257
+ return self._username
258
+
259
+ @username.setter
260
+ def username(self, username: str):
261
+ if username is None:
262
+ del self.username
263
+ return
264
+ if not isinstance(username, str):
265
+ raise TypeError('username must be of type str')
266
+ self._username = username
267
+
268
+ @property
269
+ def user_id(self) -> int:
270
+ """Id the of user who authorized/owns this token."""
271
+ return self._user_id
272
+
273
+ @user_id.setter
274
+ def user_id(self, user_id: int):
275
+ if user_id is None:
276
+ del self.user_id
277
+ return
278
+ if not isinstance(user_id, int):
279
+ raise TypeError('user_id must be of type int')
280
+ self._user_id = user_id
281
+
282
+ @property
283
+ def scope(self) -> str:
284
+ """The scope of the access token as a space-delimited list of strings."""
285
+ return self._scope or ""
286
+
287
+ @scope.setter
288
+ def scope(self, scope: Optional[str]):
289
+ if scope is None:
290
+ del self.scope
291
+ return
292
+ if not isinstance(scope, str):
293
+ raise TypeError('scope must be of type str')
294
+ self._scope = scope
295
+
167
296
  @property
168
297
  def accessToken(self):
169
298
  return self.access_token
@@ -180,6 +309,596 @@ class ExchangeOAuthTokenResponse(KaggleObject):
180
309
  def expiresIn(self):
181
310
  return self.expires_in
182
311
 
312
+ @property
313
+ def userId(self):
314
+ return self.user_id
315
+
316
+
317
+ class IntrospectTokenRequest(KaggleObject):
318
+ r"""
319
+ Attributes:
320
+ token (str)
321
+ Token to introspect (access token or refresh token), returned in the
322
+ response of '/api/v1/oauth2/token' (ExchangeOAuthToken) RPC.
323
+ """
324
+
325
+ def __init__(self):
326
+ self._token = ""
327
+ self._freeze()
328
+
329
+ @property
330
+ def token(self) -> str:
331
+ r"""
332
+ Token to introspect (access token or refresh token), returned in the
333
+ response of '/api/v1/oauth2/token' (ExchangeOAuthToken) RPC.
334
+ """
335
+ return self._token
336
+
337
+ @token.setter
338
+ def token(self, token: str):
339
+ if token is None:
340
+ del self.token
341
+ return
342
+ if not isinstance(token, str):
343
+ raise TypeError('token must be of type str')
344
+ self._token = token
345
+
346
+ def endpoint(self):
347
+ path = '/api/v1/oauth2/introspect'
348
+ return path.format_map(self.to_field_map(self))
349
+
350
+
351
+ @staticmethod
352
+ def method():
353
+ return 'POST'
354
+
355
+ @staticmethod
356
+ def body_fields():
357
+ return '*'
358
+
359
+
360
+ class IntrospectTokenResponse(KaggleObject):
361
+ r"""
362
+ Attributes:
363
+ active (bool)
364
+ Indicates if the token is active, i.e., not revoked nor expired.
365
+ client_id (str)
366
+ The client identifier for the OAuth 2.0 client that the token was issued
367
+ to.
368
+ username (str)
369
+ Username of the user who authorized this token.
370
+ user_id (int)
371
+ Id of the user who authorized this token.
372
+ scope (str)
373
+ Space-separated list of scopes.
374
+ exp (int)
375
+ The unix timestamp indicating when this token will expire.
376
+ """
377
+
378
+ def __init__(self):
379
+ self._active = False
380
+ self._client_id = ""
381
+ self._username = ""
382
+ self._user_id = None
383
+ self._scope = ""
384
+ self._exp = None
385
+ self._freeze()
386
+
387
+ @property
388
+ def active(self) -> bool:
389
+ """Indicates if the token is active, i.e., not revoked nor expired."""
390
+ return self._active
391
+
392
+ @active.setter
393
+ def active(self, active: bool):
394
+ if active is None:
395
+ del self.active
396
+ return
397
+ if not isinstance(active, bool):
398
+ raise TypeError('active must be of type bool')
399
+ self._active = active
400
+
401
+ @property
402
+ def client_id(self) -> str:
403
+ r"""
404
+ The client identifier for the OAuth 2.0 client that the token was issued
405
+ to.
406
+ """
407
+ return self._client_id
408
+
409
+ @client_id.setter
410
+ def client_id(self, client_id: str):
411
+ if client_id is None:
412
+ del self.client_id
413
+ return
414
+ if not isinstance(client_id, str):
415
+ raise TypeError('client_id must be of type str')
416
+ self._client_id = client_id
417
+
418
+ @property
419
+ def username(self) -> str:
420
+ """Username of the user who authorized this token."""
421
+ return self._username
422
+
423
+ @username.setter
424
+ def username(self, username: str):
425
+ if username is None:
426
+ del self.username
427
+ return
428
+ if not isinstance(username, str):
429
+ raise TypeError('username must be of type str')
430
+ self._username = username
431
+
432
+ @property
433
+ def user_id(self) -> int:
434
+ """Id of the user who authorized this token."""
435
+ return self._user_id or 0
436
+
437
+ @user_id.setter
438
+ def user_id(self, user_id: Optional[int]):
439
+ if user_id is None:
440
+ del self.user_id
441
+ return
442
+ if not isinstance(user_id, int):
443
+ raise TypeError('user_id must be of type int')
444
+ self._user_id = user_id
445
+
446
+ @property
447
+ def scope(self) -> str:
448
+ """Space-separated list of scopes."""
449
+ return self._scope
450
+
451
+ @scope.setter
452
+ def scope(self, scope: str):
453
+ if scope is None:
454
+ del self.scope
455
+ return
456
+ if not isinstance(scope, str):
457
+ raise TypeError('scope must be of type str')
458
+ self._scope = scope
459
+
460
+ @property
461
+ def exp(self) -> int:
462
+ """The unix timestamp indicating when this token will expire."""
463
+ return self._exp or 0
464
+
465
+ @exp.setter
466
+ def exp(self, exp: Optional[int]):
467
+ if exp is None:
468
+ del self.exp
469
+ return
470
+ if not isinstance(exp, int):
471
+ raise TypeError('exp must be of type int')
472
+ self._exp = exp
473
+
474
+ @property
475
+ def clientId(self):
476
+ return self.client_id
477
+
478
+ @property
479
+ def userId(self):
480
+ return self.user_id
481
+
482
+
483
+ class RegisterOAuthClientRequest(KaggleObject):
484
+ r"""
485
+ Attributes:
486
+ client_name (str)
487
+ Human-readable name for the client (e.g., 'Gemini CLI MCP Client')
488
+ redirect_uris (str)
489
+ Array of redirect URIs the client will use (e.g.,
490
+ 'http://localhost:7777/oauth/callback')
491
+ grant_types (str)
492
+ Array of OAuth 2.0 grant types the client requests (expected:
493
+ authorization_code, refresh_token)
494
+ token_endpoint_auth_method (str)
495
+ Client Authentication method (expected: 'none')
496
+ scope (str)
497
+ Space-separated list of scopes the client would like to use
498
+ code_challenge_method (str)
499
+ Array of supported PKCE methods (expected: 'S256')
500
+ """
501
+
502
+ def __init__(self):
503
+ self._client_name = ""
504
+ self._redirect_uris = []
505
+ self._grant_types = []
506
+ self._token_endpoint_auth_method = ""
507
+ self._scope = None
508
+ self._code_challenge_method = []
509
+ self._freeze()
510
+
511
+ @property
512
+ def client_name(self) -> str:
513
+ """Human-readable name for the client (e.g., 'Gemini CLI MCP Client')"""
514
+ return self._client_name
515
+
516
+ @client_name.setter
517
+ def client_name(self, client_name: str):
518
+ if client_name is None:
519
+ del self.client_name
520
+ return
521
+ if not isinstance(client_name, str):
522
+ raise TypeError('client_name must be of type str')
523
+ self._client_name = client_name
524
+
525
+ @property
526
+ def redirect_uris(self) -> Optional[List[str]]:
527
+ r"""
528
+ Array of redirect URIs the client will use (e.g.,
529
+ 'http://localhost:7777/oauth/callback')
530
+ """
531
+ return self._redirect_uris
532
+
533
+ @redirect_uris.setter
534
+ def redirect_uris(self, redirect_uris: Optional[List[str]]):
535
+ if redirect_uris is None:
536
+ del self.redirect_uris
537
+ return
538
+ if not isinstance(redirect_uris, list):
539
+ raise TypeError('redirect_uris must be of type list')
540
+ if not all([isinstance(t, str) for t in redirect_uris]):
541
+ raise TypeError('redirect_uris must contain only items of type str')
542
+ self._redirect_uris = redirect_uris
543
+
544
+ @property
545
+ def grant_types(self) -> Optional[List[str]]:
546
+ r"""
547
+ Array of OAuth 2.0 grant types the client requests (expected:
548
+ authorization_code, refresh_token)
549
+ """
550
+ return self._grant_types
551
+
552
+ @grant_types.setter
553
+ def grant_types(self, grant_types: Optional[List[str]]):
554
+ if grant_types is None:
555
+ del self.grant_types
556
+ return
557
+ if not isinstance(grant_types, list):
558
+ raise TypeError('grant_types must be of type list')
559
+ if not all([isinstance(t, str) for t in grant_types]):
560
+ raise TypeError('grant_types must contain only items of type str')
561
+ self._grant_types = grant_types
562
+
563
+ @property
564
+ def token_endpoint_auth_method(self) -> str:
565
+ """Client Authentication method (expected: 'none')"""
566
+ return self._token_endpoint_auth_method
567
+
568
+ @token_endpoint_auth_method.setter
569
+ def token_endpoint_auth_method(self, token_endpoint_auth_method: str):
570
+ if token_endpoint_auth_method is None:
571
+ del self.token_endpoint_auth_method
572
+ return
573
+ if not isinstance(token_endpoint_auth_method, str):
574
+ raise TypeError('token_endpoint_auth_method must be of type str')
575
+ self._token_endpoint_auth_method = token_endpoint_auth_method
576
+
577
+ @property
578
+ def scope(self) -> str:
579
+ """Space-separated list of scopes the client would like to use"""
580
+ return self._scope or ""
581
+
582
+ @scope.setter
583
+ def scope(self, scope: Optional[str]):
584
+ if scope is None:
585
+ del self.scope
586
+ return
587
+ if not isinstance(scope, str):
588
+ raise TypeError('scope must be of type str')
589
+ self._scope = scope
590
+
591
+ @property
592
+ def code_challenge_method(self) -> Optional[List[str]]:
593
+ """Array of supported PKCE methods (expected: 'S256')"""
594
+ return self._code_challenge_method
595
+
596
+ @code_challenge_method.setter
597
+ def code_challenge_method(self, code_challenge_method: Optional[List[str]]):
598
+ if code_challenge_method is None:
599
+ del self.code_challenge_method
600
+ return
601
+ if not isinstance(code_challenge_method, list):
602
+ raise TypeError('code_challenge_method must be of type list')
603
+ if not all([isinstance(t, str) for t in code_challenge_method]):
604
+ raise TypeError('code_challenge_method must contain only items of type str')
605
+ self._code_challenge_method = code_challenge_method
606
+
607
+ def endpoint(self):
608
+ path = '/api/v1/oauth2/register'
609
+ return path.format_map(self.to_field_map(self))
610
+
611
+
612
+ @staticmethod
613
+ def method():
614
+ return 'POST'
615
+
616
+ @staticmethod
617
+ def body_fields():
618
+ return '*'
619
+
620
+
621
+ class RegisterOAuthClientResponse(KaggleObject):
622
+ r"""
623
+ According to RFC 7591 &&
624
+ https://github.com/google-gemini/gemini-cli/blob/56f394cefd04696a5192fef9bbff8ba0e5b0583f/packages/core/src/mcp/oauth-provider.ts#L69
625
+
626
+ Attributes:
627
+ client_id (str)
628
+ redirect_uris (str)
629
+ grant_types (str)
630
+ response_types (str)
631
+ token_endpoint_auth_method (str)
632
+ scope (str)
633
+ authorization_url (str)
634
+ token_url (str)
635
+ client_secret (str)
636
+ client_id_issued_at (int)
637
+ client_secret_expires_at (int)
638
+ revocation_url (str)
639
+ userinfo_url (str)
640
+ code_challenge_methods_supported (str)
641
+ """
642
+
643
+ def __init__(self):
644
+ self._client_id = ""
645
+ self._redirect_uris = []
646
+ self._grant_types = []
647
+ self._response_types = []
648
+ self._token_endpoint_auth_method = ""
649
+ self._scope = None
650
+ self._authorization_url = None
651
+ self._token_url = None
652
+ self._client_secret = None
653
+ self._client_id_issued_at = None
654
+ self._client_secret_expires_at = None
655
+ self._revocation_url = None
656
+ self._userinfo_url = None
657
+ self._code_challenge_methods_supported = []
658
+ self._freeze()
659
+
660
+ @property
661
+ def client_id(self) -> str:
662
+ return self._client_id
663
+
664
+ @client_id.setter
665
+ def client_id(self, client_id: str):
666
+ if client_id is None:
667
+ del self.client_id
668
+ return
669
+ if not isinstance(client_id, str):
670
+ raise TypeError('client_id must be of type str')
671
+ self._client_id = client_id
672
+
673
+ @property
674
+ def redirect_uris(self) -> Optional[List[str]]:
675
+ return self._redirect_uris
676
+
677
+ @redirect_uris.setter
678
+ def redirect_uris(self, redirect_uris: Optional[List[str]]):
679
+ if redirect_uris is None:
680
+ del self.redirect_uris
681
+ return
682
+ if not isinstance(redirect_uris, list):
683
+ raise TypeError('redirect_uris must be of type list')
684
+ if not all([isinstance(t, str) for t in redirect_uris]):
685
+ raise TypeError('redirect_uris must contain only items of type str')
686
+ self._redirect_uris = redirect_uris
687
+
688
+ @property
689
+ def grant_types(self) -> Optional[List[str]]:
690
+ return self._grant_types
691
+
692
+ @grant_types.setter
693
+ def grant_types(self, grant_types: Optional[List[str]]):
694
+ if grant_types is None:
695
+ del self.grant_types
696
+ return
697
+ if not isinstance(grant_types, list):
698
+ raise TypeError('grant_types must be of type list')
699
+ if not all([isinstance(t, str) for t in grant_types]):
700
+ raise TypeError('grant_types must contain only items of type str')
701
+ self._grant_types = grant_types
702
+
703
+ @property
704
+ def response_types(self) -> Optional[List[str]]:
705
+ return self._response_types
706
+
707
+ @response_types.setter
708
+ def response_types(self, response_types: Optional[List[str]]):
709
+ if response_types is None:
710
+ del self.response_types
711
+ return
712
+ if not isinstance(response_types, list):
713
+ raise TypeError('response_types must be of type list')
714
+ if not all([isinstance(t, str) for t in response_types]):
715
+ raise TypeError('response_types must contain only items of type str')
716
+ self._response_types = response_types
717
+
718
+ @property
719
+ def token_endpoint_auth_method(self) -> str:
720
+ return self._token_endpoint_auth_method
721
+
722
+ @token_endpoint_auth_method.setter
723
+ def token_endpoint_auth_method(self, token_endpoint_auth_method: str):
724
+ if token_endpoint_auth_method is None:
725
+ del self.token_endpoint_auth_method
726
+ return
727
+ if not isinstance(token_endpoint_auth_method, str):
728
+ raise TypeError('token_endpoint_auth_method must be of type str')
729
+ self._token_endpoint_auth_method = token_endpoint_auth_method
730
+
731
+ @property
732
+ def scope(self) -> str:
733
+ return self._scope or ""
734
+
735
+ @scope.setter
736
+ def scope(self, scope: Optional[str]):
737
+ if scope is None:
738
+ del self.scope
739
+ return
740
+ if not isinstance(scope, str):
741
+ raise TypeError('scope must be of type str')
742
+ self._scope = scope
743
+
744
+ @property
745
+ def authorization_url(self) -> str:
746
+ return self._authorization_url or ""
747
+
748
+ @authorization_url.setter
749
+ def authorization_url(self, authorization_url: Optional[str]):
750
+ if authorization_url is None:
751
+ del self.authorization_url
752
+ return
753
+ if not isinstance(authorization_url, str):
754
+ raise TypeError('authorization_url must be of type str')
755
+ self._authorization_url = authorization_url
756
+
757
+ @property
758
+ def token_url(self) -> str:
759
+ return self._token_url or ""
760
+
761
+ @token_url.setter
762
+ def token_url(self, token_url: Optional[str]):
763
+ if token_url is None:
764
+ del self.token_url
765
+ return
766
+ if not isinstance(token_url, str):
767
+ raise TypeError('token_url must be of type str')
768
+ self._token_url = token_url
769
+
770
+ @property
771
+ def revocation_url(self) -> str:
772
+ return self._revocation_url or ""
773
+
774
+ @revocation_url.setter
775
+ def revocation_url(self, revocation_url: Optional[str]):
776
+ if revocation_url is None:
777
+ del self.revocation_url
778
+ return
779
+ if not isinstance(revocation_url, str):
780
+ raise TypeError('revocation_url must be of type str')
781
+ self._revocation_url = revocation_url
782
+
783
+ @property
784
+ def userinfo_url(self) -> str:
785
+ return self._userinfo_url or ""
786
+
787
+ @userinfo_url.setter
788
+ def userinfo_url(self, userinfo_url: Optional[str]):
789
+ if userinfo_url is None:
790
+ del self.userinfo_url
791
+ return
792
+ if not isinstance(userinfo_url, str):
793
+ raise TypeError('userinfo_url must be of type str')
794
+ self._userinfo_url = userinfo_url
795
+
796
+ @property
797
+ def code_challenge_methods_supported(self) -> Optional[List[str]]:
798
+ return self._code_challenge_methods_supported
799
+
800
+ @code_challenge_methods_supported.setter
801
+ def code_challenge_methods_supported(self, code_challenge_methods_supported: Optional[List[str]]):
802
+ if code_challenge_methods_supported is None:
803
+ del self.code_challenge_methods_supported
804
+ return
805
+ if not isinstance(code_challenge_methods_supported, list):
806
+ raise TypeError('code_challenge_methods_supported must be of type list')
807
+ if not all([isinstance(t, str) for t in code_challenge_methods_supported]):
808
+ raise TypeError('code_challenge_methods_supported must contain only items of type str')
809
+ self._code_challenge_methods_supported = code_challenge_methods_supported
810
+
811
+ @property
812
+ def client_secret(self) -> str:
813
+ return self._client_secret or ""
814
+
815
+ @client_secret.setter
816
+ def client_secret(self, client_secret: Optional[str]):
817
+ if client_secret is None:
818
+ del self.client_secret
819
+ return
820
+ if not isinstance(client_secret, str):
821
+ raise TypeError('client_secret must be of type str')
822
+ self._client_secret = client_secret
823
+
824
+ @property
825
+ def client_id_issued_at(self) -> int:
826
+ return self._client_id_issued_at or 0
827
+
828
+ @client_id_issued_at.setter
829
+ def client_id_issued_at(self, client_id_issued_at: Optional[int]):
830
+ if client_id_issued_at is None:
831
+ del self.client_id_issued_at
832
+ return
833
+ if not isinstance(client_id_issued_at, int):
834
+ raise TypeError('client_id_issued_at must be of type int')
835
+ self._client_id_issued_at = client_id_issued_at
836
+
837
+ @property
838
+ def client_secret_expires_at(self) -> int:
839
+ return self._client_secret_expires_at or 0
840
+
841
+ @client_secret_expires_at.setter
842
+ def client_secret_expires_at(self, client_secret_expires_at: Optional[int]):
843
+ if client_secret_expires_at is None:
844
+ del self.client_secret_expires_at
845
+ return
846
+ if not isinstance(client_secret_expires_at, int):
847
+ raise TypeError('client_secret_expires_at must be of type int')
848
+ self._client_secret_expires_at = client_secret_expires_at
849
+
850
+ @property
851
+ def clientId(self):
852
+ return self.client_id
853
+
854
+ @property
855
+ def redirectUris(self):
856
+ return self.redirect_uris
857
+
858
+ @property
859
+ def grantTypes(self):
860
+ return self.grant_types
861
+
862
+ @property
863
+ def responseTypes(self):
864
+ return self.response_types
865
+
866
+ @property
867
+ def tokenEndpointAuthMethod(self):
868
+ return self.token_endpoint_auth_method
869
+
870
+ @property
871
+ def authorizationUrl(self):
872
+ return self.authorization_url
873
+
874
+ @property
875
+ def tokenUrl(self):
876
+ return self.token_url
877
+
878
+ @property
879
+ def revocationUrl(self):
880
+ return self.revocation_url
881
+
882
+ @property
883
+ def userinfoUrl(self):
884
+ return self.userinfo_url
885
+
886
+ @property
887
+ def codeChallengeMethodsSupported(self):
888
+ return self.code_challenge_methods_supported
889
+
890
+ @property
891
+ def clientSecret(self):
892
+ return self.client_secret
893
+
894
+ @property
895
+ def clientIdIssuedAt(self):
896
+ return self.client_id_issued_at
897
+
898
+ @property
899
+ def clientSecretExpiresAt(self):
900
+ return self.client_secret_expires_at
901
+
183
902
 
184
903
  class StartOAuthFlowRequest(KaggleObject):
185
904
  r"""
@@ -213,6 +932,9 @@ class StartOAuthFlowRequest(KaggleObject):
213
932
  response_mode (str)
214
933
  Mode of the OAuth flow completed response. Must be set to 'query', which
215
934
  means response will be sent as query string parameters.
935
+ resource (str)
936
+ The 'resource' parameter is not part of the OAuth2 spec, but is sent by
937
+ some clients. We are capturing it here to avoid 'invalid field' errors.
216
938
  """
217
939
 
218
940
  def __init__(self):
@@ -224,6 +946,7 @@ class StartOAuthFlowRequest(KaggleObject):
224
946
  self._code_challenge_method = None
225
947
  self._response_type = ""
226
948
  self._response_mode = ""
949
+ self._resource = None
227
950
  self._freeze()
228
951
 
229
952
  @property
@@ -303,7 +1026,7 @@ class StartOAuthFlowRequest(KaggleObject):
303
1026
  return self._code_challenge or ""
304
1027
 
305
1028
  @code_challenge.setter
306
- def code_challenge(self, code_challenge: str):
1029
+ def code_challenge(self, code_challenge: Optional[str]):
307
1030
  if code_challenge is None:
308
1031
  del self.code_challenge
309
1032
  return
@@ -321,7 +1044,7 @@ class StartOAuthFlowRequest(KaggleObject):
321
1044
  return self._code_challenge_method or ""
322
1045
 
323
1046
  @code_challenge_method.setter
324
- def code_challenge_method(self, code_challenge_method: str):
1047
+ def code_challenge_method(self, code_challenge_method: Optional[str]):
325
1048
  if code_challenge_method is None:
326
1049
  del self.code_challenge_method
327
1050
  return
@@ -363,15 +1086,36 @@ class StartOAuthFlowRequest(KaggleObject):
363
1086
  raise TypeError('response_mode must be of type str')
364
1087
  self._response_mode = response_mode
365
1088
 
1089
+ @property
1090
+ def resource(self) -> str:
1091
+ r"""
1092
+ The 'resource' parameter is not part of the OAuth2 spec, but is sent by
1093
+ some clients. We are capturing it here to avoid 'invalid field' errors.
1094
+ """
1095
+ return self._resource or ""
1096
+
1097
+ @resource.setter
1098
+ def resource(self, resource: Optional[str]):
1099
+ if resource is None:
1100
+ del self.resource
1101
+ return
1102
+ if not isinstance(resource, str):
1103
+ raise TypeError('resource must be of type str')
1104
+ self._resource = resource
1105
+
366
1106
  def endpoint(self):
367
1107
  path = '/api/v1/oauth2/authorize'
368
1108
  return path.format_map(self.to_field_map(self))
369
1109
 
370
1110
 
371
1111
  ExchangeOAuthTokenRequest._fields = [
372
- FieldMetadata("code", "code", "_code", str, "", PredefinedSerializer()),
1112
+ FieldMetadata("code", "code", "_code", str, None, PredefinedSerializer(), optional=True),
373
1113
  FieldMetadata("codeVerifier", "code_verifier", "_code_verifier", str, None, PredefinedSerializer(), optional=True),
374
1114
  FieldMetadata("grantType", "grant_type", "_grant_type", str, "", PredefinedSerializer()),
1115
+ FieldMetadata("clientId", "client_id", "_client_id", str, None, PredefinedSerializer(), optional=True),
1116
+ FieldMetadata("redirectUri", "redirect_uri", "_redirect_uri", str, None, PredefinedSerializer(), optional=True),
1117
+ FieldMetadata("resource", "resource", "_resource", str, None, PredefinedSerializer(), optional=True),
1118
+ FieldMetadata("refreshToken", "refresh_token", "_refresh_token", str, None, PredefinedSerializer(), optional=True),
375
1119
  ]
376
1120
 
377
1121
  ExchangeOAuthTokenResponse._fields = [
@@ -379,6 +1123,48 @@ ExchangeOAuthTokenResponse._fields = [
379
1123
  FieldMetadata("refreshToken", "refresh_token", "_refresh_token", str, "", PredefinedSerializer()),
380
1124
  FieldMetadata("tokenType", "token_type", "_token_type", str, "", PredefinedSerializer()),
381
1125
  FieldMetadata("expiresIn", "expires_in", "_expires_in", int, 0, PredefinedSerializer()),
1126
+ FieldMetadata("username", "username", "_username", str, "", PredefinedSerializer()),
1127
+ FieldMetadata("userId", "user_id", "_user_id", int, 0, PredefinedSerializer()),
1128
+ FieldMetadata("scope", "scope", "_scope", str, None, PredefinedSerializer(), optional=True),
1129
+ ]
1130
+
1131
+ IntrospectTokenRequest._fields = [
1132
+ FieldMetadata("token", "token", "_token", str, "", PredefinedSerializer()),
1133
+ ]
1134
+
1135
+ IntrospectTokenResponse._fields = [
1136
+ FieldMetadata("active", "active", "_active", bool, False, PredefinedSerializer()),
1137
+ FieldMetadata("clientId", "client_id", "_client_id", str, "", PredefinedSerializer()),
1138
+ FieldMetadata("username", "username", "_username", str, "", PredefinedSerializer()),
1139
+ FieldMetadata("userId", "user_id", "_user_id", int, None, PredefinedSerializer(), optional=True),
1140
+ FieldMetadata("scope", "scope", "_scope", str, "", PredefinedSerializer()),
1141
+ FieldMetadata("exp", "exp", "_exp", int, None, PredefinedSerializer(), optional=True),
1142
+ ]
1143
+
1144
+ RegisterOAuthClientRequest._fields = [
1145
+ FieldMetadata("clientName", "client_name", "_client_name", str, "", PredefinedSerializer()),
1146
+ FieldMetadata("redirectUris", "redirect_uris", "_redirect_uris", str, [], ListSerializer(PredefinedSerializer())),
1147
+ FieldMetadata("grantTypes", "grant_types", "_grant_types", str, [], ListSerializer(PredefinedSerializer())),
1148
+ FieldMetadata("tokenEndpointAuthMethod", "token_endpoint_auth_method", "_token_endpoint_auth_method", str, "", PredefinedSerializer()),
1149
+ FieldMetadata("scope", "scope", "_scope", str, None, PredefinedSerializer(), optional=True),
1150
+ FieldMetadata("codeChallengeMethod", "code_challenge_method", "_code_challenge_method", str, [], ListSerializer(PredefinedSerializer())),
1151
+ ]
1152
+
1153
+ RegisterOAuthClientResponse._fields = [
1154
+ FieldMetadata("client_id", "client_id", "_client_id", str, "", PredefinedSerializer()),
1155
+ FieldMetadata("redirect_uris", "redirect_uris", "_redirect_uris", str, [], ListSerializer(PredefinedSerializer())),
1156
+ FieldMetadata("grant_types", "grant_types", "_grant_types", str, [], ListSerializer(PredefinedSerializer())),
1157
+ FieldMetadata("response_types", "response_types", "_response_types", str, [], ListSerializer(PredefinedSerializer())),
1158
+ FieldMetadata("token_endpoint_auth_method", "token_endpoint_auth_method", "_token_endpoint_auth_method", str, "", PredefinedSerializer()),
1159
+ FieldMetadata("scope", "scope", "_scope", str, None, PredefinedSerializer(), optional=True),
1160
+ FieldMetadata("authorization_url", "authorization_url", "_authorization_url", str, None, PredefinedSerializer(), optional=True),
1161
+ FieldMetadata("token_url", "token_url", "_token_url", str, None, PredefinedSerializer(), optional=True),
1162
+ FieldMetadata("client_secret", "client_secret", "_client_secret", str, None, PredefinedSerializer(), optional=True),
1163
+ FieldMetadata("client_id_issued_at", "client_id_issued_at", "_client_id_issued_at", int, None, PredefinedSerializer(), optional=True),
1164
+ FieldMetadata("client_secret_expires_at", "client_secret_expires_at", "_client_secret_expires_at", int, None, PredefinedSerializer(), optional=True),
1165
+ FieldMetadata("revocation_url", "revocation_url", "_revocation_url", str, None, PredefinedSerializer(), optional=True),
1166
+ FieldMetadata("userinfo_url", "userinfo_url", "_userinfo_url", str, None, PredefinedSerializer(), optional=True),
1167
+ FieldMetadata("code_challenge_methods_supported", "code_challenge_methods_supported", "_code_challenge_methods_supported", str, [], ListSerializer(PredefinedSerializer())),
382
1168
  ]
383
1169
 
384
1170
  StartOAuthFlowRequest._fields = [
@@ -390,5 +1176,6 @@ StartOAuthFlowRequest._fields = [
390
1176
  FieldMetadata("codeChallengeMethod", "code_challenge_method", "_code_challenge_method", str, None, PredefinedSerializer(), optional=True),
391
1177
  FieldMetadata("responseType", "response_type", "_response_type", str, "", PredefinedSerializer()),
392
1178
  FieldMetadata("responseMode", "response_mode", "_response_mode", str, "", PredefinedSerializer()),
1179
+ FieldMetadata("resource", "resource", "_resource", str, None, PredefinedSerializer(), optional=True),
393
1180
  ]
394
1181