cloudsmith-cli 1.20.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.
Files changed (130) hide show
  1. cloudsmith_cli/__init__.py +10 -0
  2. cloudsmith_cli/__main__.py +8 -0
  3. cloudsmith_cli/cli/__init__.py +1 -0
  4. cloudsmith_cli/cli/command.py +160 -0
  5. cloudsmith_cli/cli/commands/__init__.py +33 -0
  6. cloudsmith_cli/cli/commands/auth.py +173 -0
  7. cloudsmith_cli/cli/commands/check.py +129 -0
  8. cloudsmith_cli/cli/commands/copy.py +98 -0
  9. cloudsmith_cli/cli/commands/credential_helper/__init__.py +39 -0
  10. cloudsmith_cli/cli/commands/credential_helper/docker.py +66 -0
  11. cloudsmith_cli/cli/commands/credential_helper/manage.py +299 -0
  12. cloudsmith_cli/cli/commands/delete.py +67 -0
  13. cloudsmith_cli/cli/commands/dependencies.py +108 -0
  14. cloudsmith_cli/cli/commands/docs.py +16 -0
  15. cloudsmith_cli/cli/commands/download.py +620 -0
  16. cloudsmith_cli/cli/commands/entitlements.py +819 -0
  17. cloudsmith_cli/cli/commands/help_.py +12 -0
  18. cloudsmith_cli/cli/commands/list_.py +317 -0
  19. cloudsmith_cli/cli/commands/login.py +99 -0
  20. cloudsmith_cli/cli/commands/logout.py +151 -0
  21. cloudsmith_cli/cli/commands/main.py +73 -0
  22. cloudsmith_cli/cli/commands/mcp.py +523 -0
  23. cloudsmith_cli/cli/commands/metadata.py +503 -0
  24. cloudsmith_cli/cli/commands/metrics/__init__.py +2 -0
  25. cloudsmith_cli/cli/commands/metrics/command.py +20 -0
  26. cloudsmith_cli/cli/commands/metrics/entitlements.py +148 -0
  27. cloudsmith_cli/cli/commands/metrics/packages.py +134 -0
  28. cloudsmith_cli/cli/commands/move.py +111 -0
  29. cloudsmith_cli/cli/commands/policy/__init__.py +3 -0
  30. cloudsmith_cli/cli/commands/policy/command.py +20 -0
  31. cloudsmith_cli/cli/commands/policy/deny.py +248 -0
  32. cloudsmith_cli/cli/commands/policy/license.py +335 -0
  33. cloudsmith_cli/cli/commands/policy/vulnerability.py +322 -0
  34. cloudsmith_cli/cli/commands/push.py +1323 -0
  35. cloudsmith_cli/cli/commands/quarantine.py +148 -0
  36. cloudsmith_cli/cli/commands/quota/__init__.py +2 -0
  37. cloudsmith_cli/cli/commands/quota/command.py +20 -0
  38. cloudsmith_cli/cli/commands/quota/history.py +122 -0
  39. cloudsmith_cli/cli/commands/quota/quota.py +107 -0
  40. cloudsmith_cli/cli/commands/repos.py +330 -0
  41. cloudsmith_cli/cli/commands/resync.py +90 -0
  42. cloudsmith_cli/cli/commands/status.py +92 -0
  43. cloudsmith_cli/cli/commands/tags.py +375 -0
  44. cloudsmith_cli/cli/commands/tokens.py +318 -0
  45. cloudsmith_cli/cli/commands/upstream.py +479 -0
  46. cloudsmith_cli/cli/commands/vulnerabilities.py +141 -0
  47. cloudsmith_cli/cli/commands/whoami.py +188 -0
  48. cloudsmith_cli/cli/config.py +635 -0
  49. cloudsmith_cli/cli/decorators.py +624 -0
  50. cloudsmith_cli/cli/exceptions.py +215 -0
  51. cloudsmith_cli/cli/metadata_common.py +146 -0
  52. cloudsmith_cli/cli/saml.py +109 -0
  53. cloudsmith_cli/cli/table.py +59 -0
  54. cloudsmith_cli/cli/types.py +14 -0
  55. cloudsmith_cli/cli/utils.py +267 -0
  56. cloudsmith_cli/cli/validators.py +378 -0
  57. cloudsmith_cli/cli/webserver.py +263 -0
  58. cloudsmith_cli/core/__init__.py +1 -0
  59. cloudsmith_cli/core/api/__init__.py +1 -0
  60. cloudsmith_cli/core/api/distros.py +31 -0
  61. cloudsmith_cli/core/api/entitlements.py +130 -0
  62. cloudsmith_cli/core/api/exceptions.py +57 -0
  63. cloudsmith_cli/core/api/files.py +131 -0
  64. cloudsmith_cli/core/api/init.py +109 -0
  65. cloudsmith_cli/core/api/metadata.py +217 -0
  66. cloudsmith_cli/core/api/metrics.py +78 -0
  67. cloudsmith_cli/core/api/orgs.py +201 -0
  68. cloudsmith_cli/core/api/packages.py +309 -0
  69. cloudsmith_cli/core/api/quota.py +64 -0
  70. cloudsmith_cli/core/api/rates.py +28 -0
  71. cloudsmith_cli/core/api/repos.py +81 -0
  72. cloudsmith_cli/core/api/status.py +27 -0
  73. cloudsmith_cli/core/api/upstreams.py +72 -0
  74. cloudsmith_cli/core/api/user.py +109 -0
  75. cloudsmith_cli/core/api/version.py +15 -0
  76. cloudsmith_cli/core/api/vulnerabilities.py +230 -0
  77. cloudsmith_cli/core/cache_utils.py +160 -0
  78. cloudsmith_cli/core/config.py +140 -0
  79. cloudsmith_cli/core/credentials/__init__.py +0 -0
  80. cloudsmith_cli/core/credentials/chain.py +69 -0
  81. cloudsmith_cli/core/credentials/models.py +44 -0
  82. cloudsmith_cli/core/credentials/oidc/__init__.py +6 -0
  83. cloudsmith_cli/core/credentials/oidc/cache.py +220 -0
  84. cloudsmith_cli/core/credentials/oidc/detectors/__init__.py +122 -0
  85. cloudsmith_cli/core/credentials/oidc/detectors/aws.py +85 -0
  86. cloudsmith_cli/core/credentials/oidc/detectors/azure_devops.py +70 -0
  87. cloudsmith_cli/core/credentials/oidc/detectors/base.py +26 -0
  88. cloudsmith_cli/core/credentials/oidc/detectors/bitbucket_pipelines.py +35 -0
  89. cloudsmith_cli/core/credentials/oidc/detectors/circleci.py +40 -0
  90. cloudsmith_cli/core/credentials/oidc/detectors/generic.py +42 -0
  91. cloudsmith_cli/core/credentials/oidc/detectors/github_actions.py +64 -0
  92. cloudsmith_cli/core/credentials/oidc/detectors/gitlab_ci.py +49 -0
  93. cloudsmith_cli/core/credentials/oidc/exchange.py +87 -0
  94. cloudsmith_cli/core/credentials/provider.py +17 -0
  95. cloudsmith_cli/core/credentials/providers/__init__.py +15 -0
  96. cloudsmith_cli/core/credentials/providers/cli_flag.py +24 -0
  97. cloudsmith_cli/core/credentials/providers/credentials_file.py +24 -0
  98. cloudsmith_cli/core/credentials/providers/env_var.py +24 -0
  99. cloudsmith_cli/core/credentials/providers/keyring_provider.py +59 -0
  100. cloudsmith_cli/core/credentials/providers/oidc_provider.py +115 -0
  101. cloudsmith_cli/core/download.py +594 -0
  102. cloudsmith_cli/core/keyring.py +171 -0
  103. cloudsmith_cli/core/mcp/__init__.py +0 -0
  104. cloudsmith_cli/core/mcp/data.py +17 -0
  105. cloudsmith_cli/core/mcp/server.py +786 -0
  106. cloudsmith_cli/core/pagination.py +131 -0
  107. cloudsmith_cli/core/ratelimits.py +88 -0
  108. cloudsmith_cli/core/rest.py +255 -0
  109. cloudsmith_cli/core/utils.py +95 -0
  110. cloudsmith_cli/core/version.py +20 -0
  111. cloudsmith_cli/credential_helpers/__init__.py +7 -0
  112. cloudsmith_cli/credential_helpers/backends.py +41 -0
  113. cloudsmith_cli/credential_helpers/common.py +111 -0
  114. cloudsmith_cli/credential_helpers/custom_domains.py +281 -0
  115. cloudsmith_cli/credential_helpers/docker/__init__.py +4 -0
  116. cloudsmith_cli/credential_helpers/docker/installer.py +349 -0
  117. cloudsmith_cli/credential_helpers/docker/runtime.py +117 -0
  118. cloudsmith_cli/credential_helpers/launchers.py +175 -0
  119. cloudsmith_cli/data/VERSION +1 -0
  120. cloudsmith_cli/data/config.ini +23 -0
  121. cloudsmith_cli/data/credentials.ini +14 -0
  122. cloudsmith_cli/templates/__init__.py +3 -0
  123. cloudsmith_cli/templates/auth_error.html +45 -0
  124. cloudsmith_cli/templates/auth_success.html +37 -0
  125. cloudsmith_cli-1.20.0.dist-info/METADATA +610 -0
  126. cloudsmith_cli-1.20.0.dist-info/RECORD +130 -0
  127. cloudsmith_cli-1.20.0.dist-info/WHEEL +5 -0
  128. cloudsmith_cli-1.20.0.dist-info/entry_points.txt +2 -0
  129. cloudsmith_cli-1.20.0.dist-info/licenses/LICENSE +201 -0
  130. cloudsmith_cli-1.20.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,148 @@
