Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12,076 changes: 8,588 additions & 3,488 deletions openapi.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/splunk_ao/resources/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""A client library for accessing FastAPI."""
"""A client library for accessing FastAPI"""

from .client import AuthenticatedClient, Client

Expand Down
2 changes: 1 addition & 1 deletion src/splunk_ao/resources/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"""Contains methods for accessing the API."""
"""Contains methods for accessing the API"""
1 change: 1 addition & 0 deletions src/splunk_ao/resources/api/annotation_queue/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Contains endpoint functions for accessing the API"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
from http import HTTPStatus
from typing import Any, Optional, Union

import httpx

from galileo_core.constants.request_method import RequestMethod
from galileo_core.helpers.api_client import ApiClient
from splunk_ao.exceptions import (
AuthenticationError,
BadRequestError,
ConflictError,
ForbiddenError,
NotFoundError,
RateLimitError,
ServerError,
)
from splunk_ao.utils.headers_data import get_sdk_header

from ... import errors
from ...models.annotation_queue_response import AnnotationQueueResponse
from ...models.create_annotation_queue_request import CreateAnnotationQueueRequest
from ...models.http_validation_error import HTTPValidationError
from ...types import Response


def _get_kwargs(*, body: CreateAnnotationQueueRequest) -> dict[str, Any]:
headers: dict[str, Any] = {}

_kwargs: dict[str, Any] = {"method": RequestMethod.POST, "return_raw_response": True, "path": "/annotation_queues"}

_kwargs["json"] = body.to_dict()

headers["Content-Type"] = "application/json"

headers["X-Galileo-SDK"] = get_sdk_header()

_kwargs["content_headers"] = headers
return _kwargs


def _parse_response(
*, client: ApiClient, response: httpx.Response
) -> Union[AnnotationQueueResponse, HTTPValidationError]:
if response.status_code == 200:
response_200 = AnnotationQueueResponse.from_dict(response.json())

return response_200

if response.status_code == 422:
response_422 = HTTPValidationError.from_dict(response.json())

return response_422

# Handle common HTTP errors with actionable messages
if response.status_code == 400:
raise BadRequestError(response.status_code, response.content)
if response.status_code == 401:
raise AuthenticationError(response.status_code, response.content)
if response.status_code == 403:
raise ForbiddenError(response.status_code, response.content)
if response.status_code == 404:
raise NotFoundError(response.status_code, response.content)
if response.status_code == 409:
raise ConflictError(response.status_code, response.content)
if response.status_code == 429:
raise RateLimitError(response.status_code, response.content)
if response.status_code >= 500:
raise ServerError(response.status_code, response.content)
raise errors.UnexpectedStatus(response.status_code, response.content)


def _build_response(
*, client: ApiClient, response: httpx.Response
) -> Response[Union[AnnotationQueueResponse, HTTPValidationError]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)


def sync_detailed(
*, client: ApiClient, body: CreateAnnotationQueueRequest
) -> Response[Union[AnnotationQueueResponse, HTTPValidationError]]:
"""Create Annotation Queue

Create an annotation queue at the organization level.

The creator will automatically be granted the 'owner' role.
Optionally accepts a list of annotator emails. Users that don't exist in the organization will be
invited.
Optionally copies templates from an existing queue if copy_templates_from_queue_id is provided.

Args:
body (CreateAnnotationQueueRequest):

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[AnnotationQueueResponse, HTTPValidationError]]
"""

kwargs = _get_kwargs(body=body)

response = client.request(**kwargs)

return _build_response(client=client, response=response)


def sync(
*, client: ApiClient, body: CreateAnnotationQueueRequest
) -> Optional[Union[AnnotationQueueResponse, HTTPValidationError]]:
"""Create Annotation Queue

Create an annotation queue at the organization level.

The creator will automatically be granted the 'owner' role.
Optionally accepts a list of annotator emails. Users that don't exist in the organization will be
invited.
Optionally copies templates from an existing queue if copy_templates_from_queue_id is provided.

Args:
body (CreateAnnotationQueueRequest):

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[AnnotationQueueResponse, HTTPValidationError]
"""

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


async def asyncio_detailed(
*, client: ApiClient, body: CreateAnnotationQueueRequest
) -> Response[Union[AnnotationQueueResponse, HTTPValidationError]]:
"""Create Annotation Queue

Create an annotation queue at the organization level.

The creator will automatically be granted the 'owner' role.
Optionally accepts a list of annotator emails. Users that don't exist in the organization will be
invited.
Optionally copies templates from an existing queue if copy_templates_from_queue_id is provided.

Args:
body (CreateAnnotationQueueRequest):

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[AnnotationQueueResponse, HTTPValidationError]]
"""

kwargs = _get_kwargs(body=body)

response = await client.arequest(**kwargs)

return _build_response(client=client, response=response)


async def asyncio(
*, client: ApiClient, body: CreateAnnotationQueueRequest
) -> Optional[Union[AnnotationQueueResponse, HTTPValidationError]]:
"""Create Annotation Queue

Create an annotation queue at the organization level.

The creator will automatically be granted the 'owner' role.
Optionally accepts a list of annotator emails. Users that don't exist in the organization will be
invited.
Optionally copies templates from an existing queue if copy_templates_from_queue_id is provided.

Args:
body (CreateAnnotationQueueRequest):

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[AnnotationQueueResponse, HTTPValidationError]
"""

return (await asyncio_detailed(client=client, body=body)).parsed
Loading
Loading