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
274 changes: 274 additions & 0 deletions robosystems_client/api/extensions_robo_ledger/bind_text_block.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,274 @@
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.bind_text_block_request import BindTextBlockRequest
from ...models.error_response import ErrorResponse
from ...models.operation_envelope_bind_text_block_response import (
OperationEnvelopeBindTextBlockResponse,
)
from ...types import UNSET, Response, Unset


def _get_kwargs(
graph_id: str,
*,
body: BindTextBlockRequest,
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": "/extensions/roboledger/{graph_id}/operations/bind-text-block".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 | OperationEnvelopeBindTextBlockResponse | None:
if response.status_code == 200:
response_200 = OperationEnvelopeBindTextBlockResponse.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 | OperationEnvelopeBindTextBlockResponse]:
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: BindTextBlockRequest,
idempotency_key: None | str | Unset = UNSET,
) -> Response[ErrorResponse | OperationEnvelopeBindTextBlockResponse]:
"""Bind Text Block

Bind a platform Document (markdown) — or one of its sections — to a disclosure element as a
Nonnumeric text-block fact. The document stays the editable source of truth; the fact snapshots its
text into a standing 'disclosure' FactSet with document provenance (document_id + section +
content_hash). Re-binding the same element and period replaces the fact and refreshes the hash.
Reports generated afterward snapshot the standing set, so filed reports are immutable against later
document edits.

**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 (BindTextBlockRequest):

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 | OperationEnvelopeBindTextBlockResponse]
"""

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: BindTextBlockRequest,
idempotency_key: None | str | Unset = UNSET,
) -> ErrorResponse | OperationEnvelopeBindTextBlockResponse | None:
"""Bind Text Block

Bind a platform Document (markdown) — or one of its sections — to a disclosure element as a
Nonnumeric text-block fact. The document stays the editable source of truth; the fact snapshots its
text into a standing 'disclosure' FactSet with document provenance (document_id + section +
content_hash). Re-binding the same element and period replaces the fact and refreshes the hash.
Reports generated afterward snapshot the standing set, so filed reports are immutable against later
document edits.

**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 (BindTextBlockRequest):

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 | OperationEnvelopeBindTextBlockResponse
"""

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: BindTextBlockRequest,
idempotency_key: None | str | Unset = UNSET,
) -> Response[ErrorResponse | OperationEnvelopeBindTextBlockResponse]:
"""Bind Text Block

Bind a platform Document (markdown) — or one of its sections — to a disclosure element as a
Nonnumeric text-block fact. The document stays the editable source of truth; the fact snapshots its
text into a standing 'disclosure' FactSet with document provenance (document_id + section +
content_hash). Re-binding the same element and period replaces the fact and refreshes the hash.
Reports generated afterward snapshot the standing set, so filed reports are immutable against later
document edits.

**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 (BindTextBlockRequest):

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 | OperationEnvelopeBindTextBlockResponse]
"""

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: BindTextBlockRequest,
idempotency_key: None | str | Unset = UNSET,
) -> ErrorResponse | OperationEnvelopeBindTextBlockResponse | None:
"""Bind Text Block

Bind a platform Document (markdown) — or one of its sections — to a disclosure element as a
Nonnumeric text-block fact. The document stays the editable source of truth; the fact snapshots its
text into a standing 'disclosure' FactSet with document provenance (document_id + section +
content_hash). Re-binding the same element and period replaces the fact and refreshes the hash.
Reports generated afterward snapshot the standing set, so filed reports are immutable against later
document edits.

**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 (BindTextBlockRequest):

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 | OperationEnvelopeBindTextBlockResponse
"""

return (
await asyncio_detailed(
graph_id=graph_id,
client=client,
body=body,
idempotency_key=idempotency_key,
)
).parsed
26 changes: 26 additions & 0 deletions robosystems_client/clients/ledger_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@
from ..api.extensions_robo_ledger.delete_taxonomy_block import (
sync_detailed as op_delete_taxonomy_block,
)
from ..api.extensions_robo_ledger.bind_text_block import (
sync_detailed as op_bind_text_block,
)
from ..api.extensions_robo_ledger.evaluate_rules import (
sync_detailed as op_evaluate_rules,
)
Expand Down Expand Up @@ -287,6 +290,8 @@
from ..models.update_publish_list_operation import UpdatePublishListOperation
from ..models.reopen_period_operation import ReopenPeriodOperation
from ..models.set_close_target_operation import SetCloseTargetOperation
from ..models.bind_text_block_request import BindTextBlockRequest
from ..models.bind_text_block_response import BindTextBlockResponse
from ..models.create_taxonomy_block_request import CreateTaxonomyBlockRequest
from ..models.update_taxonomy_block_request import UpdateTaxonomyBlockRequest
from ..models.delete_taxonomy_block_request import DeleteTaxonomyBlockRequest
Expand Down Expand Up @@ -799,6 +804,27 @@ def delete_taxonomy_block(
"Delete taxonomy block", envelope, DeleteTaxonomyBlockResponse
)

def bind_text_block(
self, graph_id: str, body: dict[str, Any], idempotency_key: str | None = None
) -> BindTextBlockResponse:
"""Bind a platform Document (or one section) to a disclosure element
as a Nonnumeric text-block fact in a standing 'disclosure' FactSet.

``body`` mirrors BindTextBlockRequest: document_id, structure_id,
exactly one of element_id / element_qname, period_start, period_end,
plus optional section_id / entity_id. Re-binding the same element
and period replaces the fact (``replaced=True`` in the response).
"""
request = BindTextBlockRequest.from_dict(body)
response = op_bind_text_block(
graph_id=graph_id,
body=request,
client=self._get_client(),
idempotency_key=idempotency_key if idempotency_key is not None else UNSET,
)
envelope = self._call_op("Bind text block", response)
return self._typed_result("Bind text block", envelope, BindTextBlockResponse)

def link_entity_taxonomy(
self,
graph_id: str,
Expand Down
16 changes: 16 additions & 0 deletions robosystems_client/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
from .batch_operator_request import BatchOperatorRequest
from .batch_operator_response import BatchOperatorResponse
from .billing_customer import BillingCustomer
from .bind_text_block_request import BindTextBlockRequest
from .bind_text_block_response import BindTextBlockResponse
from .cancel_operation_response_canceloperation import (
CancelOperationResponseCanceloperation,
)
Expand Down Expand Up @@ -297,6 +299,12 @@
from .operation_envelope_association_response_status import (
OperationEnvelopeAssociationResponseStatus,
)
from .operation_envelope_bind_text_block_response import (
OperationEnvelopeBindTextBlockResponse,
)
from .operation_envelope_bind_text_block_response_status import (
OperationEnvelopeBindTextBlockResponseStatus,
)
from .operation_envelope_change_reporting_style_response import (
OperationEnvelopeChangeReportingStyleResponse,
)
Expand Down Expand Up @@ -645,6 +653,9 @@
from .taxonomy_block_structure_request_block_type import (
TaxonomyBlockStructureRequestBlockType,
)
from .taxonomy_block_structure_request_concept_arrangement_type_0 import (
TaxonomyBlockStructureRequestConceptArrangementType0,
)
from .taxonomy_block_structure_request_metadata import (
TaxonomyBlockStructureRequestMetadata,
)
Expand Down Expand Up @@ -744,6 +755,8 @@
"BatchOperatorRequest",
"BatchOperatorResponse",
"BillingCustomer",
"BindTextBlockRequest",
"BindTextBlockResponse",
"CancelOperationResponseCanceloperation",
"CancelSubscriptionRequest",
"ChangeReportingStyleRequest",
Expand Down Expand Up @@ -964,6 +977,8 @@
"OperationEnvelope",
"OperationEnvelopeAssociationResponse",
"OperationEnvelopeAssociationResponseStatus",
"OperationEnvelopeBindTextBlockResponse",
"OperationEnvelopeBindTextBlockResponseStatus",
"OperationEnvelopeChangeReportingStyleResponse",
"OperationEnvelopeChangeReportingStyleResponseStatus",
"OperationEnvelopeClosePeriodResponse",
Expand Down Expand Up @@ -1180,6 +1195,7 @@
"TaxonomyBlockStructure",
"TaxonomyBlockStructureRequest",
"TaxonomyBlockStructureRequestBlockType",
"TaxonomyBlockStructureRequestConceptArrangementType0",
"TaxonomyBlockStructureRequestMetadata",
"TierCapacity",
"TokenPricing",
Expand Down
Loading