wy_qcos_client package

Subpackages

Submodules

wy_qcos_client.client module

class wy_qcos_client.client.SSL

基类:object

SSL configs.

use_ssl = False
cert_file = None
key_file = None
ca_file = None
class wy_qcos_client.client.Client(api_server_ip=Constant.DEFAULT_API_SERVER_LISTEN_IP, api_server_port=Constant.DEFAULT_API_SERVER_LISTEN_PORT, use_ssl=False, ssl_certfile=None, ssl_keyfile=None, ssl_cafile=None, timeout=30)

基类:object

QCOS client api.

verbose = False
timeout = 30
static print_api_response(status_code, reason, text, result=None)

Print API response.

参数:
  • status_code -- status code

  • reason -- reason

  • text -- text

  • result -- result text (Default value = None)

set_token(token)

Set JWT access token for subsequent requests.

参数:

token -- JWT access token string

get_token()

Get current JWT token.

返回:

Current JWT access token or None

clear_token()

Clear stored JWT token.

call_json_rpc(url, method_name, data=None, params=None)

Call json-rpc.

参数:
  • url -- json-rpc url

  • method_name -- json-rpc method

  • data -- json-rpc data (Default value = None)

  • params -- json-rpc params (Default value = None)

static parse_jsonrpc_response(jsonrpc_response)

Parse json-rpc response.

参数:

jsonrpc_response -- json-rpc response

static handle_invalid_arguments(results)

Handle invalid arguments.

参数:

results -- results

version()

Get all api versions and capabilities.

返回:

Version

get_drivers()

Get driver list.

返回:

Driver list message

get_driver(driver_name)

Get driver info.

参数:

driver_name -- driver name

返回:

driver info

get_devices()

Get device list.

返回:

Device list message

get_device(device_name, details=False)

Get device info.

参数:
  • device_name -- device name

  • details -- need details information or not

返回:

device info

calibrate_device(device_name, options=None)

Calibrate device.

参数:
  • device_name -- device name

  • options -- calibration options

get_calibrate_results(device_name)

Get calibrate results.

参数:

device_name -- device name

set_device_options(device_name, options=None)

Set device options.

参数:
  • device_name -- device name

  • options -- device options

get_device_options(device_name)

Get device options.

参数:

device_name -- device name

返回:

status_code, reason, text, result

get_transpilers()

Get transpiler list.

返回:

Transpiler list message

get_transpiler(transpiler_name)

Get transpiler info.

参数:

transpiler_name -- transpiler name

返回:

transpiler info

ping(message)

Ping-pong to verify the availability of the system.

参数:

message -- Ping message

返回:

Pong message

system_info()

Get system info.

返回:

System info

submit_job(source_code, *, circuit_aggregation=None, code_type=Constant.CODE_TYPE_QASM, job_id=None, job_name=None, job_type=Constant.JOB_TYPE_SAMPLING, job_priority=Constant.DEFAULT_JOB_PRIORITY, description=None, shots=Constant.DEFAULT_SHOTS, backend=Constant.DRIVER_DUMMY, driver_options=None, transpiler=Constant.TRANSPILER_CMSS, transpiler_options=None, profiling=None, callbacks=None, dry_run=False)

Submit new job.

参数:
  • source_code -- source code

  • code_type -- code type

  • circuit_aggregation -- circuit aggregation

  • job_id -- job uuid

  • job_name -- job name

  • job_type -- job type

  • job_priority -- job priority. Values: 1-10, Default: 5. Highest priority: 1, Lowest Priority: 10

  • description -- job description

  • shots -- shots

  • backend -- backend name

  • driver_options -- driver options

  • transpiler -- transpiler name

  • transpiler_options -- transpiler options

  • profiling -- profiling types

  • callbacks -- callbacks

  • dry_run -- dry run

返回:

submit_job result

get_job_status(job_id)

Get job status.

参数:

job_id -- job ID

返回:

job status

get_job_results(job_id)

Get job results.

参数:

job_id -- job ID

返回:

job results

get_jobs()

Get job status.

返回:

job status

cancel_jobs(job_ids)

Cancel jobs.

参数:

job_ids -- job IDs

返回:

jobs

delete_jobs(job_ids)

Delete jobs.

参数:

job_ids -- job IDs

返回:

jobs

set_job_results(job_id, new_results)

Set job results.

参数:
  • job_id -- job ID

  • new_results -- new results list to set

返回:

jobs

