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
  •  
  •  
  •  
23,400 changes: 16,030 additions & 7,370 deletions openapi.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
from http import HTTPStatus
from typing import Any, Optional

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_settings_response import AnnotationQueueSettingsResponse
from ...models.http_validation_error import HTTPValidationError
from ...types import Response


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

_kwargs: dict[str, Any] = {
"method": RequestMethod.GET,
"return_raw_response": True,
"path": "/annotation_queues/{queue_id}/settings".format(queue_id=queue_id),
}

headers["Splunk-AO-SDK"] = get_sdk_header()

_kwargs["content_headers"] = headers
return _kwargs


def _parse_response(
*, client: ApiClient, response: httpx.Response
) -> AnnotationQueueSettingsResponse | HTTPValidationError:
if response.status_code == 200:
response_200 = AnnotationQueueSettingsResponse.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[AnnotationQueueSettingsResponse | 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(
queue_id: str, *, client: ApiClient
) -> Response[AnnotationQueueSettingsResponse | HTTPValidationError]:
"""Get Settings

Get the settings for an annotation queue.

Returns the default settings if none have been saved yet. Any user who can read the queue can fetch
them.

Args:
queue_id (str):

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

kwargs = _get_kwargs(queue_id=queue_id)

response = client.request(**kwargs)

return _build_response(client=client, response=response)


def sync(queue_id: str, *, client: ApiClient) -> Optional[AnnotationQueueSettingsResponse | HTTPValidationError]:
"""Get Settings

Get the settings for an annotation queue.

Returns the default settings if none have been saved yet. Any user who can read the queue can fetch
them.

Args:
queue_id (str):

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:
AnnotationQueueSettingsResponse | HTTPValidationError
"""

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


async def asyncio_detailed(
queue_id: str, *, client: ApiClient
) -> Response[AnnotationQueueSettingsResponse | HTTPValidationError]:
"""Get Settings

Get the settings for an annotation queue.

Returns the default settings if none have been saved yet. Any user who can read the queue can fetch
them.

Args:
queue_id (str):

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

kwargs = _get_kwargs(queue_id=queue_id)

response = await client.arequest(**kwargs)

return _build_response(client=client, response=response)


async def asyncio(
queue_id: str, *, client: ApiClient
) -> Optional[AnnotationQueueSettingsResponse | HTTPValidationError]:
"""Get Settings

Get the settings for an annotation queue.

Returns the default settings if none have been saved yet. Any user who can read the queue can fetch
them.

Args:
queue_id (str):

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:
AnnotationQueueSettingsResponse | HTTPValidationError
"""

return (await asyncio_detailed(queue_id=queue_id, client=client)).parsed
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def sync_detailed(
Can update:
- Template name (must be unique within the queue)
- Template criteria
- Whether the template is required

Note: Constraints and other fields cannot be updated.

Expand Down Expand Up @@ -127,6 +128,7 @@ def sync(
Can update:
- Template name (must be unique within the queue)
- Template criteria
- Whether the template is required

Note: Constraints and other fields cannot be updated.

Expand Down Expand Up @@ -156,6 +158,7 @@ async def asyncio_detailed(
Can update:
- Template name (must be unique within the queue)
- Template criteria
- Whether the template is required

Note: Constraints and other fields cannot be updated.

Expand Down Expand Up @@ -189,6 +192,7 @@ async def asyncio(
Can update:
- Template name (must be unique within the queue)
- Template criteria
- Whether the template is required

Note: Constraints and other fields cannot be updated.

Expand Down
Loading