Skip to content

Commit

Permalink
add more properties to environmets
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbroks committed Nov 13, 2024
1 parent 69ef0db commit bffc341
Show file tree
Hide file tree
Showing 16 changed files with 605 additions and 86 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ client = Client(base_url="https://api.example.com")
If the endpoints you're going to hit require authentication, use `AuthenticatedClient` instead:

```python
from ctrlplane_api_client import AuthenticatedClient
from ctrlplane import AuthenticatedClient

client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken")
```

Now call your endpoint and use your models:

```python
from ctrlplane_api_client.models import MyDataModel
from ctrlplane_api_client.api.my_tag import get_my_data_model
from ctrlplane_api_client.types import Response
from ctrlplane.models import MyDataModel
from ctrlplane.api.my_tag import get_my_data_model
from ctrlplane.types import Response

with client as client:
my_data: MyDataModel = get_my_data_model.sync(client=client)
Expand All @@ -36,9 +36,9 @@ with client as client:
Or do the same thing with an async version:

```python
from ctrlplane_api_client.models import MyDataModel
from ctrlplane_api_client.api.my_tag import get_my_data_model
from ctrlplane_api_client.types import Response
from ctrlplane.models import MyDataModel
from ctrlplane.api.my_tag import get_my_data_model
from ctrlplane.types import Response

async with client as client:
my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
Expand Down Expand Up @@ -76,7 +76,7 @@ Things to know:

1. All path/query params, and bodies become method arguments.
1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)
1. Any endpoint which did not have a tag will be in `ctrlplane_api_client.api.default`
1. Any endpoint which did not have a tag will be in `ctrlplane.api.default`

## Advanced customizations

Expand Down
2 changes: 1 addition & 1 deletion ctrlplane/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .client import AuthenticatedClient, Client


__version__ = "0.1.0"
__version__ = "0.1.1"


__all__ = (
Expand Down
25 changes: 15 additions & 10 deletions ctrlplane/api/default/create_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from ...client import AuthenticatedClient, Client
from ...models.create_environment_body import CreateEnvironmentBody
from ...models.create_environment_response_200 import CreateEnvironmentResponse200
from ...models.create_environment_response_409 import CreateEnvironmentResponse409
from ...models.create_environment_response_500 import CreateEnvironmentResponse500
from ...types import Response

Expand All @@ -33,11 +34,15 @@ def _get_kwargs(

def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[CreateEnvironmentResponse200, CreateEnvironmentResponse500]]:
) -> Optional[Union[CreateEnvironmentResponse200, CreateEnvironmentResponse409, CreateEnvironmentResponse500]]:
if response.status_code == 200:
response_200 = CreateEnvironmentResponse200.from_dict(response.json())

return response_200
if response.status_code == 409:
response_409 = CreateEnvironmentResponse409.from_dict(response.json())

return response_409
if response.status_code == 500:
response_500 = CreateEnvironmentResponse500.from_dict(response.json())

Expand All @@ -50,7 +55,7 @@ def _parse_response(

def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[Union[CreateEnvironmentResponse200, CreateEnvironmentResponse500]]:
) -> Response[Union[CreateEnvironmentResponse200, CreateEnvironmentResponse409, CreateEnvironmentResponse500]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
Expand All @@ -63,7 +68,7 @@ def sync_detailed(
*,
client: Union[AuthenticatedClient, Client],
body: CreateEnvironmentBody,
) -> Response[Union[CreateEnvironmentResponse200, CreateEnvironmentResponse500]]:
) -> Response[Union[CreateEnvironmentResponse200, CreateEnvironmentResponse409, CreateEnvironmentResponse500]]:
"""Create an environment
Args:
Expand All @@ -74,7 +79,7 @@ def sync_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
Response[Union[CreateEnvironmentResponse200, CreateEnvironmentResponse500]]
Response[Union[CreateEnvironmentResponse200, CreateEnvironmentResponse409, CreateEnvironmentResponse500]]
"""

kwargs = _get_kwargs(
Expand All @@ -92,7 +97,7 @@ def sync(
*,
client: Union[AuthenticatedClient, Client],
body: CreateEnvironmentBody,
) -> Optional[Union[CreateEnvironmentResponse200, CreateEnvironmentResponse500]]:
) -> Optional[Union[CreateEnvironmentResponse200, CreateEnvironmentResponse409, CreateEnvironmentResponse500]]:
"""Create an environment
Args:
Expand All @@ -103,7 +108,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
Union[CreateEnvironmentResponse200, CreateEnvironmentResponse500]
Union[CreateEnvironmentResponse200, CreateEnvironmentResponse409, CreateEnvironmentResponse500]
"""

