Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
296 changes: 296 additions & 0 deletions robosystems_client/api/graph_operations/op_change_reporting_style.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,296 @@
from http import HTTPStatus
from typing import Any
from urllib.parse import quote

import httpx

from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.change_reporting_style_op import ChangeReportingStyleOp
from ...models.error_response import ErrorResponse
from ...models.operation_envelope import OperationEnvelope
from ...types import UNSET, Response, Unset


def _get_kwargs(
graph_id: str,
*,
body: ChangeReportingStyleOp,
idempotency_key: None | str | Unset = UNSET,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
if not isinstance(idempotency_key, Unset):
headers["Idempotency-Key"] = idempotency_key

_kwargs: dict[str, Any] = {
"method": "post",
"url": "/v1/graphs/{graph_id}/operations/change-reporting-style".format(
graph_id=quote(str(graph_id), safe=""),
),
}

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

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

_kwargs["headers"] = headers
return _kwargs


def _parse_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> ErrorResponse | OperationEnvelope | None:
if response.status_code == 200:
response_200 = OperationEnvelope.from_dict(response.json())

return response_200

if response.status_code == 400:
response_400 = ErrorResponse.from_dict(response.json())

return response_400

if response.status_code == 401:
response_401 = ErrorResponse.from_dict(response.json())

return response_401

if response.status_code == 403:
response_403 = ErrorResponse.from_dict(response.json())

return response_403

if response.status_code == 404:
response_404 = ErrorResponse.from_dict(response.json())

return response_404

if response.status_code == 409:
response_409 = ErrorResponse.from_dict(response.json())

return response_409

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

return response_422

if response.status_code == 429:
response_429 = ErrorResponse.from_dict(response.json())

return response_429

if response.status_code == 500:
response_500 = ErrorResponse.from_dict(response.json())

return response_500

if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
return None


def _build_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> Response[ErrorResponse | OperationEnvelope]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)


def sync_detailed(
graph_id: str,
*,
client: AuthenticatedClient,
body: ChangeReportingStyleOp,
idempotency_key: None | str | Unset = UNSET,
) -> Response[ErrorResponse | OperationEnvelope]:
"""Change Reporting Style

Switches the graph's Reporting Style (Phase 2 of §3.2). Synchronous: validates the target Style has
a complete composition in the tenant schema, then updates `graphs.reporting_style_id`. Filed Reports
are unaffected; new reports use the new Style. Idempotent on the same id.

**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

Args:
graph_id (str):
idempotency_key (None | str | Unset):
body (ChangeReportingStyleOp): Body for the change-reporting-style operation (Phase 2 of
§3.2).

Switches the graph to a different Reporting Style. The target Style
must be a library- or customer-authored Structure with
``structure_type='reporting_style'`` and a complete composition
(one Network per required statement type — BS / IS / CF / SE). Filed
Reports are unaffected because each ``Report`` already pins its own
``structure_id`` per FactSet at create-time; new reports use the new
Style. Idempotent on the same target id.

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[ErrorResponse | OperationEnvelope]
"""

kwargs = _get_kwargs(
graph_id=graph_id,
body=body,
idempotency_key=idempotency_key,
)

response = client.get_httpx_client().request(
**kwargs,
)

return _build_response(client=client, response=response)


def sync(
graph_id: str,
*,
client: AuthenticatedClient,
body: ChangeReportingStyleOp,
idempotency_key: None | str | Unset = UNSET,
) -> ErrorResponse | OperationEnvelope | None:
"""Change Reporting Style

Switches the graph's Reporting Style (Phase 2 of §3.2). Synchronous: validates the target Style has
a complete composition in the tenant schema, then updates `graphs.reporting_style_id`. Filed Reports
are unaffected; new reports use the new Style. Idempotent on the same id.

**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

Args:
graph_id (str):
idempotency_key (None | str | Unset):
body (ChangeReportingStyleOp): Body for the change-reporting-style operation (Phase 2 of
§3.2).

Switches the graph to a different Reporting Style. The target Style
must be a library- or customer-authored Structure with
``structure_type='reporting_style'`` and a complete composition
(one Network per required statement type — BS / IS / CF / SE). Filed
Reports are unaffected because each ``Report`` already pins its own
``structure_id`` per FactSet at create-time; new reports use the new
Style. Idempotent on the same target id.

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:
ErrorResponse | OperationEnvelope
"""

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


