Skip to content

Commit 07cd959

Browse files
committed
add docstring sweep 2
1 parent bc92a37 commit 07cd959

17 files changed

Lines changed: 86 additions & 11 deletions

‎src/pytfe/resources/cidr_range_list.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ def add_agent_pools(
304304
305305
Raises:
306306
InvalidCIDRRangeListIDError: If ``cidr_range_list_id`` is not valid.
307+
InvalidAgentPoolIDError: If an agent pool ID is not a valid resource ID.
307308
TFEError: If the API request fails.
308309
309310
Example:
@@ -335,6 +336,7 @@ def remove_agent_pools(
335336
336337
Raises:
337338
InvalidCIDRRangeListIDError: If ``cidr_range_list_id`` is not valid.
339+
InvalidAgentPoolIDError: If an agent pool ID is not a valid resource ID.
338340
TFEError: If the API request fails.
339341
340342
Example:

‎src/pytfe/resources/configuration_version.py‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ def read(self, cv_id: str) -> ConfigurationVersion:
181181
The :class:`ConfigurationVersion`.
182182
183183
Raises:
184+
ValueError: If ``cv_id`` is not a valid resource ID.
184185
TFEError: If the API request fails.
185186
186187
Example:
@@ -270,8 +271,11 @@ def upload_tar_gzip(self, upload_url: str, archive: io.IOBase) -> None:
270271
271272
Example:
272273
>>> import io
273-
>>> archive = io.BytesIO(gzipped_tar_bytes)
274-
>>> client.configuration_versions.upload_tar_gzip(upload_url, archive)
274+
>>> version = client.configuration_versions.create("ws-YnyXLq9fy38afEeb")
275+
>>> with open("terraform.tar.gz", "rb") as fh:
276+
... client.configuration_versions.upload_tar_gzip(
277+
... version.upload_url, io.BytesIO(fh.read())
278+
... )
275279
"""
276280
# Get the binary content from the archive
277281
if hasattr(archive, "getvalue"):
@@ -425,6 +429,7 @@ def soft_delete_backing_data(self, cv_id: str) -> None:
425429
None.
426430
427431
Raises:
432+
ValueError: If ``cv_id`` is not a valid resource ID.
428433
TFEError: If the API request fails.
429434
430435
Example:
@@ -444,6 +449,7 @@ def restore_backing_data(self, cv_id: str) -> None:
444449
None.
445450
446451
Raises:
452+
ValueError: If ``cv_id`` is not a valid resource ID.
447453
TFEError: If the API request fails.
448454
449455
Example:
@@ -463,6 +469,7 @@ def permanently_delete_backing_data(self, cv_id: str) -> None:
463469
None.
464470
465471
Raises:
472+
ValueError: If ``cv_id`` is not a valid resource ID.
466473
TFEError: If the API request fails.
467474
468475
Example:

‎src/pytfe/resources/oauth_client.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ def read(self, oauth_client_id: str) -> OAuthClient:
137137
The :class:`OAuthClient`.
138138
139139
Raises:
140+
ValueError: If ``oauth_client_id`` is not a valid resource ID.
140141
TFEError: If the API request fails.
141142
142143
Example:

‎src/pytfe/resources/oidc_configurations.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def create(
164164
The created :class:`AWSOIDCConfiguration`.
165165
166166
Raises:
167+
InvalidOrgError: If ``organization`` is not a valid organization name.
167168
TFEError: If the API request fails.
168169
169170
Example:
@@ -188,6 +189,7 @@ def read(self, oidc_configuration_id: str) -> AWSOIDCConfiguration:
188189
The :class:`AWSOIDCConfiguration`.
189190
190191
Raises:
192+
InvalidOIDCConfigurationIDError: If ``oidc_configuration_id`` is not a valid resource ID.
191193
TFEError: If the API request fails.
192194
193195
Example:
@@ -213,6 +215,7 @@ def update(
213215
The updated :class:`AWSOIDCConfiguration`.
214216
215217
Raises:
218+
InvalidOIDCConfigurationIDError: If ``oidc_configuration_id`` is not a valid resource ID.
216219
TFEError: If the API request fails.
217220
218221
Example:
@@ -237,6 +240,7 @@ def delete(self, oidc_configuration_id: str) -> None:
237240
None.
238241
239242
Raises:
243+
InvalidOIDCConfigurationIDError: If ``oidc_configuration_id`` is not a valid resource ID.
240244
TFEError: If the API request fails.
241245
242246
Example:
@@ -270,6 +274,7 @@ def create(
270274
The created :class:`AzureOIDCConfiguration`.
271275
272276
Raises:
277+
InvalidOrgError: If ``organization`` is not a valid organization name.
273278
TFEError: If the API request fails.
274279
275280
Example:
@@ -296,6 +301,7 @@ def read(self, oidc_configuration_id: str) -> AzureOIDCConfiguration:
296301
The :class:`AzureOIDCConfiguration`.
297302
298303
Raises:
304+
InvalidOIDCConfigurationIDError: If ``oidc_configuration_id`` is not a valid resource ID.
299305
TFEError: If the API request fails.
300306
301307
Example:
@@ -321,6 +327,7 @@ def update(
321327
The updated :class:`AzureOIDCConfiguration`.
322328
323329
Raises:
330+
InvalidOIDCConfigurationIDError: If ``oidc_configuration_id`` is not a valid resource ID.
324331
TFEError: If the API request fails.
325332
326333
Example:
@@ -343,6 +350,7 @@ def delete(self, oidc_configuration_id: str) -> None:
343350
None.
344351
345352
Raises:
353+
InvalidOIDCConfigurationIDError: If ``oidc_configuration_id`` is not a valid resource ID.
346354
TFEError: If the API request fails.
347355
348356
Example:
@@ -376,6 +384,7 @@ def create(
376384
The created :class:`GCPOIDCConfiguration`.
377385
378386
Raises:
387+
InvalidOrgError: If ``organization`` is not a valid organization name.
379388
TFEError: If the API request fails.
380389
381390
Example:
@@ -402,6 +411,7 @@ def read(self, oidc_configuration_id: str) -> GCPOIDCConfiguration:
402411
The :class:`GCPOIDCConfiguration`.
403412
404413
Raises:
414+
InvalidOIDCConfigurationIDError: If ``oidc_configuration_id`` is not a valid resource ID.
405415
TFEError: If the API request fails.
406416
407417
Example:
@@ -427,6 +437,7 @@ def update(
427437
The updated :class:`GCPOIDCConfiguration`.
428438
429439
Raises:
440+
InvalidOIDCConfigurationIDError: If ``oidc_configuration_id`` is not a valid resource ID.
430441
TFEError: If the API request fails.
431442
432443
Example:
@@ -451,6 +462,7 @@ def delete(self, oidc_configuration_id: str) -> None:
451462
None.
452463
453464
Raises:
465+
InvalidOIDCConfigurationIDError: If ``oidc_configuration_id`` is not a valid resource ID.
454466
TFEError: If the API request fails.
455467
456468
Example:
@@ -484,6 +496,7 @@ def create(
484496
The created :class:`VaultOIDCConfiguration`.
485497
486498
Raises:
499+
InvalidOrgError: If ``organization`` is not a valid organization name.
487500
TFEError: If the API request fails.
488501
489502
Example:
@@ -508,6 +521,7 @@ def read(self, oidc_configuration_id: str) -> VaultOIDCConfiguration:
508521
The :class:`VaultOIDCConfiguration`.
509522
510523
Raises:
524+
InvalidOIDCConfigurationIDError: If ``oidc_configuration_id`` is not a valid resource ID.
511525
TFEError: If the API request fails.
512526
513527
Example:
@@ -533,6 +547,7 @@ def update(
533547
The updated :class:`VaultOIDCConfiguration`.
534548
535549
Raises:
550+
InvalidOIDCConfigurationIDError: If ``oidc_configuration_id`` is not a valid resource ID.
536551
TFEError: If the API request fails.
537552
538553
Example:
@@ -555,6 +570,7 @@ def delete(self, oidc_configuration_id: str) -> None:
555570
None.
556571
557572
Raises:
573+
InvalidOIDCConfigurationIDError: If ``oidc_configuration_id`` is not a valid resource ID.
558574
TFEError: If the API request fails.
559575
560576
Example:

‎src/pytfe/resources/organization_membership.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ def read(self, organization_membership_id: str) -> OrganizationMembership:
190190
The :class:`OrganizationMembership`.
191191
192192
Raises:
193+
ValueError: If ``organization_membership_id`` is not a valid resource ID.
193194
TFEError: If the API request fails.
194195
195196
Example:

‎src/pytfe/resources/organization_token.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def read(self, organization: str) -> OrganizationToken:
107107
The :class:`OrganizationToken`.
108108
109109
Raises:
110+
ValueError: If ``organization`` is not a valid organization name.
110111
TFEError: If the API request fails.
111112
112113
Example:
@@ -168,6 +169,7 @@ def delete(self, organization: str) -> None:
168169
None.
169170
170171
Raises:
172+
ValueError: If ``organization`` is not a valid organization name.
171173
TFEError: If the API request fails.
172174
173175
Example:

‎src/pytfe/resources/organizations.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ def reset_default_settings(self, organization: str) -> OrganizationDefaultSettin
309309
The :class:`OrganizationDefaultSettings`.
310310
311311
Raises:
312+
ValueError: If ``organization`` is not a valid organization name.
312313
TFEError: If the API request fails.
313314
314315
Example:

‎src/pytfe/resources/policy_set.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ def read(self, policy_set_id: str) -> PolicySet:
213213
The :class:`PolicySet`.
214214
215215
Raises:
216+
InvalidPolicySetIDError: If ``policy_set_id`` is not a valid resource ID.
216217
TFEError: If the API request fails.
217218
218219
Example:

‎src/pytfe/resources/registry.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ def list_latest_for_all_providers(
188188
to materialize the results or iterate more than once.
189189
190190
Raises:
191+
InvalidModuleNamespaceError: If ``namespace`` is not a valid module namespace.
192+
InvalidModuleNameError: If ``name`` is not a valid module name.
191193
TFEError: If the API request fails.
192194
193195
Example:
@@ -216,6 +218,9 @@ def latest_for_provider(
216218
The :class:`PublicRegistryModule`.
217219
218220
Raises:
221+
InvalidModuleNamespaceError: If ``namespace`` is not a valid module namespace.
222+
InvalidModuleNameError: If ``name`` is not a valid module name.
223+
InvalidModuleProviderError: If ``provider`` is not a valid module provider.
219224
TFEError: If the API request fails.
220225
221226
Example:
@@ -243,6 +248,10 @@ def get_module(
243248
The :class:`PublicRegistryModule`.
244249
245250
Raises:
251+
InvalidModuleNamespaceError: If ``namespace`` is not a valid module namespace.
252+
InvalidModuleNameError: If ``name`` is not a valid module name.
253+
InvalidModuleProviderError: If ``provider`` is not a valid module provider.
254+
InvalidModuleVersionError: If ``version`` is not a valid module version.
246255
TFEError: If the API request fails.
247256
248257
Example:
@@ -272,6 +281,9 @@ def list_versions(
272281
The :class:`PublicRegistryModuleVersions`.
273282
274283
Raises:
284+
InvalidModuleNamespaceError: If ``namespace`` is not a valid module namespace.
285+
InvalidModuleNameError: If ``name`` is not a valid module name.
286+
InvalidModuleProviderError: If ``provider`` is not a valid module provider.
275287
TFEError: If the API request fails.
276288
277289
Example:
@@ -303,6 +315,10 @@ def download_url(
303315
The ``str``.
304316
305317
Raises:
318+
InvalidModuleNamespaceError: If ``namespace`` is not a valid module namespace.
319+
InvalidModuleNameError: If ``name`` is not a valid module name.
320+
InvalidModuleProviderError: If ``provider`` is not a valid module provider.
321+
InvalidModuleVersionError: If ``version`` is not a valid module version.
306322
TFEError: If the API request fails.
307323
308324
Example:
@@ -332,6 +348,9 @@ def latest_download_url(self, namespace: str, name: str, provider: str) -> str:
332348
The ``str``.
333349
334350
Raises:
351+
InvalidModuleNamespaceError: If ``namespace`` is not a valid module namespace.
352+
InvalidModuleNameError: If ``name`` is not a valid module name.
353+
InvalidModuleProviderError: If ``provider`` is not a valid module provider.
335354
TFEError: If the API request fails.
336355
337356
Example:
@@ -356,6 +375,9 @@ def downloads_summary(
356375
The :class:`PublicRegistryModuleDownloadsSummary`.
357376
358377
Raises:
378+
InvalidModuleNamespaceError: If ``namespace`` is not a valid module namespace.
379+
InvalidModuleNameError: If ``name`` is not a valid module name.
380+
InvalidModuleProviderError: If ``provider`` is not a valid module provider.
359381
TFEError: If the API request fails.
360382
361383
Example:

‎src/pytfe/resources/registry_module.py‎

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -653,10 +653,12 @@ def update(
653653
return self._parse_registry_module(data)
654654

655655
def upload(self, rmv: RegistryModuleVersion, path: str) -> None:
656-
"""Upload Terraform configuration files for a module version.
656+
"""Package and upload module files from a local path (not implemented yet).
657657
658-
It requires a path to the configuration files on disk, which will be
659-
packaged before being uploaded.
658+
Packaging a local directory is not implemented, so this always raises
659+
``NotImplementedError`` once an upload link is present. To upload a module
660+
version today, build the gzipped tar archive yourself and pass the
661+
version's upload link to :meth:`upload_tar_gzip`.
660662
661663
Args:
662664
rmv: The registry module version with an upload link, as a
@@ -667,12 +669,18 @@ def upload(self, rmv: RegistryModuleVersion, path: str) -> None:
667669
None.
668670
669671
Raises:
670-
NotImplementedError: This method does not implement packaging yet.
671-
ValueError: If an argument or options value is invalid.
672+
ValueError: If ``rmv`` has no upload link.
673+
NotImplementedError: Always (when an upload link is present) —
674+
local-path packaging is not implemented yet.
672675
673676
Example:
674-
>>> version = client.registry_modules.create_version(module_id, options)
675-
>>> client.registry_modules.upload(version, "./module")
677+
>>> import io
678+
>>> # upload() is not implemented; build the archive yourself and use
679+
>>> # upload_tar_gzip with the version's upload link instead:
680+
>>> with open("module.tar.gz", "rb") as fh:
681+
... client.registry_modules.upload_tar_gzip(
682+
... rmv.links["upload"], io.BytesIO(fh.read())
683+
... )
676684
"""
677685
upload_url = rmv.links.get("upload")
678686
if not upload_url:
@@ -705,8 +713,11 @@ def upload_tar_gzip(self, upload_url: str, archive: io.IOBase) -> None:
705713
706714
Example:
707715
>>> import io
708-
>>> archive = io.BytesIO(tar_gzip_bytes)
709-
>>> client.registry_modules.upload_tar_gzip(upload_url, archive)
716+
>>> version = client.registry_modules.create_version(module_id, options)
717+
>>> with open("module.tar.gz", "rb") as fh:
718+
... client.registry_modules.upload_tar_gzip(
719+
... version.links["upload"], io.BytesIO(fh.read())
720+
... )
710721
"""
711722
# Use the httpx client for direct upload to external URL
712723
response = self.t._sync.put(upload_url, content=archive.read())

0 commit comments

Comments
 (0)