ScriptsProxy Class
An interface to interact with stored procedures.
This class should not be instantiated directly. Instead, use the scripts attribute.
Constructor
ScriptsProxy(container: ContainerProxy, client_connection: CosmosClientConnection, container_link: str)
Parameters
| Name | Description |
|---|---|
|
container
Required
|
|
|
client_connection
Required
|
|
|
container_link
Required
|
|
Methods
| create_stored_procedure |
Create a new stored procedure in the container. To replace an existing stored procedure, use the <xref:Container.scripts.replace_stored_procedure> method. |
| create_trigger |
Create a trigger in the container. To replace an existing trigger, use the <xref:ContainerProxy.scripts.replace_trigger> method. |
| create_user_defined_function |
Create a user-defined function in the container. To replace an existing user-defined function, use the <xref:ContainerProxy.scripts.replace_user_defined_function> method. |
| delete_stored_procedure |
Delete a specified stored procedure from the container. If the stored procedure does not already exist in the container, an exception is raised. |
| delete_trigger |
Delete a specified trigger from the container. If the trigger does not already exist in the container, an exception is raised. |
| delete_user_defined_function |
Delete a specified user-defined function from the container. If the user-defined function does not already exist in the container, an exception is raised. |
| execute_stored_procedure |
Execute a specified stored procedure. If the stored procedure does not already exist in the container, an exception is raised. |
| get_stored_procedure |
Get the stored procedure identified by sproc. |
| get_trigger |
Get a trigger identified by id. |
| get_user_defined_function |
Get a user-defined function identified by id. |
| list_stored_procedures |
List all stored procedures in the container. |
| list_triggers |
List all triggers in the container. |
| list_user_defined_functions |
List all the user-defined functions in the container. |
| query_stored_procedures |
Return all stored procedures matching the given query. |
| query_triggers |
Return all triggers matching the given query. |
| query_user_defined_functions |
Return user-defined functions matching a given query. |
| replace_stored_procedure |
Replace a specified stored procedure in the container. If the stored procedure does not already exist in the container, an exception is raised. |
| replace_trigger |
Replace a specified trigger in the container. If the trigger does not already exist in the container, an exception is raised. |
| replace_user_defined_function |
Replace a specified user-defined function in the container. If the user-defined function does not already exist in the container, an exception is raised. |
create_stored_procedure
Create a new stored procedure in the container.
To replace an existing stored procedure, use the <xref:Container.scripts.replace_stored_procedure> method.
async create_stored_procedure(body: dict[str, Any], **kwargs: Any) -> CosmosDict
Parameters
| Name | Description |
|---|---|
|
body
Required
|
A dict representing the stored procedure to create. |
Returns
| Type | Description |
|---|---|
|
A CosmosDict representing the new stored procedure. |
Exceptions
| Type | Description |
|---|---|
|
If the given stored procedure couldn't be created. |
create_trigger
Create a trigger in the container.
To replace an existing trigger, use the <xref:ContainerProxy.scripts.replace_trigger> method.
async create_trigger(body: dict[str, Any], **kwargs: Any) -> dict[str, Any]
Parameters
| Name | Description |
|---|---|
|
body
Required
|
A dict-like object representing the trigger to create. |
Returns
| Type | Description |
|---|---|
|
A dict representing the new trigger. |
Exceptions
| Type | Description |
|---|---|
|
If the given trigger couldn't be created. |
create_user_defined_function
Create a user-defined function in the container.
To replace an existing user-defined function, use the <xref:ContainerProxy.scripts.replace_user_defined_function> method.
async create_user_defined_function(body: dict[str, Any], **kwargs: Any) -> dict[str, Any]
Parameters
| Name | Description |
|---|---|
|
body
Required
|
A dict-like object representing the user-defined function to create. |
Returns
| Type | Description |
|---|---|
|
A dict representing the new user-defined function. |
Exceptions
| Type | Description |
|---|---|
|
If the user-defined function couldn't be created. |
delete_stored_procedure
Delete a specified stored procedure from the container.
If the stored procedure does not already exist in the container, an exception is raised.
async delete_stored_procedure(sproc: str | Mapping[str, Any], **kwargs: Any) -> None
Parameters
| Name | Description |
|---|---|
|
sproc
Required
|
The ID (name) or dict representing stored procedure to be deleted. |
Returns
| Type | Description |
|---|---|
Exceptions
| Type | Description |
|---|---|
|
The stored procedure wasn't deleted successfully. |
|
|
The stored procedure does not exist in the container. |
delete_trigger
Delete a specified trigger from the container.
If the trigger does not already exist in the container, an exception is raised.
async delete_trigger(trigger: str | Mapping[str, Any], **kwargs: Any) -> None
Parameters
| Name | Description |
|---|---|
|
trigger
Required
|
The ID (name) or dict representing trigger to be deleted. |
Returns
| Type | Description |
|---|---|
Exceptions
| Type | Description |
|---|---|
|
The trigger wasn't deleted successfully. |
|
|
The trigger does not exist in the container. |
delete_user_defined_function
Delete a specified user-defined function from the container.
If the user-defined function does not already exist in the container, an exception is raised.
async delete_user_defined_function(udf: str | Mapping[str, Any], **kwargs: Any) -> None
Parameters
| Name | Description |
|---|---|
|
udf
Required
|
The ID (name) or dict representing udf to be deleted. |
Returns
| Type | Description |
|---|---|
Exceptions
| Type | Description |
|---|---|
|
The udf wasn't deleted successfully. |
|
|
The UDF does not exist in the container. |
execute_stored_procedure
Execute a specified stored procedure.
If the stored procedure does not already exist in the container, an exception is raised.
async execute_stored_procedure(sproc: str | dict[str, Any], *, partition_key: None | bool | float | int | str | Type[NonePartitionKeyValue] | Type[NullPartitionKeyValue] | _Empty | _Undefined | Sequence[None | bool | float | int | str | Type[NonePartitionKeyValue] | Type[NullPartitionKeyValue] | _Empty | _Undefined] = None, parameters: list[dict[str, Any]] | None = None, enable_script_logging: bool | None = None, **kwargs: Any) -> Any
Parameters
| Name | Description |
|---|---|
|
sproc
Required
|
The ID (name) or dict representing the stored procedure to be executed. |
Keyword-Only Parameters
| Name | Description |
|---|---|
|
partition_key
|
Specifies the partition key to indicate which partition the stored procedure should execute on. Default value: None
|
|
parameters
|
List of parameters to be passed to the stored procedure to be executed. Default value: None
|
|
enable_script_logging
|
Enables or disables script logging for the current request. Default value: None
|
Returns
| Type | Description |
|---|---|
|
Result of the executed stored procedure for the given parameters. |
Exceptions
| Type | Description |
|---|---|
|
If the stored procedure execution failed or if the stored procedure with given id does not exists in the container. |
get_stored_procedure
Get the stored procedure identified by sproc.
async get_stored_procedure(sproc: str | Mapping[str, Any], **kwargs: Any) -> CosmosDict
Parameters
| Name | Description |
|---|---|
|
sproc
Required
|
The ID (name) or dict representing the stored procedure to retrieve. |
Returns
| Type | Description |
|---|---|
|
A CosmosDict representing the retrieved stored procedure. |
Exceptions
| Type | Description |
|---|---|
|
If the given stored procedure couldn't be retrieved. |
get_trigger
Get a trigger identified by id.
async get_trigger(trigger: str | Mapping[str, Any], **kwargs: Any) -> dict[str, Any]
Parameters
| Name | Description |
|---|---|
|
trigger
Required
|
The ID (name) or dict representing trigger to retrieve. |
Returns
| Type | Description |
|---|---|
|
A dict representing the retrieved trigger. |
Exceptions
| Type | Description |
|---|---|
|
If the given trigger couldn't be retrieved. |
get_user_defined_function
Get a user-defined function identified by id.
async get_user_defined_function(udf: str | Mapping[str, Any], **kwargs: Any) -> dict[str, Any]
Parameters
| Name | Description |
|---|---|
|
udf
Required
|
The ID (name) or dict representing udf to retrieve. |
Returns
| Type | Description |
|---|---|
|
A dict representing the retrieved user-defined function. |
Exceptions
| Type | Description |
|---|---|
|
If the user-defined function couldn't be retrieved. |
list_stored_procedures
List all stored procedures in the container.
list_stored_procedures(*, max_item_count: int | None = None, **kwargs: Any) -> AsyncItemPaged[dict[str, Any]]
Keyword-Only Parameters
| Name | Description |
|---|---|
|
max_item_count
|
Max number of items to be returned in the enumeration operation. Default value: None
|
Returns
| Type | Description |
|---|---|
|
An AsyncItemPaged of stored procedures (dicts). |
list_triggers
List all triggers in the container.
list_triggers(*, max_item_count: int | None = None, **kwargs: Any) -> AsyncItemPaged[dict[str, Any]]
Keyword-Only Parameters
| Name | Description |
|---|---|
|
max_item_count
|
Max number of items to be returned in the enumeration operation. Default value: None
|
Returns
| Type | Description |
|---|---|
|
An AsyncItemPaged of triggers (dicts). |
list_user_defined_functions
List all the user-defined functions in the container.
list_user_defined_functions(*, max_item_count: int | None = None, **kwargs: Any) -> AsyncItemPaged[dict[str, Any]]
Keyword-Only Parameters
| Name | Description |
|---|---|
|
max_item_count
|
Max number of items to be returned in the enumeration operation. Default value: None
|
Returns
| Type | Description |
|---|---|
|
An AsyncItemPaged of user-defined functions (dicts). |
query_stored_procedures
Return all stored procedures matching the given query.
query_stored_procedures(query: str, *, parameters: list[dict[str, Any]] | None = None, max_item_count: int | None = None, **kwargs: Any) -> AsyncItemPaged[dict[str, Any]]
Parameters
| Name | Description |
|---|---|
|
query
Required
|
The Azure Cosmos DB SQL query to execute. |
Keyword-Only Parameters
| Name | Description |
|---|---|
|
parameters
|
Optional array of parameters to the query. Ignored if no query is provided. Default value: None
|
|
max_item_count
|
Max number of items to be returned in the enumeration operation. Default value: None
|
Returns
| Type | Description |
|---|---|
|
An AsyncItemPaged of stored procedures (dicts). |
query_triggers
Return all triggers matching the given query.
query_triggers(query: str, *, parameters: list[dict[str, Any]] | None = None, max_item_count: int | None = None, **kwargs: Any) -> AsyncItemPaged[dict[str, Any]]
Parameters
| Name | Description |
|---|---|
|
query
Required
|
The Azure Cosmos DB SQL query to execute. |
Keyword-Only Parameters
| Name | Description |
|---|---|
|
parameters
|
Optional array of parameters to the query. Ignored if no query is provided. Default value: None
|
|
max_item_count
|
Max number of items to be returned in the enumeration operation. Default value: None
|
Returns
| Type | Description |
|---|---|
|
An AsyncItemPaged of triggers (dicts). |
query_user_defined_functions
Return user-defined functions matching a given query.
query_user_defined_functions(query: str, *, parameters: list[dict[str, Any]] | None = None, max_item_count: int | None = None, **kwargs: Any) -> AsyncItemPaged[dict[str, Any]]
Parameters
| Name | Description |
|---|---|
|
query
Required
|
The Azure Cosmos DB SQL query to execute. |
Keyword-Only Parameters
| Name | Description |
|---|---|
|
parameters
|
Optional array of parameters to the query. Ignored if no query is provided. Default value: None
|
|
max_item_count
|
Max number of items to be returned in the enumeration operation. Default value: None
|
Returns
| Type | Description |
|---|---|
|
An AsyncItemPaged of user-defined functions (dicts). |
replace_stored_procedure
Replace a specified stored procedure in the container.
If the stored procedure does not already exist in the container, an exception is raised.
async replace_stored_procedure(sproc: str | Mapping[str, Any], body: dict[str, Any], **kwargs: Any) -> CosmosDict
Parameters
| Name | Description |
|---|---|
|
sproc
Required
|
The ID (name) or dict representing stored procedure to be replaced. |
|
body
Required
|
A dict representing the stored procedure to replace. |
Returns
| Type | Description |
|---|---|
|
A CosmosDict representing the stored procedure after replace went through. |
Exceptions
| Type | Description |
|---|---|
|
If the replace operation failed or the stored procedure with given id does not exist. |
replace_trigger
Replace a specified trigger in the container.
If the trigger does not already exist in the container, an exception is raised.
async replace_trigger(trigger: str | Mapping[str, Any], body: dict[str, Any], **kwargs: Any) -> dict[str, Any]
Parameters
| Name | Description |
|---|---|
|
trigger
Required
|
The ID (name) or dict representing trigger to be replaced. |
|
body
Required
|
A dict-like object representing the trigger to replace. |
Returns
| Type | Description |
|---|---|
|
A dict representing the trigger after replace went through. |
Exceptions
| Type | Description |
|---|---|
|
If the replace operation failed or the trigger with given id does not exist. |
replace_user_defined_function
Replace a specified user-defined function in the container.
If the user-defined function does not already exist in the container, an exception is raised.
async replace_user_defined_function(udf: str | Mapping[str, Any], body: dict[str, Any], **kwargs: Any) -> dict[str, Any]
Parameters
| Name | Description |
|---|---|
|
udf
Required
|
The ID (name) or dict representing user-defined function to be replaced. |
|
body
Required
|
A dict-like object representing the udf to replace. |
Returns
| Type | Description |
|---|---|
|
A dict representing the user-defined function after replace went through. |
Exceptions
| Type | Description |
|---|---|
|
If the replace operation failed or the user-defined function with the given id does not exist. |