API Plugin Model

Smarter API PluginData Sql Connection Manifest Constants.

Smarter API Manifest - Plugin.spec.

class smarter.apps.llmtool.manifest.models.api_plugin.spec.ApiData(*, endpoint, method='GET', urlParams=None, headers=None, body=None, parameters=None, testValues=None, limit=100)[source]

Bases: SmarterBasePydanticModel

Smarter API - apiData class.

body: dict[str, Any] | list[Any] | None
endpoint: str
headers: List[RequestHeader] | None
limit: int | None
method: str
model_config = {'arbitrary_types_allowed': True, 'from_attributes': True, 'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

Return type:

None

parameters: List[Parameter] | None
testValues: List[TestValue] | None
urlParams: List[UrlParam] | None
classmethod validate_endpoint(v)[source]

Validate the API endpoint; if it is not valid and has no trailing slash, retry with one.

An endpoint that is not valid, but already ends with a slash, is returned unchanged.

Parameters:

v – The endpoint, e.g. /weather/.

Returns:

The endpoint, with the trailing slash if the retry added one.

Raises:

SAMValidationError – If the retry with a trailing slash is not valid either.

classmethod validate_method(v)[source]

Validate the HTTP method, case-insensitively.

Parameters:

v – The HTTP method, e.g. get.

Returns:

The method in upper case.

Raises:

SAMValidationError – If it is not one of SmarterHttpMethods.

class smarter.apps.llmtool.manifest.models.api_plugin.spec.SAMApiPluginSpec(*, selector, prompt, connection, apiData)[source]

Bases: SAMPluginCommonSpec

Smarter API Manifest ApiConnection.spec.

apiData: ApiData
class_identifier: ClassVar[str] = 'ApiPlugin.spec'
connection: str
model_config = {'arbitrary_types_allowed': True, 'from_attributes': True, 'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

Return type:

None

validate_connection()[source]

Validate that the connection value is a valid cleanstring and that at.

least 1 record exists in the ApiConnection table with the given name.

If the model includes an authenticated user then also validate that at least 1 record exists in the ApiConnection table with the given name that is accessible by the authenticated user.

Smarter API Plugin Manifest.

class smarter.apps.llmtool.manifest.models.api_plugin.model.SAMApiPlugin(*, apiVersion, kind, metadata, spec, status=None)[source]

Bases: SAMPluginCommon

Smarter API Manifest - ApiPlugin Model.

class_identifier: ClassVar[str] = 'ApiPlugin'
model_config = {'arbitrary_types_allowed': True, 'from_attributes': True, 'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

Return type:

None

spec: SAMApiPluginSpec