Skip to content

Commit

Permalink
Release v0.23.2 [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
semantic-release-bot committed Apr 4, 2024
1 parent 9233cf2 commit 91575be
Show file tree
Hide file tree
Showing 11 changed files with 170 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "qcs-api-client"
version = "0.23.1"
version = "0.23.2"
description = "A client library for accessing the Rigetti QCS API"
license = "Apache-2.0"
repository = "https://github.com/rigetti/qcs-api-client-python"
Expand Down
2 changes: 1 addition & 1 deletion qcs_api_client/api/default/health_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def _get_kwargs(
*,
client: httpx.Client,
) -> Dict[str, Any]:
url = "{}/v1/".format(client.base_url)
url = "{}/v1/healthcheck".format(client.base_url)

headers = {k: v for (k, v) in client.headers.items()}
cookies = {k: v for (k, v) in client.cookies}
Expand Down
130 changes: 130 additions & 0 deletions qcs_api_client/api/default/health_check_deprecated.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
from typing import Any, Dict, cast

import httpx
from retrying import retry

from ...types import Response
from ...util.errors import QCSHTTPStatusError, raise_for_status
from ...util.retry import DEFAULT_RETRY_ARGUMENTS


def _get_kwargs(
*,
client: httpx.Client,
) -> Dict[str, Any]:
url = "{}/v1/".format(client.base_url)

headers = {k: v for (k, v) in client.headers.items()}
cookies = {k: v for (k, v) in client.cookies}

return {
"method": "get",
"url": url,
"headers": headers,
"cookies": cookies,
"timeout": client.timeout,
}


def _parse_response(*, response: httpx.Response) -> Any:
raise_for_status(response)
if response.status_code == 200:
response_200 = cast(Any, response.json())
return response_200
else:
raise QCSHTTPStatusError(
f"Unexpected response: status code {response.status_code}", response=response, error=None
)


def _build_response(*, response: httpx.Response) -> Response[Any]:
"""
Construct the Response class from the raw ``httpx.Response``.
"""
return Response.build_from_httpx_response(response=response, parse_function=_parse_response)


@retry(**DEFAULT_RETRY_ARGUMENTS)
def sync(
*,
client: httpx.Client,
httpx_request_kwargs: Dict[str, Any] = {},
) -> Response[Any]:
"""Health Check
Endpoint to return a status 200 for load balancer health checks
Returns:
Response[Any]
"""

kwargs = _get_kwargs(
client=client,
)
kwargs.update(httpx_request_kwargs)
response = client.request(
**kwargs,
)

return _build_response(response=response)


@retry(**DEFAULT_RETRY_ARGUMENTS)
def sync_from_dict(
*,
client: httpx.Client,
httpx_request_kwargs: Dict[str, Any] = {},
) -> Response[Any]:

kwargs = _get_kwargs(
client=client,
)
kwargs.update(httpx_request_kwargs)
response = client.request(
**kwargs,
)

return _build_response(response=response)


@retry(**DEFAULT_RETRY_ARGUMENTS)
async def asyncio(
*,
client: httpx.AsyncClient,
httpx_request_kwargs: Dict[str, Any] = {},
) -> Response[Any]:
"""Health Check
Endpoint to return a status 200 for load balancer health checks
Returns:
Response[Any]
"""

kwargs = _get_kwargs(
client=client,
)
kwargs.update(httpx_request_kwargs)
response = await client.request(
**kwargs,
)

return _build_response(response=response)


@retry(**DEFAULT_RETRY_ARGUMENTS)
async def asyncio_from_dict(
*,
client: httpx.AsyncClient,
httpx_request_kwargs: Dict[str, Any] = {},
) -> Response[Any]:

kwargs = _get_kwargs(
client=client,
)
kwargs.update(httpx_request_kwargs)
response = client.request(
**kwargs,
)

return _build_response(response=response)
2 changes: 2 additions & 0 deletions qcs_api_client/client/_configuration/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class QCSClientConfigurationSettingsProfile(EnvironmentModel):
auth_server_name: str = "default"
"""Which of the configured ``QCSClientConfigurationSettings.auth_servers`` to use"""

grpc_api_url: HttpUrl = "https://grpc.qcs.rigetti.com"

applications: QCSClientConfigurationSettingsApplications = Field(
default_factory=QCSClientConfigurationSettingsApplications
)
Expand Down
27 changes: 27 additions & 0 deletions qcs_api_client/models/reservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class Reservation:
user_id (str): Deprecated in favor of `accountId`.
cancellation_billing_invoice_item_id (Union[Unset, str]):
cancelled (Union[Unset, bool]):
created_by_account_id (Union[Unset, str]): userId for `accountType` "user", group name for `accountType`
"group".
created_by_account_type (Union[Unset, AccountType]): There are two types of accounts within QCS: user
(representing a single user in Okta) and group
(representing one or more users in Okta).
creation_billing_invoice_item_id (Union[Unset, str]):
notes (Union[Unset, str]):
updated_time (Union[Unset, datetime.datetime]):
Expand All @@ -45,6 +50,8 @@ class Reservation:
user_id: str
cancellation_billing_invoice_item_id: Union[Unset, str] = UNSET
cancelled: Union[Unset, bool] = UNSET
created_by_account_id: Union[Unset, str] = UNSET
created_by_account_type: Union[Unset, AccountType] = UNSET
creation_billing_invoice_item_id: Union[Unset, str] = UNSET
notes: Union[Unset, str] = UNSET
updated_time: Union[Unset, datetime.datetime] = UNSET
Expand All @@ -69,6 +76,11 @@ def to_dict(self, pick_by_predicate: Optional[Callable[[Any], bool]] = is_not_no
user_id = self.user_id
cancellation_billing_invoice_item_id = self.cancellation_billing_invoice_item_id
cancelled = self.cancelled
created_by_account_id = self.created_by_account_id
created_by_account_type: Union[Unset, str] = UNSET
if not isinstance(self.created_by_account_type, Unset):
created_by_account_type = self.created_by_account_type.value

creation_billing_invoice_item_id = self.creation_billing_invoice_item_id
notes = self.notes
updated_time: Union[Unset, str] = UNSET
Expand All @@ -94,6 +106,10 @@ def to_dict(self, pick_by_predicate: Optional[Callable[[Any], bool]] = is_not_no
field_dict["cancellationBillingInvoiceItemId"] = cancellation_billing_invoice_item_id
if cancelled is not UNSET:
field_dict["cancelled"] = cancelled
if created_by_account_id is not UNSET:
field_dict["createdByAccountId"] = created_by_account_id
if created_by_account_type is not UNSET:
field_dict["createdByAccountType"] = created_by_account_type
if creation_billing_invoice_item_id is not UNSET:
field_dict["creationBillingInvoiceItemId"] = creation_billing_invoice_item_id
if notes is not UNSET:
Expand Down Expand Up @@ -132,6 +148,15 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:

cancelled = d.pop("cancelled", UNSET)

created_by_account_id = d.pop("createdByAccountId", UNSET)

_created_by_account_type = d.pop("createdByAccountType", UNSET)
created_by_account_type: Union[Unset, AccountType]
if isinstance(_created_by_account_type, Unset):
created_by_account_type = UNSET
else:
created_by_account_type = AccountType(_created_by_account_type)

creation_billing_invoice_item_id = d.pop("creationBillingInvoiceItemId", UNSET)

notes = d.pop("notes", UNSET)
Expand All @@ -155,6 +180,8 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
user_id=user_id,
cancellation_billing_invoice_item_id=cancellation_billing_invoice_item_id,
cancelled=cancelled,
created_by_account_id=created_by_account_id,
created_by_account_type=created_by_account_type,
creation_billing_invoice_item_id=creation_billing_invoice_item_id,
notes=notes,
updated_time=updated_time,
Expand Down
1 change: 1 addition & 0 deletions qcs_api_client/operations/asyncio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from qcs_api_client.api.client_applications.list_client_applications import asyncio as list_client_applications
from qcs_api_client.api.default.get_health import asyncio as get_health
from qcs_api_client.api.default.health_check import asyncio as health_check
from qcs_api_client.api.default.health_check_deprecated import asyncio as health_check_deprecated
from qcs_api_client.api.endpoints.create_endpoint import asyncio as create_endpoint
from qcs_api_client.api.endpoints.delete_endpoint import asyncio as delete_endpoint
from qcs_api_client.api.endpoints.get_default_endpoint import asyncio as get_default_endpoint
Expand Down
1 change: 1 addition & 0 deletions qcs_api_client/operations/asyncio_from_dict/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
)
from qcs_api_client.api.default.get_health import asyncio_from_dict as get_health
from qcs_api_client.api.default.health_check import asyncio_from_dict as health_check
from qcs_api_client.api.default.health_check_deprecated import asyncio_from_dict as health_check_deprecated
from qcs_api_client.api.endpoints.create_endpoint import asyncio_from_dict as create_endpoint
from qcs_api_client.api.endpoints.delete_endpoint import asyncio_from_dict as delete_endpoint
from qcs_api_client.api.endpoints.get_default_endpoint import asyncio_from_dict as get_default_endpoint
Expand Down
1 change: 1 addition & 0 deletions qcs_api_client/operations/sync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from qcs_api_client.api.client_applications.list_client_applications import sync as list_client_applications
from qcs_api_client.api.default.get_health import sync as get_health
from qcs_api_client.api.default.health_check import sync as health_check
from qcs_api_client.api.default.health_check_deprecated import sync as health_check_deprecated
from qcs_api_client.api.endpoints.create_endpoint import sync as create_endpoint
from qcs_api_client.api.endpoints.delete_endpoint import sync as delete_endpoint
from qcs_api_client.api.endpoints.get_default_endpoint import sync as get_default_endpoint
Expand Down
1 change: 1 addition & 0 deletions qcs_api_client/operations/sync_from_dict/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from qcs_api_client.api.client_applications.list_client_applications import sync_from_dict as list_client_applications
from qcs_api_client.api.default.get_health import sync_from_dict as get_health
from qcs_api_client.api.default.health_check import sync_from_dict as health_check
from qcs_api_client.api.default.health_check_deprecated import sync_from_dict as health_check_deprecated
from qcs_api_client.api.endpoints.create_endpoint import sync_from_dict as create_endpoint
from qcs_api_client.api.endpoints.delete_endpoint import sync_from_dict as delete_endpoint
from qcs_api_client.api.endpoints.get_default_endpoint import sync_from_dict as get_default_endpoint
Expand Down
1 change: 1 addition & 0 deletions tests/__fixtures__/settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ default_profile_name = "staging1"
[profiles.staging1]
auth_server_name = "staging"
api_url = "https://api.staging.qcs.rigetti.com"
grpc_api_url = "https://grpc.staging.qcs.rigetti.com"
credentials_name = "staging1"
[profiles.staging1.applications]
cli = {verbosity = "info"}
Expand Down
4 changes: 4 additions & 0 deletions tests/test_client/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def test_settings_file_does_not_exist(fixture_directory: Path):
)
assert client_configuration.auth_server.client_id == _DEFAULT_AUTH_SERVER.client_id
assert client_configuration.auth_server.issuer == _DEFAULT_AUTH_SERVER.issuer
assert client_configuration.profile.grpc_api_url == "https://grpc.qcs.rigetti.com"

assert client_configuration.profile_name == "default"
assert client_configuration.credentials.refresh_token == "refresh"
Expand All @@ -105,6 +106,7 @@ def test_secrets_file_does_not_exist(fixture_directory: Path):

client_configuration.profile.api_url = MOCK_URL
client_configuration.profile.credentials_name = "default"
client_configuration.profile.grpc_api_url = "https://grpc.staging.qcs.rigetti.com/"

assert client_configuration.credentials.token_payload is None
assert client_configuration.credentials.access_token is None
Expand All @@ -118,13 +120,15 @@ def test_env_overrides(monkeypatch):
monkeypatch.setenv("QCS_SECRETS_FILE_PATH", "secrets-path.file")
monkeypatch.setenv("QCS_SETTINGS_FILE_PATH", "settings-path.file")
monkeypatch.setenv("QCS_SETTINGS_API_URL", "http://api.mock")
monkeypatch.setenv("QCS_SETTINGS_GRPC_API_URL", "http://grpc.mock")
monkeypatch.setenv("QCS_SETTINGS_APPLICATIONS_CLI_VERBOSITY", "fatal")

client_configuration = QCSClientConfiguration.load()

assert client_configuration.secrets.file_path == Path("secrets-path.file")
assert client_configuration.settings.file_path == Path("settings-path.file")
assert client_configuration.profile.api_url == "http://api.mock"
assert client_configuration.profile.grpc_api_url == "http://grpc.mock"
assert client_configuration.profile.applications.cli.verbosity == "fatal"


Expand Down

0 comments on commit 91575be

Please sign in to comment.