update_job(job_id=None, job_priority=Constant.DEFAULT_JOB_PRIORITY)

Update job.

参数:
  • job_id -- job uuid

  • job_priority -- job priority. Values: 1-10, Default: 5. Highest priority: 1, Lowest Priority: 10

返回:

update_job result

static resolve_user_id(client, user_identifier)

Resolve user_id from either UUID or user_name.

If user_identifier is a valid UUID, return it directly. Otherwise, treat it as a user_name and fetch the user_id from server.

参数:
  • client -- The QCOS client instance

  • user_identifier -- Either a user UUID or user name

返回:

The user UUID

static resolve_role_id(client, role_identifier)

Resolve role_id from either UUID or role_name.

If role_identifier is a valid UUID, return it directly. Otherwise, treat it as a role_name and fetch the role_id from server.

参数:
  • client -- The QCOS client instance

  • role_identifier -- Either a role UUID or role name

返回:

The role UUID

get_user_mgmt()

Get user management settings.

返回:

status_code, reason, text, result

set_user_mgmt(auth_mode)

Set user management authentication mode.

参数:

auth_mode -- Authentication mode ('no', 'jwt', or 'virtual_instance')

返回:

status_code, reason, text, result

create_user(user_name, password, roles, description=None, password_expiry_days=None, is_enabled=True, is_locked=True)

Create user.

get_user(user_id)

Get user by ID.

参数:

user_id -- User ID (UUID)

update_user(user_id, roles=None, description=None, password_expiry_days=None, is_enabled=None, is_locked=None)

Update user by ID.

参数:
  • user_id -- User ID (UUID)

  • roles -- List of role names to assign

  • description -- User description

  • password_expiry_days -- Number of days until password expires

  • is_enabled -- Whether user account is enabled

  • is_locked -- Whether user account is locked

delete_user(user_id, force=False)

Delete user by ID.

参数:
  • user_id -- User ID (UUID)

  • force -- Force delete user and cascade delete related resources

get_users(filters=None)

Get users with optional filtering.

参数:

filters -- Optional filter conditions dictionary

create_role(role_name, permissions, description=None)

Create role.

get_role(role_id)

Get role by ID.

参数:

role_id -- Role ID (UUID)

update_role(role_id, permissions=None, description=None)

Update role by ID.

参数:
  • role_id -- Role ID (UUID)

  • permissions -- List of permission strings

  • description -- Role description

delete_role(role_id)

Delete role by ID.

参数:

role_id -- Role ID (UUID)

get_roles(filters=None)

Get roles with optional filtering.

参数:

filters -- Optional dict with filter conditions, e.g. {'role_name': 'admin'}

change_password(user_id, old_password, new_password)

Change password for user by ID.

参数:
  • user_id -- User ID (UUID)

  • old_password -- Current password

  • new_password -- New password to set

get_login_logs(user_id=None, user_name=None, limit=100, offset=0)

Get login logs by user ID or user_name.

参数:
  • user_id -- User ID (UUID) to filter logs (optional)

  • user_name -- User name to filter logs (optional)

  • limit -- Maximum number of logs to return (default: 100)

  • offset -- Number of logs to skip (default: 0)

clear_login_logs(user_id=None, user_name=None)

Clear login logs (all or for a specific user).

参数:
  • user_id -- User ID (UUID) to clear logs for (optional)

  • user_name -- User name to clear logs for (optional)

返回:

Number of logs cleared

login(username, password)

User login to get JWT tokens.

This method implements the standard JWT login pattern: - Sends username and password to the server - Receives access_token (short-lived) and refresh_token (long-lived) - Stores both tokens for subsequent requests

参数:
  • username -- Username for authentication

  • password -- Password for authentication

返回:

Login response with JWT access and refresh tokens

logout()

User logout.

返回:

Logout response

refresh_token()

Refresh JWT token using refresh_token.

This method implements the standard JWT refresh token pattern: - Sends the stored refresh_token to the server - Receives new access_token and refresh_token - Updates stored tokens

返回:

Token refresh response with new JWT access and refresh tokens

get_me()

Get current authenticated user info.

返回:

Current user information

get_system_health()

Get system health status.

返回:

System health status

get_api_stats()

Get API access statistics.

返回:

API statistics including total requests, last hour and last day counts

get_job_stats()

Get job statistics.

返回:

Job statistics including total, success, failed, running, etc.

wy_qcos_client.shell module

Module contents