MCPcopy
hub / github.com/Agenta-AI/agenta / create_api_key

Method create_api_key

sdk/agenta/client/client.py:180–229  ·  view source on GitHub ↗

Creates an API key for a user. Args: request (Request): The request object containing the user ID in the request state. Returns: str: The created API key. Parameters ---------- request_options : typing.Optional[RequestOption

(
        self, *, request_options: typing.Optional[RequestOptions] = None
    )

Source from the content-addressed store, hash-verified

178 raise ApiError(status_code=_response.status_code, body=_response_json)
179
180 def create_api_key(
181 self, *, request_options: typing.Optional[RequestOptions] = None
182 ) -> str:
183 """
184 Creates an API key for a user.
185
186 Args:
187 request (Request): The request object containing the user ID in the request state.
188
189 Returns:
190 str: The created API key.
191
192 Parameters
193 ----------
194 request_options : typing.Optional[RequestOptions]
195 Request-specific configuration.
196
197 Returns
198 -------
199 str
200 Successful Response
201
202 Examples
203 --------
204 from agenta import AgentaApi
205
206 client = AgentaApi(
207 api_key="YOUR_API_KEY",
208 base_url="https://yourhost.com/path/to/api",
209 )
210 client.create_api_key()
211 """
212 _response = self._client_wrapper.httpx_client.request(
213 "keys",
214 method="POST",
215 request_options=request_options,
216 )
217 try:
218 if 200 <= _response.status_code < 300:
219 return typing.cast(
220 str,
221 parse_obj_as(
222 type_=str, # type: ignore
223 object_=_response.json(),
224 ),
225 )
226 _response_json = _response.json()
227 except JSONDecodeError:
228 raise ApiError(status_code=_response.status_code, body=_response.text)
229 raise ApiError(status_code=_response.status_code, body=_response_json)
230
231 def delete_api_key(
232 self,

Callers 1

create_api_keyFunction · 0.45

Calls 4

parse_obj_asFunction · 0.85
jsonMethod · 0.80
ApiErrorClass · 0.50
requestMethod · 0.45

Tested by

no test coverage detected