Example Operations
class Instance
Get subclasses of the operation instance.
py
api = mcsm.instance()
method search(daemonId: str, page: int = 1, page_size: int = 20, instance_name: str = "", status: Literal[-1, 0, 1, 2, 3, ""] = "", tag: list[str] | None = None)
Search for instance information based on specified parameters.
Parameters
daemonId
: UUID of the nodepage
: Page number, indicating which page of data to returnpage_size
: Number of items per page, default is 20instance_name
: Instance name for filteringstatus
: Instance status for filteringtag
: List of tags for filtering
Returns
InstanceSearchList
: Search result model
method detail(daemonId: str, uuid: str)
Get detailed information of a specified instance.
Parameters
daemonId
: UUID of the nodeuuid
: UUID of the instance
Returns
InstanceDetail
: Model containing detailed instance information
method create(daemonId: str, config: dict[str, Any])
Create a new instance.
Parameters
daemonId
: UUID of the nodeconfig
: Configuration of the new instance, provided as a dictionary. Missing values are filled with default values from theInstanceConfig
model.
Returns
InstanceCreateResult
: Object containing information about the newly created instance
method updateConfig(daemonId: str, uuid: str, config: dict[str, Any])
Update the configuration of an instance.
Parameters
daemonId
: UUID of the nodeuuid
: UUID of the instanceconfig
: New configuration, provided as a dictionary. Missing values are filled with default values from theInstanceConfig
model.
Returns
str
: UUID of the instance whose configuration was updated
method delete(daemonId: str, uuids: list[str])
Delete instances.
Parameters
daemonId
: UUID of the nodeuuids
: List of UUIDs of instances to deletedeleteFile
: Whether to delete instance files
Returns
str
: List of UUIDs of deleted instances
method start(daemonId: str, uuid: str)
Start an instance.
Parameters
daemonId
: UUID of the nodeuuid
: UUID of the instance to start
Returns
str
: UUID of the started instance
method stop(daemonId: str, uuid: str)
Stop an instance.
Parameters
daemonId
: UUID of the nodeuuid
: UUID of the instance to stop
Returns
str
: UUID of the stopped instance
method restart(daemonId: str, uuid: str)
Restart an instance.
Parameters
daemonId
: UUID of the nodeuuid
: UUID of the instance to restart
Returns
str
: UUID of the restarted instance
method kill(daemonId: str, uuid: str)
Forcefully stop an instance.
Parameters
daemonId
: UUID of the nodeuuid
: UUID of the instance to stop
Returns
str
: UUID of the stopped instance
method batchOperation(instances: list[batchOperationDetail], operation: Literal["start", "stop", "restart", "kill"])
Perform batch operations on instances.
Parameters
instances
: List of instances to operate onoperation
: Type of operation
Returns
bool
: ReturnsTrue
if the operation is successful
method update(daemonId: str, uuid: str)
Update an instance.
Parameters
daemonId
: UUID of the nodeuuid
: UUID of the instance
Returns
bool
: ReturnsTrue
if the operation is successful
method command(daemonId: str, uuid: str, command: str)
Send a command to an instance.
Parameters
daemonId
: UUID of the nodeuuid
: UUID of the instancecommand
: Command to send
Returns
str
: UUID of the operated instance
method get_output(daemonId: str, uuid: str, size: int | None = None)
Get instance output.
Parameters
daemonId
: UUID of the nodeuuid
: UUID of the instancesize
: Size of output to retrieve, in KB (1KB ~ 2048KB). If not set, all logs are returned.
Returns
str
: Log content
method reinstall(daemonId: str, uuid: str, targetUrl: str, title: str = "", description: str = "")
Reinstall an instance.
Parameters
daemonId
: UUID of the nodeuuid
: UUID of the instancetargetUrl
: Target URL of the file for reinstallationtitle
: Title of the reinstallation filedescription
: Description of the reinstallation file
Returns
bool
: ReturnsTrue
if the operation is successful