return sync_detailed(
Expand All @@ -116,7 +121,7 @@ async def asyncio_detailed(
*,
client: Union[AuthenticatedClient, Client],
body: CreateEnvironmentBody,
) -> Response[Union[CreateEnvironmentResponse200, CreateEnvironmentResponse500]]:
) -> Response[Union[CreateEnvironmentResponse200, CreateEnvironmentResponse409, CreateEnvironmentResponse500]]:
"""Create an environment
Args:
Expand All @@ -127,7 +132,7 @@ async def asyncio_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
Response[Union[CreateEnvironmentResponse200, CreateEnvironmentResponse500]]
Response[Union[CreateEnvironmentResponse200, CreateEnvironmentResponse409, CreateEnvironmentResponse500]]
"""

kwargs = _get_kwargs(
Expand All @@ -143,7 +148,7 @@ async def asyncio(
*,
client: Union[AuthenticatedClient, Client],
body: CreateEnvironmentBody,
) -> Optional[Union[CreateEnvironmentResponse200, CreateEnvironmentResponse500]]:
) -> Optional[Union[CreateEnvironmentResponse200, CreateEnvironmentResponse409, CreateEnvironmentResponse500]]:
"""Create an environment
Args:
Expand All @@ -154,7 +159,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
Union[CreateEnvironmentResponse200, CreateEnvironmentResponse500]
Union[CreateEnvironmentResponse200, CreateEnvironmentResponse409, CreateEnvironmentResponse500]
"""

return (
Expand Down
101 changes: 73 additions & 28 deletions ctrlplane/api/default/create_release_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@
from ...models.create_release_channel_response_200 import CreateReleaseChannelResponse200
from ...models.create_release_channel_response_401 import CreateReleaseChannelResponse401
from ...models.create_release_channel_response_403 import CreateReleaseChannelResponse403
from ...models.create_release_channel_response_409 import CreateReleaseChannelResponse409
from ...models.create_release_channel_response_500 import CreateReleaseChannelResponse500
from ...types import Response


def _get_kwargs(
deployment_id: str,
*,
body: CreateReleaseChannelBody,
) -> Dict[str, Any]:
headers: Dict[str, Any] = {}

_kwargs: Dict[str, Any] = {
"method": "post",
"url": f"/v1/deployments/{deployment_id}/release-channels",
"url": "/v1/release-channels",
}

_body = body.to_dict()
Expand All @@ -35,7 +36,15 @@ def _get_kwargs(

def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[CreateReleaseChannelResponse200, CreateReleaseChannelResponse401, CreateReleaseChannelResponse403]]:
) -> Optional[
Union[
CreateReleaseChannelResponse200,
CreateReleaseChannelResponse401,
CreateReleaseChannelResponse403,
CreateReleaseChannelResponse409,
CreateReleaseChannelResponse500,
]
]:
if response.status_code == 200:
response_200 = CreateReleaseChannelResponse200.from_dict(response.json())