1
+ """CLI/Commands - Quarantine."""
2
+
3
+ import functools
4
+
5
+ import click
6
+
7
+ from ...core.api import packages as api
8
+ from .. import command, decorators, utils, validators
9
+ from ..exceptions import handle_api_exceptions
10
+ from ..utils import maybe_spinner
11
+ from .main import main
12
+
13
+
14
+ def common_quarantine_options(f):
15
+ """Add common options for quarantine commands."""
16
+
17
+ @decorators.common_cli_config_options
18
+ @decorators.common_cli_list_options
19
+ @decorators.common_cli_output_options
20
+ @decorators.common_api_auth_options
21
+ @decorators.initialise_api
22
+ @click.argument(
23
+ "owner_repo_package",
24
+ metavar="OWNER/REPO/PACKAGE",
25
+ callback=validators.validate_owner_repo_package,
26
+ )
27
+ @click.pass_context
28
+ @functools.wraps(f)
29
+ def wrapper(ctx, *args, **kwargs):
30
+ # pylint: disable=missing-docstring
31
+ return ctx.invoke(f, *args, **kwargs)
32
+
33
+ return wrapper
34
+
35
+
36
+ @main.group(cls=command.AliasGroup, aliases=["block"])
37
+ @decorators.common_cli_config_options
38
+ @decorators.common_cli_output_options
39
+ @decorators.common_api_auth_options
40
+ @decorators.initialise_api
41
+ @click.pass_context
42
+ def quarantine(ctx, opts): # pylint: disable=unused-argument
43
+ """
44
+ Manage quarantined packages in a repository.
45
+
46
+ A quarantined package is not available for download from cloudsmith.
47
+ This functionality is currently in Invitational Beta. Reach out through
48
+ the chat function on the website to get it enabled for testing.
49
+
50
+ See the help for subcommands for more information on each.
51
+ """
52
+
53
+
54
+ def add_quarantine(ctx, opts, owner_repo_package, page, page_size, page_all):
55
+ """
56
+ Add a package to quarantine.
57
+
58
+ A quarantined package is not available for download from cloudsmith.
59
+
60
+ - OWNER/REPO/PACKAGE: Specify the OWNER namespace (i.e. user or org), the
61
+ REPO name where the package is stored, and the PACKAGE name (slug) of the
62
+ package itself. All separated by a slash.
63
+
64
+ Example: 'your-org/awesome-repo/bad-pkg'
65
+
66
+ Full CLI example:
67
+
68
+ $ cloudsmith qu add your-org/awesome-repo/bad-pkg
69
+ """
70
+ owner, repo, slug = owner_repo_package
71
+
72
+ use_stderr = utils.should_use_stderr(opts)
73
+
74
+ click.echo(
75
+ "Adding %(repository)s/%(package_slug)s to quarantine... "
76
+ % {
77
+ "repository": click.style(repo, bold=True),
78
+ "package_slug": click.style(slug, bold=True),
79
+ },
80
+ nl=False,
81
+ err=use_stderr,
82
+ )
83
+
84
+ context_msg = "Failed quarantine!"
85
+ with handle_api_exceptions(ctx, opts=opts, context_msg=context_msg):
86
+ with maybe_spinner(opts):
87
+ api.quarantine_package(owner=owner, repo=repo, identifier=slug)
88
+
89
+ click.secho("OK", fg="green", err=use_stderr)
90
+
91
+ utils.maybe_print_status_json(opts, {"slug": slug, "status": "OK"})
92
+
93
+
94
+ @quarantine.command(name="add")
95
+ @common_quarantine_options
96
+ @functools.wraps(add_quarantine)
97
+ @click.pass_context
98
+ def add(*args, **kwargs): # pylint: disable=missing-docstring
99
+ return add_quarantine(*args, **kwargs)
100
+
101
+
102
+ def remove_quarantine(ctx, opts, owner_repo_package, page, page_size, page_all):
103
+ """
104
+ Remove a package from quarantine.
105
+
106
+ A quarantined package is not available for download from cloudsmith.
107
+
108
+ - OWNER/REPO/PACKAGE: Specify the OWNER namespace (i.e. user or org), the
109
+ REPO name where the package is stored, and the PACKAGE name (slug) of the
110
+ package itself. All separated by a slash.
111
+
112
+ Example: 'your-org/awesome-repo/checked-pkg'
113
+
114
+ Full CLI example:
115
+
116
+ $ cloudsmith qu rm your-org/awesome-repo/checked-pkg
117
+ """
118
+ owner, repo, slug = owner_repo_package
119
+
120
+ # Use stderr for messages if the output is something else (e.g. # JSON)
121
+ use_stderr = utils.should_use_stderr(opts)
122
+
123
+ click.echo(
124
+ "Removing %(repository)s/%(package_slug)s from quarantine... "
125
+ % {
126
+ "repository": click.style(repo, bold=True),
127
+ "package_slug": click.style(slug, bold=True),
128
+ },
129
+ nl=False,
130
+ err=use_stderr,
131
+ )
132
+
133
+ context_msg = "Failed quarantine!"
134
+ with handle_api_exceptions(ctx, opts=opts, context_msg=context_msg):
135
+ with maybe_spinner(opts):
136
+ api.quarantine_restore_package(owner=owner, repo=repo, identifier=slug)
137
+
138
+ click.secho("OK", fg="green", err=use_stderr)
139
+
140
+ utils.maybe_print_status_json(opts, {"slug": slug, "status": "OK"})
141
+
142
+
143
+ @quarantine.command(name="remove", aliases=["rm", "restore"])
144
+ @common_quarantine_options
145
+ @functools.wraps(remove_quarantine)
146
+ @click.pass_context
147
+ def remove(*args, **kwargs): # pylint: disable=missing-docstring
148
+ return remove_quarantine(*args, **kwargs)
@@ -0,0 +1,2 @@
1
+ from .history import usage as history_usage
2
+ from .quota import usage as quota_usage
@@ -0,0 +1,20 @@
1
+ """CLI/Commands - Import all Quota commands."""
2
+
3
+ import click
4
+
5
+ from ... import command, decorators
6
+ from ..main import main
7
+
8
+
9
+ @main.group(cls=command.AliasGroup, name="quota", aliases=[])
10
+ @decorators.common_cli_config_options
11
+ @decorators.common_cli_output_options
12
+ @decorators.common_api_auth_options
13
+ @decorators.initialise_api
14
+ @click.pass_context
15
+ def quota(ctx, opts): # pylink: disable=unused-argument
16
+ """
17
+ Display Quota limits and history for an organisation.
18
+
19
+ See the help for subcommands for more information on each.
20
+ """
@@ -0,0 +1,122 @@
1
+ """CLI/Commands - List Quota History for Namespace."""
2
+
3
+ import click
4
+
5
+ from ....core.api import quota as api
6
+ from ... import decorators, utils, validators
7
+ from ...exceptions import handle_api_exceptions
8
+ from ...utils import maybe_spinner
9
+ from .command import quota
10
+
11
+
12
+ def display_history(opts, data):
13
+ histories = data.history
14
+
15
+ click.echo()
16
+ click.echo(click.style("Quota History", bold=True, fg="white"))
17
+ click.echo(
18
+ "---------------------------------------------------------------", nl=False
19
+ )
20
+
21
+ headers = [
22
+ "Plan",
23
+ "Start",
24
+ "End",
25
+ "Days",
26
+ "Uploaded",
27
+ "Downloaded",
28
+ "Download Limit",
29
+ "Download Used",
30
+ "Storage",
31
+ "Storage Limit",
32
+ "Storage Used",
33
+ ]
34
+
35
+ rows = []
36
+ for history in histories:
37
+ display = getattr(history, "display", {})
38
+ uploaded = getattr(display, "uploaded", {})
39
+ uploaded_used = getattr(uploaded, "used", "")
40
+
41
+ downloaded = getattr(display, "downloaded", {})
42
+ downloaded_used = getattr(downloaded, "used", "")
43
+ downloaded_limit = getattr(downloaded, "limit", "")
44
+ downloaded_percentage = getattr(downloaded, "percentage", "")
45
+
46
+ storage = getattr(display, "storage_used", {})
47
+ storage_used = getattr(storage, "used", "")
48
+ storage_limit = getattr(storage, "limit", "")
49
+ storage_percentage = getattr(storage, "percentage", "")
50
+
51
+ history_start = str(history.start)[0:10]
52
+ history_end = str(history.end)[0:10]
53
+
54
+ rows.append(
55
+ [
56
+ click.style(str(history.plan), fg="green"),
57
+ click.style(history_start, fg="white"),
58
+ click.style(history_end, fg="white"),
59
+ click.style(str(history.days), fg="white"),
60
+ click.style(str(uploaded_used), fg="yellow"),
61
+ click.style(str(downloaded_used), fg="cyan"),
62
+ click.style(str(downloaded_limit), fg="white"),
63
+ click.style(str(downloaded_percentage), fg="white"),
64
+ click.style(str(storage_used), fg="magenta"),
65
+ click.style(str(storage_limit), fg="white"),
66
+ click.style(str(storage_percentage), fg="white"),
67
+ ]
68
+ )
69
+
70
+ click.echo()
71
+ utils.pretty_print_table(headers, rows)
72
+
73
+
74
+ @quota.command(name="history", aliases=[])
75
+ @decorators.common_cli_config_options
76
+ @decorators.common_cli_output_options
77
+ @decorators.common_api_auth_options
78
+ @decorators.initialise_api
79
+ @click.argument(
80
+ "owner", metavar="OWNER", callback=validators.validate_owner, required=True
81
+ )
82
+ @click.option(
83
+ "-oss",
84
+ "--oss",
85
+ default=False,
86
+ is_flag=True,
87
+ help="Shows the open source quota for a namespace",
88
+ )
89
+ @click.pass_context
90
+ def usage(ctx, opts, owner, oss):
91
+ """
92
+ Retrieve Quota history for namespace.
93
+
94
+ This requires appropriate permissions for the owner (a member of the
95
+ organisation and a valid API key).
96
+
97
+ - OWNER: Specify the OWNER namespace (i.e. org)
98
+
99
+ Example: 'your-org'
100
+
101
+ Full CLI example:
102
+
103
+ $ cloudsmith quota history your-org
104
+ """
105
+
106
+ # Use stderr for messages if the output is something else (e.g. # JSON)
107
+ use_stderr = utils.should_use_stderr(opts)
108
+ click.echo("Getting quota ... ", nl=False, err=use_stderr)
109
+
110
+ owner = owner[0]
111
+
112
+ context_msg = "Failed to get quota!"
113
+ with handle_api_exceptions(ctx, opts=opts, context_msg=context_msg):
114
+ with maybe_spinner(opts):
115
+ quota_ = api.quota_history(owner=owner, oss=oss)
116
+
117
+ click.secho("OK", fg="green", err=use_stderr)
118
+
119
+ if utils.maybe_print_as_json(opts, quota_):
120
+ return
121
+
122
+ display_history(opts=opts, data=quota_)
@@ -0,0 +1,107 @@
1
+ """CLI/Commands - Display Quota for Namespace."""
2
+
3
+ import click
4
+
5
+ from ....core.api import quota as api
6
+ from ... import decorators, utils, validators
7
+ from ...exceptions import handle_api_exceptions
8
+ from ...utils import maybe_spinner
9
+ from .command import quota
10
+
11
+
12
+ def display_quota(opts, data):
13
+ """Display Quota usage as a table."""
14
+ display = getattr(data.usage, "display", {})
15
+ bandwidth = getattr(display, "bandwidth", {})
16
+ storage = getattr(display, "storage", {})
17
+
18
+ click.echo()
19
+ click.echo(click.style("Bandwidth Quota", bold=True, fg="white"))
20
+ click.echo(
21
+ "---------------------------------------------------------------", nl=False
22
+ )
23
+
24
+ headers = ["Bandwidth Used", "Configured", "Plan Limit", "Total Used"]
25
+ rows = []
26
+ rows.append(
27
+ [
28
+ click.style(str(getattr(bandwidth, "used", "")), fg="white"),
29
+ click.style(str(getattr(bandwidth, "configured", "")), fg="white"),
30
+ click.style(str(getattr(bandwidth, "plan_limit", "")), fg="white"),
31
+ click.style(str(getattr(bandwidth, "percentage_used", "")), fg="white"),
32
+ ]
33
+ )
34
+ click.echo()
35
+ utils.pretty_print_table(headers, rows)
36
+
37
+ click.echo()
38
+ click.echo(click.style("Storage Quota", bold=True, fg="white"))
39
+ click.echo(
40
+ "---------------------------------------------------------------", nl=False
41
+ )
42
+
43
+ headers = ["Storage Used", "Configured", "Plan Limit", "Total Used"]
44
+ rows = []
45
+ rows.append(
46
+ [
47
+ click.style(str(getattr(storage, "used", "")), fg="white"),
48
+ click.style(str(getattr(storage, "configured", "")), fg="white"),
49
+ click.style(str(getattr(storage, "plan_limit", "")), fg="white"),
50
+ click.style(str(getattr(storage, "percentage_used", "")), fg="white"),
51
+ ]
52
+ )
53
+ click.echo()
54
+ utils.pretty_print_table(headers, rows)
55
+
56
+ click.echo()
57
+
58
+
59
+ @quota.command(name="limits", aliases=[])
60
+ @decorators.common_cli_config_options
61
+ @decorators.common_cli_output_options
62
+ @decorators.common_api_auth_options
63
+ @decorators.initialise_api
64
+ @click.argument(
65
+ "owner", metavar="OWNER", callback=validators.validate_owner, required=True
66
+ )
67
+ @click.option(
68
+ "-oss",
69
+ "--oss",
70
+ default=False,
71
+ is_flag=True,
72
+ help="Shows the open source quota for a namespace",
73
+ )
74
+ @click.pass_context
75
+ def usage(ctx, opts, owner, oss):
76
+ """
77
+ Retrieve Quota limits.
78
+
79
+ This requires appropriate permissions for the owner (a member of the
80
+ organisation and a valid API key).
81
+
82
+ - OWNER: Specify the OWNER namespace (i.e. org)
83
+
84
+ Example: 'your-org'
85
+
86
+ Full CLI example:
87
+
88
+ $ cloudsmith quota limits your-org
89
+ """
90
+
91
+ # Use stderr for messages if the output is something else (e.g. # JSON)
92
+ use_stderr = utils.should_use_stderr(opts)
93
+ click.echo("Getting quota ... ", nl=False, err=use_stderr)
94
+
95
+ owner = owner[0]
96
+
97
+ context_msg = "Failed to get quota!"
98
+ with handle_api_exceptions(ctx, opts=opts, context_msg=context_msg):
99
+ with maybe_spinner(opts):
100
+ quota_ = api.quota_limits(owner=owner, oss=oss)
101
+
102
+ click.secho("OK", fg="green", err=use_stderr)
103
+
104
+ if utils.maybe_print_as_json(opts, quota_):
105
+ return
106
+
107
+ display_quota(opts=opts, data=quota_)