|
| 1 | +# This file was auto-generated by Fern from our API Definition. |
| 2 | + |
| 3 | +import typing |
| 4 | + |
| 5 | +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper |
| 6 | +from ...core.request_options import RequestOptions |
| 7 | +from ...types.create_application_keys_request import CreateApplicationKeysRequest |
| 8 | +from ...types.create_application_keys_response import CreateApplicationKeysResponse |
| 9 | +from ...types.delete_application_keys_response import DeleteApplicationKeysResponse |
| 10 | +from .raw_client import AsyncRawApplicationApiKeysClient, RawApplicationApiKeysClient |
| 11 | + |
| 12 | +# this is used as the default value for optional parameters |
| 13 | +OMIT = typing.cast(typing.Any, ...) |
| 14 | + |
| 15 | + |
| 16 | +class ApplicationApiKeysClient: |
| 17 | + def __init__(self, *, client_wrapper: SyncClientWrapper): |
| 18 | + self._raw_client = RawApplicationApiKeysClient(client_wrapper=client_wrapper) |
| 19 | + |
| 20 | + @property |
| 21 | + def with_raw_response(self) -> RawApplicationApiKeysClient: |
| 22 | + """ |
| 23 | + Retrieves a raw implementation of this client that returns raw responses. |
| 24 | +
|
| 25 | + Returns |
| 26 | + ------- |
| 27 | + RawApplicationApiKeysClient |
| 28 | + """ |
| 29 | + return self._raw_client |
| 30 | + |
| 31 | + def create( |
| 32 | + self, *, request: CreateApplicationKeysRequest, request_options: typing.Optional[RequestOptions] = None |
| 33 | + ) -> CreateApplicationKeysResponse: |
| 34 | + """ |
| 35 | + Create application API keys scoped to specific users. Each key can only perform operations on behalf of the user it was created for. |
| 36 | +
|
| 37 | + Parameters |
| 38 | + ---------- |
| 39 | + request : CreateApplicationKeysRequest |
| 40 | +
|
| 41 | + request_options : typing.Optional[RequestOptions] |
| 42 | + Request-specific configuration. |
| 43 | +
|
| 44 | + Returns |
| 45 | + ------- |
| 46 | + CreateApplicationKeysResponse |
| 47 | + Successful operation (no keys created) |
| 48 | +
|
| 49 | + Examples |
| 50 | + -------- |
| 51 | + from trophy import CreateApplicationKeyRequestItem, TrophyApi |
| 52 | +
|
| 53 | + client = TrophyApi( |
| 54 | + "1.18.0", |
| 55 | + tenant_id="YOUR_TENANT_ID", |
| 56 | + api_key="YOUR_API_KEY", |
| 57 | + ) |
| 58 | + client.admin.application_api_keys.create( |
| 59 | + request=[ |
| 60 | + CreateApplicationKeyRequestItem( |
| 61 | + user_id="user_123", |
| 62 | + ), |
| 63 | + CreateApplicationKeyRequestItem( |
| 64 | + user_id="user_456", |
| 65 | + ), |
| 66 | + ], |
| 67 | + ) |
| 68 | + """ |
| 69 | + _response = self._raw_client.create(request=request, request_options=request_options) |
| 70 | + return _response.data |
| 71 | + |
| 72 | + def delete( |
| 73 | + self, |
| 74 | + *, |
| 75 | + ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, |
| 76 | + request_options: typing.Optional[RequestOptions] = None, |
| 77 | + ) -> DeleteApplicationKeysResponse: |
| 78 | + """ |
| 79 | + Delete application API keys by ID. |
| 80 | +
|
| 81 | + Parameters |
| 82 | + ---------- |
| 83 | + ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] |
| 84 | + Application API key IDs (UUIDs returned at creation time). Repeat the query param or provide a comma-separated list. Maximum 100 IDs per request. |
| 85 | +
|
| 86 | + request_options : typing.Optional[RequestOptions] |
| 87 | + Request-specific configuration. |
| 88 | +
|
| 89 | + Returns |
| 90 | + ------- |
| 91 | + DeleteApplicationKeysResponse |
| 92 | + Successful operation |
| 93 | +
|
| 94 | + Examples |
| 95 | + -------- |
| 96 | + from trophy import TrophyApi |
| 97 | +
|
| 98 | + client = TrophyApi( |
| 99 | + "1.18.0", |
| 100 | + tenant_id="YOUR_TENANT_ID", |
| 101 | + api_key="YOUR_API_KEY", |
| 102 | + ) |
| 103 | + client.admin.application_api_keys.delete( |
| 104 | + ids=["550e8400-e29b-41d4-a716-446655440000"], |
| 105 | + ) |
| 106 | + """ |
| 107 | + _response = self._raw_client.delete(ids=ids, request_options=request_options) |
| 108 | + return _response.data |
| 109 | + |
| 110 | + |
| 111 | +class AsyncApplicationApiKeysClient: |
| 112 | + def __init__(self, *, client_wrapper: AsyncClientWrapper): |
| 113 | + self._raw_client = AsyncRawApplicationApiKeysClient(client_wrapper=client_wrapper) |
| 114 | + |
| 115 | + @property |
| 116 | + def with_raw_response(self) -> AsyncRawApplicationApiKeysClient: |
| 117 | + """ |
| 118 | + Retrieves a raw implementation of this client that returns raw responses. |
| 119 | +
|
| 120 | + Returns |
| 121 | + ------- |
| 122 | + AsyncRawApplicationApiKeysClient |
| 123 | + """ |
| 124 | + return self._raw_client |
| 125 | + |
| 126 | + async def create( |
| 127 | + self, *, request: CreateApplicationKeysRequest, request_options: typing.Optional[RequestOptions] = None |
| 128 | + ) -> CreateApplicationKeysResponse: |
| 129 | + """ |
| 130 | + Create application API keys scoped to specific users. Each key can only perform operations on behalf of the user it was created for. |
| 131 | +
|
| 132 | + Parameters |
| 133 | + ---------- |
| 134 | + request : CreateApplicationKeysRequest |
| 135 | +
|
| 136 | + request_options : typing.Optional[RequestOptions] |
| 137 | + Request-specific configuration. |
| 138 | +
|
| 139 | + Returns |
| 140 | + ------- |
| 141 | + CreateApplicationKeysResponse |
| 142 | + Successful operation (no keys created) |
| 143 | +
|
| 144 | + Examples |
| 145 | + -------- |
| 146 | + import asyncio |
| 147 | +
|
| 148 | + from trophy import AsyncTrophyApi, CreateApplicationKeyRequestItem |
| 149 | +
|
| 150 | + client = AsyncTrophyApi( |
| 151 | + "1.18.0", |
| 152 | + tenant_id="YOUR_TENANT_ID", |
| 153 | + api_key="YOUR_API_KEY", |
| 154 | + ) |
| 155 | +
|
| 156 | +
|
| 157 | + async def main() -> None: |
| 158 | + await client.admin.application_api_keys.create( |
| 159 | + request=[ |
| 160 | + CreateApplicationKeyRequestItem( |
| 161 | + user_id="user_123", |
| 162 | + ), |
| 163 | + CreateApplicationKeyRequestItem( |
| 164 | + user_id="user_456", |
| 165 | + ), |
| 166 | + ], |
| 167 | + ) |
| 168 | +
|
| 169 | +
|
| 170 | + asyncio.run(main()) |
| 171 | + """ |
| 172 | + _response = await self._raw_client.create(request=request, request_options=request_options) |
| 173 | + return _response.data |
| 174 | + |
| 175 | + async def delete( |
| 176 | + self, |
| 177 | + *, |
| 178 | + ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, |
| 179 | + request_options: typing.Optional[RequestOptions] = None, |
| 180 | + ) -> DeleteApplicationKeysResponse: |
| 181 | + """ |
| 182 | + Delete application API keys by ID. |
| 183 | +
|
| 184 | + Parameters |
| 185 | + ---------- |
| 186 | + ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] |
| 187 | + Application API key IDs (UUIDs returned at creation time). Repeat the query param or provide a comma-separated list. Maximum 100 IDs per request. |
| 188 | +
|
| 189 | + request_options : typing.Optional[RequestOptions] |
| 190 | + Request-specific configuration. |
| 191 | +
|
| 192 | + Returns |
| 193 | + ------- |
| 194 | + DeleteApplicationKeysResponse |
| 195 | + Successful operation |
| 196 | +
|
| 197 | + Examples |
| 198 | + -------- |
| 199 | + import asyncio |
| 200 | +
|
| 201 | + from trophy import AsyncTrophyApi |
| 202 | +
|
| 203 | + client = AsyncTrophyApi( |
| 204 | + "1.18.0", |
| 205 | + tenant_id="YOUR_TENANT_ID", |
| 206 | + api_key="YOUR_API_KEY", |
| 207 | + ) |
| 208 | +
|
| 209 | +
|
| 210 | + async def main() -> None: |
| 211 | + await client.admin.application_api_keys.delete( |
| 212 | + ids=["550e8400-e29b-41d4-a716-446655440000"], |
| 213 | + ) |
| 214 | +
|
| 215 | +
|
| 216 | + asyncio.run(main()) |
| 217 | + """ |
| 218 | + _response = await self._raw_client.delete(ids=ids, request_options=request_options) |
| 219 | + return _response.data |
0 commit comments