Expand All @@ -48,6 +57,14 @@ def _parse_response(
response_403 = CreateReleaseChannelResponse403.from_dict(response.json())

return response_403
if response.status_code == 409:
response_409 = CreateReleaseChannelResponse409.from_dict(response.json())

return response_409
if response.status_code == 500:
response_500 = CreateReleaseChannelResponse500.from_dict(response.json())

return response_500
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
Expand All @@ -56,7 +73,15 @@ def _parse_response(

def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[Union[CreateReleaseChannelResponse200, CreateReleaseChannelResponse401, CreateReleaseChannelResponse403]]:
) -> Response[
Union[
CreateReleaseChannelResponse200,
CreateReleaseChannelResponse401,
CreateReleaseChannelResponse403,
CreateReleaseChannelResponse409,
CreateReleaseChannelResponse500,
]
]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
Expand All @@ -66,27 +91,32 @@ def _build_response(


def sync_detailed(
deployment_id: str,
*,
client: Union[AuthenticatedClient, Client],
client: AuthenticatedClient,
body: CreateReleaseChannelBody,
) -> Response[Union[CreateReleaseChannelResponse200, CreateReleaseChannelResponse401, CreateReleaseChannelResponse403]]:
) -> Response[
Union[
CreateReleaseChannelResponse200,
CreateReleaseChannelResponse401,
CreateReleaseChannelResponse403,
CreateReleaseChannelResponse409,
CreateReleaseChannelResponse500,
]
]:
"""Create a release channel
Args:
deployment_id (str):
body (CreateReleaseChannelBody):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
Response[Union[CreateReleaseChannelResponse200, CreateReleaseChannelResponse401, CreateReleaseChannelResponse403]]
Response[Union[CreateReleaseChannelResponse200, CreateReleaseChannelResponse401, CreateReleaseChannelResponse403, CreateReleaseChannelResponse409, CreateReleaseChannelResponse500]]
"""

kwargs = _get_kwargs(
deployment_id=deployment_id,
body=body,
)

Expand All @@ -98,54 +128,64 @@ def sync_detailed(


def sync(
deployment_id: str,
*,
client: Union[AuthenticatedClient, Client],
client: AuthenticatedClient,
body: CreateReleaseChannelBody,
) -> Optional[Union[CreateReleaseChannelResponse200, CreateReleaseChannelResponse401, CreateReleaseChannelResponse403]]:
) -> Optional[
Union[
CreateReleaseChannelResponse200,
CreateReleaseChannelResponse401,
CreateReleaseChannelResponse403,
CreateReleaseChannelResponse409,
CreateReleaseChannelResponse500,
]
]:
"""Create a release channel
Args:
deployment_id (str):
body (CreateReleaseChannelBody):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
Union[CreateReleaseChannelResponse200, CreateReleaseChannelResponse401, CreateReleaseChannelResponse403]
Union[CreateReleaseChannelResponse200, CreateReleaseChannelResponse401, CreateReleaseChannelResponse403, CreateReleaseChannelResponse409, CreateReleaseChannelResponse500]
"""

return sync_detailed(
deployment_id=deployment_id,
client=client,
body=body,
).parsed


async def asyncio_detailed(
deployment_id: str,
*,
client: Union[AuthenticatedClient, Client],
client: AuthenticatedClient,
body: CreateReleaseChannelBody,
) -> Response[Union[CreateReleaseChannelResponse200, CreateReleaseChannelResponse401, CreateReleaseChannelResponse403]]:
) -> Response[
Union[
CreateReleaseChannelResponse200,
CreateReleaseChannelResponse401,
CreateReleaseChannelResponse403,
CreateReleaseChannelResponse409,
CreateReleaseChannelResponse500,
]
]:
"""Create a release channel
Args:
deployment_id (str):
body (CreateReleaseChannelBody):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
Response[Union[CreateReleaseChannelResponse200, CreateReleaseChannelResponse401, CreateReleaseChannelResponse403]]
Response[Union[CreateReleaseChannelResponse200, CreateReleaseChannelResponse401, CreateReleaseChannelResponse403, CreateReleaseChannelResponse409, CreateReleaseChannelResponse500]]
"""

kwargs = _get_kwargs(
deployment_id=deployment_id,
body=body,
)

Expand All @@ -155,28 +195,33 @@ async def asyncio_detailed(


async def asyncio(
deployment_id: str,
*,
client: Union[AuthenticatedClient, Client],
client: AuthenticatedClient,
body: CreateReleaseChannelBody,
) -> Optional[Union[CreateReleaseChannelResponse200, CreateReleaseChannelResponse401, CreateReleaseChannelResponse403]]:
) -> Optional[
Union[
CreateReleaseChannelResponse200,
CreateReleaseChannelResponse401,
CreateReleaseChannelResponse403,
CreateReleaseChannelResponse409,
CreateReleaseChannelResponse500,
]
]:
"""Create a release channel
Args:
deployment_id (str):
body (CreateReleaseChannelBody):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
Union[CreateReleaseChannelResponse200, CreateReleaseChannelResponse401, CreateReleaseChannelResponse403]
Union[CreateReleaseChannelResponse200, CreateReleaseChannelResponse401, CreateReleaseChannelResponse403, CreateReleaseChannelResponse409, CreateReleaseChannelResponse500]
"""

return (
await asyncio_detailed(
deployment_id=deployment_id,
client=client,
body=body,
)
Expand Down
Loading

0 comments on commit bffc341

Please sign in to comment.