async def asyncio_detailed(
graph_id: str,
*,
client: AuthenticatedClient,
body: ChangeReportingStyleOp,
idempotency_key: None | str | Unset = UNSET,
) -> Response[ErrorResponse | OperationEnvelope]:
"""Change Reporting Style

Switches the graph's Reporting Style (Phase 2 of §3.2). Synchronous: validates the target Style has
a complete composition in the tenant schema, then updates `graphs.reporting_style_id`. Filed Reports
are unaffected; new reports use the new Style. Idempotent on the same id.

**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

Args:
graph_id (str):
idempotency_key (None | str | Unset):
body (ChangeReportingStyleOp): Body for the change-reporting-style operation (Phase 2 of
§3.2).

Switches the graph to a different Reporting Style. The target Style
must be a library- or customer-authored Structure with
``structure_type='reporting_style'`` and a complete composition
(one Network per required statement type — BS / IS / CF / SE). Filed
Reports are unaffected because each ``Report`` already pins its own
``structure_id`` per FactSet at create-time; new reports use the new
Style. Idempotent on the same target id.

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[ErrorResponse | OperationEnvelope]
"""

kwargs = _get_kwargs(
graph_id=graph_id,
body=body,
idempotency_key=idempotency_key,
)

response = await client.get_async_httpx_client().request(**kwargs)

return _build_response(client=client, response=response)


async def asyncio(
graph_id: str,
*,
client: AuthenticatedClient,
body: ChangeReportingStyleOp,
idempotency_key: None | str | Unset = UNSET,
) -> ErrorResponse | OperationEnvelope | None:
"""Change Reporting Style

Switches the graph's Reporting Style (Phase 2 of §3.2). Synchronous: validates the target Style has
a complete composition in the tenant schema, then updates `graphs.reporting_style_id`. Filed Reports
are unaffected; new reports use the new Style. Idempotent on the same id.

**Idempotency**: supply an `Idempotency-Key` header to make safe retries; replays within 24 hours
return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

Args:
graph_id (str):
idempotency_key (None | str | Unset):
body (ChangeReportingStyleOp): Body for the change-reporting-style operation (Phase 2 of
§3.2).

Switches the graph to a different Reporting Style. The target Style
must be a library- or customer-authored Structure with
``structure_type='reporting_style'`` and a complete composition
(one Network per required statement type — BS / IS / CF / SE). Filed
Reports are unaffected because each ``Report`` already pins its own
``structure_id`` per FactSet at create-time; new reports use the new
Style. Idempotent on the same target id.

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:
ErrorResponse | OperationEnvelope
"""

return (
await asyncio_detailed(
graph_id=graph_id,
client=client,
body=body,
idempotency_key=idempotency_key,
)
).parsed
8 changes: 8 additions & 0 deletions robosystems_client/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@
CancelOperationResponseCanceloperation,
)
from .cancel_subscription_request import CancelSubscriptionRequest
from .change_reporting_style_op import ChangeReportingStyleOp
from .change_tier_op import ChangeTierOp
from .change_tier_op_new_tier import ChangeTierOpNewTier
from .checkout_response import CheckoutResponse
from .checkout_status_response import CheckoutStatusResponse
from .classification_lite import ClassificationLite
from .close_period_operation import ClosePeriodOperation
from .close_period_response import ClosePeriodResponse
from .close_period_response_rule_summary_type_0 import (
ClosePeriodResponseRuleSummaryType0,
)
from .connection_lite import ConnectionLite
from .connection_options_response import ConnectionOptionsResponse
from .connection_provider_info import ConnectionProviderInfo
Expand Down Expand Up @@ -438,6 +442,7 @@
from .password_policy_response import PasswordPolicyResponse
from .password_policy_response_policy import PasswordPolicyResponsePolicy
from .payment_method import PaymentMethod
from .pending_obligation_detail_response import PendingObligationDetailResponse
from .performance_insights import PerformanceInsights
from .performance_insights_operation_stats import PerformanceInsightsOperationStats
from .performance_insights_slow_queries_item import PerformanceInsightsSlowQueriesItem
Expand Down Expand Up @@ -677,13 +682,15 @@
"BillingCustomer",
"CancelOperationResponseCanceloperation",
"CancelSubscriptionRequest",
"ChangeReportingStyleOp",
"ChangeTierOp",
"ChangeTierOpNewTier",
"CheckoutResponse",
"CheckoutStatusResponse",
"ClassificationLite",
"ClosePeriodOperation",
"ClosePeriodResponse",
"ClosePeriodResponseRuleSummaryType0",
"ConnectionLite",
"ConnectionOptionsResponse",
"ConnectionProviderInfo",
Expand Down Expand Up @@ -947,6 +954,7 @@
"PasswordPolicyResponse",
"PasswordPolicyResponsePolicy",
"PaymentMethod",
"PendingObligationDetailResponse",
"PerformanceInsights",
"PerformanceInsightsOperationStats",
"PerformanceInsightsSlowQueriesItem",
Expand Down
Loading
Loading