MCPcopy Create free account
hub / github.com/dwavesystems/dwave-cloud-client / list_leap_projects

Function list_leap_projects

dwave/cloud/cli.py:1140–1158  ·  view source on GitHub ↗

List available Leap projects.

(*, config_file, profile, json_output, output)

Source from the content-addressed store, hash-verified

1138@json_output
1139@standardized_output
1140def list_leap_projects(*, config_file, profile, json_output, output):
1141 """List available Leap projects."""
1142
1143 config = validate_config_v1(load_config(config_file=config_file, profile=profile))
1144
1145 with LeapAuthFlow.from_config_model(config) as flow:
1146 if not flow.token or 'access_token' not in flow.token:
1147 raise CLIError('Leap API access token not found. Please run "dwave auth login".', code=100)
1148
1149 if flow.token_expires_soon(within=60):
1150 output("Access token expired (or expires soon), refreshing it.")
1151 flow.refresh_token()
1152
1153 with api.LeapAccount.from_config(config=flow.config,
1154 token=flow.token.get('access_token')) as account:
1155 projects = account.list_projects()
1156 output("Leap projects:", projects=[p.model_dump() for p in projects])
1157 for project in projects:
1158 output(f" - {project.name} (code={project.code!r}, id={project.id})")
1159
1160
1161@project.command(name='token')

Callers

nothing calls this directly

Calls 10

validate_config_v1Function · 0.90
load_configFunction · 0.90
CLIErrorClass · 0.90
outputFunction · 0.85
token_expires_soonMethod · 0.80
refresh_tokenMethod · 0.80
list_projectsMethod · 0.80
from_config_modelMethod · 0.45
from_configMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected