diff --git a/workflows_definition/.gitattributes b/workflows_definition/.gitattributes new file mode 100644 index 0000000000..4d75d59008 --- /dev/null +++ b/workflows_definition/.gitattributes @@ -0,0 +1,2 @@ +# This allows generated code to be indexed correctly +*.py linguist-generated=false \ No newline at end of file diff --git a/workflows_definition/.gitignore b/workflows_definition/.gitignore new file mode 100644 index 0000000000..3cdf338022 --- /dev/null +++ b/workflows_definition/.gitignore @@ -0,0 +1,6 @@ +venv/ +src/*.egg-info/ +__pycache__/ +.pytest_cache/ +.python-version +.DS_Store diff --git a/workflows_definition/.speakeasy/gen.lock b/workflows_definition/.speakeasy/gen.lock new file mode 100755 index 0000000000..0ab88447b2 --- /dev/null +++ b/workflows_definition/.speakeasy/gen.lock @@ -0,0 +1,130 @@ +lockVersion: 2.0.0 +id: 732dcb31-dff8-4f0e-9983-a3e9372d68c1 +management: + docChecksum: 8a2ff4be25db818a35891d602baa4a25 + docVersion: 1.0.0 + speakeasyVersion: 1.285.1 + generationVersion: 2.326.3 + releaseVersion: 1.3.0 + configChecksum: b29236b46ac06e62eaa323f1e56c9da0 + repoURL: https://github.com/epilot-dev/sdk-python.git + repoSubDirectory: workflows_definition + installationURL: https://github.com/epilot-dev/sdk-python.git#subdirectory=workflows_definition +features: + python: + additionalDependencies: 0.1.0 + core: 4.6.7 + deprecations: 2.81.1 + flattening: 2.81.1 + globalSecurity: 2.83.5 + globalSecurityCallbacks: 0.1.0 + globalSecurityFlattening: 0.1.0 + globalServerURLs: 2.82.2 + responseFormat: 0.1.0 + sdkHooks: 0.1.0 + unions: 2.82.6 +generatedFiles: + - src/sdk/sdkconfiguration.py + - src/sdk/closing_reason.py + - src/sdk/workflows.py + - src/sdk/sdk.py + - py.typed + - pylintrc + - setup.py + - src/sdk/__init__.py + - src/sdk/utils/__init__.py + - src/sdk/utils/retries.py + - src/sdk/utils/utils.py + - src/sdk/models/errors/sdkerror.py + - src/sdk/models/operations/changereasonstatus.py + - src/sdk/models/operations/createclosingreason.py + - src/sdk/models/operations/getallclosingreasons.py + - src/sdk/models/operations/createdefinition.py + - src/sdk/models/operations/deletedefinition.py + - src/sdk/models/operations/getdefinition.py + - src/sdk/models/operations/getdefinitions.py + - src/sdk/models/operations/getmaxallowedlimit.py + - src/sdk/models/operations/getworkflowclosingreasons.py + - src/sdk/models/operations/setworkflowclosingreasons.py + - src/sdk/models/operations/updatedefinition.py + - src/sdk/models/components/httpmetadata.py + - src/sdk/models/components/changereasonstatusreq.py + - src/sdk/models/components/closingreasonsstatus.py + - src/sdk/models/components/closingreason.py + - src/sdk/models/components/closingreasons.py + - src/sdk/models/components/workflowdefinition.py + - src/sdk/models/components/updateentityattributes.py + - src/sdk/models/components/section.py + - src/sdk/models/components/itemtype.py + - src/sdk/models/components/step.py + - src/sdk/models/components/steprequirement.py + - src/sdk/models/components/stepjourney.py + - src/sdk/models/components/ecpdetails.py + - src/sdk/models/components/steptype.py + - src/sdk/models/components/dynamicduedate.py + - src/sdk/models/components/stepdescription.py + - src/sdk/models/components/closingreasonid.py + - src/sdk/models/components/maxallowedlimit.py + - src/sdk/models/components/closingreasonsids.py + - src/sdk/models/components/security.py + - src/sdk/models/errors/errorresp.py + - src/sdk/models/errors/definitionnotfoundresp.py + - src/sdk/models/__init__.py + - src/sdk/models/errors/__init__.py + - src/sdk/models/operations/__init__.py + - src/sdk/models/components/__init__.py + - docs/models/operations/changereasonstatusrequest.md + - docs/models/operations/changereasonstatusresponse.md + - docs/models/operations/createclosingreasonresponse.md + - docs/models/operations/getallclosingreasonsrequest.md + - docs/models/operations/getallclosingreasonsresponse.md + - docs/models/operations/createdefinitionresponse.md + - docs/models/operations/deletedefinitionrequest.md + - docs/models/operations/deletedefinitionresponse.md + - docs/models/operations/getdefinitionrequest.md + - docs/models/operations/getdefinitionresponse.md + - docs/models/operations/getdefinitionsresponse.md + - docs/models/operations/getmaxallowedlimitresponse.md + - docs/models/operations/getworkflowclosingreasonsrequest.md + - docs/models/operations/getworkflowclosingreasonsresponse.md + - docs/models/operations/setworkflowclosingreasonsrequest.md + - docs/models/operations/setworkflowclosingreasonsresponse.md + - docs/models/operations/updatedefinitionrequest.md + - docs/models/operations/updatedefinitionresponse.md + - docs/models/components/httpmetadata.md + - docs/models/components/changereasonstatusreq.md + - docs/models/components/closingreasonsstatus.md + - docs/models/components/closingreason.md + - docs/models/components/closingreasons.md + - docs/models/components/flow.md + - docs/models/components/workflowdefinition.md + - docs/models/components/source.md + - docs/models/components/target.md + - docs/models/components/updateentityattributes.md + - docs/models/components/section.md + - docs/models/components/itemtype.md + - docs/models/components/automationconfig.md + - docs/models/components/step.md + - docs/models/components/condition.md + - docs/models/components/steprequirement.md + - docs/models/components/stepjourney.md + - docs/models/components/ecpdetails.md + - docs/models/components/steptype.md + - docs/models/components/actiontypecondition.md + - docs/models/components/timeperiod.md + - docs/models/components/dynamicduedate.md + - docs/models/components/stepdescription.md + - docs/models/components/closingreasonid.md + - docs/models/components/maxallowedlimit.md + - docs/models/components/closingreasonsids.md + - docs/models/components/security.md + - docs/models/errors/errorresp.md + - docs/models/errors/definitionnotfoundresp.md + - docs/sdks/sdk/README.md + - docs/sdks/closingreason/README.md + - docs/sdks/workflows/README.md + - USAGE.md + - .gitattributes + - src/sdk/_hooks/sdkhooks.py + - src/sdk/_hooks/types.py + - src/sdk/_hooks/__init__.py diff --git a/workflows_definition/README.md b/workflows_definition/README.md index a1825dc80c..f70b5784db 100755 --- a/workflows_definition/README.md +++ b/workflows_definition/README.md @@ -1,60 +1,202 @@ # openapi - + ## SDK Installation ```bash pip install git+https://github.com/epilot-dev/sdk-python.git#subdirectory=workflows_definition ``` - + + ## SDK Example Usage - + +### Example + ```python import sdk -from sdk.models import operations, shared +from sdk.models import components s = sdk.SDK( - security=shared.Security( - bearer_auth="Bearer YOUR_BEARER_TOKEN_HERE", - ), + bearer_auth="", ) +res = s.closing_reason.change_reason_status(reason_id='', change_reason_status_req=components.ChangeReasonStatusReq( + status=components.ClosingReasonsStatus.ACTIVE, +)) + +if res is not None: + # handle response + pass + +``` + + + +## Available Resources and Operations + +### [closing_reason](docs/sdks/closingreason/README.md) + +* [change_reason_status](docs/sdks/closingreason/README.md#change_reason_status) - changeReasonStatus +* [create_closing_reason](docs/sdks/closingreason/README.md#create_closing_reason) - createClosingReason +* [get_all_closing_reasons](docs/sdks/closingreason/README.md#get_all_closing_reasons) - getAllClosingReasons + +### [workflows](docs/sdks/workflows/README.md) + +* [create_definition](docs/sdks/workflows/README.md#create_definition) - createDefinition +* [delete_definition](docs/sdks/workflows/README.md#delete_definition) - deleteDefinition +* [get_definition](docs/sdks/workflows/README.md#get_definition) - getDefinition +* [get_definitions](docs/sdks/workflows/README.md#get_definitions) - getDefinitions +* [get_max_allowed_limit](docs/sdks/workflows/README.md#get_max_allowed_limit) - getMaxAllowedLimit +* [get_workflow_closing_reasons](docs/sdks/workflows/README.md#get_workflow_closing_reasons) - getWorkflowClosingReasons +* [set_workflow_closing_reasons](docs/sdks/workflows/README.md#set_workflow_closing_reasons) - setWorkflowClosingReasons +* [update_definition](docs/sdks/workflows/README.md#update_definition) - updateDefinition + + + +## Error Handling + +Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an error. If Error objects are specified in your OpenAPI Spec, the SDK will raise the appropriate Error type. + +| Error Object | Status Code | Content Type | +| ---------------- | ---------------- | ---------------- | +| errors.ErrorResp | 400,500 | application/json | +| errors.SDKError | 4xx-5xx | */* | + +### Example + +```python +import sdk +from sdk.models import components, errors -req = operations.ChangeReasonStatusRequest( - change_reason_status_req=shared.ChangeReasonStatusReq( - status="INACTIVE", - ), - reason_id="deserunt", +s = sdk.SDK( + bearer_auth="", ) - -res = s.closing_reason.change_reason_status(req) -if res.status_code == 200: +res = None +try: + res = s.closing_reason.change_reason_status(reason_id='', change_reason_status_req=components.ChangeReasonStatusReq( + status=components.ClosingReasonsStatus.ACTIVE, +)) +except errors.ErrorResp as e: + # handle exception + raise(e) +except errors.SDKError as e: + # handle exception + raise(e) + +if res is not None: # handle response + pass + ``` - + + + +## Server Selection + +### Select Server by Index - -## SDK Available Operations +You can override the default server globally by passing a server index to the `server_idx: int` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers: +| # | Server | Variables | +| - | ------ | --------- | +| 0 | `https://workflows-definition.sls.epilot.io` | None | + +#### Example + +```python +import sdk +from sdk.models import components + +s = sdk.SDK( + server_idx=0, + bearer_auth="", +) + +res = s.closing_reason.change_reason_status(reason_id='', change_reason_status_req=components.ChangeReasonStatusReq( + status=components.ClosingReasonsStatus.ACTIVE, +)) + +if res is not None: + # handle response + pass + +``` -### closing_reason -* `change_reason_status` - changeReasonStatus -* `create_closing_reason` - createClosingReason -* `get_all_closing_reasons` - getAllClosingReasons +### Override Server URL Per-Client + +The default server can also be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example: +```python +import sdk +from sdk.models import components + +s = sdk.SDK( + server_url="https://workflows-definition.sls.epilot.io", + bearer_auth="", +) + +res = s.closing_reason.change_reason_status(reason_id='', change_reason_status_req=components.ChangeReasonStatusReq( + status=components.ClosingReasonsStatus.ACTIVE, +)) + +if res is not None: + # handle response + pass + +``` + + + +## Custom HTTP Client + +The Python SDK makes API calls using the [requests](https://pypi.org/project/requests/) HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with a custom `requests.Session` object. + +For example, you could specify a header for every request that this sdk makes as follows: +```python +import sdk +import requests + +http_client = requests.Session() +http_client.headers.update({'x-custom-header': 'someValue'}) +s = sdk.SDK(client=http_client) +``` + + + +## Authentication + +### Per-Client Security Schemes + +This SDK supports the following security scheme globally: + +| Name | Type | Scheme | +| ------------- | ------------- | ------------- | +| `bearer_auth` | http | HTTP Bearer | + +To authenticate with the API the `bearer_auth` parameter must be set when initializing the SDK client instance. For example: +```python +import sdk +from sdk.models import components + +s = sdk.SDK( + bearer_auth="", +) + +res = s.closing_reason.change_reason_status(reason_id='', change_reason_status_req=components.ChangeReasonStatusReq( + status=components.ClosingReasonsStatus.ACTIVE, +)) + +if res is not None: + # handle response + pass + +``` + + + -### workflows -* `create_definition` - createDefinition -* `delete_definition` - deleteDefinition -* `get_definition` - getDefinition -* `get_definitions` - getDefinitions -* `get_max_allowed_limit` - getMaxAllowedLimit -* `get_workflow_closing_reasons` - getWorkflowClosingReasons -* `set_workflow_closing_reasons` - setWorkflowClosingReasons -* `update_definition` - updateDefinition - ### SDK Generated by [Speakeasy](https://docs.speakeasyapi.dev/docs/using-speakeasy/client-sdks) diff --git a/workflows_definition/RELEASES.md b/workflows_definition/RELEASES.md index 123baccfc1..e0a42785c0 100644 --- a/workflows_definition/RELEASES.md +++ b/workflows_definition/RELEASES.md @@ -34,4 +34,12 @@ Based on: ### Changes Based on: - OpenAPI Doc 1.0.0 https://docs.api.epilot.io/workflows-definition.yaml -- Speakeasy CLI 1.19.2 (2.16.5) https://github.com/speakeasy-api/speakeasy \ No newline at end of file +- Speakeasy CLI 1.19.2 (2.16.5) https://github.com/speakeasy-api/speakeasy + +## 2024-05-09 00:22:56 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/workflows-definition.yaml +- Speakeasy CLI 1.285.1 (2.326.3) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.3.0] workflows_definition \ No newline at end of file diff --git a/workflows_definition/USAGE.md b/workflows_definition/USAGE.md old mode 100755 new mode 100644 index bc7b4fadbf..34d993b64e --- a/workflows_definition/USAGE.md +++ b/workflows_definition/USAGE.md @@ -1,25 +1,19 @@ - + ```python import sdk -from sdk.models import operations, shared +from sdk.models import components s = sdk.SDK( - security=shared.Security( - bearer_auth="Bearer YOUR_BEARER_TOKEN_HERE", - ), + bearer_auth="", ) +res = s.closing_reason.change_reason_status(reason_id='', change_reason_status_req=components.ChangeReasonStatusReq( + status=components.ClosingReasonsStatus.ACTIVE, +)) -req = operations.ChangeReasonStatusRequest( - change_reason_status_req=shared.ChangeReasonStatusReq( - status="INACTIVE", - ), - reason_id="deserunt", -) - -res = s.closing_reason.change_reason_status(req) - -if res.status_code == 200: +if res is not None: # handle response + pass + ``` - \ No newline at end of file + \ No newline at end of file diff --git a/workflows_definition/docs/models/components/actiontypecondition.md b/workflows_definition/docs/models/components/actiontypecondition.md new file mode 100644 index 0000000000..0b5f24cc8b --- /dev/null +++ b/workflows_definition/docs/models/components/actiontypecondition.md @@ -0,0 +1,9 @@ +# ActionTypeCondition + + +## Values + +| Name | Value | +| ------------------ | ------------------ | +| `WORKFLOW_STARTED` | WORKFLOW_STARTED | +| `STEP_CLOSED` | STEP_CLOSED | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/automationconfig.md b/workflows_definition/docs/models/components/automationconfig.md new file mode 100644 index 0000000000..e0608b94dc --- /dev/null +++ b/workflows_definition/docs/models/components/automationconfig.md @@ -0,0 +1,8 @@ +# AutomationConfig + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------- | -------------------------------------- | -------------------------------------- | -------------------------------------- | +| `flow_id` | *str* | :heavy_check_mark: | Id of the configured automation to run | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/changereasonstatusreq.md b/workflows_definition/docs/models/components/changereasonstatusreq.md new file mode 100644 index 0000000000..1a16e25bab --- /dev/null +++ b/workflows_definition/docs/models/components/changereasonstatusreq.md @@ -0,0 +1,8 @@ +# ChangeReasonStatusReq + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | +| `status` | [components.ClosingReasonsStatus](../../models/components/closingreasonsstatus.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/closingreason.md b/workflows_definition/docs/models/components/closingreason.md new file mode 100644 index 0000000000..7bcf547f5f --- /dev/null +++ b/workflows_definition/docs/models/components/closingreason.md @@ -0,0 +1,14 @@ +# ClosingReason + +One Closing reason for a workflow + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | +| `status` | [components.ClosingReasonsStatus](../../models/components/closingreasonsstatus.md) | :heavy_check_mark: | N/A | +| `title` | *str* | :heavy_check_mark: | N/A | +| `creation_time` | *Optional[str]* | :heavy_minus_sign: | N/A | +| `id` | *Optional[str]* | :heavy_minus_sign: | N/A | +| `last_update_time` | *Optional[str]* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/closingreasonid.md b/workflows_definition/docs/models/components/closingreasonid.md new file mode 100644 index 0000000000..3f125cffcc --- /dev/null +++ b/workflows_definition/docs/models/components/closingreasonid.md @@ -0,0 +1,8 @@ +# ClosingReasonID + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------ | ------------------ | ------------------ | ------------------ | ------------------ | +| `id` | *str* | :heavy_check_mark: | N/A | x739cew | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/closingreasons.md b/workflows_definition/docs/models/components/closingreasons.md new file mode 100644 index 0000000000..41692238f3 --- /dev/null +++ b/workflows_definition/docs/models/components/closingreasons.md @@ -0,0 +1,8 @@ +# ClosingReasons + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | +| `reasons` | List[[components.ClosingReason](../../models/components/closingreason.md)] | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/closingreasonsids.md b/workflows_definition/docs/models/components/closingreasonsids.md new file mode 100644 index 0000000000..00537002be --- /dev/null +++ b/workflows_definition/docs/models/components/closingreasonsids.md @@ -0,0 +1,8 @@ +# ClosingReasonsIds + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | +| `reasons` | List[[components.ClosingReasonID](../../models/components/closingreasonid.md)] | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/closingreasonsstatus.md b/workflows_definition/docs/models/components/closingreasonsstatus.md new file mode 100644 index 0000000000..b76021aaac --- /dev/null +++ b/workflows_definition/docs/models/components/closingreasonsstatus.md @@ -0,0 +1,9 @@ +# ClosingReasonsStatus + + +## Values + +| Name | Value | +| ---------- | ---------- | +| `ACTIVE` | ACTIVE | +| `INACTIVE` | INACTIVE | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/condition.md b/workflows_definition/docs/models/components/condition.md new file mode 100644 index 0000000000..ddb895be97 --- /dev/null +++ b/workflows_definition/docs/models/components/condition.md @@ -0,0 +1,8 @@ +# Condition + + +## Values + +| Name | Value | +| -------- | -------- | +| `CLOSED` | CLOSED | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/dynamicduedate.md b/workflows_definition/docs/models/components/dynamicduedate.md new file mode 100644 index 0000000000..553c7f72f5 --- /dev/null +++ b/workflows_definition/docs/models/components/dynamicduedate.md @@ -0,0 +1,13 @@ +# DynamicDueDate + +set a Duedate for a step then a specific + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | +| `action_type_condition` | [components.ActionTypeCondition](../../models/components/actiontypecondition.md) | :heavy_check_mark: | N/A | +| `number_of_units` | *float* | :heavy_check_mark: | N/A | +| `time_period` | [components.TimePeriod](../../models/components/timeperiod.md) | :heavy_check_mark: | N/A | +| `step_id` | *Optional[str]* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/ecpdetails.md b/workflows_definition/docs/models/components/ecpdetails.md new file mode 100644 index 0000000000..0959a6ae6e --- /dev/null +++ b/workflows_definition/docs/models/components/ecpdetails.md @@ -0,0 +1,13 @@ +# ECPDetails + +Details regarding ECP for the workflow step + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | +| `description` | *Optional[str]* | :heavy_minus_sign: | N/A | +| `enabled` | *Optional[bool]* | :heavy_minus_sign: | N/A | +| `journey` | [Optional[components.StepJourney]](../../models/components/stepjourney.md) | :heavy_minus_sign: | N/A | +| `label` | *Optional[str]* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/flow.md b/workflows_definition/docs/models/components/flow.md new file mode 100644 index 0000000000..f4731ed413 --- /dev/null +++ b/workflows_definition/docs/models/components/flow.md @@ -0,0 +1,17 @@ +# Flow + + +## Supported Types + +### Section + +```python +flow: components.Section = /* values here */ +``` + +### Step + +```python +flow: components.Step = /* values here */ +``` + diff --git a/workflows_definition/docs/models/components/httpmetadata.md b/workflows_definition/docs/models/components/httpmetadata.md new file mode 100644 index 0000000000..5febcce063 --- /dev/null +++ b/workflows_definition/docs/models/components/httpmetadata.md @@ -0,0 +1,9 @@ +# HTTPMetadata + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | +| `response` | [requests.Response](https://requests.readthedocs.io/en/latest/api/#requests.Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | +| `request` | [requests.Request](https://requests.readthedocs.io/en/latest/api/#requests.Request) | :heavy_check_mark: | Raw HTTP request; suitable for debugging | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/itemtype.md b/workflows_definition/docs/models/components/itemtype.md new file mode 100644 index 0000000000..9d5135e839 --- /dev/null +++ b/workflows_definition/docs/models/components/itemtype.md @@ -0,0 +1,9 @@ +# ItemType + + +## Values + +| Name | Value | +| --------- | --------- | +| `STEP` | STEP | +| `SECTION` | SECTION | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/maxallowedlimit.md b/workflows_definition/docs/models/components/maxallowedlimit.md new file mode 100644 index 0000000000..9f6a5064d2 --- /dev/null +++ b/workflows_definition/docs/models/components/maxallowedlimit.md @@ -0,0 +1,9 @@ +# MaxAllowedLimit + + +## Fields + +| Field | Type | Required | Description | +| ------------------------- | ------------------------- | ------------------------- | ------------------------- | +| `current_no_of_workflows` | *Optional[float]* | :heavy_minus_sign: | N/A | +| `max_allowed` | *Optional[float]* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/section.md b/workflows_definition/docs/models/components/section.md new file mode 100644 index 0000000000..91b4ac610e --- /dev/null +++ b/workflows_definition/docs/models/components/section.md @@ -0,0 +1,14 @@ +# Section + +A group of Steps that define the progress of the Workflow + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | +| `name` | *str* | :heavy_check_mark: | N/A | +| `order` | *float* | :heavy_check_mark: | N/A | +| `steps` | List[[components.Step](../../models/components/step.md)] | :heavy_check_mark: | N/A | +| `type` | [components.ItemType](../../models/components/itemtype.md) | :heavy_check_mark: | N/A | +| `id` | *Optional[str]* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/security.md b/workflows_definition/docs/models/components/security.md new file mode 100644 index 0000000000..f218fa1efc --- /dev/null +++ b/workflows_definition/docs/models/components/security.md @@ -0,0 +1,8 @@ +# Security + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `bearer_auth` | *str* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/source.md b/workflows_definition/docs/models/components/source.md new file mode 100644 index 0000000000..06268eff35 --- /dev/null +++ b/workflows_definition/docs/models/components/source.md @@ -0,0 +1,10 @@ +# Source + + +## Values + +| Name | Value | +| ----------------- | ----------------- | +| `WORKFLOW_STATUS` | workflow_status | +| `CURRENT_SECTION` | current_section | +| `CURRENT_STEP` | current_step | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/step.md b/workflows_definition/docs/models/components/step.md new file mode 100644 index 0000000000..861b97c731 --- /dev/null +++ b/workflows_definition/docs/models/components/step.md @@ -0,0 +1,24 @@ +# Step + +Action that needs to be done in a Workflow + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `name` | *str* | :heavy_check_mark: | N/A | | +| `order` | *float* | :heavy_check_mark: | N/A | | +| `type` | [components.ItemType](../../models/components/itemtype.md) | :heavy_check_mark: | N/A | | +| `assigned_to` | List[*str*] | :heavy_minus_sign: | N/A | | +| `automation_config` | [Optional[components.AutomationConfig]](../../models/components/automationconfig.md) | :heavy_minus_sign: | N/A | | +| `description` | [Optional[components.StepDescription]](../../models/components/stepdescription.md) | :heavy_minus_sign: | Longer information regarding Task | | +| `due_date` | *Optional[str]* | :heavy_minus_sign: | N/A | 2021-04-27T12:00:00.000Z | +| `dynamic_due_date` | [Optional[components.DynamicDueDate]](../../models/components/dynamicduedate.md) | :heavy_minus_sign: | set a Duedate for a step then a specific | | +| `ecp` | [Optional[components.ECPDetails]](../../models/components/ecpdetails.md) | :heavy_minus_sign: | Details regarding ECP for the workflow step | | +| `execution_type` | [Optional[components.StepType]](../../models/components/steptype.md) | :heavy_minus_sign: | N/A | | +| `id` | *Optional[str]* | :heavy_minus_sign: | N/A | | +| `installer` | [Optional[components.ECPDetails]](../../models/components/ecpdetails.md) | :heavy_minus_sign: | Details regarding ECP for the workflow step | | +| `journey` | [Optional[components.StepJourney]](../../models/components/stepjourney.md) | :heavy_minus_sign: | N/A | | +| `requirements` | List[[components.StepRequirement](../../models/components/steprequirement.md)] | :heavy_minus_sign: | requirements that need to be fulfilled in order to enable the step execution | | +| ~~`user_ids`~~ | List[*float*] | :heavy_minus_sign: | : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

This field is deprecated. Please use assignedTo | | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/stepdescription.md b/workflows_definition/docs/models/components/stepdescription.md new file mode 100644 index 0000000000..c78ad90af0 --- /dev/null +++ b/workflows_definition/docs/models/components/stepdescription.md @@ -0,0 +1,11 @@ +# StepDescription + +Longer information regarding Task + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `enabled` | *Optional[bool]* | :heavy_minus_sign: | N/A | +| `value` | *Optional[str]* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/stepjourney.md b/workflows_definition/docs/models/components/stepjourney.md new file mode 100644 index 0000000000..03111fed33 --- /dev/null +++ b/workflows_definition/docs/models/components/stepjourney.md @@ -0,0 +1,10 @@ +# StepJourney + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `id` | *Optional[str]* | :heavy_minus_sign: | N/A | +| `journey_id` | *Optional[str]* | :heavy_minus_sign: | N/A | +| `name` | *Optional[str]* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/steprequirement.md b/workflows_definition/docs/models/components/steprequirement.md new file mode 100644 index 0000000000..f5955f19f0 --- /dev/null +++ b/workflows_definition/docs/models/components/steprequirement.md @@ -0,0 +1,12 @@ +# StepRequirement + +describe the requirement for step enablement + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| `condition` | [components.Condition](../../models/components/condition.md) | :heavy_check_mark: | N/A | +| `definition_id` | *str* | :heavy_check_mark: | N/A | +| `type` | [components.ItemType](../../models/components/itemtype.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/steptype.md b/workflows_definition/docs/models/components/steptype.md new file mode 100644 index 0000000000..c52f47ba5b --- /dev/null +++ b/workflows_definition/docs/models/components/steptype.md @@ -0,0 +1,9 @@ +# StepType + + +## Values + +| Name | Value | +| ------------ | ------------ | +| `MANUAL` | MANUAL | +| `AUTOMATION` | AUTOMATION | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/target.md b/workflows_definition/docs/models/components/target.md new file mode 100644 index 0000000000..d56e270af4 --- /dev/null +++ b/workflows_definition/docs/models/components/target.md @@ -0,0 +1,9 @@ +# Target + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------ | ------------------ | ------------------ | ------------------ | ------------------ | +| `entity_attribute` | *str* | :heavy_check_mark: | N/A | my_status | +| `entity_schema` | *str* | :heavy_check_mark: | N/A | opportunity | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/timeperiod.md b/workflows_definition/docs/models/components/timeperiod.md new file mode 100644 index 0000000000..0c7ea26a69 --- /dev/null +++ b/workflows_definition/docs/models/components/timeperiod.md @@ -0,0 +1,10 @@ +# TimePeriod + + +## Values + +| Name | Value | +| -------- | -------- | +| `DAYS` | days | +| `WEEKS` | weeks | +| `MONTHS` | months | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/updateentityattributes.md b/workflows_definition/docs/models/components/updateentityattributes.md new file mode 100644 index 0000000000..7e7d519bce --- /dev/null +++ b/workflows_definition/docs/models/components/updateentityattributes.md @@ -0,0 +1,9 @@ +# UpdateEntityAttributes + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | +| `source` | [components.Source](../../models/components/source.md) | :heavy_check_mark: | N/A | +| `target` | [components.Target](../../models/components/target.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/workflows_definition/docs/models/components/workflowdefinition.md b/workflows_definition/docs/models/components/workflowdefinition.md new file mode 100644 index 0000000000..7f6bc649fb --- /dev/null +++ b/workflows_definition/docs/models/components/workflowdefinition.md @@ -0,0 +1,20 @@ +# WorkflowDefinition + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `flow` | List[[Union[components.Section, components.Step]](../../models/components/flow.md)] | :heavy_check_mark: | N/A | | +| `name` | *str* | :heavy_check_mark: | N/A | | +| `assigned_to` | List[*str*] | :heavy_minus_sign: | N/A | | +| `closing_reasons` | List[[components.ClosingReasonID](../../models/components/closingreasonid.md)] | :heavy_minus_sign: | N/A | | +| `creation_time` | *Optional[str]* | :heavy_minus_sign: | ISO String Date & Time | 2021-04-27T12:01:13.000Z | +| `description` | *Optional[str]* | :heavy_minus_sign: | N/A | | +| `due_date` | *Optional[str]* | :heavy_minus_sign: | N/A | 2021-04-27T12:00:00.000Z | +| `dynamic_due_date` | [Optional[components.DynamicDueDate]](../../models/components/dynamicduedate.md) | :heavy_minus_sign: | set a Duedate for a step then a specific | | +| `enable_ecp_workflow` | *Optional[bool]* | :heavy_minus_sign: | Indicates whether this workflow is available for End Customer Portal or not. By default it's not. | | +| `id` | *Optional[str]* | :heavy_minus_sign: | N/A | | +| `last_update_time` | *Optional[str]* | :heavy_minus_sign: | ISO String Date & Time | 2021-04-27T12:01:13.000Z | +| `update_entity_attributes` | List[[components.UpdateEntityAttributes](../../models/components/updateentityattributes.md)] | :heavy_minus_sign: | N/A | | +| ~~`user_ids`~~ | List[*float*] | :heavy_minus_sign: | : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

This field is deprecated. Please use assignedTo | | \ No newline at end of file diff --git a/workflows_definition/docs/models/errors/definitionnotfoundresp.md b/workflows_definition/docs/models/errors/definitionnotfoundresp.md new file mode 100644 index 0000000000..f839d1b4d0 --- /dev/null +++ b/workflows_definition/docs/models/errors/definitionnotfoundresp.md @@ -0,0 +1,10 @@ +# DefinitionNotFoundResp + +Definition could be not found + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `message` | *Optional[str]* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/workflows_definition/docs/models/errors/errorresp.md b/workflows_definition/docs/models/errors/errorresp.md new file mode 100644 index 0000000000..03b756e06f --- /dev/null +++ b/workflows_definition/docs/models/errors/errorresp.md @@ -0,0 +1,10 @@ +# ErrorResp + +Other errors + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `message` | *Optional[str]* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/workflows_definition/docs/models/operations/changereasonstatusrequest.md b/workflows_definition/docs/models/operations/changereasonstatusrequest.md new file mode 100644 index 0000000000..ee3ae7cb5b --- /dev/null +++ b/workflows_definition/docs/models/operations/changereasonstatusrequest.md @@ -0,0 +1,9 @@ +# ChangeReasonStatusRequest + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | +| `reason_id` | *str* | :heavy_check_mark: | N/A | +| `change_reason_status_req` | [Optional[components.ChangeReasonStatusReq]](../../models/components/changereasonstatusreq.md) | :heavy_minus_sign: | change the status of a closing reason | \ No newline at end of file diff --git a/workflows_definition/docs/models/operations/changereasonstatusresponse.md b/workflows_definition/docs/models/operations/changereasonstatusresponse.md new file mode 100644 index 0000000000..79b0093afa --- /dev/null +++ b/workflows_definition/docs/models/operations/changereasonstatusresponse.md @@ -0,0 +1,8 @@ +# ChangeReasonStatusResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `http_meta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/workflows_definition/docs/models/operations/createclosingreasonresponse.md b/workflows_definition/docs/models/operations/createclosingreasonresponse.md new file mode 100644 index 0000000000..00368ad622 --- /dev/null +++ b/workflows_definition/docs/models/operations/createclosingreasonresponse.md @@ -0,0 +1,9 @@ +# CreateClosingReasonResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | +| `http_meta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `closing_reason` | [Optional[components.ClosingReason]](../../models/components/closingreason.md) | :heavy_minus_sign: | closing reason is stored successfully in the repository | \ No newline at end of file diff --git a/workflows_definition/docs/models/operations/createdefinitionresponse.md b/workflows_definition/docs/models/operations/createdefinitionresponse.md new file mode 100644 index 0000000000..4d1e275c81 --- /dev/null +++ b/workflows_definition/docs/models/operations/createdefinitionresponse.md @@ -0,0 +1,9 @@ +# CreateDefinitionResponse + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | +| `http_meta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `workflow_definition` | [Optional[components.WorkflowDefinition]](../../models/components/workflowdefinition.md) | :heavy_minus_sign: | Success - if the definition is created successfully | \ No newline at end of file diff --git a/workflows_definition/docs/models/operations/deletedefinitionrequest.md b/workflows_definition/docs/models/operations/deletedefinitionrequest.md new file mode 100644 index 0000000000..ed9bb335d1 --- /dev/null +++ b/workflows_definition/docs/models/operations/deletedefinitionrequest.md @@ -0,0 +1,8 @@ +# DeleteDefinitionRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------- | ----------------------------------- | ----------------------------------- | ----------------------------------- | ----------------------------------- | +| `definition_id` | *str* | :heavy_check_mark: | Id of the definition to de deleted. | CustomerRequest | \ No newline at end of file diff --git a/workflows_definition/docs/models/operations/deletedefinitionresponse.md b/workflows_definition/docs/models/operations/deletedefinitionresponse.md new file mode 100644 index 0000000000..a4ee50811c --- /dev/null +++ b/workflows_definition/docs/models/operations/deletedefinitionresponse.md @@ -0,0 +1,8 @@ +# DeleteDefinitionResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `http_meta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/workflows_definition/docs/models/operations/getallclosingreasonsrequest.md b/workflows_definition/docs/models/operations/getallclosingreasonsrequest.md new file mode 100644 index 0000000000..86888699f2 --- /dev/null +++ b/workflows_definition/docs/models/operations/getallclosingreasonsrequest.md @@ -0,0 +1,8 @@ +# GetAllClosingReasonsRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | +| `include_inactive` | *Optional[bool]* | :heavy_minus_sign: | Filter Closing Reasons by status like active inactiv | true | \ No newline at end of file diff --git a/workflows_definition/docs/models/operations/getallclosingreasonsresponse.md b/workflows_definition/docs/models/operations/getallclosingreasonsresponse.md new file mode 100644 index 0000000000..e8c3404f81 --- /dev/null +++ b/workflows_definition/docs/models/operations/getallclosingreasonsresponse.md @@ -0,0 +1,9 @@ +# GetAllClosingReasonsResponse + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | +| `http_meta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `closing_reasons` | [Optional[components.ClosingReasons]](../../models/components/closingreasons.md) | :heavy_minus_sign: | Returns the entire catalog of closing reasons per organization | \ No newline at end of file diff --git a/workflows_definition/docs/models/operations/getdefinitionrequest.md b/workflows_definition/docs/models/operations/getdefinitionrequest.md new file mode 100644 index 0000000000..29699a25ae --- /dev/null +++ b/workflows_definition/docs/models/operations/getdefinitionrequest.md @@ -0,0 +1,8 @@ +# GetDefinitionRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | +| `definition_id` | *str* | :heavy_check_mark: | Short uuid (length 8) to identify the Workflow Definition. | 7hj28a | \ No newline at end of file diff --git a/workflows_definition/docs/models/operations/getdefinitionresponse.md b/workflows_definition/docs/models/operations/getdefinitionresponse.md new file mode 100644 index 0000000000..e14f99a65f --- /dev/null +++ b/workflows_definition/docs/models/operations/getdefinitionresponse.md @@ -0,0 +1,9 @@ +# GetDefinitionResponse + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | +| `http_meta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `workflow_definition` | [Optional[components.WorkflowDefinition]](../../models/components/workflowdefinition.md) | :heavy_minus_sign: | Returns the Workflow definition | \ No newline at end of file diff --git a/workflows_definition/docs/models/operations/getdefinitionsresponse.md b/workflows_definition/docs/models/operations/getdefinitionsresponse.md new file mode 100644 index 0000000000..e29574830e --- /dev/null +++ b/workflows_definition/docs/models/operations/getdefinitionsresponse.md @@ -0,0 +1,9 @@ +# GetDefinitionsResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | +| `http_meta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `classes` | List[[components.WorkflowDefinition](../../models/components/workflowdefinition.md)] | :heavy_minus_sign: | Success - definitions loaded with success. Empty array if org has no definitions. | \ No newline at end of file diff --git a/workflows_definition/docs/models/operations/getmaxallowedlimitresponse.md b/workflows_definition/docs/models/operations/getmaxallowedlimitresponse.md new file mode 100644 index 0000000000..d4a29a20ce --- /dev/null +++ b/workflows_definition/docs/models/operations/getmaxallowedlimitresponse.md @@ -0,0 +1,9 @@ +# GetMaxAllowedLimitResponse + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | +| `http_meta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `max_allowed_limit` | [Optional[components.MaxAllowedLimit]](../../models/components/maxallowedlimit.md) | :heavy_minus_sign: | A combo of current number of workflows, and the max allowed number of workflows. | \ No newline at end of file diff --git a/workflows_definition/docs/models/operations/getworkflowclosingreasonsrequest.md b/workflows_definition/docs/models/operations/getworkflowclosingreasonsrequest.md new file mode 100644 index 0000000000..e83a71c030 --- /dev/null +++ b/workflows_definition/docs/models/operations/getworkflowclosingreasonsrequest.md @@ -0,0 +1,8 @@ +# GetWorkflowClosingReasonsRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| --------------------------- | --------------------------- | --------------------------- | --------------------------- | --------------------------- | +| `definition_id` | *str* | :heavy_check_mark: | ID of a workflow definition | fxcwfw | \ No newline at end of file diff --git a/workflows_definition/docs/models/operations/getworkflowclosingreasonsresponse.md b/workflows_definition/docs/models/operations/getworkflowclosingreasonsresponse.md new file mode 100644 index 0000000000..174e2e1520 --- /dev/null +++ b/workflows_definition/docs/models/operations/getworkflowclosingreasonsresponse.md @@ -0,0 +1,9 @@ +# GetWorkflowClosingReasonsResponse + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | +| `http_meta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `closing_reasons_ids` | [Optional[components.ClosingReasonsIds]](../../models/components/closingreasonsids.md) | :heavy_minus_sign: | Returns the entire catalog of closing reasons for a specific workflow | \ No newline at end of file diff --git a/workflows_definition/docs/models/operations/setworkflowclosingreasonsrequest.md b/workflows_definition/docs/models/operations/setworkflowclosingreasonsrequest.md new file mode 100644 index 0000000000..6b5e866b8f --- /dev/null +++ b/workflows_definition/docs/models/operations/setworkflowclosingreasonsrequest.md @@ -0,0 +1,9 @@ +# SetWorkflowClosingReasonsRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | +| `closing_reasons_ids` | [components.ClosingReasonsIds](../../models/components/closingreasonsids.md) | :heavy_check_mark: | set all closing reasons for a specific definition | | +| `definition_id` | *str* | :heavy_check_mark: | ID of a workflow definition | 7889 | \ No newline at end of file diff --git a/workflows_definition/docs/models/operations/setworkflowclosingreasonsresponse.md b/workflows_definition/docs/models/operations/setworkflowclosingreasonsresponse.md new file mode 100644 index 0000000000..a476f64abc --- /dev/null +++ b/workflows_definition/docs/models/operations/setworkflowclosingreasonsresponse.md @@ -0,0 +1,8 @@ +# SetWorkflowClosingReasonsResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `http_meta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/workflows_definition/docs/models/operations/updatedefinitionrequest.md b/workflows_definition/docs/models/operations/updatedefinitionrequest.md new file mode 100644 index 0000000000..9579e682a8 --- /dev/null +++ b/workflows_definition/docs/models/operations/updatedefinitionrequest.md @@ -0,0 +1,9 @@ +# UpdateDefinitionRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | +| `workflow_definition` | [components.WorkflowDefinition](../../models/components/workflowdefinition.md) | :heavy_check_mark: | Workflow Definition payload | | +| `definition_id` | *str* | :heavy_check_mark: | Short uuid (length 8) to identify the Workflow Definition. | 7hj28a | \ No newline at end of file diff --git a/workflows_definition/docs/models/operations/updatedefinitionresponse.md b/workflows_definition/docs/models/operations/updatedefinitionresponse.md new file mode 100644 index 0000000000..ea2e791ca2 --- /dev/null +++ b/workflows_definition/docs/models/operations/updatedefinitionresponse.md @@ -0,0 +1,9 @@ +# UpdateDefinitionResponse + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | +| `http_meta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `workflow_definition` | [Optional[components.WorkflowDefinition]](../../models/components/workflowdefinition.md) | :heavy_minus_sign: | Success - if the definition is updated successfully | \ No newline at end of file diff --git a/workflows_definition/docs/sdks/closingreason/README.md b/workflows_definition/docs/sdks/closingreason/README.md new file mode 100644 index 0000000000..8cac54ccb5 --- /dev/null +++ b/workflows_definition/docs/sdks/closingreason/README.md @@ -0,0 +1,128 @@ +# ClosingReason +(*closing_reason*) + +### Available Operations + +* [change_reason_status](#change_reason_status) - changeReasonStatus +* [create_closing_reason](#create_closing_reason) - createClosingReason +* [get_all_closing_reasons](#get_all_closing_reasons) - getAllClosingReasons + +## change_reason_status + +Change the status of a Closing Reason (eg. ACTIVE to INACTIVE). + +### Example Usage + +```python +import sdk +from sdk.models import components + +s = sdk.SDK( + bearer_auth="", +) + +res = s.closing_reason.change_reason_status(reason_id='', change_reason_status_req=components.ChangeReasonStatusReq( + status=components.ClosingReasonsStatus.ACTIVE, +)) + +if res is not None: + # handle response + pass + +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | +| `reason_id` | *str* | :heavy_check_mark: | N/A | +| `change_reason_status_req` | [Optional[components.ChangeReasonStatusReq]](../../models/components/changereasonstatusreq.md) | :heavy_minus_sign: | change the status of a closing reason | + + +### Response + +**[operations.ChangeReasonStatusResponse](../../models/operations/changereasonstatusresponse.md)** +### Errors + +| Error Object | Status Code | Content Type | +| ---------------- | ---------------- | ---------------- | +| errors.ErrorResp | 400,500 | application/json | +| errors.SDKError | 4xx-5xx | */* | + +## create_closing_reason + +A created Closing Reason is stored for the organization and will be displayed in the library of reasons. + +### Example Usage + +```python +import sdk +from sdk.models import components + +s = sdk.SDK( + bearer_auth="", +) + +res = s.closing_reason.create_closing_reason(request=components.ClosingReason( + status=components.ClosingReasonsStatus.ACTIVE, + title='better offer', +)) + +if res.closing_reason is not None: + # handle response + pass + +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | +| `request` | [components.ClosingReason](../../models/components/closingreason.md) | :heavy_check_mark: | The request object to use for the request. | + + +### Response + +**[operations.CreateClosingReasonResponse](../../models/operations/createclosingreasonresponse.md)** +### Errors + +| Error Object | Status Code | Content Type | +| --------------- | --------------- | --------------- | +| errors.SDKError | 4xx-5xx | */* | + +## get_all_closing_reasons + +Get all Closing Reasons defined in the organization by default all Active. + +### Example Usage + +```python +import sdk + +s = sdk.SDK( + bearer_auth="", +) + +res = s.closing_reason.get_all_closing_reasons(include_inactive=True) + +if res.closing_reasons is not None: + # handle response + pass + +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | +| `include_inactive` | *Optional[bool]* | :heavy_minus_sign: | Filter Closing Reasons by status like active inactiv | true | + + +### Response + +**[operations.GetAllClosingReasonsResponse](../../models/operations/getallclosingreasonsresponse.md)** +### Errors + +| Error Object | Status Code | Content Type | +| --------------- | --------------- | --------------- | +| errors.SDKError | 4xx-5xx | */* | diff --git a/workflows_definition/docs/sdks/sdk/README.md b/workflows_definition/docs/sdks/sdk/README.md new file mode 100644 index 0000000000..c7cf50bc9f --- /dev/null +++ b/workflows_definition/docs/sdks/sdk/README.md @@ -0,0 +1,10 @@ +# SDK + + +## Overview + +Workflows Definitions: Service for Workflow Definitions for different processes inside of an Organization + + +### Available Operations + diff --git a/workflows_definition/docs/sdks/workflows/README.md b/workflows_definition/docs/sdks/workflows/README.md new file mode 100644 index 0000000000..074b6da63b --- /dev/null +++ b/workflows_definition/docs/sdks/workflows/README.md @@ -0,0 +1,466 @@ +# Workflows +(*workflows*) + +### Available Operations + +* [create_definition](#create_definition) - createDefinition +* [delete_definition](#delete_definition) - deleteDefinition +* [get_definition](#get_definition) - getDefinition +* [get_definitions](#get_definitions) - getDefinitions +* [get_max_allowed_limit](#get_max_allowed_limit) - getMaxAllowedLimit +* [get_workflow_closing_reasons](#get_workflow_closing_reasons) - getWorkflowClosingReasons +* [set_workflow_closing_reasons](#set_workflow_closing_reasons) - setWorkflowClosingReasons +* [update_definition](#update_definition) - updateDefinition + +## create_definition + +Create a Workflow Definition. + +### Example Usage + +```python +import sdk +from sdk.models import components + +s = sdk.SDK( + bearer_auth="", +) + +res = s.workflows.create_definition(request=components.WorkflowDefinition( + flow=[ + components.Section( + name='Initial Information Gathering', + order=1, + steps=[ + components.Step( + name='Call client and confirm address and product', + order=1, + type=components.ItemType.STEP, + assigned_to=[ + '123482', + ], + due_date='2021-04-27T12:00:00.000Z', + ), + components.Step( + name='Check product availability', + order=2, + type=components.ItemType.STEP, + assigned_to=[ + '123482', + ], + due_date='2021-04-27T12:00:00.000Z', + ), + components.Step( + name='Send email confirming contact with the client', + order=3, + type=components.ItemType.STEP, + assigned_to=[ + '123482', + ], + due_date='2021-04-27T12:00:00.000Z', + ), + ], + type=components.ItemType.SECTION, + ), + components.Section( + name='Print and send catalog', + order=2, + steps=[ + components.Step( + name='', + order=4108.47, + type=components.ItemType.STEP, + due_date='2021-04-27T12:00:00.000Z', + ), + ], + type=components.ItemType.STEP, + ), + ], + name='Lead Qualification', + assigned_to=[ + '952802', + '80225', + ], + closing_reasons=[ + components.ClosingReasonID( + id='x739cew', + ), + ], + creation_time='2021-04-27T12:01:13.000Z', + description='Lead Qualification description', + due_date='2022-08-04T12:00:00.000Z', + last_update_time='2021-04-27T12:01:13.000Z', + update_entity_attributes=[ + components.UpdateEntityAttributes( + source=components.Source.CURRENT_SECTION, + target=components.Target( + entity_attribute='my_status', + entity_schema='opportunity', + ), + ), + ], +)) + +if res.workflow_definition is not None: + # handle response + pass + +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | +| `request` | [components.WorkflowDefinition](../../models/components/workflowdefinition.md) | :heavy_check_mark: | The request object to use for the request. | + + +### Response + +**[operations.CreateDefinitionResponse](../../models/operations/createdefinitionresponse.md)** +### Errors + +| Error Object | Status Code | Content Type | +| ---------------- | ---------------- | ---------------- | +| errors.ErrorResp | 400,401,500 | application/json | +| errors.SDKError | 4xx-5xx | */* | + +## delete_definition + +Delete Workflow Definition. + +### Example Usage + +```python +import sdk + +s = sdk.SDK( + bearer_auth="", +) + +res = s.workflows.delete_definition(definition_id='CustomerRequest') + +if res is not None: + # handle response + pass + +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| ----------------------------------- | ----------------------------------- | ----------------------------------- | ----------------------------------- | ----------------------------------- | +| `definition_id` | *str* | :heavy_check_mark: | Id of the definition to de deleted. | CustomerRequest | + + +### Response + +**[operations.DeleteDefinitionResponse](../../models/operations/deletedefinitionresponse.md)** +### Errors + +| Error Object | Status Code | Content Type | +| ---------------- | ---------------- | ---------------- | +| errors.ErrorResp | 401 | application/json | +| errors.SDKError | 4xx-5xx | */* | + +## get_definition + +Get specific Definition by id from the Organization. + +### Example Usage + +```python +import sdk + +s = sdk.SDK( + bearer_auth="", +) + +res = s.workflows.get_definition(definition_id='7hj28a') + +if res.workflow_definition is not None: + # handle response + pass + +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | +| `definition_id` | *str* | :heavy_check_mark: | Short uuid (length 8) to identify the Workflow Definition. | 7hj28a | + + +### Response + +**[operations.GetDefinitionResponse](../../models/operations/getdefinitionresponse.md)** +### Errors + +| Error Object | Status Code | Content Type | +| ----------------------------- | ----------------------------- | ----------------------------- | +| errors.ErrorResp | 400,401,500 | application/json | +| errors.DefinitionNotFoundResp | 404 | application/json | +| errors.SDKError | 4xx-5xx | */* | + +## get_definitions + +Retrieve all Workflow Definitions from an Organization + +### Example Usage + +```python +import sdk + +s = sdk.SDK( + bearer_auth="", +) + +res = s.workflows.get_definitions() + +if res.classes is not None: + # handle response + pass + +``` + + +### Response + +**[operations.GetDefinitionsResponse](../../models/operations/getdefinitionsresponse.md)** +### Errors + +| Error Object | Status Code | Content Type | +| ---------------- | ---------------- | ---------------- | +| errors.ErrorResp | 500 | application/json | +| errors.SDKError | 4xx-5xx | */* | + +## get_max_allowed_limit + +Get limits and number of created executions for an Organization. + +### Example Usage + +```python +import sdk + +s = sdk.SDK( + bearer_auth="", +) + +res = s.workflows.get_max_allowed_limit() + +if res.max_allowed_limit is not None: + # handle response + pass + +``` + + +### Response + +**[operations.GetMaxAllowedLimitResponse](../../models/operations/getmaxallowedlimitresponse.md)** +### Errors + +| Error Object | Status Code | Content Type | +| ---------------- | ---------------- | ---------------- | +| errors.ErrorResp | 500 | application/json | +| errors.SDKError | 4xx-5xx | */* | + +## get_workflow_closing_reasons + +Returns all closing reasons defined for the workflow. + +### Example Usage + +```python +import sdk + +s = sdk.SDK( + bearer_auth="", +) + +res = s.workflows.get_workflow_closing_reasons(definition_id='fxcwfw') + +if res.closing_reasons_ids is not None: + # handle response + pass + +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| --------------------------- | --------------------------- | --------------------------- | --------------------------- | --------------------------- | +| `definition_id` | *str* | :heavy_check_mark: | ID of a workflow definition | fxcwfw | + + +### Response + +**[operations.GetWorkflowClosingReasonsResponse](../../models/operations/getworkflowclosingreasonsresponse.md)** +### Errors + +| Error Object | Status Code | Content Type | +| --------------- | --------------- | --------------- | +| errors.SDKError | 4xx-5xx | */* | + +## set_workflow_closing_reasons + +Sets which closing reasons are defined for this workflow, based on the entire closing reasons catalog. + +### Example Usage + +```python +import sdk +from sdk.models import components + +s = sdk.SDK( + bearer_auth="", +) + +res = s.workflows.set_workflow_closing_reasons(closing_reasons_ids=components.ClosingReasonsIds( + reasons=[ + components.ClosingReasonID( + id='x739cew', + ), + ], +), definition_id='7889') + +if res is not None: + # handle response + pass + +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | +| `closing_reasons_ids` | [components.ClosingReasonsIds](../../models/components/closingreasonsids.md) | :heavy_check_mark: | set all closing reasons for a specific definition | | +| `definition_id` | *str* | :heavy_check_mark: | ID of a workflow definition | 7889 | + + +### Response + +**[operations.SetWorkflowClosingReasonsResponse](../../models/operations/setworkflowclosingreasonsresponse.md)** +### Errors + +| Error Object | Status Code | Content Type | +| --------------- | --------------- | --------------- | +| errors.SDKError | 4xx-5xx | */* | + +## update_definition + +Update Workflow Definition. + +### Example Usage + +```python +import sdk +from sdk.models import components + +s = sdk.SDK( + bearer_auth="", +) + +res = s.workflows.update_definition(workflow_definition=components.WorkflowDefinition( + flow=[ + components.Section( + name='Initial Information Gathering', + order=1, + steps=[ + components.Step( + name='Call client and confirm address and product', + order=1, + type=components.ItemType.STEP, + assigned_to=[ + '8988', + ], + due_date='2021-04-27T12:00:00.000Z', + id='2hja82a', + ), + components.Step( + name='Check product availability', + order=2, + type=components.ItemType.STEP, + assigned_to=[ + '8988', + ], + due_date='2021-04-27T12:00:00.000Z', + id='ga92ha2', + ), + components.Step( + name='Send email confirming contact with the client', + order=3, + type=components.ItemType.STEP, + assigned_to=[ + '8988', + ], + due_date='2021-04-27T12:00:00.000Z', + id='jga92ha', + ), + ], + type=components.ItemType.SECTION, + id='5892na2', + ), + components.Section( + name='Print and send catalog', + order=2, + steps=[ + components.Step( + name='', + order=4279.02, + type=components.ItemType.SECTION, + due_date='2021-04-27T12:00:00.000Z', + ), + ], + type=components.ItemType.STEP, + id='0a7g22a', + ), + ], + name='Lead Qualification', + assigned_to=[ + '952802', + '80225', + ], + closing_reasons=[ + components.ClosingReasonID( + id='x739cew', + ), + ], + creation_time='2021-08-04T21:13:50.373Z', + due_date='2022-08-04T12:00:00.000Z', + id='25n2k52ja', + last_update_time='2021-08-04T21:13:50.373Z', + update_entity_attributes=[ + components.UpdateEntityAttributes( + source=components.Source.CURRENT_STEP, + target=components.Target( + entity_attribute='my_status', + entity_schema='opportunity', + ), + ), + ], +), definition_id='7hj28a') + +if res.workflow_definition is not None: + # handle response + pass + +``` + +### Parameters + +| Parameter | Type | Required | Description | Example | +| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | +| `workflow_definition` | [components.WorkflowDefinition](../../models/components/workflowdefinition.md) | :heavy_check_mark: | Workflow Definition payload | | +| `definition_id` | *str* | :heavy_check_mark: | Short uuid (length 8) to identify the Workflow Definition. | 7hj28a | + + +### Response + +**[operations.UpdateDefinitionResponse](../../models/operations/updatedefinitionresponse.md)** +### Errors + +| Error Object | Status Code | Content Type | +| ---------------- | ---------------- | ---------------- | +| errors.ErrorResp | 400,401,500 | application/json | +| errors.SDKError | 4xx-5xx | */* | diff --git a/workflows_definition/gen.yaml b/workflows_definition/gen.yaml index 38abb52c11..820d0f1d82 100755 --- a/workflows_definition/gen.yaml +++ b/workflows_definition/gen.yaml @@ -1,16 +1,38 @@ -configVersion: 1.0.0 -management: - docChecksum: 3f8335b3dac5dd26e396d579dbc082e7 - docVersion: 1.0.0 - speakeasyVersion: 1.19.2 - generationVersion: 2.16.5 +configVersion: 2.0.0 generation: - telemetryEnabled: false sdkClassName: SDK + usageSnippets: + optionalPropertyRendering: withExample + fixes: + nameResolutionDec2023: false + parameterOrderingFeb2024: false + requestResponseComponentNamesFeb2024: false + auth: + oAuth2ClientCredentialsEnabled: false sdkFlattening: true - singleTagPerOp: false + telemetryEnabled: false python: - version: 1.2.2 + version: 1.3.0 + additionalDependencies: + dependencies: {} + extraDependencies: + dev: {} author: Speakeasy + clientServerStatusCodesAsErrors: true description: Python Client SDK Generated by Speakeasy + flattenGlobalSecurity: true + imports: + option: openapi + paths: + callbacks: models/callbacks + errors: models/errors + operations: models/operations + shared: models/components + webhooks: models/webhooks + inputModelSuffix: input + maxMethodParams: 4 + methodArguments: require-security-and-request + outputModelSuffix: output packageName: openapi + projectUrls: {} + responseFormat: envelope-http diff --git a/workflows_definition/py.typed b/workflows_definition/py.typed new file mode 100644 index 0000000000..3e38f1a929 --- /dev/null +++ b/workflows_definition/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. The package enables type hints. diff --git a/workflows_definition/pylintrc b/workflows_definition/pylintrc old mode 100755 new mode 100644 index 79b8008d09..6a1c3fc066 --- a/workflows_definition/pylintrc +++ b/workflows_definition/pylintrc @@ -88,7 +88,7 @@ persistent=yes # Minimum Python version to use for version dependent checks. Will default to # the version used to run pylint. -py-version=3.9 +py-version=3.8 # Discover python modules and packages in the file system subtree. recursive=no @@ -116,20 +116,15 @@ argument-naming-style=snake_case #argument-rgx= # Naming style matching correct attribute names. -attr-naming-style=snake_case +#attr-naming-style=snake_case # Regular expression matching correct attribute names. Overrides attr-naming- # style. If left empty, attribute names will be checked with the set naming # style. -#attr-rgx= +attr-rgx=[^\W\d][^\W]*|__.*__$ # Bad variable names which should always be refused, separated by a comma. -bad-names=foo, - bar, - baz, - toto, - tutu, - tata +bad-names= # Bad variable names regexes, separated by a comma. If names match any regex, # they will always be refused @@ -185,6 +180,7 @@ good-names=i, ex, Run, _, + e, id # Good variable names regexes, separated by a comma. If names match any regex, @@ -439,7 +435,15 @@ disable=raw-checker-failed, trailing-newlines, too-many-public-methods, too-many-locals, - too-many-lines + too-many-lines, + using-constant-test, + too-many-statements, + cyclic-import, + too-many-nested-blocks, + too-many-boolean-expressions, + no-else-raise, + bare-except, + broad-exception-caught # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option @@ -620,7 +624,7 @@ additional-builtins= allow-global-unused-variables=yes # List of names allowed to shadow builtins -allowed-redefined-builtins= +allowed-redefined-builtins=id,object # List of strings which can identify a callback function by name. A callback # name must start or end with one of those strings. diff --git a/workflows_definition/setup.py b/workflows_definition/setup.py old mode 100755 new mode 100644 index 997ae148da..20c4e55578 --- a/workflows_definition/setup.py +++ b/workflows_definition/setup.py @@ -1,39 +1,55 @@ """Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" import setuptools +import re try: - with open("README.md", "r") as fh: + with open('README.md', 'r') as fh: long_description = fh.read() + GITHUB_URL = 'https://github.com/epilot-dev/sdk-python.git' + GITHUB_URL = GITHUB_URL[: -len('.git')] if GITHUB_URL.endswith('.git') else GITHUB_URL + # links on PyPI should have absolute URLs + long_description = re.sub( + r'(\[[^\]]+\]\()((?!https?:)[^\)]+)(\))', + lambda m: m.group(1) + GITHUB_URL + '/blob/master/' + m.group(2) + m.group(3), + long_description, + ) except FileNotFoundError: - long_description = "" + long_description = '' setuptools.setup( - name="openapi", - version="1.2.2", - author="Speakeasy", - description="Python Client SDK Generated by Speakeasy", + name='openapi', + version='1.3.0', + author='Speakeasy', + description='Python Client SDK Generated by Speakeasy', + url='https://github.com/epilot-dev/sdk-python.git', long_description=long_description, - long_description_content_type="text/markdown", - packages=setuptools.find_packages(where="src"), + long_description_content_type='text/markdown', + packages=setuptools.find_packages(where='src'), install_requires=[ - "certifi==2022.12.07", - "charset-normalizer==2.1.1", - "dataclasses-json-speakeasy==0.5.8", - "idna==3.3", - "marshmallow==3.17.1", - "marshmallow-enum==1.5.1", - "mypy-extensions==0.4.3", - "packaging==21.3", - "pyparsing==3.0.9", - "python-dateutil==2.8.2", - "requests==2.28.1", - "six==1.16.0", - "typing-inspect==0.8.0", - "typing_extensions==4.3.0", - "urllib3==1.26.12", - "pylint==2.16.2", + "certifi>=2023.7.22", + "charset-normalizer>=3.2.0", + "dataclasses-json>=0.6.4", + "idna>=3.4", + "jsonpath-python>=1.0.6", + "marshmallow>=3.19.0", + "mypy-extensions>=1.0.0", + "packaging>=23.1", + "python-dateutil>=2.8.2", + "requests>=2.31.0", + "six>=1.16.0", + "typing-inspect>=0.9.0", + "typing_extensions>=4.7.1", + "urllib3>=1.26.18", ], + extras_require={ + "dev": [ + "pylint==3.1.0", + ], + }, package_dir={'': 'src'}, - python_requires='>=3.9' + python_requires='>=3.8', + package_data={ + 'openapi': ['py.typed'] + }, ) diff --git a/workflows_definition/src/sdk/__init__.py b/workflows_definition/src/sdk/__init__.py old mode 100755 new mode 100644 index b9e232018a..e6c0deeb64 --- a/workflows_definition/src/sdk/__init__.py +++ b/workflows_definition/src/sdk/__init__.py @@ -1,3 +1,4 @@ """Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" from .sdk import * +from .sdkconfiguration import * diff --git a/workflows_definition/src/sdk/_hooks/__init__.py b/workflows_definition/src/sdk/_hooks/__init__.py new file mode 100644 index 0000000000..5fd985a8ad --- /dev/null +++ b/workflows_definition/src/sdk/_hooks/__init__.py @@ -0,0 +1,5 @@ +"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" + +from .sdkhooks import * +from .types import * +from .registration import * diff --git a/workflows_definition/src/sdk/_hooks/registration.py b/workflows_definition/src/sdk/_hooks/registration.py new file mode 100644 index 0000000000..1db6a52934 --- /dev/null +++ b/workflows_definition/src/sdk/_hooks/registration.py @@ -0,0 +1,13 @@ +from .types import Hooks + + +# This file is only ever generated once on the first generation and then is free to be modified. +# Any hooks you wish to add should be registered in the init_hooks function. Feel free to define them +# in this file or in separate files in the hooks folder. + + +def init_hooks(hooks: Hooks): + # pylint: disable=unused-argument + """Add hooks by calling hooks.register{sdk_init/before_request/after_success/after_error}Hook + with an instance of a hook that implements that specific Hook interface + Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance""" diff --git a/workflows_definition/src/sdk/_hooks/sdkhooks.py b/workflows_definition/src/sdk/_hooks/sdkhooks.py new file mode 100644 index 0000000000..17750b62ca --- /dev/null +++ b/workflows_definition/src/sdk/_hooks/sdkhooks.py @@ -0,0 +1,57 @@ +"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" + +import requests +from .types import SDKInitHook, BeforeRequestContext, BeforeRequestHook, AfterSuccessContext, AfterSuccessHook, AfterErrorContext, AfterErrorHook, Hooks +from .registration import init_hooks +from typing import List, Optional, Tuple + + +class SDKHooks(Hooks): + def __init__(self): + self.sdk_init_hooks: List[SDKInitHook] = [] + self.before_request_hooks: List[BeforeRequestHook] = [] + self.after_success_hooks: List[AfterSuccessHook] = [] + self.after_error_hooks: List[AfterErrorHook] = [] + init_hooks(self) + + def register_sdk_init_hook(self, hook: SDKInitHook) -> None: + self.sdk_init_hooks.append(hook) + + def register_before_request_hook(self, hook: BeforeRequestHook) -> None: + self.before_request_hooks.append(hook) + + def register_after_success_hook(self, hook: AfterSuccessHook) -> None: + self.after_success_hooks.append(hook) + + def register_after_error_hook(self, hook: AfterErrorHook) -> None: + self.after_error_hooks.append(hook) + + def sdk_init(self, base_url: str, client: requests.Session) -> Tuple[str, requests.Session]: + for hook in self.sdk_init_hooks: + base_url, client = hook.sdk_init(base_url, client) + return base_url, client + + def before_request(self, hook_ctx: BeforeRequestContext, request: requests.PreparedRequest) -> requests.PreparedRequest: + for hook in self.before_request_hooks: + out = hook.before_request(hook_ctx, request) + if isinstance(out, Exception): + raise out + request = out + + return request + + def after_success(self, hook_ctx: AfterSuccessContext, response: requests.Response) -> requests.Response: + for hook in self.after_success_hooks: + out = hook.after_success(hook_ctx, response) + if isinstance(out, Exception): + raise out + response = out + return response + + def after_error(self, hook_ctx: AfterErrorContext, response: Optional[requests.Response], error: Optional[Exception]) -> Tuple[Optional[requests.Response], Optional[Exception]]: + for hook in self.after_error_hooks: + result = hook.after_error(hook_ctx, response, error) + if isinstance(result, Exception): + raise result + response, error = result + return response, error diff --git a/workflows_definition/src/sdk/_hooks/types.py b/workflows_definition/src/sdk/_hooks/types.py new file mode 100644 index 0000000000..b24c14146e --- /dev/null +++ b/workflows_definition/src/sdk/_hooks/types.py @@ -0,0 +1,74 @@ +"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" + +import requests as requests_http +from abc import ABC, abstractmethod +from typing import Any, Callable, List, Optional, Tuple, Union + + +class HookContext: + operation_id: str + oauth2_scopes: Optional[List[str]] = None + security_source: Optional[Union[Any, Callable[[], Any]]] = None + + def __init__(self, operation_id: str, oauth2_scopes: Optional[List[str]], security_source: Optional[Union[Any, Callable[[], Any]]]): + self.operation_id = operation_id + self.oauth2_scopes = oauth2_scopes + self.security_source = security_source + + +class BeforeRequestContext(HookContext): + def __init__(self, hook_ctx: HookContext): + super().__init__(hook_ctx.operation_id, hook_ctx.oauth2_scopes, hook_ctx.security_source) + + +class AfterSuccessContext(HookContext): + def __init__(self, hook_ctx: HookContext): + super().__init__(hook_ctx.operation_id, hook_ctx.oauth2_scopes, hook_ctx.security_source) + + + +class AfterErrorContext(HookContext): + def __init__(self, hook_ctx: HookContext): + super().__init__(hook_ctx.operation_id, hook_ctx.oauth2_scopes, hook_ctx.security_source) + + +class SDKInitHook(ABC): + @abstractmethod + def sdk_init(self, base_url: str, client: requests_http.Session) -> Tuple[str, requests_http.Session]: + pass + + +class BeforeRequestHook(ABC): + @abstractmethod + def before_request(self, hook_ctx: BeforeRequestContext, request: requests_http.PreparedRequest) -> Union[requests_http.PreparedRequest, Exception]: + pass + + +class AfterSuccessHook(ABC): + @abstractmethod + def after_success(self, hook_ctx: AfterSuccessContext, response: requests_http.Response) -> Union[requests_http.Response, Exception]: + pass + + +class AfterErrorHook(ABC): + @abstractmethod + def after_error(self, hook_ctx: AfterErrorContext, response: Optional[requests_http.Response], error: Optional[Exception]) -> Union[Tuple[Optional[requests_http.Response], Optional[Exception]], Exception]: + pass + + +class Hooks(ABC): + @abstractmethod + def register_sdk_init_hook(self, hook: SDKInitHook): + pass + + @abstractmethod + def register_before_request_hook(self, hook: BeforeRequestHook): + pass + + @abstractmethod + def register_after_success_hook(self, hook: AfterSuccessHook): + pass + + @abstractmethod + def register_after_error_hook(self, hook: AfterErrorHook): + pass diff --git a/workflows_definition/src/sdk/closing_reason.py b/workflows_definition/src/sdk/closing_reason.py old mode 100755 new mode 100644 index f36c81d19e..1ed6c50b54 --- a/workflows_definition/src/sdk/closing_reason.py +++ b/workflows_definition/src/sdk/closing_reason.py @@ -1,106 +1,208 @@ """Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" import requests as requests_http -from . import utils -from sdk.models import operations, shared +from .sdkconfiguration import SDKConfiguration +from sdk import utils +from sdk._hooks import AfterErrorContext, AfterSuccessContext, BeforeRequestContext, HookContext +from sdk.models import components, errors, operations from typing import Optional class ClosingReason: - _client: requests_http.Session - _security_client: requests_http.Session - _server_url: str - _language: str - _sdk_version: str - _gen_version: str + sdk_configuration: SDKConfiguration - def __init__(self, client: requests_http.Session, security_client: requests_http.Session, server_url: str, language: str, sdk_version: str, gen_version: str) -> None: - self._client = client - self._security_client = security_client - self._server_url = server_url - self._language = language - self._sdk_version = sdk_version - self._gen_version = gen_version - - def change_reason_status(self, request: operations.ChangeReasonStatusRequest) -> operations.ChangeReasonStatusResponse: + def __init__(self, sdk_config: SDKConfiguration) -> None: + self.sdk_configuration = sdk_config + + + + def change_reason_status(self, reason_id: str, change_reason_status_req: Optional[components.ChangeReasonStatusReq] = None) -> operations.ChangeReasonStatusResponse: r"""changeReasonStatus Change the status of a Closing Reason (eg. ACTIVE to INACTIVE). """ - base_url = self._server_url + hook_ctx = HookContext(operation_id='changeReasonStatus', oauth2_scopes=[], security_source=self.sdk_configuration.security) + request = operations.ChangeReasonStatusRequest( + reason_id=reason_id, + change_reason_status_req=change_reason_status_req, + ) - url = utils.generate_url(operations.ChangeReasonStatusRequest, base_url, '/v1/workflows/closing-reasons/{reasonId}', request) + base_url = utils.template_url(*self.sdk_configuration.get_server_details()) - headers = {} - req_content_type, data, form = utils.serialize_request_body(request, "change_reason_status_req", 'json') - if req_content_type not in ('multipart/form-data', 'multipart/mixed'): - headers['content-type'] = req_content_type + url = utils.generate_url(base_url, '/v1/workflows/closing-reasons/{reasonId}', request) - client = self._security_client + if callable(self.sdk_configuration.security): + headers, query_params = utils.get_security(self.sdk_configuration.security()) + else: + headers, query_params = utils.get_security(self.sdk_configuration.security) - http_res = client.request('PATCH', url, data=data, files=form, headers=headers) - content_type = http_res.headers.get('Content-Type') + req_content_type, data, form = utils.serialize_request_body(request, operations.ChangeReasonStatusRequest, "change_reason_status_req", False, True, 'json') + if req_content_type is not None and req_content_type not in ('multipart/form-data', 'multipart/mixed'): + headers['content-type'] = req_content_type + headers['Accept'] = 'application/json' + headers['user-agent'] = self.sdk_configuration.user_agent + client = self.sdk_configuration.client + + try: + req = client.prepare_request(requests_http.Request('PATCH', url, params=query_params, data=data, files=form, headers=headers)) + req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req) + http_res = client.send(req) + except Exception as e: + _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e) + if e is not None: + raise e - res = operations.ChangeReasonStatusResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res) + if utils.match_status_codes(['400','4XX','500','5XX'], http_res.status_code): + result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None) + if e is not None: + raise e + if result is not None: + http_res = result + else: + http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res) + + + + res = operations.ChangeReasonStatusResponse(http_meta=components.HTTPMetadata(request=req, response=http_res)) if http_res.status_code == 202: pass elif http_res.status_code in [400, 500]: - if utils.match_content_type(content_type, 'application/json'): - out = utils.unmarshal_json(http_res.text, Optional[shared.ErrorResp]) - res.error_resp = out + # pylint: disable=no-else-return + if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'): + out = utils.unmarshal_json(http_res.text, errors.ErrorResp) + raise out + else: + content_type = http_res.headers.get('Content-Type') + raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res) + elif http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: + raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) + else: + raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res) return res - def create_closing_reason(self, request: shared.ClosingReason) -> operations.CreateClosingReasonResponse: + + + def create_closing_reason(self, request: components.ClosingReason) -> operations.CreateClosingReasonResponse: r"""createClosingReason A created Closing Reason is stored for the organization and will be displayed in the library of reasons. """ - base_url = self._server_url + hook_ctx = HookContext(operation_id='createClosingReason', oauth2_scopes=[], security_source=self.sdk_configuration.security) + base_url = utils.template_url(*self.sdk_configuration.get_server_details()) + + url = base_url + '/v1/workflows/closing-reasons' - url = base_url.removesuffix('/') + '/v1/workflows/closing-reasons' + if callable(self.sdk_configuration.security): + headers, query_params = utils.get_security(self.sdk_configuration.security()) + else: + headers, query_params = utils.get_security(self.sdk_configuration.security) - headers = {} - req_content_type, data, form = utils.serialize_request_body(request, "request", 'json') - if req_content_type not in ('multipart/form-data', 'multipart/mixed'): + req_content_type, data, form = utils.serialize_request_body(request, components.ClosingReason, "request", False, False, 'json') + if req_content_type is not None and req_content_type not in ('multipart/form-data', 'multipart/mixed'): headers['content-type'] = req_content_type if data is None and form is None: raise Exception('request body is required') + headers['Accept'] = 'application/json' + headers['user-agent'] = self.sdk_configuration.user_agent + client = self.sdk_configuration.client + + try: + req = client.prepare_request(requests_http.Request('POST', url, params=query_params, data=data, files=form, headers=headers)) + req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req) + http_res = client.send(req) + except Exception as e: + _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e) + if e is not None: + raise e + + if utils.match_status_codes(['4XX','5XX'], http_res.status_code): + result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None) + if e is not None: + raise e + if result is not None: + http_res = result + else: + http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res) + - client = self._security_client - http_res = client.request('POST', url, data=data, files=form, headers=headers) - content_type = http_res.headers.get('Content-Type') - - res = operations.CreateClosingReasonResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res) + res = operations.CreateClosingReasonResponse(http_meta=components.HTTPMetadata(request=req, response=http_res)) if http_res.status_code == 201: - if utils.match_content_type(content_type, 'application/json'): - out = utils.unmarshal_json(http_res.text, Optional[shared.ClosingReason]) + # pylint: disable=no-else-return + if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'): + out = utils.unmarshal_json(http_res.text, Optional[components.ClosingReason]) res.closing_reason = out + else: + content_type = http_res.headers.get('Content-Type') + raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res) + elif http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: + raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) + else: + raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res) return res - def get_all_closing_reasons(self, request: operations.GetAllClosingReasonsRequest) -> operations.GetAllClosingReasonsResponse: + + + def get_all_closing_reasons(self, include_inactive: Optional[bool] = None) -> operations.GetAllClosingReasonsResponse: r"""getAllClosingReasons Get all Closing Reasons defined in the organization by default all Active. """ - base_url = self._server_url - - url = base_url.removesuffix('/') + '/v1/workflows/closing-reasons' - - query_params = utils.get_query_params(operations.GetAllClosingReasonsRequest, request) + hook_ctx = HookContext(operation_id='getAllClosingReasons', oauth2_scopes=[], security_source=self.sdk_configuration.security) + request = operations.GetAllClosingReasonsRequest( + include_inactive=include_inactive, + ) + + base_url = utils.template_url(*self.sdk_configuration.get_server_details()) + + url = base_url + '/v1/workflows/closing-reasons' + + if callable(self.sdk_configuration.security): + headers, query_params = utils.get_security(self.sdk_configuration.security()) + else: + headers, query_params = utils.get_security(self.sdk_configuration.security) + + query_params = { **utils.get_query_params(request), **query_params } + headers['Accept'] = 'application/json' + headers['user-agent'] = self.sdk_configuration.user_agent + client = self.sdk_configuration.client + + try: + req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers)) + req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req) + http_res = client.send(req) + except Exception as e: + _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e) + if e is not None: + raise e + + if utils.match_status_codes(['4XX','5XX'], http_res.status_code): + result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None) + if e is not None: + raise e + if result is not None: + http_res = result + else: + http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res) + - client = self._security_client - http_res = client.request('GET', url, params=query_params) - content_type = http_res.headers.get('Content-Type') - - res = operations.GetAllClosingReasonsResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res) + res = operations.GetAllClosingReasonsResponse(http_meta=components.HTTPMetadata(request=req, response=http_res)) if http_res.status_code == 200: - if utils.match_content_type(content_type, 'application/json'): - out = utils.unmarshal_json(http_res.text, Optional[shared.ClosingReasons]) + # pylint: disable=no-else-return + if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'): + out = utils.unmarshal_json(http_res.text, Optional[components.ClosingReasons]) res.closing_reasons = out + else: + content_type = http_res.headers.get('Content-Type') + raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res) + elif http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: + raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) + else: + raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res) return res - \ No newline at end of file + + diff --git a/workflows_definition/src/sdk/models/__init__.py b/workflows_definition/src/sdk/models/__init__.py old mode 100755 new mode 100644 index 889f8adcf4..722bb99827 --- a/workflows_definition/src/sdk/models/__init__.py +++ b/workflows_definition/src/sdk/models/__init__.py @@ -1,2 +1,4 @@ """Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" + +# package diff --git a/workflows_definition/src/sdk/models/components/__init__.py b/workflows_definition/src/sdk/models/components/__init__.py new file mode 100644 index 0000000000..f02c2ed74b --- /dev/null +++ b/workflows_definition/src/sdk/models/components/__init__.py @@ -0,0 +1,24 @@ +"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" + +from .changereasonstatusreq import * +from .closingreason import * +from .closingreasonid import * +from .closingreasons import * +from .closingreasonsids import * +from .closingreasonsstatus import * +from .dynamicduedate import * +from .ecpdetails import * +from .httpmetadata import * +from .itemtype import * +from .maxallowedlimit import * +from .section import * +from .security import * +from .step import * +from .stepdescription import * +from .stepjourney import * +from .steprequirement import * +from .steptype import * +from .updateentityattributes import * +from .workflowdefinition import * + +__all__ = ["ActionTypeCondition","AutomationConfig","ChangeReasonStatusReq","ClosingReason","ClosingReasonID","ClosingReasons","ClosingReasonsIds","ClosingReasonsStatus","Condition","DynamicDueDate","ECPDetails","HTTPMetadata","ItemType","MaxAllowedLimit","Section","Security","Source","Step","StepDescription","StepJourney","StepRequirement","StepType","Target","TimePeriod","UpdateEntityAttributes","WorkflowDefinition"] diff --git a/workflows_definition/src/sdk/models/shared/changereasonstatusreq.py b/workflows_definition/src/sdk/models/components/changereasonstatusreq.py old mode 100755 new mode 100644 similarity index 50% rename from workflows_definition/src/sdk/models/shared/changereasonstatusreq.py rename to workflows_definition/src/sdk/models/components/changereasonstatusreq.py index 778594aa8b..064b2c1ca0 --- a/workflows_definition/src/sdk/models/shared/changereasonstatusreq.py +++ b/workflows_definition/src/sdk/models/components/changereasonstatusreq.py @@ -2,7 +2,7 @@ from __future__ import annotations import dataclasses -from ..shared import closingreasonsstatus_enum as shared_closingreasonsstatus_enum +from .closingreasonsstatus import ClosingReasonsStatus from dataclasses_json import Undefined, dataclass_json from sdk import utils @@ -10,7 +10,6 @@ @dataclass_json(undefined=Undefined.EXCLUDE) @dataclasses.dataclass class ChangeReasonStatusReq: - r"""change the status of a closing reason""" + status: ClosingReasonsStatus = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('status') }}) - status: shared_closingreasonsstatus_enum.ClosingReasonsStatusEnum = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('status') }}) - \ No newline at end of file + diff --git a/workflows_definition/src/sdk/models/shared/closingreason.py b/workflows_definition/src/sdk/models/components/closingreason.py old mode 100755 new mode 100644 similarity index 63% rename from workflows_definition/src/sdk/models/shared/closingreason.py rename to workflows_definition/src/sdk/models/components/closingreason.py index 5de90d0153..c9ba5493ad --- a/workflows_definition/src/sdk/models/shared/closingreason.py +++ b/workflows_definition/src/sdk/models/components/closingreason.py @@ -2,7 +2,7 @@ from __future__ import annotations import dataclasses -from ..shared import closingreasonsstatus_enum as shared_closingreasonsstatus_enum +from .closingreasonsstatus import ClosingReasonsStatus from dataclasses_json import Undefined, dataclass_json from sdk import utils from typing import Optional @@ -12,10 +12,10 @@ @dataclasses.dataclass class ClosingReason: r"""One Closing reason for a workflow""" + status: ClosingReasonsStatus = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('status') }}) + title: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('title') }}) + creation_time: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('creationTime'), 'exclude': lambda f: f is None }}) + id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('id'), 'exclude': lambda f: f is None }}) + last_update_time: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('lastUpdateTime'), 'exclude': lambda f: f is None }}) - status: shared_closingreasonsstatus_enum.ClosingReasonsStatusEnum = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('status') }}) - title: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('title') }}) - creation_time: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('creationTime'), 'exclude': lambda f: f is None }}) - id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('id'), 'exclude': lambda f: f is None }}) - last_update_time: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('lastUpdateTime'), 'exclude': lambda f: f is None }}) - \ No newline at end of file + diff --git a/workflows_definition/src/sdk/models/shared/closingreasonid.py b/workflows_definition/src/sdk/models/components/closingreasonid.py old mode 100755 new mode 100644 similarity index 87% rename from workflows_definition/src/sdk/models/shared/closingreasonid.py rename to workflows_definition/src/sdk/models/components/closingreasonid.py index 4be444c3f0..6f3f25cc05 --- a/workflows_definition/src/sdk/models/shared/closingreasonid.py +++ b/workflows_definition/src/sdk/models/components/closingreasonid.py @@ -9,6 +9,6 @@ @dataclass_json(undefined=Undefined.EXCLUDE) @dataclasses.dataclass class ClosingReasonID: + id: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('id') }}) - id: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('id') }}) - \ No newline at end of file + diff --git a/workflows_definition/src/sdk/models/shared/closingreasons.py b/workflows_definition/src/sdk/models/components/closingreasons.py old mode 100755 new mode 100644 similarity index 50% rename from workflows_definition/src/sdk/models/shared/closingreasons.py rename to workflows_definition/src/sdk/models/components/closingreasons.py index f596d73e55..dc1ede7392 --- a/workflows_definition/src/sdk/models/shared/closingreasons.py +++ b/workflows_definition/src/sdk/models/components/closingreasons.py @@ -2,15 +2,15 @@ from __future__ import annotations import dataclasses -from ..shared import closingreason as shared_closingreason +from .closingreason import ClosingReason from dataclasses_json import Undefined, dataclass_json from sdk import utils +from typing import List @dataclass_json(undefined=Undefined.EXCLUDE) @dataclasses.dataclass class ClosingReasons: - r"""Returns the entire catalog of closing reasons per organization""" + reasons: List[ClosingReason] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('reasons') }}) - reasons: list[shared_closingreason.ClosingReason] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('reasons') }}) - \ No newline at end of file + diff --git a/workflows_definition/src/sdk/models/components/closingreasonsids.py b/workflows_definition/src/sdk/models/components/closingreasonsids.py new file mode 100644 index 0000000000..93cd79e756 --- /dev/null +++ b/workflows_definition/src/sdk/models/components/closingreasonsids.py @@ -0,0 +1,16 @@ +"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" + +from __future__ import annotations +import dataclasses +from .closingreasonid import ClosingReasonID +from dataclasses_json import Undefined, dataclass_json +from sdk import utils +from typing import List + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class ClosingReasonsIds: + reasons: List[ClosingReasonID] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('reasons') }}) + + diff --git a/workflows_definition/src/sdk/models/shared/closingreasonsstatus_enum.py b/workflows_definition/src/sdk/models/components/closingreasonsstatus.py old mode 100755 new mode 100644 similarity index 59% rename from workflows_definition/src/sdk/models/shared/closingreasonsstatus_enum.py rename to workflows_definition/src/sdk/models/components/closingreasonsstatus.py index c38dcb0224..78cb078938 --- a/workflows_definition/src/sdk/models/shared/closingreasonsstatus_enum.py +++ b/workflows_definition/src/sdk/models/components/closingreasonsstatus.py @@ -3,6 +3,6 @@ from __future__ import annotations from enum import Enum -class ClosingReasonsStatusEnum(str, Enum): - ACTIVE = "ACTIVE" - INACTIVE = "INACTIVE" +class ClosingReasonsStatus(str, Enum): + ACTIVE = 'ACTIVE' + INACTIVE = 'INACTIVE' diff --git a/workflows_definition/src/sdk/models/shared/dynamicduedate.py b/workflows_definition/src/sdk/models/components/dynamicduedate.py old mode 100755 new mode 100644 similarity index 51% rename from workflows_definition/src/sdk/models/shared/dynamicduedate.py rename to workflows_definition/src/sdk/models/components/dynamicduedate.py index 9168c322cb..ae9fc46e60 --- a/workflows_definition/src/sdk/models/shared/dynamicduedate.py +++ b/workflows_definition/src/sdk/models/components/dynamicduedate.py @@ -7,23 +7,23 @@ from sdk import utils from typing import Optional -class DynamicDueDateActionTypeConditionEnum(str, Enum): - WORKFLOW_STARTED = "WORKFLOW_STARTED" - STEP_CLOSED = "STEP_CLOSED" +class ActionTypeCondition(str, Enum): + WORKFLOW_STARTED = 'WORKFLOW_STARTED' + STEP_CLOSED = 'STEP_CLOSED' -class DynamicDueDateTimePeriodEnum(str, Enum): - DAYS = "days" - WEEKS = "weeks" - MONTHS = "months" +class TimePeriod(str, Enum): + DAYS = 'days' + WEEKS = 'weeks' + MONTHS = 'months' @dataclass_json(undefined=Undefined.EXCLUDE) @dataclasses.dataclass class DynamicDueDate: r"""set a Duedate for a step then a specific""" + action_type_condition: ActionTypeCondition = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('actionTypeCondition') }}) + number_of_units: float = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('numberOfUnits') }}) + time_period: TimePeriod = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('timePeriod') }}) + step_id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('stepId'), 'exclude': lambda f: f is None }}) - action_type_condition: DynamicDueDateActionTypeConditionEnum = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('actionTypeCondition') }}) - number_of_units: float = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('numberOfUnits') }}) - time_period: DynamicDueDateTimePeriodEnum = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('timePeriod') }}) - step_id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('stepId'), 'exclude': lambda f: f is None }}) - \ No newline at end of file + diff --git a/workflows_definition/src/sdk/models/components/ecpdetails.py b/workflows_definition/src/sdk/models/components/ecpdetails.py new file mode 100644 index 0000000000..c3b3e1f3cf --- /dev/null +++ b/workflows_definition/src/sdk/models/components/ecpdetails.py @@ -0,0 +1,20 @@ +"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" + +from __future__ import annotations +import dataclasses +from .stepjourney import StepJourney +from dataclasses_json import Undefined, dataclass_json +from sdk import utils +from typing import Optional + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class ECPDetails: + r"""Details regarding ECP for the workflow step""" + description: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('description'), 'exclude': lambda f: f is None }}) + enabled: Optional[bool] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('enabled'), 'exclude': lambda f: f is None }}) + journey: Optional[StepJourney] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('journey'), 'exclude': lambda f: f is None }}) + label: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('label'), 'exclude': lambda f: f is None }}) + + diff --git a/workflows_definition/src/sdk/models/components/httpmetadata.py b/workflows_definition/src/sdk/models/components/httpmetadata.py new file mode 100644 index 0000000000..5a87cb4efd --- /dev/null +++ b/workflows_definition/src/sdk/models/components/httpmetadata.py @@ -0,0 +1,17 @@ +"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" + +from __future__ import annotations +import dataclasses +import requests as requests_http +from dataclasses_json import Undefined, dataclass_json + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class HTTPMetadata: + response: requests_http.Response = dataclasses.field(metadata={'dataclasses_json': { 'exclude': lambda f: True }}) + r"""Raw HTTP response; suitable for custom response parsing""" + request: requests_http.Request = dataclasses.field(metadata={'dataclasses_json': { 'exclude': lambda f: True }}) + r"""Raw HTTP request; suitable for debugging""" + + diff --git a/workflows_definition/src/sdk/models/shared/itemtype_enum.py b/workflows_definition/src/sdk/models/components/itemtype.py old mode 100755 new mode 100644 similarity index 64% rename from workflows_definition/src/sdk/models/shared/itemtype_enum.py rename to workflows_definition/src/sdk/models/components/itemtype.py index 0449374b70..9c9bb00b2e --- a/workflows_definition/src/sdk/models/shared/itemtype_enum.py +++ b/workflows_definition/src/sdk/models/components/itemtype.py @@ -3,6 +3,6 @@ from __future__ import annotations from enum import Enum -class ItemTypeEnum(str, Enum): - STEP = "STEP" - SECTION = "SECTION" +class ItemType(str, Enum): + STEP = 'STEP' + SECTION = 'SECTION' diff --git a/workflows_definition/src/sdk/models/shared/maxallowedlimit.py b/workflows_definition/src/sdk/models/components/maxallowedlimit.py old mode 100755 new mode 100644 similarity index 79% rename from workflows_definition/src/sdk/models/shared/maxallowedlimit.py rename to workflows_definition/src/sdk/models/components/maxallowedlimit.py index 27a27b3f19..683c672a5e --- a/workflows_definition/src/sdk/models/shared/maxallowedlimit.py +++ b/workflows_definition/src/sdk/models/components/maxallowedlimit.py @@ -10,8 +10,7 @@ @dataclass_json(undefined=Undefined.EXCLUDE) @dataclasses.dataclass class MaxAllowedLimit: - r"""A combo of current number of workflows, and the max allowed number of workflows.""" + current_no_of_workflows: Optional[float] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('currentNoOfWorkflows'), 'exclude': lambda f: f is None }}) + max_allowed: Optional[float] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('maxAllowed'), 'exclude': lambda f: f is None }}) - current_no_of_workflows: Optional[float] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('currentNoOfWorkflows'), 'exclude': lambda f: f is None }}) - max_allowed: Optional[float] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('maxAllowed'), 'exclude': lambda f: f is None }}) - \ No newline at end of file + diff --git a/workflows_definition/src/sdk/models/shared/section.py b/workflows_definition/src/sdk/models/components/section.py old mode 100755 new mode 100644 similarity index 52% rename from workflows_definition/src/sdk/models/shared/section.py rename to workflows_definition/src/sdk/models/components/section.py index 7d3aaadede..815561a3e8 --- a/workflows_definition/src/sdk/models/shared/section.py +++ b/workflows_definition/src/sdk/models/components/section.py @@ -2,21 +2,21 @@ from __future__ import annotations import dataclasses -from ..shared import itemtype_enum as shared_itemtype_enum -from ..shared import step as shared_step +from .itemtype import ItemType +from .step import Step from dataclasses_json import Undefined, dataclass_json from sdk import utils -from typing import Optional +from typing import List, Optional @dataclass_json(undefined=Undefined.EXCLUDE) @dataclasses.dataclass class Section: r"""A group of Steps that define the progress of the Workflow""" + name: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('name') }}) + order: float = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('order') }}) + steps: List[Step] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('steps') }}) + type: ItemType = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('type') }}) + id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('id'), 'exclude': lambda f: f is None }}) - name: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('name') }}) - order: float = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('order') }}) - steps: list[shared_step.Step] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('steps') }}) - type: shared_itemtype_enum.ItemTypeEnum = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('type') }}) - id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('id'), 'exclude': lambda f: f is None }}) - \ No newline at end of file + diff --git a/workflows_definition/src/sdk/models/shared/security.py b/workflows_definition/src/sdk/models/components/security.py old mode 100755 new mode 100644 similarity index 90% rename from workflows_definition/src/sdk/models/shared/security.py rename to workflows_definition/src/sdk/models/components/security.py index e41721b578..6cd735f54c --- a/workflows_definition/src/sdk/models/shared/security.py +++ b/workflows_definition/src/sdk/models/components/security.py @@ -6,6 +6,6 @@ @dataclasses.dataclass class Security: + bearer_auth: str = dataclasses.field(metadata={'security': { 'scheme': True, 'type': 'http', 'sub_type': 'bearer', 'field_name': 'Authorization' }}) - bearer_auth: str = dataclasses.field(metadata={'security': { 'scheme': True, 'type': 'http', 'sub_type': 'bearer', 'field_name': 'Authorization' }}) - \ No newline at end of file + diff --git a/workflows_definition/src/sdk/models/components/step.py b/workflows_definition/src/sdk/models/components/step.py new file mode 100644 index 0000000000..f7eff4c255 --- /dev/null +++ b/workflows_definition/src/sdk/models/components/step.py @@ -0,0 +1,55 @@ +"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" + +from __future__ import annotations +import dataclasses +from .dynamicduedate import DynamicDueDate +from .ecpdetails import ECPDetails +from .itemtype import ItemType +from .stepdescription import StepDescription +from .stepjourney import StepJourney +from .steprequirement import StepRequirement +from .steptype import StepType +from dataclasses_json import Undefined, dataclass_json +from sdk import utils +from typing import List, Optional + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class AutomationConfig: + flow_id: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('flowId') }}) + r"""Id of the configured automation to run""" + + + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class Step: + r"""Action that needs to be done in a Workflow""" + name: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('name') }}) + order: float = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('order') }}) + type: ItemType = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('type') }}) + assigned_to: Optional[List[str]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('assignedTo'), 'exclude': lambda f: f is None }}) + automation_config: Optional[AutomationConfig] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('automationConfig'), 'exclude': lambda f: f is None }}) + description: Optional[StepDescription] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('description'), 'exclude': lambda f: f is None }}) + r"""Longer information regarding Task""" + due_date: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('dueDate'), 'exclude': lambda f: f is None }}) + dynamic_due_date: Optional[DynamicDueDate] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('dynamicDueDate'), 'exclude': lambda f: f is None }}) + r"""set a Duedate for a step then a specific""" + ecp: Optional[ECPDetails] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('ecp'), 'exclude': lambda f: f is None }}) + r"""Details regarding ECP for the workflow step""" + execution_type: Optional[StepType] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('executionType'), 'exclude': lambda f: f is None }}) + id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('id'), 'exclude': lambda f: f is None }}) + installer: Optional[ECPDetails] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('installer'), 'exclude': lambda f: f is None }}) + r"""Details regarding ECP for the workflow step""" + journey: Optional[StepJourney] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('journey'), 'exclude': lambda f: f is None }}) + requirements: Optional[List[StepRequirement]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('requirements'), 'exclude': lambda f: f is None }}) + r"""requirements that need to be fulfilled in order to enable the step execution""" + user_ids: Optional[List[float]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('userIds'), 'exclude': lambda f: f is None }}) + r"""This field is deprecated. Please use assignedTo + + Deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + """ + + diff --git a/workflows_definition/src/sdk/models/shared/ecpdetails.py b/workflows_definition/src/sdk/models/components/stepdescription.py old mode 100755 new mode 100644 similarity index 51% rename from workflows_definition/src/sdk/models/shared/ecpdetails.py rename to workflows_definition/src/sdk/models/components/stepdescription.py index 9862030a02..8aa1442cd7 --- a/workflows_definition/src/sdk/models/shared/ecpdetails.py +++ b/workflows_definition/src/sdk/models/components/stepdescription.py @@ -9,8 +9,9 @@ @dataclass_json(undefined=Undefined.EXCLUDE) @dataclasses.dataclass -class ECPDetails: - r"""Details regarding ECP for the workflow step""" +class StepDescription: + r"""Longer information regarding Task""" + enabled: Optional[bool] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('enabled'), 'exclude': lambda f: f is None }}) + value: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('value'), 'exclude': lambda f: f is None }}) - label: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('label'), 'exclude': lambda f: f is None }}) - \ No newline at end of file + diff --git a/workflows_definition/src/sdk/models/components/stepjourney.py b/workflows_definition/src/sdk/models/components/stepjourney.py new file mode 100644 index 0000000000..4aa0cb7448 --- /dev/null +++ b/workflows_definition/src/sdk/models/components/stepjourney.py @@ -0,0 +1,17 @@ +"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" + +from __future__ import annotations +import dataclasses +from dataclasses_json import Undefined, dataclass_json +from sdk import utils +from typing import Optional + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class StepJourney: + id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('id'), 'exclude': lambda f: f is None }}) + journey_id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('journeyId'), 'exclude': lambda f: f is None }}) + name: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('name'), 'exclude': lambda f: f is None }}) + + diff --git a/workflows_definition/src/sdk/models/shared/steprequirement.py b/workflows_definition/src/sdk/models/components/steprequirement.py old mode 100755 new mode 100644 similarity index 54% rename from workflows_definition/src/sdk/models/shared/steprequirement.py rename to workflows_definition/src/sdk/models/components/steprequirement.py index da66f00759..a07881f13e --- a/workflows_definition/src/sdk/models/shared/steprequirement.py +++ b/workflows_definition/src/sdk/models/components/steprequirement.py @@ -2,21 +2,21 @@ from __future__ import annotations import dataclasses -from ..shared import itemtype_enum as shared_itemtype_enum +from .itemtype import ItemType from dataclasses_json import Undefined, dataclass_json from enum import Enum from sdk import utils -class StepRequirementConditionEnum(str, Enum): - CLOSED = "CLOSED" +class Condition(str, Enum): + CLOSED = 'CLOSED' @dataclass_json(undefined=Undefined.EXCLUDE) @dataclasses.dataclass class StepRequirement: r"""describe the requirement for step enablement""" + condition: Condition = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('condition') }}) + definition_id: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('definitionId') }}) + type: ItemType = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('type') }}) - condition: StepRequirementConditionEnum = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('condition') }}) - definition_id: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('definitionId') }}) - type: shared_itemtype_enum.ItemTypeEnum = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('type') }}) - \ No newline at end of file + diff --git a/workflows_definition/src/sdk/models/shared/steptype_enum.py b/workflows_definition/src/sdk/models/components/steptype.py old mode 100755 new mode 100644 similarity index 61% rename from workflows_definition/src/sdk/models/shared/steptype_enum.py rename to workflows_definition/src/sdk/models/components/steptype.py index bd26773ba4..178c7ab17b --- a/workflows_definition/src/sdk/models/shared/steptype_enum.py +++ b/workflows_definition/src/sdk/models/components/steptype.py @@ -3,6 +3,6 @@ from __future__ import annotations from enum import Enum -class StepTypeEnum(str, Enum): - MANUAL = "MANUAL" - AUTOMATION = "AUTOMATION" +class StepType(str, Enum): + MANUAL = 'MANUAL' + AUTOMATION = 'AUTOMATION' diff --git a/workflows_definition/src/sdk/models/shared/updateentityattributes.py b/workflows_definition/src/sdk/models/components/updateentityattributes.py old mode 100755 new mode 100644 similarity index 56% rename from workflows_definition/src/sdk/models/shared/updateentityattributes.py rename to workflows_definition/src/sdk/models/components/updateentityattributes.py index 8092aca87c..0e2b4c0bb0 --- a/workflows_definition/src/sdk/models/shared/updateentityattributes.py +++ b/workflows_definition/src/sdk/models/components/updateentityattributes.py @@ -6,24 +6,25 @@ from enum import Enum from sdk import utils -class UpdateEntityAttributesSourceEnum(str, Enum): - WORKFLOW_STATUS = "workflow_status" - CURRENT_SECTION = "current_section" - CURRENT_STEP = "current_step" +class Source(str, Enum): + WORKFLOW_STATUS = 'workflow_status' + CURRENT_SECTION = 'current_section' + CURRENT_STEP = 'current_step' @dataclass_json(undefined=Undefined.EXCLUDE) @dataclasses.dataclass -class UpdateEntityAttributesTarget: - - entity_attribute: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('entityAttribute') }}) - entity_schema: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('entitySchema') }}) +class Target: + entity_attribute: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('entityAttribute') }}) + entity_schema: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('entitySchema') }}) + + @dataclass_json(undefined=Undefined.EXCLUDE) @dataclasses.dataclass class UpdateEntityAttributes: + source: Source = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('source') }}) + target: Target = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('target') }}) - source: UpdateEntityAttributesSourceEnum = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('source') }}) - target: UpdateEntityAttributesTarget = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('target') }}) - \ No newline at end of file + diff --git a/workflows_definition/src/sdk/models/components/workflowdefinition.py b/workflows_definition/src/sdk/models/components/workflowdefinition.py new file mode 100644 index 0000000000..9cc67d2713 --- /dev/null +++ b/workflows_definition/src/sdk/models/components/workflowdefinition.py @@ -0,0 +1,40 @@ +"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" + +from __future__ import annotations +import dataclasses +from .closingreasonid import ClosingReasonID +from .dynamicduedate import DynamicDueDate +from .section import Section +from .step import Step +from .updateentityattributes import UpdateEntityAttributes +from dataclasses_json import Undefined, dataclass_json +from sdk import utils +from typing import List, Optional, Union + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class WorkflowDefinition: + flow: List[Union[Section, Step]] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('flow') }}) + name: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('name') }}) + assigned_to: Optional[List[str]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('assignedTo'), 'exclude': lambda f: f is None }}) + closing_reasons: Optional[List[ClosingReasonID]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('closingReasons'), 'exclude': lambda f: f is None }}) + creation_time: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('creationTime'), 'exclude': lambda f: f is None }}) + r"""ISO String Date & Time""" + description: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('description'), 'exclude': lambda f: f is None }}) + due_date: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('dueDate'), 'exclude': lambda f: f is None }}) + dynamic_due_date: Optional[DynamicDueDate] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('dynamicDueDate'), 'exclude': lambda f: f is None }}) + r"""set a Duedate for a step then a specific""" + enable_ecp_workflow: Optional[bool] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('enableECPWorkflow'), 'exclude': lambda f: f is None }}) + r"""Indicates whether this workflow is available for End Customer Portal or not. By default it's not.""" + id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('id'), 'exclude': lambda f: f is None }}) + last_update_time: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('lastUpdateTime'), 'exclude': lambda f: f is None }}) + r"""ISO String Date & Time""" + update_entity_attributes: Optional[List[UpdateEntityAttributes]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('updateEntityAttributes'), 'exclude': lambda f: f is None }}) + user_ids: Optional[List[float]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('userIds'), 'exclude': lambda f: f is None }}) + r"""This field is deprecated. Please use assignedTo + + Deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. + """ + + diff --git a/workflows_definition/src/sdk/models/errors/__init__.py b/workflows_definition/src/sdk/models/errors/__init__.py new file mode 100644 index 0000000000..d8094abdc2 --- /dev/null +++ b/workflows_definition/src/sdk/models/errors/__init__.py @@ -0,0 +1,7 @@ +"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" + +from .definitionnotfoundresp import * +from .errorresp import * +from .sdkerror import * + +__all__ = ["DefinitionNotFoundResp","ErrorResp","SDKError"] diff --git a/workflows_definition/src/sdk/models/errors/definitionnotfoundresp.py b/workflows_definition/src/sdk/models/errors/definitionnotfoundresp.py new file mode 100644 index 0000000000..170f93588a --- /dev/null +++ b/workflows_definition/src/sdk/models/errors/definitionnotfoundresp.py @@ -0,0 +1,19 @@ +"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" + +from __future__ import annotations +import dataclasses +from dataclasses_json import Undefined, dataclass_json +from sdk import utils +from typing import Optional + + +@dataclass_json(undefined=Undefined.EXCLUDE) + +@dataclasses.dataclass +class DefinitionNotFoundResp(Exception): + r"""Definition could be not found""" + message: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('message'), 'exclude': lambda f: f is None }}) + + + def __str__(self) -> str: + return utils.marshal_json(self, type(self)) diff --git a/workflows_definition/src/sdk/models/shared/errorresp.py b/workflows_definition/src/sdk/models/errors/errorresp.py old mode 100755 new mode 100644 similarity index 70% rename from workflows_definition/src/sdk/models/shared/errorresp.py rename to workflows_definition/src/sdk/models/errors/errorresp.py index 50110f5306..46955699bc --- a/workflows_definition/src/sdk/models/shared/errorresp.py +++ b/workflows_definition/src/sdk/models/errors/errorresp.py @@ -8,9 +8,12 @@ @dataclass_json(undefined=Undefined.EXCLUDE) + @dataclasses.dataclass -class ErrorResp: - r"""bad request""" +class ErrorResp(Exception): + r"""Other errors""" + message: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('message'), 'exclude': lambda f: f is None }}) - message: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('message'), 'exclude': lambda f: f is None }}) - \ No newline at end of file + + def __str__(self) -> str: + return utils.marshal_json(self, type(self)) diff --git a/workflows_definition/src/sdk/models/errors/sdkerror.py b/workflows_definition/src/sdk/models/errors/sdkerror.py new file mode 100644 index 0000000000..6bb02bbd61 --- /dev/null +++ b/workflows_definition/src/sdk/models/errors/sdkerror.py @@ -0,0 +1,24 @@ +"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" + +import requests as requests_http + + +class SDKError(Exception): + """Represents an error returned by the API.""" + message: str + status_code: int + body: str + raw_response: requests_http.Response + + def __init__(self, message: str, status_code: int, body: str, raw_response: requests_http.Response): + self.message = message + self.status_code = status_code + self.body = body + self.raw_response = raw_response + + def __str__(self): + body = '' + if len(self.body) > 0: + body = f'\n{self.body}' + + return f'{self.message}: Status {self.status_code}{body}' diff --git a/workflows_definition/src/sdk/models/operations/__init__.py b/workflows_definition/src/sdk/models/operations/__init__.py old mode 100755 new mode 100644 diff --git a/workflows_definition/src/sdk/models/operations/changereasonstatus.py b/workflows_definition/src/sdk/models/operations/changereasonstatus.py old mode 100755 new mode 100644 index a6a1295100..7eb1735fba --- a/workflows_definition/src/sdk/models/operations/changereasonstatus.py +++ b/workflows_definition/src/sdk/models/operations/changereasonstatus.py @@ -2,26 +2,22 @@ from __future__ import annotations import dataclasses -import requests as requests_http -from ..shared import changereasonstatusreq as shared_changereasonstatusreq -from ..shared import errorresp as shared_errorresp +from ...models.components import changereasonstatusreq as components_changereasonstatusreq +from ...models.components import httpmetadata as components_httpmetadata from typing import Optional @dataclasses.dataclass class ChangeReasonStatusRequest: + reason_id: str = dataclasses.field(metadata={'path_param': { 'field_name': 'reasonId', 'style': 'simple', 'explode': False }}) + change_reason_status_req: Optional[components_changereasonstatusreq.ChangeReasonStatusReq] = dataclasses.field(default=None, metadata={'request': { 'media_type': 'application/json' }}) + r"""change the status of a closing reason""" - reason_id: str = dataclasses.field(metadata={'path_param': { 'field_name': 'reasonId', 'style': 'simple', 'explode': False }}) - change_reason_status_req: Optional[shared_changereasonstatusreq.ChangeReasonStatusReq] = dataclasses.field(default=None, metadata={'request': { 'media_type': 'application/json' }}) - r"""change the status of a closing reason""" - + + @dataclasses.dataclass class ChangeReasonStatusResponse: + http_meta: components_httpmetadata.HTTPMetadata = dataclasses.field() - content_type: str = dataclasses.field() - status_code: int = dataclasses.field() - error_resp: Optional[shared_errorresp.ErrorResp] = dataclasses.field(default=None) - r"""bad request""" - raw_response: Optional[requests_http.Response] = dataclasses.field(default=None) - \ No newline at end of file + diff --git a/workflows_definition/src/sdk/models/operations/createclosingreason.py b/workflows_definition/src/sdk/models/operations/createclosingreason.py old mode 100755 new mode 100644 index c4e3980061..74657c8d61 --- a/workflows_definition/src/sdk/models/operations/createclosingreason.py +++ b/workflows_definition/src/sdk/models/operations/createclosingreason.py @@ -2,17 +2,15 @@ from __future__ import annotations import dataclasses -import requests as requests_http -from ..shared import closingreason as shared_closingreason +from ...models.components import closingreason as components_closingreason +from ...models.components import httpmetadata as components_httpmetadata from typing import Optional @dataclasses.dataclass class CreateClosingReasonResponse: + http_meta: components_httpmetadata.HTTPMetadata = dataclasses.field() + closing_reason: Optional[components_closingreason.ClosingReason] = dataclasses.field(default=None) + r"""closing reason is stored successfully in the repository""" - content_type: str = dataclasses.field() - status_code: int = dataclasses.field() - closing_reason: Optional[shared_closingreason.ClosingReason] = dataclasses.field(default=None) - r"""closing reason is stored successfully in the repository""" - raw_response: Optional[requests_http.Response] = dataclasses.field(default=None) - \ No newline at end of file + diff --git a/workflows_definition/src/sdk/models/operations/createdefinition.py b/workflows_definition/src/sdk/models/operations/createdefinition.py old mode 100755 new mode 100644 index 684e8b7b36..0dd2243691 --- a/workflows_definition/src/sdk/models/operations/createdefinition.py +++ b/workflows_definition/src/sdk/models/operations/createdefinition.py @@ -2,20 +2,15 @@ from __future__ import annotations import dataclasses -import requests as requests_http -from ..shared import errorresp as shared_errorresp -from ..shared import workflowdefinition as shared_workflowdefinition +from ...models.components import httpmetadata as components_httpmetadata +from ...models.components import workflowdefinition as components_workflowdefinition from typing import Optional @dataclasses.dataclass class CreateDefinitionResponse: + http_meta: components_httpmetadata.HTTPMetadata = dataclasses.field() + workflow_definition: Optional[components_workflowdefinition.WorkflowDefinition] = dataclasses.field(default=None) + r"""Success - if the definition is created successfully""" - content_type: str = dataclasses.field() - status_code: int = dataclasses.field() - error_resp: Optional[shared_errorresp.ErrorResp] = dataclasses.field(default=None) - r"""Validation Errors""" - raw_response: Optional[requests_http.Response] = dataclasses.field(default=None) - workflow_definition: Optional[shared_workflowdefinition.WorkflowDefinition] = dataclasses.field(default=None) - r"""Success - if the definition is created successfully""" - \ No newline at end of file + diff --git a/workflows_definition/src/sdk/models/operations/deletedefinition.py b/workflows_definition/src/sdk/models/operations/deletedefinition.py old mode 100755 new mode 100644 index 072a47c07c..0299800ecb --- a/workflows_definition/src/sdk/models/operations/deletedefinition.py +++ b/workflows_definition/src/sdk/models/operations/deletedefinition.py @@ -2,24 +2,19 @@ from __future__ import annotations import dataclasses -import requests as requests_http -from ..shared import errorresp as shared_errorresp -from typing import Optional +from ...models.components import httpmetadata as components_httpmetadata @dataclasses.dataclass class DeleteDefinitionRequest: - definition_id: str = dataclasses.field(metadata={'path_param': { 'field_name': 'definitionId', 'style': 'simple', 'explode': False }}) - r"""Id of the definition to de deleted.""" + r"""Id of the definition to de deleted.""" + + @dataclasses.dataclass class DeleteDefinitionResponse: + http_meta: components_httpmetadata.HTTPMetadata = dataclasses.field() - content_type: str = dataclasses.field() - status_code: int = dataclasses.field() - error_resp: Optional[shared_errorresp.ErrorResp] = dataclasses.field(default=None) - r"""Failed to authenticate""" - raw_response: Optional[requests_http.Response] = dataclasses.field(default=None) - \ No newline at end of file + diff --git a/workflows_definition/src/sdk/models/operations/getallclosingreasons.py b/workflows_definition/src/sdk/models/operations/getallclosingreasons.py old mode 100755 new mode 100644 index eb38791a47..5560147344 --- a/workflows_definition/src/sdk/models/operations/getallclosingreasons.py +++ b/workflows_definition/src/sdk/models/operations/getallclosingreasons.py @@ -2,24 +2,23 @@ from __future__ import annotations import dataclasses -import requests as requests_http -from ..shared import closingreasons as shared_closingreasons +from ...models.components import closingreasons as components_closingreasons +from ...models.components import httpmetadata as components_httpmetadata from typing import Optional @dataclasses.dataclass class GetAllClosingReasonsRequest: - include_inactive: Optional[bool] = dataclasses.field(default=None, metadata={'query_param': { 'field_name': 'includeInactive', 'style': 'form', 'explode': True }}) - r"""Filter Closing Reasons by status like active inactiv""" + r"""Filter Closing Reasons by status like active inactiv""" + + @dataclasses.dataclass class GetAllClosingReasonsResponse: + http_meta: components_httpmetadata.HTTPMetadata = dataclasses.field() + closing_reasons: Optional[components_closingreasons.ClosingReasons] = dataclasses.field(default=None) + r"""Returns the entire catalog of closing reasons per organization""" - content_type: str = dataclasses.field() - status_code: int = dataclasses.field() - closing_reasons: Optional[shared_closingreasons.ClosingReasons] = dataclasses.field(default=None) - r"""Returns the entire catalog of closing reasons per organization""" - raw_response: Optional[requests_http.Response] = dataclasses.field(default=None) - \ No newline at end of file + diff --git a/workflows_definition/src/sdk/models/operations/getdefinition.py b/workflows_definition/src/sdk/models/operations/getdefinition.py old mode 100755 new mode 100644 index 75129d9dff..0654a41024 --- a/workflows_definition/src/sdk/models/operations/getdefinition.py +++ b/workflows_definition/src/sdk/models/operations/getdefinition.py @@ -2,29 +2,23 @@ from __future__ import annotations import dataclasses -import requests as requests_http -from ..shared import errorresp as shared_errorresp -from ..shared import workflowdefinition as shared_workflowdefinition -from typing import Any, Optional +from ...models.components import httpmetadata as components_httpmetadata +from ...models.components import workflowdefinition as components_workflowdefinition +from typing import Optional @dataclasses.dataclass class GetDefinitionRequest: - definition_id: str = dataclasses.field(metadata={'path_param': { 'field_name': 'definitionId', 'style': 'simple', 'explode': False }}) - r"""Short uuid (length 8) to identify the Workflow Definition.""" + r"""Short uuid (length 8) to identify the Workflow Definition.""" + + @dataclasses.dataclass class GetDefinitionResponse: + http_meta: components_httpmetadata.HTTPMetadata = dataclasses.field() + workflow_definition: Optional[components_workflowdefinition.WorkflowDefinition] = dataclasses.field(default=None) + r"""Returns the Workflow definition""" - content_type: str = dataclasses.field() - status_code: int = dataclasses.field() - definition_not_found_resp: Optional[Any] = dataclasses.field(default=None) - r"""Definition Not found""" - error_resp: Optional[shared_errorresp.ErrorResp] = dataclasses.field(default=None) - r"""Validation Errors""" - raw_response: Optional[requests_http.Response] = dataclasses.field(default=None) - workflow_definition: Optional[shared_workflowdefinition.WorkflowDefinition] = dataclasses.field(default=None) - r"""Returns the Workflow definition""" - \ No newline at end of file + diff --git a/workflows_definition/src/sdk/models/operations/getdefinitions.py b/workflows_definition/src/sdk/models/operations/getdefinitions.py old mode 100755 new mode 100644 index a4c55c8901..cffc3c2fb2 --- a/workflows_definition/src/sdk/models/operations/getdefinitions.py +++ b/workflows_definition/src/sdk/models/operations/getdefinitions.py @@ -2,20 +2,15 @@ from __future__ import annotations import dataclasses -import requests as requests_http -from ..shared import errorresp as shared_errorresp -from ..shared import workflowdefinition as shared_workflowdefinition -from typing import Optional +from ...models.components import httpmetadata as components_httpmetadata +from ...models.components import workflowdefinition as components_workflowdefinition +from typing import List, Optional @dataclasses.dataclass class GetDefinitionsResponse: + http_meta: components_httpmetadata.HTTPMetadata = dataclasses.field() + classes: Optional[List[components_workflowdefinition.WorkflowDefinition]] = dataclasses.field(default=None) + r"""Success - definitions loaded with success. Empty array if org has no definitions.""" - content_type: str = dataclasses.field() - status_code: int = dataclasses.field() - error_resp: Optional[shared_errorresp.ErrorResp] = dataclasses.field(default=None) - r"""Other errors""" - raw_response: Optional[requests_http.Response] = dataclasses.field(default=None) - workflow_definitions: Optional[list[shared_workflowdefinition.WorkflowDefinition]] = dataclasses.field(default=None) - r"""Success - definitions loaded with success. Empty array if org has no definitions.""" - \ No newline at end of file + diff --git a/workflows_definition/src/sdk/models/operations/getmaxallowedlimit.py b/workflows_definition/src/sdk/models/operations/getmaxallowedlimit.py old mode 100755 new mode 100644 index 0ecca43748..6035547bd1 --- a/workflows_definition/src/sdk/models/operations/getmaxallowedlimit.py +++ b/workflows_definition/src/sdk/models/operations/getmaxallowedlimit.py @@ -2,20 +2,15 @@ from __future__ import annotations import dataclasses -import requests as requests_http -from ..shared import errorresp as shared_errorresp -from ..shared import maxallowedlimit as shared_maxallowedlimit +from ...models.components import httpmetadata as components_httpmetadata +from ...models.components import maxallowedlimit as components_maxallowedlimit from typing import Optional @dataclasses.dataclass class GetMaxAllowedLimitResponse: + http_meta: components_httpmetadata.HTTPMetadata = dataclasses.field() + max_allowed_limit: Optional[components_maxallowedlimit.MaxAllowedLimit] = dataclasses.field(default=None) + r"""A combo of current number of workflows, and the max allowed number of workflows.""" - content_type: str = dataclasses.field() - status_code: int = dataclasses.field() - error_resp: Optional[shared_errorresp.ErrorResp] = dataclasses.field(default=None) - r"""Other errors""" - max_allowed_limit: Optional[shared_maxallowedlimit.MaxAllowedLimit] = dataclasses.field(default=None) - r"""A combo of current number of workflows, and the max allowed number of workflows.""" - raw_response: Optional[requests_http.Response] = dataclasses.field(default=None) - \ No newline at end of file + diff --git a/workflows_definition/src/sdk/models/operations/getworkflowclosingreasons.py b/workflows_definition/src/sdk/models/operations/getworkflowclosingreasons.py old mode 100755 new mode 100644 index 7d3fdd9b8f..0121a175c0 --- a/workflows_definition/src/sdk/models/operations/getworkflowclosingreasons.py +++ b/workflows_definition/src/sdk/models/operations/getworkflowclosingreasons.py @@ -2,24 +2,23 @@ from __future__ import annotations import dataclasses -import requests as requests_http -from ..shared import closingreasonsids as shared_closingreasonsids +from ...models.components import closingreasonsids as components_closingreasonsids +from ...models.components import httpmetadata as components_httpmetadata from typing import Optional @dataclasses.dataclass class GetWorkflowClosingReasonsRequest: - definition_id: str = dataclasses.field(metadata={'path_param': { 'field_name': 'definitionId', 'style': 'simple', 'explode': False }}) - r"""ID of a workflow definition""" + r"""ID of a workflow definition""" + + @dataclasses.dataclass class GetWorkflowClosingReasonsResponse: + http_meta: components_httpmetadata.HTTPMetadata = dataclasses.field() + closing_reasons_ids: Optional[components_closingreasonsids.ClosingReasonsIds] = dataclasses.field(default=None) + r"""Returns the entire catalog of closing reasons for a specific workflow""" - content_type: str = dataclasses.field() - status_code: int = dataclasses.field() - closing_reasons_ids: Optional[shared_closingreasonsids.ClosingReasonsIds] = dataclasses.field(default=None) - r"""Returns the entire catalog of closing reasons for a specific workflow""" - raw_response: Optional[requests_http.Response] = dataclasses.field(default=None) - \ No newline at end of file + diff --git a/workflows_definition/src/sdk/models/operations/setworkflowclosingreasons.py b/workflows_definition/src/sdk/models/operations/setworkflowclosingreasons.py old mode 100755 new mode 100644 index 73d4a13e33..8853e5b6c6 --- a/workflows_definition/src/sdk/models/operations/setworkflowclosingreasons.py +++ b/workflows_definition/src/sdk/models/operations/setworkflowclosingreasons.py @@ -2,24 +2,22 @@ from __future__ import annotations import dataclasses -import requests as requests_http -from ..shared import closingreasonsids as shared_closingreasonsids -from typing import Optional +from ...models.components import closingreasonsids as components_closingreasonsids +from ...models.components import httpmetadata as components_httpmetadata @dataclasses.dataclass class SetWorkflowClosingReasonsRequest: - - closing_reasons_ids: shared_closingreasonsids.ClosingReasonsIds = dataclasses.field(metadata={'request': { 'media_type': 'application/json' }}) - r"""set all closing reasons for a specific definition""" + closing_reasons_ids: components_closingreasonsids.ClosingReasonsIds = dataclasses.field(metadata={'request': { 'media_type': 'application/json' }}) + r"""set all closing reasons for a specific definition""" definition_id: str = dataclasses.field(metadata={'path_param': { 'field_name': 'definitionId', 'style': 'simple', 'explode': False }}) - r"""ID of a workflow definition""" + r"""ID of a workflow definition""" + + @dataclasses.dataclass class SetWorkflowClosingReasonsResponse: + http_meta: components_httpmetadata.HTTPMetadata = dataclasses.field() - content_type: str = dataclasses.field() - status_code: int = dataclasses.field() - raw_response: Optional[requests_http.Response] = dataclasses.field(default=None) - \ No newline at end of file + diff --git a/workflows_definition/src/sdk/models/operations/updatedefinition.py b/workflows_definition/src/sdk/models/operations/updatedefinition.py old mode 100755 new mode 100644 index 793dbe7b9f..7e4ea37701 --- a/workflows_definition/src/sdk/models/operations/updatedefinition.py +++ b/workflows_definition/src/sdk/models/operations/updatedefinition.py @@ -2,29 +2,25 @@ from __future__ import annotations import dataclasses -import requests as requests_http -from ..shared import errorresp as shared_errorresp -from ..shared import workflowdefinition as shared_workflowdefinition +from ...models.components import httpmetadata as components_httpmetadata +from ...models.components import workflowdefinition as components_workflowdefinition from typing import Optional @dataclasses.dataclass class UpdateDefinitionRequest: - + workflow_definition: components_workflowdefinition.WorkflowDefinition = dataclasses.field(metadata={'request': { 'media_type': 'application/json' }}) + r"""Workflow Definition payload""" definition_id: str = dataclasses.field(metadata={'path_param': { 'field_name': 'definitionId', 'style': 'simple', 'explode': False }}) - r"""Short uuid (length 8) to identify the Workflow Definition.""" - workflow_definition: shared_workflowdefinition.WorkflowDefinition = dataclasses.field(metadata={'request': { 'media_type': 'application/json' }}) - r"""Workflow Definition payload""" + r"""Short uuid (length 8) to identify the Workflow Definition.""" + + @dataclasses.dataclass class UpdateDefinitionResponse: + http_meta: components_httpmetadata.HTTPMetadata = dataclasses.field() + workflow_definition: Optional[components_workflowdefinition.WorkflowDefinition] = dataclasses.field(default=None) + r"""Success - if the definition is updated successfully""" - content_type: str = dataclasses.field() - status_code: int = dataclasses.field() - error_resp: Optional[shared_errorresp.ErrorResp] = dataclasses.field(default=None) - r"""Validation Errors""" - raw_response: Optional[requests_http.Response] = dataclasses.field(default=None) - workflow_definition: Optional[shared_workflowdefinition.WorkflowDefinition] = dataclasses.field(default=None) - r"""Success - if the definition is updated successfully""" - \ No newline at end of file + diff --git a/workflows_definition/src/sdk/models/shared/__init__.py b/workflows_definition/src/sdk/models/shared/__init__.py deleted file mode 100755 index e2d4de35cb..0000000000 --- a/workflows_definition/src/sdk/models/shared/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" - -from .changereasonstatusreq import * -from .closingreason import * -from .closingreasonid import * -from .closingreasons import * -from .closingreasonsids import * -from .closingreasonsstatus_enum import * -from .dynamicduedate import * -from .ecpdetails import * -from .errorresp import * -from .itemtype_enum import * -from .maxallowedlimit import * -from .section import * -from .security import * -from .step import * -from .steprequirement import * -from .steptype_enum import * -from .updateentityattributes import * -from .workflowdefinition import * - -__all__ = ["ChangeReasonStatusReq","ClosingReason","ClosingReasonID","ClosingReasons","ClosingReasonsIds","ClosingReasonsStatusEnum","DynamicDueDate","DynamicDueDateActionTypeConditionEnum","DynamicDueDateTimePeriodEnum","ECPDetails","ErrorResp","ItemTypeEnum","MaxAllowedLimit","Section","Security","Step","StepAutomationConfig","StepRequirement","StepRequirementConditionEnum","StepTypeEnum","UpdateEntityAttributes","UpdateEntityAttributesSourceEnum","UpdateEntityAttributesTarget","WorkflowDefinition"] diff --git a/workflows_definition/src/sdk/models/shared/closingreasonsids.py b/workflows_definition/src/sdk/models/shared/closingreasonsids.py deleted file mode 100755 index e09a205988..0000000000 --- a/workflows_definition/src/sdk/models/shared/closingreasonsids.py +++ /dev/null @@ -1,16 +0,0 @@ -"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" - -from __future__ import annotations -import dataclasses -from ..shared import closingreasonid as shared_closingreasonid -from dataclasses_json import Undefined, dataclass_json -from sdk import utils - - -@dataclass_json(undefined=Undefined.EXCLUDE) -@dataclasses.dataclass -class ClosingReasonsIds: - r"""Returns the entire catalog of closing reasons for a specific workflow""" - - reasons: list[shared_closingreasonid.ClosingReasonID] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('reasons') }}) - \ No newline at end of file diff --git a/workflows_definition/src/sdk/models/shared/step.py b/workflows_definition/src/sdk/models/shared/step.py deleted file mode 100755 index 721ab3632c..0000000000 --- a/workflows_definition/src/sdk/models/shared/step.py +++ /dev/null @@ -1,44 +0,0 @@ -"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" - -from __future__ import annotations -import dataclasses -from ..shared import dynamicduedate as shared_dynamicduedate -from ..shared import ecpdetails as shared_ecpdetails -from ..shared import itemtype_enum as shared_itemtype_enum -from ..shared import steprequirement as shared_steprequirement -from ..shared import steptype_enum as shared_steptype_enum -from dataclasses_json import Undefined, dataclass_json -from sdk import utils -from typing import Optional - - -@dataclass_json(undefined=Undefined.EXCLUDE) -@dataclasses.dataclass -class StepAutomationConfig: - - flow_id: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('flowId') }}) - r"""Id of the configured automation to run""" - - -@dataclass_json(undefined=Undefined.EXCLUDE) -@dataclasses.dataclass -class Step: - r"""Action that needs to be done in a Workflow""" - - name: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('name') }}) - order: float = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('order') }}) - type: shared_itemtype_enum.ItemTypeEnum = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('type') }}) - assigned_to: Optional[list[str]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('assignedTo'), 'exclude': lambda f: f is None }}) - automation_config: Optional[StepAutomationConfig] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('automationConfig'), 'exclude': lambda f: f is None }}) - due_date: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('dueDate'), 'exclude': lambda f: f is None }}) - dynamic_due_date: Optional[shared_dynamicduedate.DynamicDueDate] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('dynamicDueDate'), 'exclude': lambda f: f is None }}) - r"""set a Duedate for a step then a specific""" - ecp: Optional[shared_ecpdetails.ECPDetails] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('ecp'), 'exclude': lambda f: f is None }}) - r"""Details regarding ECP for the workflow step""" - execution_type: Optional[shared_steptype_enum.StepTypeEnum] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('executionType'), 'exclude': lambda f: f is None }}) - id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('id'), 'exclude': lambda f: f is None }}) - requirements: Optional[list[shared_steprequirement.StepRequirement]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('requirements'), 'exclude': lambda f: f is None }}) - r"""requirements that need to be fulfilled in order to enable the step execution""" - user_ids: Optional[list[float]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('userIds'), 'exclude': lambda f: f is None }}) - r"""This field is deprecated. Please use assignedTo""" - \ No newline at end of file diff --git a/workflows_definition/src/sdk/models/shared/workflowdefinition.py b/workflows_definition/src/sdk/models/shared/workflowdefinition.py deleted file mode 100755 index 1ca247d15e..0000000000 --- a/workflows_definition/src/sdk/models/shared/workflowdefinition.py +++ /dev/null @@ -1,36 +0,0 @@ -"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" - -from __future__ import annotations -import dataclasses -from ..shared import closingreasonid as shared_closingreasonid -from ..shared import dynamicduedate as shared_dynamicduedate -from ..shared import updateentityattributes as shared_updateentityattributes -from dataclasses_json import Undefined, dataclass_json -from sdk import utils -from typing import Any, Optional - - -@dataclass_json(undefined=Undefined.EXCLUDE) -@dataclasses.dataclass -class WorkflowDefinition: - r"""Workflow Definition payload""" - - flow: list[Any] = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('flow') }}) - name: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('name') }}) - assigned_to: Optional[list[str]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('assignedTo'), 'exclude': lambda f: f is None }}) - closing_reasons: Optional[list[shared_closingreasonid.ClosingReasonID]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('closingReasons'), 'exclude': lambda f: f is None }}) - creation_time: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('creationTime'), 'exclude': lambda f: f is None }}) - r"""ISO String Date & Time""" - description: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('description'), 'exclude': lambda f: f is None }}) - due_date: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('dueDate'), 'exclude': lambda f: f is None }}) - dynamic_due_date: Optional[shared_dynamicduedate.DynamicDueDate] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('dynamicDueDate'), 'exclude': lambda f: f is None }}) - r"""set a Duedate for a step then a specific""" - enable_ecp_workflow: Optional[bool] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('enableECPWorkflow'), 'exclude': lambda f: f is None }}) - r"""Indicates whether this workflow is available for End Customer Portal or not. By default it's not.""" - id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('id'), 'exclude': lambda f: f is None }}) - last_update_time: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('lastUpdateTime'), 'exclude': lambda f: f is None }}) - r"""ISO String Date & Time""" - update_entity_attributes: Optional[list[shared_updateentityattributes.UpdateEntityAttributes]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('updateEntityAttributes'), 'exclude': lambda f: f is None }}) - user_ids: Optional[list[float]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('userIds'), 'exclude': lambda f: f is None }}) - r"""This field is deprecated. Please use assignedTo""" - \ No newline at end of file diff --git a/workflows_definition/src/sdk/sdk.py b/workflows_definition/src/sdk/sdk.py old mode 100755 new mode 100644 index 4ea77f02e0..a1c25f2792 --- a/workflows_definition/src/sdk/sdk.py +++ b/workflows_definition/src/sdk/sdk.py @@ -1,81 +1,80 @@ """Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" import requests as requests_http -from . import utils from .closing_reason import ClosingReason +from .sdkconfiguration import SDKConfiguration +from .utils.retries import RetryConfig from .workflows import Workflows -from sdk.models import shared - -SERVERS = [ - "https://workflows-definition.sls.epilot.io", -] -"""Contains the list of servers available to the SDK""" +from sdk import utils +from sdk._hooks import SDKHooks +from sdk.models import components +from typing import Callable, Dict, Optional, Union class SDK: - r"""Service for Workflow Definitions for different processes inside of an Organization - - """ + r"""Workflows Definitions: Service for Workflow Definitions for different processes inside of an Organization""" closing_reason: ClosingReason workflows: Workflows - _client: requests_http.Session - _security_client: requests_http.Session - _server_url: str = SERVERS[0] - _language: str = "python" - _sdk_version: str = "1.2.2" - _gen_version: str = "2.16.5" + sdk_configuration: SDKConfiguration def __init__(self, - security: shared.Security = None, - server_url: str = None, - url_params: dict[str, str] = None, - client: requests_http.Session = None + bearer_auth: Union[str, Callable[[], str]], + server_idx: Optional[int] = None, + server_url: Optional[str] = None, + url_params: Optional[Dict[str, str]] = None, + client: Optional[requests_http.Session] = None, + retry_config: Optional[RetryConfig] = None ) -> None: """Instantiates the SDK configuring it with the provided parameters. - - :param security: The security details required for authentication - :type security: shared.Security + + :param bearer_auth: The bearer_auth required for authentication + :type bearer_auth: Union[str, Callable[[], str]] + :param server_idx: The index of the server to use for all operations + :type server_idx: int :param server_url: The server URL to use for all operations :type server_url: str :param url_params: Parameters to optionally template the server URL with - :type url_params: dict[str, str] + :type url_params: Dict[str, str] :param client: The requests.Session HTTP client to use for all operations - :type client: requests_http.Session + :type client: requests_http.Session + :param retry_config: The utils.RetryConfig to use globally + :type retry_config: RetryConfig """ - self._client = requests_http.Session() - - + if client is None: + client = requests_http.Session() + + if callable(bearer_auth): + def security(): + return components.Security(bearer_auth = bearer_auth()) + else: + security = components.Security(bearer_auth = bearer_auth) + if server_url is not None: if url_params is not None: - self._server_url = utils.template_url(server_url, url_params) - else: - self._server_url = server_url + server_url = utils.template_url(server_url, url_params) + + + self.sdk_configuration = SDKConfiguration( + client, + security, + server_url, + server_idx, + retry_config=retry_config + ) - if client is not None: - self._client = client - - self._security_client = utils.configure_security_client(self._client, security) - + hooks = SDKHooks() + + current_server_url, *_ = self.sdk_configuration.get_server_details() + server_url, self.sdk_configuration.client = hooks.sdk_init(current_server_url, self.sdk_configuration.client) + if current_server_url != server_url: + self.sdk_configuration.server_url = server_url + + # pylint: disable=protected-access + self.sdk_configuration.__dict__['_hooks'] = hooks self._init_sdks() - + + def _init_sdks(self): - self.closing_reason = ClosingReason( - self._client, - self._security_client, - self._server_url, - self._language, - self._sdk_version, - self._gen_version - ) - - self.workflows = Workflows( - self._client, - self._security_client, - self._server_url, - self._language, - self._sdk_version, - self._gen_version - ) - - \ No newline at end of file + self.closing_reason = ClosingReason(self.sdk_configuration) + self.workflows = Workflows(self.sdk_configuration) diff --git a/workflows_definition/src/sdk/sdkconfiguration.py b/workflows_definition/src/sdk/sdkconfiguration.py new file mode 100644 index 0000000000..877143150d --- /dev/null +++ b/workflows_definition/src/sdk/sdkconfiguration.py @@ -0,0 +1,44 @@ +"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" + + +import requests as requests_http +from ._hooks import SDKHooks +from .utils import utils +from .utils.retries import RetryConfig +from dataclasses import dataclass +from sdk.models import components +from typing import Callable, Dict, Optional, Tuple, Union + + +SERVERS = [ + 'https://workflows-definition.sls.epilot.io', +] +"""Contains the list of servers available to the SDK""" + +@dataclass +class SDKConfiguration: + client: requests_http.Session + security: Union[components.Security,Callable[[], components.Security]] = None + server_url: Optional[str] = '' + server_idx: Optional[int] = 0 + language: str = 'python' + openapi_doc_version: str = '1.0.0' + sdk_version: str = '1.3.0' + gen_version: str = '2.326.3' + user_agent: str = 'speakeasy-sdk/python 1.3.0 2.326.3 1.0.0 openapi' + retry_config: Optional[RetryConfig] = None + + def __post_init__(self): + self._hooks = SDKHooks() + + def get_server_details(self) -> Tuple[str, Dict[str, str]]: + if self.server_url is not None and self.server_url != '': + return utils.remove_suffix(self.server_url, '/'), {} + if self.server_idx is None: + self.server_idx = 0 + + return SERVERS[self.server_idx], {} + + + def get_hooks(self) -> SDKHooks: + return self._hooks diff --git a/workflows_definition/src/sdk/utils/__init__.py b/workflows_definition/src/sdk/utils/__init__.py old mode 100755 new mode 100644 diff --git a/workflows_definition/src/sdk/utils/retries.py b/workflows_definition/src/sdk/utils/retries.py old mode 100755 new mode 100644 index c6251d948e..c40fc413c0 --- a/workflows_definition/src/sdk/utils/retries.py +++ b/workflows_definition/src/sdk/utils/retries.py @@ -2,6 +2,7 @@ import random import time +from typing import List import requests @@ -24,16 +25,17 @@ class RetryConfig: backoff: BackoffStrategy retry_connection_errors: bool - def __init__(self, strategy: str, retry_connection_errors: bool): + def __init__(self, strategy: str, backoff: BackoffStrategy, retry_connection_errors: bool): self.strategy = strategy + self.backoff = backoff self.retry_connection_errors = retry_connection_errors class Retries: config: RetryConfig - status_codes: list[str] + status_codes: List[str] - def __init__(self, config: RetryConfig, status_codes: list[str]): + def __init__(self, config: RetryConfig, status_codes: List[str]): self.config = config self.status_codes = status_codes @@ -73,12 +75,12 @@ def do_request(): if res.status_code == parsed_code: raise TemporaryError(res) except requests.exceptions.ConnectionError as exception: - if not retries.config.config.retry_connection_errors: + if retries.config.retry_connection_errors: raise raise PermanentError(exception) from exception except requests.exceptions.Timeout as exception: - if not retries.config.config.retry_connection_errors: + if retries.config.retry_connection_errors: raise raise PermanentError(exception) from exception @@ -112,7 +114,6 @@ def retry_with_backoff(func, initial_interval=500, max_interval=60000, exponent= raise sleep = ((initial_interval/1000) * exponent**retries + random.uniform(0, 1)) - if sleep > max_interval/1000: - sleep = max_interval/1000 + sleep = min(sleep, max_interval / 1000) time.sleep(sleep) retries += 1 diff --git a/workflows_definition/src/sdk/utils/utils.py b/workflows_definition/src/sdk/utils/utils.py old mode 100755 new mode 100644 index 9d4fba3248..e55169b101 --- a/workflows_definition/src/sdk/utils/utils.py +++ b/workflows_definition/src/sdk/utils/utils.py @@ -3,37 +3,35 @@ import base64 import json import re -from dataclasses import Field, dataclass, fields, is_dataclass, make_dataclass +import sys +from dataclasses import Field, fields, is_dataclass, make_dataclass from datetime import date, datetime +from decimal import Decimal from email.message import Message from enum import Enum -from typing import Any, Callable, Optional, Tuple, Union, get_args, get_origin +from typing import ( + Any, + Callable, + Dict, + List, + Optional, + Tuple, + Union, + get_args, + get_origin, +) from xmlrpc.client import boolean - +from typing_inspect import is_optional_type import dateutil.parser -import requests from dataclasses_json import DataClassJsonMixin -class SecurityClient: - client: requests.Session - query_params: dict[str, str] = {} - - def __init__(self, client: requests.Session): - self.client = client - - def request(self, method, url, **kwargs): - params = kwargs.get('params', {}) - kwargs["params"] = self.query_params | params - - return self.client.request(method, url, **kwargs) - - -def configure_security_client(client: requests.Session, security: dataclass): - client = SecurityClient(client) +def get_security(security: Any) -> Tuple[Dict[str, str], Dict[str, str]]: + headers: Dict[str, str] = {} + query_params: Dict[str, str] = {} if security is None: - return client + return headers, query_params sec_fields: Tuple[Field, ...] = fields(security) for sec_field in sec_fields: @@ -41,267 +39,380 @@ def configure_security_client(client: requests.Session, security: dataclass): if value is None: continue - metadata = sec_field.metadata.get('security') + metadata = sec_field.metadata.get("security") if metadata is None: continue - if metadata.get('option'): - _parse_security_option(client, value) - return client - if metadata.get('scheme'): + if metadata.get("option"): + _parse_security_option(headers, query_params, value) + return headers, query_params + if metadata.get("scheme"): # Special case for basic auth which could be a flattened struct if metadata.get("sub_type") == "basic" and not is_dataclass(value): - _parse_security_scheme(client, metadata, security) + _parse_security_scheme(headers, query_params, metadata, security) else: - _parse_security_scheme(client, metadata, value) + _parse_security_scheme(headers, query_params, metadata, value) - return client + return headers, query_params -def _parse_security_option(client: SecurityClient, option: dataclass): +def _parse_security_option( + headers: Dict[str, str], query_params: Dict[str, str], option: Any +): opt_fields: Tuple[Field, ...] = fields(option) for opt_field in opt_fields: - metadata = opt_field.metadata.get('security') - if metadata is None or metadata.get('scheme') is None: + metadata = opt_field.metadata.get("security") + if metadata is None or metadata.get("scheme") is None: continue _parse_security_scheme( - client, metadata, getattr(option, opt_field.name)) + headers, query_params, metadata, getattr(option, opt_field.name) + ) -def _parse_security_scheme(client: SecurityClient, scheme_metadata: dict, scheme: any): - scheme_type = scheme_metadata.get('type') - sub_type = scheme_metadata.get('sub_type') +def _parse_security_scheme( + headers: Dict[str, str], + query_params: Dict[str, str], + scheme_metadata: Dict, + scheme: Any, +): + scheme_type = scheme_metadata.get("type") + sub_type = scheme_metadata.get("sub_type") if is_dataclass(scheme): - if scheme_type == 'http' and sub_type == 'basic': - _parse_basic_auth_scheme(client, scheme) + if scheme_type == "http" and sub_type == "basic": + _parse_basic_auth_scheme(headers, scheme) return scheme_fields: Tuple[Field, ...] = fields(scheme) for scheme_field in scheme_fields: - metadata = scheme_field.metadata.get('security') - if metadata is None or metadata.get('field_name') is None: + metadata = scheme_field.metadata.get("security") + if metadata is None or metadata.get("field_name") is None: continue value = getattr(scheme, scheme_field.name) _parse_security_scheme_value( - client, scheme_metadata, metadata, value) + headers, query_params, scheme_metadata, metadata, value + ) else: _parse_security_scheme_value( - client, scheme_metadata, scheme_metadata, scheme) + headers, query_params, scheme_metadata, scheme_metadata, scheme + ) -def _parse_security_scheme_value(client: SecurityClient, scheme_metadata: dict, security_metadata: dict, value: any): - scheme_type = scheme_metadata.get('type') - sub_type = scheme_metadata.get('sub_type') +def _parse_security_scheme_value( + headers: Dict[str, str], + query_params: Dict[str, str], + scheme_metadata: Dict, + security_metadata: Dict, + value: Any, +): + scheme_type = scheme_metadata.get("type") + sub_type = scheme_metadata.get("sub_type") - header_name = security_metadata.get('field_name') + header_name = str(security_metadata.get("field_name")) if scheme_type == "apiKey": - if sub_type == 'header': - client.client.headers[header_name] = value - elif sub_type == 'query': - client.query_params[header_name] = value - elif sub_type == 'cookie': - client.client.cookies[header_name] = value + if sub_type == "header": + headers[header_name] = value + elif sub_type == "query": + query_params[header_name] = value else: - raise Exception('not supported') + raise Exception("not supported") elif scheme_type == "openIdConnect": - client.client.headers[header_name] = value - elif scheme_type == 'oauth2': - client.client.headers[header_name] = value - elif scheme_type == 'http': - if sub_type == 'bearer': - client.client.headers[header_name] = value + headers[header_name] = _apply_bearer(value) + elif scheme_type == "oauth2": + if sub_type != "client_credentials": + headers[header_name] = _apply_bearer(value) + elif scheme_type == "http": + if sub_type == "bearer": + headers[header_name] = _apply_bearer(value) else: - raise Exception('not supported') + raise Exception("not supported") else: - raise Exception('not supported') + raise Exception("not supported") + +def _apply_bearer(token: str) -> str: + return token.lower().startswith("bearer ") and token or f"Bearer {token}" -def _parse_basic_auth_scheme(client: SecurityClient, scheme: dataclass): + +def _parse_basic_auth_scheme(headers: Dict[str, str], scheme: Any): username = "" password = "" scheme_fields: Tuple[Field, ...] = fields(scheme) for scheme_field in scheme_fields: - metadata = scheme_field.metadata.get('security') - if metadata is None or metadata.get('field_name') is None: + metadata = scheme_field.metadata.get("security") + if metadata is None or metadata.get("field_name") is None: continue - field_name = metadata.get('field_name') + field_name = metadata.get("field_name") value = getattr(scheme, scheme_field.name) - if field_name == 'username': + if field_name == "username": username = value - if field_name == 'password': + if field_name == "password": password = value - data = f'{username}:{password}'.encode() - client.client.headers['Authorization'] = f'Basic {base64.b64encode(data).decode()}' + data = f"{username}:{password}".encode() + headers["Authorization"] = f"Basic {base64.b64encode(data).decode()}" + +def generate_url( + server_url: str, + path: str, + path_params: Any, + gbls: Optional[Any] = None, +) -> str: + path_param_values: Dict[str, str] = {} -def generate_url(clazz: type, server_url: str, path: str, path_params: dataclass, gbls: dict[str, dict[str, dict[str, Any]]] = None) -> str: - path_param_fields: Tuple[Field, ...] = fields(clazz) + globals_already_populated = _populate_path_params( + path_params, gbls, path_param_values, [] + ) + if gbls is not None: + _populate_path_params(gbls, None, path_param_values, globals_already_populated) + + for key, value in path_param_values.items(): + path = path.replace("{" + key + "}", value, 1) + + return remove_suffix(server_url, "/") + path + + +def _populate_path_params( + path_params: Any, + gbls: Any, + path_param_values: Dict[str, str], + skip_fields: List[str], +) -> List[str]: + globals_already_populated: List[str] = [] + + path_param_fields: Tuple[Field, ...] = fields(path_params) for field in path_param_fields: - request_metadata = field.metadata.get('request') - if request_metadata is not None: + if field.name in skip_fields: continue - param_metadata = field.metadata.get('path_param') + param_metadata = field.metadata.get("path_param") if param_metadata is None: continue - if param_metadata.get('style', 'simple') == 'simple': - param = getattr( - path_params, field.name) if path_params is not None else None - param = _populate_from_globals( - field.name, param, 'pathParam', gbls) - - if param is None: - continue + param = getattr(path_params, field.name) if path_params is not None else None + param, global_found = _populate_from_globals( + field.name, param, "path_param", gbls + ) + if global_found: + globals_already_populated.append(field.name) - if isinstance(param, list): - pp_vals: list[str] = [] - for pp_val in param: - if pp_val is None: - continue - pp_vals.append(_val_to_string(pp_val)) - path = path.replace( - '{' + param_metadata.get('field_name', field.name) + '}', ",".join(pp_vals), 1) - elif isinstance(param, dict): - pp_vals: list[str] = [] - for pp_key in param: - if param[pp_key] is None: - continue - if param_metadata.get('explode'): - pp_vals.append( - f"{pp_key}={_val_to_string(param[pp_key])}") - else: - pp_vals.append( - f"{pp_key},{_val_to_string(param[pp_key])}") - path = path.replace( - '{' + param_metadata.get('field_name', field.name) + '}', ",".join(pp_vals), 1) - elif not isinstance(param, (str, int, float, complex, bool)): - pp_vals: list[str] = [] - param_fields: Tuple[Field, ...] = fields(param) - for param_field in param_fields: - param_value_metadata = param_field.metadata.get( - 'path_param') - if not param_value_metadata: - continue - - parm_name = param_value_metadata.get( - 'field_name', field.name) + if param is None: + continue - param_field_val = getattr(param, param_field.name) - if param_field_val is None: - continue - if param_metadata.get('explode'): - pp_vals.append( - f"{parm_name}={_val_to_string(param_field_val)}") - else: - pp_vals.append( - f"{parm_name},{_val_to_string(param_field_val)}") - path = path.replace( - '{' + param_metadata.get('field_name', field.name) + '}', ",".join(pp_vals), 1) - else: - path = path.replace( - '{' + param_metadata.get('field_name', field.name) + '}', _val_to_string(param), 1) + f_name = param_metadata.get("field_name", field.name) + serialization = param_metadata.get("serialization", "") + if serialization != "": + serialized_params = _get_serialized_params( + param_metadata, field.type, f_name, param + ) + for key, value in serialized_params.items(): + path_param_values[key] = value + else: + if param_metadata.get("style", "simple") == "simple": + if isinstance(param, List): + pp_vals: List[str] = [] + for pp_val in param: + if pp_val is None: + continue + pp_vals.append(_val_to_string(pp_val)) + path_param_values[param_metadata.get("field_name", field.name)] = ( + ",".join(pp_vals) + ) + elif isinstance(param, Dict): + pp_vals: List[str] = [] + for pp_key in param: + if param[pp_key] is None: + continue + if param_metadata.get("explode"): + pp_vals.append(f"{pp_key}={_val_to_string(param[pp_key])}") + else: + pp_vals.append(f"{pp_key},{_val_to_string(param[pp_key])}") + path_param_values[param_metadata.get("field_name", field.name)] = ( + ",".join(pp_vals) + ) + elif not isinstance(param, (str, int, float, complex, bool, Decimal)): + pp_vals: List[str] = [] + param_fields: Tuple[Field, ...] = fields(param) + for param_field in param_fields: + param_value_metadata = param_field.metadata.get("path_param") + if not param_value_metadata: + continue + + param_name = param_value_metadata.get("field_name", field.name) + + param_field_val = getattr(param, param_field.name) + if param_field_val is None: + continue + if param_metadata.get("explode"): + pp_vals.append( + f"{param_name}={_val_to_string(param_field_val)}" + ) + else: + pp_vals.append( + f"{param_name},{_val_to_string(param_field_val)}" + ) + path_param_values[param_metadata.get("field_name", field.name)] = ( + ",".join(pp_vals) + ) + else: + path_param_values[param_metadata.get("field_name", field.name)] = ( + _val_to_string(param) + ) - return server_url.removesuffix("/") + path + return globals_already_populated def is_optional(field): return get_origin(field) is Union and type(None) in get_args(field) -def template_url(url_with_params: str, params: dict[str, str]) -> str: +def template_url(url_with_params: str, params: Dict[str, str]) -> str: for key, value in params.items(): - url_with_params = url_with_params.replace( - '{' + key + '}', value) + url_with_params = url_with_params.replace("{" + key + "}", value) return url_with_params -def get_query_params(clazz: type, query_params: dataclass, gbls: dict[str, dict[str, dict[str, Any]]] = None) -> dict[str, list[str]]: - params: dict[str, list[str]] = {} +def get_query_params( + query_params: Any, + gbls: Optional[Any] = None, +) -> Dict[str, List[str]]: + params: Dict[str, List[str]] = {} - param_fields: Tuple[Field, ...] = fields(clazz) + globals_already_populated = _populate_query_params(query_params, gbls, params, []) + if gbls is not None: + _populate_query_params(gbls, None, params, globals_already_populated) + + return params + + +def _populate_query_params( + query_params: Any, + gbls: Any, + query_param_values: Dict[str, List[str]], + skip_fields: List[str], +) -> List[str]: + globals_already_populated: List[str] = [] + + param_fields: Tuple[Field, ...] = fields(query_params) for field in param_fields: - request_metadata = field.metadata.get('request') - if request_metadata is not None: + if field.name in skip_fields: continue - metadata = field.metadata.get('query_param') + metadata = field.metadata.get("query_param") if not metadata: continue param_name = field.name - value = getattr( - query_params, param_name) if query_params is not None else None + value = getattr(query_params, param_name) if query_params is not None else None - value = _populate_from_globals(param_name, value, 'queryParam', gbls) + value, global_found = _populate_from_globals( + param_name, value, "query_param", gbls + ) + if global_found: + globals_already_populated.append(param_name) f_name = metadata.get("field_name") - serialization = metadata.get('serialization', '') - if serialization != '': - params = params | _get_serialized_query_params( - metadata, f_name, value) + serialization = metadata.get("serialization", "") + if serialization != "": + serialized_parms = _get_serialized_params( + metadata, field.type, f_name, value + ) + for key, value in serialized_parms.items(): + if key in query_param_values: + query_param_values[key].extend(value) + else: + query_param_values[key] = [value] else: - style = metadata.get('style', 'form') - if style == 'deepObject': - params = params | _get_deep_object_query_params( - metadata, f_name, value) - elif style == 'form': - params = params | _get_form_query_params( - metadata, f_name, value) + style = metadata.get("style", "form") + if style == "deepObject": + _populate_deep_object_query_params( + metadata, f_name, value, query_param_values + ) + elif style == "form": + _populate_delimited_query_params( + metadata, f_name, value, ",", query_param_values + ) + elif style == "pipeDelimited": + _populate_delimited_query_params( + metadata, f_name, value, "|", query_param_values + ) else: - raise Exception('not yet implemented') - return params + raise Exception("not yet implemented") + + return globals_already_populated -def get_headers(headers_params: dataclass) -> dict[str, str]: - if headers_params is None: - return {} +def get_headers(headers_params: Any, gbls: Optional[Any] = None) -> Dict[str, str]: + headers: Dict[str, str] = {} - headers: dict[str, str] = {} + globals_already_populated = [] + if headers_params is not None: + globals_already_populated = _populate_headers(headers_params, gbls, headers, []) + if gbls is not None: + _populate_headers(gbls, None, headers, globals_already_populated) + + return headers + + +def _populate_headers( + headers_params: Any, + gbls: Any, + header_values: Dict[str, str], + skip_fields: List[str], +) -> List[str]: + globals_already_populated: List[str] = [] param_fields: Tuple[Field, ...] = fields(headers_params) for field in param_fields: - metadata = field.metadata.get('header') + if field.name in skip_fields: + continue + + metadata = field.metadata.get("header") if not metadata: continue - value = _serialize_header(metadata.get( - 'explode', False), getattr(headers_params, field.name)) + value, global_found = _populate_from_globals( + field.name, getattr(headers_params, field.name), "header", gbls + ) + if global_found: + globals_already_populated.append(field.name) + value = _serialize_header(metadata.get("explode", False), value) - if value != '': - headers[metadata.get('field_name', field.name)] = value + if value != "": + header_values[metadata.get("field_name", field.name)] = value - return headers + return globals_already_populated -def _get_serialized_query_params(metadata: dict, field_name: str, obj: any) -> dict[str, list[str]]: - params: dict[str, list[str]] = {} +def _get_serialized_params( + metadata: Dict, field_type: type, field_name: str, obj: Any +) -> Dict[str, str]: + params: Dict[str, str] = {} - serialization = metadata.get('serialization', '') - if serialization == 'json': - params[metadata.get("field_name", field_name)] = marshal_json(obj) + serialization = metadata.get("serialization", "") + if serialization == "json": + params[metadata.get("field_name", field_name)] = marshal_json(obj, field_type) return params -def _get_deep_object_query_params(metadata: dict, field_name: str, obj: any) -> dict[str, list[str]]: - params: dict[str, list[str]] = {} - +def _populate_deep_object_query_params( + metadata: Dict, field_name: str, obj: Any, params: Dict[str, List[str]] +): if obj is None: - return params + return if is_dataclass(obj): obj_fields: Tuple[Field, ...] = fields(obj) for obj_field in obj_fields: - obj_param_metadata = obj_field.metadata.get('query_param') + obj_param_metadata = obj_field.metadata.get("query_param") if not obj_param_metadata: continue @@ -309,45 +420,55 @@ def _get_deep_object_query_params(metadata: dict, field_name: str, obj: any) -> if obj_val is None: continue - if isinstance(obj_val, list): + if isinstance(obj_val, List): for val in obj_val: if val is None: continue - if params.get(f'{metadata.get("field_name", field_name)}[{obj_param_metadata.get("field_name", obj_field.name)}]') is None: - params[f'{metadata.get("field_name", field_name)}[{obj_param_metadata.get("field_name", obj_field.name)}]'] = [ - ] + if ( + params.get( + f'{metadata.get("field_name", field_name)}[{obj_param_metadata.get("field_name", obj_field.name)}]' + ) + is None + ): + params[ + f'{metadata.get("field_name", field_name)}[{obj_param_metadata.get("field_name", obj_field.name)}]' + ] = [] params[ - f'{metadata.get("field_name", field_name)}[{obj_param_metadata.get("field_name", obj_field.name)}]'].append(_val_to_string(val)) + f'{metadata.get("field_name", field_name)}[{obj_param_metadata.get("field_name", obj_field.name)}]' + ].append(_val_to_string(val)) else: params[ - f'{metadata.get("field_name", field_name)}[{obj_param_metadata.get("field_name", obj_field.name)}]'] = [ - _val_to_string(obj_val)] - elif isinstance(obj, dict): + f'{metadata.get("field_name", field_name)}[{obj_param_metadata.get("field_name", obj_field.name)}]' + ] = [_val_to_string(obj_val)] + elif isinstance(obj, Dict): for key, value in obj.items(): if value is None: continue - if isinstance(value, list): + if isinstance(value, List): for val in value: if val is None: continue - if params.get(f'{metadata.get("field_name", field_name)}[{key}]') is None: - params[f'{metadata.get("field_name", field_name)}[{key}]'] = [ - ] + if ( + params.get(f'{metadata.get("field_name", field_name)}[{key}]') + is None + ): + params[f'{metadata.get("field_name", field_name)}[{key}]'] = [] - params[ - f'{metadata.get("field_name", field_name)}[{key}]'].append(_val_to_string(val)) + params[f'{metadata.get("field_name", field_name)}[{key}]'].append( + _val_to_string(val) + ) else: params[f'{metadata.get("field_name", field_name)}[{key}]'] = [ - _val_to_string(value)] - return params + _val_to_string(value) + ] def _get_query_param_field_name(obj_field: Field) -> str: - obj_param_metadata = obj_field.metadata.get('query_param') + obj_param_metadata = obj_field.metadata.get("query_param") if not obj_param_metadata: return "" @@ -355,48 +476,87 @@ def _get_query_param_field_name(obj_field: Field) -> str: return obj_param_metadata.get("field_name", obj_field.name) -def _get_form_query_params(metadata: dict, field_name: str, obj: any) -> dict[str, list[str]]: - return _populate_form(field_name, metadata.get("explode", True), obj, _get_query_param_field_name) +def _populate_delimited_query_params( + metadata: Dict, + field_name: str, + obj: Any, + delimiter: str, + query_param_values: Dict[str, List[str]], +): + _populate_form( + field_name, + metadata.get("explode", True), + obj, + _get_query_param_field_name, + delimiter, + query_param_values, + ) SERIALIZATION_METHOD_TO_CONTENT_TYPE = { - 'json': 'application/json', - 'form': 'application/x-www-form-urlencoded', - 'multipart': 'multipart/form-data', - 'raw': 'application/octet-stream', - 'string': 'text/plain', + "json": "application/json", + "form": "application/x-www-form-urlencoded", + "multipart": "multipart/form-data", + "raw": "application/octet-stream", + "string": "text/plain", } -def serialize_request_body(request: dataclass, request_field_name: str, serialization_method: str) -> Tuple[str, any, any]: +def serialize_request_body( + request: Any, + request_type: type, + request_field_name: str, + nullable: bool, + optional: bool, + serialization_method: str, + encoder=None, +) -> Tuple[Optional[str], Optional[Any], Optional[Any]]: if request is None: - return None, None, None, None + if not nullable and optional: + return None, None, None if not is_dataclass(request) or not hasattr(request, request_field_name): - return serialize_content_type(request_field_name, SERIALIZATION_METHOD_TO_CONTENT_TYPE[serialization_method], request) + return serialize_content_type( + request_field_name, + request_type, + SERIALIZATION_METHOD_TO_CONTENT_TYPE[serialization_method], + request, + encoder, + ) request_val = getattr(request, request_field_name) + if request_val is None: + if not nullable and optional: + return None, None, None + request_fields: Tuple[Field, ...] = fields(request) request_metadata = None for field in request_fields: if field.name == request_field_name: - request_metadata = field.metadata.get('request') + request_metadata = field.metadata.get("request") break if request_metadata is None: - raise Exception('invalid request type') - - return serialize_content_type(request_field_name, request_metadata.get('media_type', 'application/octet-stream'), request_val) - - -def serialize_content_type(field_name: str, media_type: str, request: dataclass) -> Tuple[str, any, list[list[any]]]: - if re.match(r'(application|text)\/.*?\+*json.*', media_type) is not None: - return media_type, marshal_json(request), None - if re.match(r'multipart\/.*', media_type) is not None: + raise Exception("invalid request type") + + return serialize_content_type( + request_field_name, + request_type, + request_metadata.get("media_type", "application/octet-stream"), + request_val, + ) + + +def serialize_content_type( + field_name: str, request_type: Any, media_type: str, request: Any, encoder=None +) -> Tuple[Optional[str], Optional[Any], Optional[List[List[Any]]]]: + if re.match(r"(application|text)\/.*?\+*json.*", media_type) is not None: + return media_type, marshal_json(request, request_type, encoder), None + if re.match(r"multipart\/.*", media_type) is not None: return serialize_multipart_form(media_type, request) - if re.match(r'application\/x-www-form-urlencoded.*', media_type) is not None: + if re.match(r"application\/x-www-form-urlencoded.*", media_type) is not None: return media_type, serialize_form_data(field_name, request), None if isinstance(request, (bytes, bytearray)): return media_type, request, None @@ -404,11 +564,14 @@ def serialize_content_type(field_name: str, media_type: str, request: dataclass) return media_type, request, None raise Exception( - f"invalid request body type {type(request)} for mediaType {media_type}") + f"invalid request body type {type(request)} for mediaType {media_type}" + ) -def serialize_multipart_form(media_type: str, request: dataclass) -> Tuple[str, any, list[list[any]]]: - form: list[list[any]] = [] +def serialize_multipart_form( + media_type: str, request: Any +) -> Tuple[str, Any, List[List[Any]]]: + form: List[List[Any]] = [] request_fields = fields(request) for field in request_fields: @@ -416,7 +579,7 @@ def serialize_multipart_form(media_type: str, request: dataclass) -> Tuple[str, if val is None: continue - field_metadata = field.metadata.get('multipart_form') + field_metadata = field.metadata.get("multipart_form") if not field_metadata: continue @@ -428,42 +591,42 @@ def serialize_multipart_form(media_type: str, request: dataclass) -> Tuple[str, content = bytes() for file_field in file_fields: - file_metadata = file_field.metadata.get('multipart_form') + file_metadata = file_field.metadata.get("multipart_form") if file_metadata is None: continue if file_metadata.get("content") is True: content = getattr(val, file_field.name) else: - field_name = file_metadata.get( - "field_name", file_field.name) + field_name = file_metadata.get("field_name", file_field.name) file_name = getattr(val, file_field.name) if field_name == "" or file_name == "" or content == bytes(): - raise Exception('invalid multipart/form-data file') + raise Exception("invalid multipart/form-data file") form.append([field_name, [file_name, content]]) elif field_metadata.get("json") is True: - to_append = [field_metadata.get("field_name", field.name), [ - None, marshal_json(val), "application/json"]] + to_append = [ + field_metadata.get("field_name", field.name), + [None, marshal_json(val, field.type), "application/json"], + ] form.append(to_append) else: - field_name = field_metadata.get( - "field_name", field.name) - if isinstance(val, list): + field_name = field_metadata.get("field_name", field.name) + if isinstance(val, List): for value in val: if value is None: continue - form.append( - [field_name + "[]", [None, _val_to_string(value)]]) + form.append([field_name + "[]", [None, _val_to_string(value)]]) else: form.append([field_name, [None, _val_to_string(val)]]) return media_type, None, form -def serialize_dict(original: dict, explode: bool, field_name, existing: Optional[dict[str, list[str]]]) -> dict[ - str, list[str]]: +def serialize_dict( + original: Dict, explode: bool, field_name, existing: Optional[Dict[str, List[str]]] +) -> Dict[str, List[str]]: if existing is None: - existing = [] + existing = {} if explode is True: for key, val in original.items(): @@ -481,8 +644,8 @@ def serialize_dict(original: dict, explode: bool, field_name, existing: Optional return existing -def serialize_form_data(field_name: str, data: dataclass) -> dict[str, any]: - form: dict[str, list[str]] = {} +def serialize_form_data(field_name: str, data: Any) -> Dict[str, Any]: + form: Dict[str, List[str]] = {} if is_dataclass(data): for field in fields(data): @@ -490,32 +653,37 @@ def serialize_form_data(field_name: str, data: dataclass) -> dict[str, any]: if val is None: continue - metadata = field.metadata.get('form') + metadata = field.metadata.get("form") if metadata is None: continue - field_name = metadata.get('field_name', field.name) + field_name = metadata.get("field_name", field.name) - if metadata.get('json'): - form[field_name] = [marshal_json(val)] + if metadata.get("json"): + form[field_name] = [marshal_json(val, field.type)] else: - if metadata.get('style', 'form') == 'form': - form = form | _populate_form( - field_name, metadata.get('explode', True), val, _get_form_field_name) + if metadata.get("style", "form") == "form": + _populate_form( + field_name, + metadata.get("explode", True), + val, + _get_form_field_name, + ",", + form, + ) else: - raise Exception( - f'Invalid form style for field {field.name}') - elif isinstance(data, dict): + raise Exception(f"Invalid form style for field {field.name}") + elif isinstance(data, Dict): for key, value in data.items(): form[key] = [_val_to_string(value)] else: - raise Exception(f'Invalid request body type for field {field_name}') + raise Exception(f"Invalid request body type for field {field_name}") return form def _get_form_field_name(obj_field: Field) -> str: - obj_param_metadata = obj_field.metadata.get('form') + obj_param_metadata = obj_field.metadata.get("form") if not obj_param_metadata: return "" @@ -523,11 +691,16 @@ def _get_form_field_name(obj_field: Field) -> str: return obj_param_metadata.get("field_name", obj_field.name) -def _populate_form(field_name: str, explode: boolean, obj: any, get_field_name_func: Callable) -> dict[str, list[str]]: - params: dict[str, list[str]] = {} - +def _populate_form( + field_name: str, + explode: boolean, + obj: Any, + get_field_name_func: Callable, + delimiter: str, + form: Dict[str, List[str]], +): if obj is None: - return params + return form if is_dataclass(obj): items = [] @@ -535,7 +708,7 @@ def _populate_form(field_name: str, explode: boolean, obj: any, get_field_name_f obj_fields: Tuple[Field, ...] = fields(obj) for obj_field in obj_fields: obj_field_name = get_field_name_func(obj_field) - if obj_field_name == '': + if obj_field_name == "": continue val = getattr(obj, obj_field.name) @@ -543,27 +716,26 @@ def _populate_form(field_name: str, explode: boolean, obj: any, get_field_name_f continue if explode: - params[obj_field_name] = [_val_to_string(val)] + form[obj_field_name] = [_val_to_string(val)] else: - items.append( - f'{obj_field_name},{_val_to_string(val)}') + items.append(f"{obj_field_name}{delimiter}{_val_to_string(val)}") if len(items) > 0: - params[field_name] = [','.join(items)] - elif isinstance(obj, dict): + form[field_name] = [delimiter.join(items)] + elif isinstance(obj, Dict): items = [] for key, value in obj.items(): if value is None: continue if explode: - params[key] = _val_to_string(value) + form[key] = [_val_to_string(value)] else: - items.append(f'{key},{_val_to_string(value)}') + items.append(f"{key}{delimiter}{_val_to_string(value)}") if len(items) > 0: - params[field_name] = [','.join(items)] - elif isinstance(obj, list): + form[field_name] = [delimiter.join(items)] + elif isinstance(obj, List): items = [] for value in obj: @@ -571,36 +743,35 @@ def _populate_form(field_name: str, explode: boolean, obj: any, get_field_name_f continue if explode: - if not field_name in params: - params[field_name] = [] - params[field_name].append(_val_to_string(value)) + if not field_name in form: + form[field_name] = [] + form[field_name].append(_val_to_string(value)) else: items.append(_val_to_string(value)) if len(items) > 0: - params[field_name] = [','.join([str(item) for item in items])] + form[field_name] = [delimiter.join([str(item) for item in items])] else: - params[field_name] = [_val_to_string(obj)] + form[field_name] = [_val_to_string(obj)] - return params + return form -def _serialize_header(explode: bool, obj: any) -> str: +def _serialize_header(explode: bool, obj: Any) -> str: if obj is None: - return '' + return "" if is_dataclass(obj): items = [] obj_fields: Tuple[Field, ...] = fields(obj) for obj_field in obj_fields: - obj_param_metadata = obj_field.metadata.get('header') + obj_param_metadata = obj_field.metadata.get("header") if not obj_param_metadata: continue - obj_field_name = obj_param_metadata.get( - 'field_name', obj_field.name) - if obj_field_name == '': + obj_field_name = obj_param_metadata.get("field_name", obj_field.name) + if obj_field_name == "": continue val = getattr(obj, obj_field.name) @@ -608,15 +779,14 @@ def _serialize_header(explode: bool, obj: any) -> str: continue if explode: - items.append( - f'{obj_field_name}={_val_to_string(val)}') + items.append(f"{obj_field_name}={_val_to_string(val)}") else: items.append(obj_field_name) items.append(_val_to_string(val)) if len(items) > 0: - return ','.join(items) - elif isinstance(obj, dict): + return ",".join(items) + elif isinstance(obj, Dict): items = [] for key, value in obj.items(): @@ -624,14 +794,14 @@ def _serialize_header(explode: bool, obj: any) -> str: continue if explode: - items.append(f'{key}={_val_to_string(value)}') + items.append(f"{key}={_val_to_string(value)}") else: items.append(key) items.append(_val_to_string(value)) if len(items) > 0: - return ','.join([str(item) for item in items]) - elif isinstance(obj, list): + return ",".join([str(item) for item in items]) + elif isinstance(obj, List): items = [] for value in obj: @@ -641,27 +811,36 @@ def _serialize_header(explode: bool, obj: any) -> str: items.append(_val_to_string(value)) if len(items) > 0: - return ','.join(items) + return ",".join(items) else: - return f'{_val_to_string(obj)}' + return f"{_val_to_string(obj)}" - return '' + return "" -def unmarshal_json(data, typ): - unmarhsal = make_dataclass('Unmarhsal', [('res', typ)], - bases=(DataClassJsonMixin,)) +def unmarshal_json(data, typ, decoder=None): + unmarshal = make_dataclass("Unmarshal", [("res", typ)], bases=(DataClassJsonMixin,)) json_dict = json.loads(data) - out = unmarhsal.from_dict({"res": json_dict}) - return out.res + try: + out = unmarshal.from_dict({"res": json_dict}) + except AttributeError as attr_err: + raise AttributeError( + f"unable to unmarshal {data} as {typ} - {attr_err}" + ) from attr_err + + return out.res if decoder is None else decoder(out.res) -def marshal_json(val): - marshal = make_dataclass('Marshal', [('res', type(val))], - bases=(DataClassJsonMixin,)) +def marshal_json(val, typ, encoder=None): + if not is_optional_type(typ) and val is None: + raise ValueError(f"Could not marshal None into non-optional type: {typ}") + + marshal = make_dataclass("Marshal", [("res", typ)], bases=(DataClassJsonMixin,)) marshaller = marshal(res=val) json_dict = marshaller.to_dict() - return json.dumps(json_dict["res"]) + val = json_dict["res"] if encoder is None else encoder(json_dict["res"]) + + return json.dumps(val, separators=(",", ":"), sort_keys=True) def match_content_type(content_type: str, pattern: str) -> boolean: @@ -669,7 +848,7 @@ def match_content_type(content_type: str, pattern: str) -> boolean: return True msg = Message() - msg['content-type'] = content_type + msg["content-type"] = content_type media_type = msg.get_content_type() if media_type == pattern: @@ -677,9 +856,19 @@ def match_content_type(content_type: str, pattern: str) -> boolean: parts = media_type.split("/") if len(parts) == 2: - if pattern in (f'{parts[0]}/*', f'*/{parts[1]}'): + if pattern in (f"{parts[0]}/*", f"*/{parts[1]}"): + return True + + return False + + +def match_status_codes(status_codes: List[str], status_code: int) -> bool: + for code in status_codes: + if code == str(status_code): return True + if code.endswith("XX") and code.startswith(str(status_code)[:1]): + return True return False @@ -705,6 +894,138 @@ def datefromisoformat(date_str: str): return dateutil.parser.parse(date_str).date() +def bigintencoder(optional: bool): + def bigintencode(val: int): + if optional and val is None: + return None + return str(val) + + return bigintencode + + +def bigintdecoder(val): + if isinstance(val, float): + raise ValueError(f"{val} is a float") + return int(val) + +def integerstrencoder(optional: bool): + def integerstrencode(val: int): + if optional and val is None: + return None + return str(val) + + return integerstrencode + + +def integerstrdecoder(val): + if isinstance(val, float): + raise ValueError(f"{val} is a float") + return int(val) + + +def numberstrencoder(optional: bool): + def numberstrencode(val: float): + if optional and val is None: + return None + return str(val) + + return numberstrencode + + +def numberstrdecoder(val): + return float(val) + + +def decimalencoder(optional: bool, as_str: bool): + def decimalencode(val: Decimal): + if optional and val is None: + return None + + if as_str: + return str(val) + + return float(val) + + return decimalencode + + +def decimaldecoder(val): + return Decimal(str(val)) + + +def map_encoder(optional: bool, value_encoder: Callable): + def map_encode(val: Dict): + if optional and val is None: + return None + + encoded = {} + for key, value in val.items(): + encoded[key] = value_encoder(value) + + return encoded + + return map_encode + + +def map_decoder(value_decoder: Callable): + def map_decode(val: Dict): + decoded = {} + for key, value in val.items(): + decoded[key] = value_decoder(value) + + return decoded + + return map_decode + + +def list_encoder(optional: bool, value_encoder: Callable): + def list_encode(val: List): + if optional and val is None: + return None + + encoded = [] + for value in val: + encoded.append(value_encoder(value)) + + return encoded + + return list_encode + + +def list_decoder(value_decoder: Callable): + def list_decode(val: List): + decoded = [] + for value in val: + decoded.append(value_decoder(value)) + + return decoded + + return list_decode + + +def union_encoder(all_encoders: Dict[str, Callable]): + def selective_encoder(val: Any): + if type(val) in all_encoders: + return all_encoders[type(val)](val) + return val + + return selective_encoder + + +def union_decoder(all_decoders: List[Callable]): + def selective_decoder(val: Any): + decoded = val + for decoder in all_decoders: + try: + decoded = decoder(val) + break + except (TypeError, ValueError): + continue + return decoded + + return selective_decoder + + def get_field_name(name): def override(_, _field_name=name): return _field_name @@ -712,24 +1033,55 @@ def override(_, _field_name=name): return override -def _val_to_string(val): +def _val_to_string(val) -> str: if isinstance(val, bool): return str(val).lower() if isinstance(val, datetime): - return val.isoformat().replace('+00:00', 'Z') + return str(val.isoformat().replace("+00:00", "Z")) if isinstance(val, Enum): - return val.value + return str(val.value) return str(val) -def _populate_from_globals(param_name: str, value: any, param_type: str, gbls: dict[str, dict[str, dict[str, Any]]]): - if value is None and gbls is not None: - if 'parameters' in gbls: - if param_type in gbls['parameters']: - if param_name in gbls['parameters'][param_type]: - global_value = gbls['parameters'][param_type][param_name] - if global_value is not None: - value = global_value +def _populate_from_globals( + param_name: str, value: Any, param_type: str, gbls: Any +) -> Tuple[Any, bool]: + if gbls is None: + return value, False + + global_fields = fields(gbls) + + found = False + for field in global_fields: + if field.name is not param_name: + continue + + found = True + + if value is not None: + return value, True + + global_value = getattr(gbls, field.name) + + param_metadata = field.metadata.get(param_type) + if param_metadata is None: + return value, True + + return global_value, True + + return value, found + + +def decoder_with_discriminator(field_name): + def decode_fx(obj): + kls = getattr(sys.modules["sdk.models.components"], obj[field_name]) + return unmarshal_json(json.dumps(obj), kls) + + return decode_fx + - return value +def remove_suffix(input_string, suffix): + if suffix and input_string.endswith(suffix): + return input_string[: -len(suffix)] + return input_string diff --git a/workflows_definition/src/sdk/workflows.py b/workflows_definition/src/sdk/workflows.py old mode 100755 new mode 100644 index b442b7f15d..67d17b7c22 --- a/workflows_definition/src/sdk/workflows.py +++ b/workflows_definition/src/sdk/workflows.py @@ -1,250 +1,554 @@ """Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" import requests as requests_http -from . import utils -from sdk.models import operations, shared -from typing import Any, Optional +from .sdkconfiguration import SDKConfiguration +from sdk import utils +from sdk._hooks import AfterErrorContext, AfterSuccessContext, BeforeRequestContext, HookContext +from sdk.models import components, errors, operations +from typing import List, Optional class Workflows: - _client: requests_http.Session - _security_client: requests_http.Session - _server_url: str - _language: str - _sdk_version: str - _gen_version: str - - def __init__(self, client: requests_http.Session, security_client: requests_http.Session, server_url: str, language: str, sdk_version: str, gen_version: str) -> None: - self._client = client - self._security_client = security_client - self._server_url = server_url - self._language = language - self._sdk_version = sdk_version - self._gen_version = gen_version - - def create_definition(self, request: shared.WorkflowDefinition) -> operations.CreateDefinitionResponse: + sdk_configuration: SDKConfiguration + + def __init__(self, sdk_config: SDKConfiguration) -> None: + self.sdk_configuration = sdk_config + + + + def create_definition(self, request: components.WorkflowDefinition) -> operations.CreateDefinitionResponse: r"""createDefinition Create a Workflow Definition. """ - base_url = self._server_url + hook_ctx = HookContext(operation_id='createDefinition', oauth2_scopes=[], security_source=self.sdk_configuration.security) + base_url = utils.template_url(*self.sdk_configuration.get_server_details()) + + url = base_url + '/v1/workflows/definitions' - url = base_url.removesuffix('/') + '/v1/workflows/definitions' + if callable(self.sdk_configuration.security): + headers, query_params = utils.get_security(self.sdk_configuration.security()) + else: + headers, query_params = utils.get_security(self.sdk_configuration.security) - headers = {} - req_content_type, data, form = utils.serialize_request_body(request, "request", 'json') - if req_content_type not in ('multipart/form-data', 'multipart/mixed'): + req_content_type, data, form = utils.serialize_request_body(request, components.WorkflowDefinition, "request", False, False, 'json') + if req_content_type is not None and req_content_type not in ('multipart/form-data', 'multipart/mixed'): headers['content-type'] = req_content_type if data is None and form is None: raise Exception('request body is required') + headers['Accept'] = 'application/json' + headers['user-agent'] = self.sdk_configuration.user_agent + client = self.sdk_configuration.client + + try: + req = client.prepare_request(requests_http.Request('POST', url, params=query_params, data=data, files=form, headers=headers)) + req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req) + http_res = client.send(req) + except Exception as e: + _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e) + if e is not None: + raise e + + if utils.match_status_codes(['400','401','4XX','500','5XX'], http_res.status_code): + result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None) + if e is not None: + raise e + if result is not None: + http_res = result + else: + http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res) + - client = self._security_client - http_res = client.request('POST', url, data=data, files=form, headers=headers) - content_type = http_res.headers.get('Content-Type') - - res = operations.CreateDefinitionResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res) + res = operations.CreateDefinitionResponse(http_meta=components.HTTPMetadata(request=req, response=http_res)) if http_res.status_code == 200: - if utils.match_content_type(content_type, 'application/json'): - out = utils.unmarshal_json(http_res.text, Optional[shared.WorkflowDefinition]) + # pylint: disable=no-else-return + if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'): + out = utils.unmarshal_json(http_res.text, Optional[components.WorkflowDefinition]) res.workflow_definition = out + else: + content_type = http_res.headers.get('Content-Type') + raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res) elif http_res.status_code in [400, 401, 500]: - if utils.match_content_type(content_type, 'application/json'): - out = utils.unmarshal_json(http_res.text, Optional[shared.ErrorResp]) - res.error_resp = out + # pylint: disable=no-else-return + if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'): + out = utils.unmarshal_json(http_res.text, errors.ErrorResp) + raise out + else: + content_type = http_res.headers.get('Content-Type') + raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res) + elif http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: + raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) + else: + raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res) return res - def delete_definition(self, request: operations.DeleteDefinitionRequest) -> operations.DeleteDefinitionResponse: + + + def delete_definition(self, definition_id: str) -> operations.DeleteDefinitionResponse: r"""deleteDefinition Delete Workflow Definition. """ - base_url = self._server_url - - url = utils.generate_url(operations.DeleteDefinitionRequest, base_url, '/v1/workflows/definitions/{definitionId}', request) - + hook_ctx = HookContext(operation_id='deleteDefinition', oauth2_scopes=[], security_source=self.sdk_configuration.security) + request = operations.DeleteDefinitionRequest( + definition_id=definition_id, + ) + + base_url = utils.template_url(*self.sdk_configuration.get_server_details()) + + url = utils.generate_url(base_url, '/v1/workflows/definitions/{definitionId}', request) + + if callable(self.sdk_configuration.security): + headers, query_params = utils.get_security(self.sdk_configuration.security()) + else: + headers, query_params = utils.get_security(self.sdk_configuration.security) + + headers['Accept'] = 'application/json' + headers['user-agent'] = self.sdk_configuration.user_agent + client = self.sdk_configuration.client + + try: + req = client.prepare_request(requests_http.Request('DELETE', url, params=query_params, headers=headers)) + req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req) + http_res = client.send(req) + except Exception as e: + _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e) + if e is not None: + raise e + + if utils.match_status_codes(['401','404','4XX','5XX'], http_res.status_code): + result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None) + if e is not None: + raise e + if result is not None: + http_res = result + else: + http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res) + - client = self._security_client - http_res = client.request('DELETE', url) - content_type = http_res.headers.get('Content-Type') - - res = operations.DeleteDefinitionResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res) + res = operations.DeleteDefinitionResponse(http_meta=components.HTTPMetadata(request=req, response=http_res)) - if http_res.status_code in [204, 404]: + if http_res.status_code == 204: pass elif http_res.status_code == 401: - if utils.match_content_type(content_type, 'application/json'): - out = utils.unmarshal_json(http_res.text, Optional[shared.ErrorResp]) - res.error_resp = out + # pylint: disable=no-else-return + if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'): + out = utils.unmarshal_json(http_res.text, errors.ErrorResp) + raise out + else: + content_type = http_res.headers.get('Content-Type') + raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res) + elif http_res.status_code == 404 or http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: + raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) + else: + raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res) return res - def get_definition(self, request: operations.GetDefinitionRequest) -> operations.GetDefinitionResponse: + + + def get_definition(self, definition_id: str) -> operations.GetDefinitionResponse: r"""getDefinition Get specific Definition by id from the Organization. """ - base_url = self._server_url - - url = utils.generate_url(operations.GetDefinitionRequest, base_url, '/v1/workflows/definitions/{definitionId}', request) - + hook_ctx = HookContext(operation_id='getDefinition', oauth2_scopes=[], security_source=self.sdk_configuration.security) + request = operations.GetDefinitionRequest( + definition_id=definition_id, + ) + + base_url = utils.template_url(*self.sdk_configuration.get_server_details()) + + url = utils.generate_url(base_url, '/v1/workflows/definitions/{definitionId}', request) + + if callable(self.sdk_configuration.security): + headers, query_params = utils.get_security(self.sdk_configuration.security()) + else: + headers, query_params = utils.get_security(self.sdk_configuration.security) + + headers['Accept'] = 'application/json' + headers['user-agent'] = self.sdk_configuration.user_agent + client = self.sdk_configuration.client + + try: + req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers)) + req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req) + http_res = client.send(req) + except Exception as e: + _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e) + if e is not None: + raise e + + if utils.match_status_codes(['400','401','404','4XX','500','5XX'], http_res.status_code): + result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None) + if e is not None: + raise e + if result is not None: + http_res = result + else: + http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res) + - client = self._security_client - http_res = client.request('GET', url) - content_type = http_res.headers.get('Content-Type') - - res = operations.GetDefinitionResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res) + res = operations.GetDefinitionResponse(http_meta=components.HTTPMetadata(request=req, response=http_res)) if http_res.status_code == 200: - if utils.match_content_type(content_type, 'application/json'): - out = utils.unmarshal_json(http_res.text, Optional[shared.WorkflowDefinition]) + # pylint: disable=no-else-return + if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'): + out = utils.unmarshal_json(http_res.text, Optional[components.WorkflowDefinition]) res.workflow_definition = out + else: + content_type = http_res.headers.get('Content-Type') + raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res) elif http_res.status_code in [400, 401, 500]: - if utils.match_content_type(content_type, 'application/json'): - out = utils.unmarshal_json(http_res.text, Optional[shared.ErrorResp]) - res.error_resp = out + # pylint: disable=no-else-return + if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'): + out = utils.unmarshal_json(http_res.text, errors.ErrorResp) + raise out + else: + content_type = http_res.headers.get('Content-Type') + raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res) elif http_res.status_code == 404: - if utils.match_content_type(content_type, 'application/json'): - out = utils.unmarshal_json(http_res.text, Optional[Any]) - res.definition_not_found_resp = out + # pylint: disable=no-else-return + if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'): + out = utils.unmarshal_json(http_res.text, errors.DefinitionNotFoundResp) + raise out + else: + content_type = http_res.headers.get('Content-Type') + raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res) + elif http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: + raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) + else: + raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res) return res + + def get_definitions(self) -> operations.GetDefinitionsResponse: r"""getDefinitions Retrieve all Workflow Definitions from an Organization """ - base_url = self._server_url - - url = base_url.removesuffix('/') + '/v1/workflows/definitions' - + hook_ctx = HookContext(operation_id='getDefinitions', oauth2_scopes=[], security_source=self.sdk_configuration.security) + base_url = utils.template_url(*self.sdk_configuration.get_server_details()) + + url = base_url + '/v1/workflows/definitions' + + if callable(self.sdk_configuration.security): + headers, query_params = utils.get_security(self.sdk_configuration.security()) + else: + headers, query_params = utils.get_security(self.sdk_configuration.security) + + headers['Accept'] = 'application/json' + headers['user-agent'] = self.sdk_configuration.user_agent + client = self.sdk_configuration.client + + try: + req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers)) + req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req) + http_res = client.send(req) + except Exception as e: + _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e) + if e is not None: + raise e + + if utils.match_status_codes(['4XX','500','5XX'], http_res.status_code): + result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None) + if e is not None: + raise e + if result is not None: + http_res = result + else: + http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res) + - client = self._security_client - http_res = client.request('GET', url) - content_type = http_res.headers.get('Content-Type') - - res = operations.GetDefinitionsResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res) + res = operations.GetDefinitionsResponse(http_meta=components.HTTPMetadata(request=req, response=http_res)) if http_res.status_code == 200: - if utils.match_content_type(content_type, 'application/json'): - out = utils.unmarshal_json(http_res.text, Optional[list[shared.WorkflowDefinition]]) - res.workflow_definitions = out + # pylint: disable=no-else-return + if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'): + out = utils.unmarshal_json(http_res.text, Optional[List[components.WorkflowDefinition]]) + res.classes = out + else: + content_type = http_res.headers.get('Content-Type') + raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res) + elif http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: + raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) elif http_res.status_code == 500: - if utils.match_content_type(content_type, 'application/json'): - out = utils.unmarshal_json(http_res.text, Optional[shared.ErrorResp]) - res.error_resp = out + # pylint: disable=no-else-return + if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'): + out = utils.unmarshal_json(http_res.text, errors.ErrorResp) + raise out + else: + content_type = http_res.headers.get('Content-Type') + raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res) + else: + raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res) return res + + def get_max_allowed_limit(self) -> operations.GetMaxAllowedLimitResponse: r"""getMaxAllowedLimit Get limits and number of created executions for an Organization. """ - base_url = self._server_url - - url = base_url.removesuffix('/') + '/v1/workflows/limits/max-allowed' + hook_ctx = HookContext(operation_id='getMaxAllowedLimit', oauth2_scopes=[], security_source=self.sdk_configuration.security) + base_url = utils.template_url(*self.sdk_configuration.get_server_details()) + + url = base_url + '/v1/workflows/limits/max-allowed' + + if callable(self.sdk_configuration.security): + headers, query_params = utils.get_security(self.sdk_configuration.security()) + else: + headers, query_params = utils.get_security(self.sdk_configuration.security) + + headers['Accept'] = 'application/json' + headers['user-agent'] = self.sdk_configuration.user_agent + client = self.sdk_configuration.client + + try: + req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers)) + req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req) + http_res = client.send(req) + except Exception as e: + _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e) + if e is not None: + raise e + + if utils.match_status_codes(['4XX','500','5XX'], http_res.status_code): + result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None) + if e is not None: + raise e + if result is not None: + http_res = result + else: + http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res) + - client = self._security_client - - http_res = client.request('GET', url) - content_type = http_res.headers.get('Content-Type') - - res = operations.GetMaxAllowedLimitResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res) + res = operations.GetMaxAllowedLimitResponse(http_meta=components.HTTPMetadata(request=req, response=http_res)) if http_res.status_code == 200: - if utils.match_content_type(content_type, 'application/json'): - out = utils.unmarshal_json(http_res.text, Optional[shared.MaxAllowedLimit]) + # pylint: disable=no-else-return + if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'): + out = utils.unmarshal_json(http_res.text, Optional[components.MaxAllowedLimit]) res.max_allowed_limit = out + else: + content_type = http_res.headers.get('Content-Type') + raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res) + elif http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: + raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) elif http_res.status_code == 500: - if utils.match_content_type(content_type, 'application/json'): - out = utils.unmarshal_json(http_res.text, Optional[shared.ErrorResp]) - res.error_resp = out + # pylint: disable=no-else-return + if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'): + out = utils.unmarshal_json(http_res.text, errors.ErrorResp) + raise out + else: + content_type = http_res.headers.get('Content-Type') + raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res) + else: + raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res) return res - def get_workflow_closing_reasons(self, request: operations.GetWorkflowClosingReasonsRequest) -> operations.GetWorkflowClosingReasonsResponse: + + + def get_workflow_closing_reasons(self, definition_id: str) -> operations.GetWorkflowClosingReasonsResponse: r"""getWorkflowClosingReasons Returns all closing reasons defined for the workflow. """ - base_url = self._server_url - - url = utils.generate_url(operations.GetWorkflowClosingReasonsRequest, base_url, '/v1/workflows/definitions/{definitionId}/closing-reasons', request) - + hook_ctx = HookContext(operation_id='getWorkflowClosingReasons', oauth2_scopes=[], security_source=self.sdk_configuration.security) + request = operations.GetWorkflowClosingReasonsRequest( + definition_id=definition_id, + ) + + base_url = utils.template_url(*self.sdk_configuration.get_server_details()) + + url = utils.generate_url(base_url, '/v1/workflows/definitions/{definitionId}/closing-reasons', request) + + if callable(self.sdk_configuration.security): + headers, query_params = utils.get_security(self.sdk_configuration.security()) + else: + headers, query_params = utils.get_security(self.sdk_configuration.security) + + headers['Accept'] = 'application/json' + headers['user-agent'] = self.sdk_configuration.user_agent + client = self.sdk_configuration.client + + try: + req = client.prepare_request(requests_http.Request('GET', url, params=query_params, headers=headers)) + req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req) + http_res = client.send(req) + except Exception as e: + _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e) + if e is not None: + raise e + + if utils.match_status_codes(['4XX','5XX'], http_res.status_code): + result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None) + if e is not None: + raise e + if result is not None: + http_res = result + else: + http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res) + - client = self._security_client - http_res = client.request('GET', url) - content_type = http_res.headers.get('Content-Type') - - res = operations.GetWorkflowClosingReasonsResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res) + res = operations.GetWorkflowClosingReasonsResponse(http_meta=components.HTTPMetadata(request=req, response=http_res)) if http_res.status_code == 200: - if utils.match_content_type(content_type, 'application/json'): - out = utils.unmarshal_json(http_res.text, Optional[shared.ClosingReasonsIds]) + # pylint: disable=no-else-return + if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'): + out = utils.unmarshal_json(http_res.text, Optional[components.ClosingReasonsIds]) res.closing_reasons_ids = out + else: + content_type = http_res.headers.get('Content-Type') + raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res) + elif http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: + raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) + else: + raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res) return res - def set_workflow_closing_reasons(self, request: operations.SetWorkflowClosingReasonsRequest) -> operations.SetWorkflowClosingReasonsResponse: + + + def set_workflow_closing_reasons(self, closing_reasons_ids: components.ClosingReasonsIds, definition_id: str) -> operations.SetWorkflowClosingReasonsResponse: r"""setWorkflowClosingReasons Sets which closing reasons are defined for this workflow, based on the entire closing reasons catalog. """ - base_url = self._server_url + hook_ctx = HookContext(operation_id='setWorkflowClosingReasons', oauth2_scopes=[], security_source=self.sdk_configuration.security) + request = operations.SetWorkflowClosingReasonsRequest( + closing_reasons_ids=closing_reasons_ids, + definition_id=definition_id, + ) + + base_url = utils.template_url(*self.sdk_configuration.get_server_details()) - url = utils.generate_url(operations.SetWorkflowClosingReasonsRequest, base_url, '/v1/workflows/definitions/{definitionId}/closing-reasons', request) + url = utils.generate_url(base_url, '/v1/workflows/definitions/{definitionId}/closing-reasons', request) - headers = {} - req_content_type, data, form = utils.serialize_request_body(request, "closing_reasons_ids", 'json') - if req_content_type not in ('multipart/form-data', 'multipart/mixed'): + if callable(self.sdk_configuration.security): + headers, query_params = utils.get_security(self.sdk_configuration.security()) + else: + headers, query_params = utils.get_security(self.sdk_configuration.security) + + req_content_type, data, form = utils.serialize_request_body(request, operations.SetWorkflowClosingReasonsRequest, "closing_reasons_ids", False, False, 'json') + if req_content_type is not None and req_content_type not in ('multipart/form-data', 'multipart/mixed'): headers['content-type'] = req_content_type if data is None and form is None: raise Exception('request body is required') + headers['Accept'] = '*/*' + headers['user-agent'] = self.sdk_configuration.user_agent + client = self.sdk_configuration.client + + try: + req = client.prepare_request(requests_http.Request('PATCH', url, params=query_params, data=data, files=form, headers=headers)) + req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req) + http_res = client.send(req) + except Exception as e: + _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e) + if e is not None: + raise e + + if utils.match_status_codes(['4XX','5XX'], http_res.status_code): + result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None) + if e is not None: + raise e + if result is not None: + http_res = result + else: + http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res) + - client = self._security_client - http_res = client.request('PATCH', url, data=data, files=form, headers=headers) - content_type = http_res.headers.get('Content-Type') - - res = operations.SetWorkflowClosingReasonsResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res) + res = operations.SetWorkflowClosingReasonsResponse(http_meta=components.HTTPMetadata(request=req, response=http_res)) if http_res.status_code == 201: pass + elif http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: + raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) + else: + raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res) return res - def update_definition(self, request: operations.UpdateDefinitionRequest) -> operations.UpdateDefinitionResponse: + + + def update_definition(self, workflow_definition: components.WorkflowDefinition, definition_id: str) -> operations.UpdateDefinitionResponse: r"""updateDefinition Update Workflow Definition. """ - base_url = self._server_url + hook_ctx = HookContext(operation_id='updateDefinition', oauth2_scopes=[], security_source=self.sdk_configuration.security) + request = operations.UpdateDefinitionRequest( + workflow_definition=workflow_definition, + definition_id=definition_id, + ) + + base_url = utils.template_url(*self.sdk_configuration.get_server_details()) - url = utils.generate_url(operations.UpdateDefinitionRequest, base_url, '/v1/workflows/definitions/{definitionId}', request) + url = utils.generate_url(base_url, '/v1/workflows/definitions/{definitionId}', request) - headers = {} - req_content_type, data, form = utils.serialize_request_body(request, "workflow_definition", 'json') - if req_content_type not in ('multipart/form-data', 'multipart/mixed'): + if callable(self.sdk_configuration.security): + headers, query_params = utils.get_security(self.sdk_configuration.security()) + else: + headers, query_params = utils.get_security(self.sdk_configuration.security) + + req_content_type, data, form = utils.serialize_request_body(request, operations.UpdateDefinitionRequest, "workflow_definition", False, False, 'json') + if req_content_type is not None and req_content_type not in ('multipart/form-data', 'multipart/mixed'): headers['content-type'] = req_content_type if data is None and form is None: raise Exception('request body is required') + headers['Accept'] = 'application/json' + headers['user-agent'] = self.sdk_configuration.user_agent + client = self.sdk_configuration.client + + try: + req = client.prepare_request(requests_http.Request('PUT', url, params=query_params, data=data, files=form, headers=headers)) + req = self.sdk_configuration.get_hooks().before_request(BeforeRequestContext(hook_ctx), req) + http_res = client.send(req) + except Exception as e: + _, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), None, e) + if e is not None: + raise e + + if utils.match_status_codes(['400','401','4XX','500','5XX'], http_res.status_code): + result, e = self.sdk_configuration.get_hooks().after_error(AfterErrorContext(hook_ctx), http_res, None) + if e is not None: + raise e + if result is not None: + http_res = result + else: + http_res = self.sdk_configuration.get_hooks().after_success(AfterSuccessContext(hook_ctx), http_res) + - client = self._security_client - http_res = client.request('PUT', url, data=data, files=form, headers=headers) - content_type = http_res.headers.get('Content-Type') - - res = operations.UpdateDefinitionResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res) + res = operations.UpdateDefinitionResponse(http_meta=components.HTTPMetadata(request=req, response=http_res)) if http_res.status_code == 200: - if utils.match_content_type(content_type, 'application/json'): - out = utils.unmarshal_json(http_res.text, Optional[shared.WorkflowDefinition]) + # pylint: disable=no-else-return + if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'): + out = utils.unmarshal_json(http_res.text, Optional[components.WorkflowDefinition]) res.workflow_definition = out + else: + content_type = http_res.headers.get('Content-Type') + raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res) elif http_res.status_code in [400, 401, 500]: - if utils.match_content_type(content_type, 'application/json'): - out = utils.unmarshal_json(http_res.text, Optional[shared.ErrorResp]) - res.error_resp = out + # pylint: disable=no-else-return + if utils.match_content_type(http_res.headers.get('Content-Type') or '', 'application/json'): + out = utils.unmarshal_json(http_res.text, errors.ErrorResp) + raise out + else: + content_type = http_res.headers.get('Content-Type') + raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res) + elif http_res.status_code >= 400 and http_res.status_code < 500 or http_res.status_code >= 500 and http_res.status_code < 600: + raise errors.SDKError('API error occurred', http_res.status_code, http_res.text, http_res) + else: + raise errors.SDKError('unknown status code received', http_res.status_code, http_res.text, http_res) return res - \ No newline at end of file + +