public static final class RunCommandRequest.Builder extends Object
限定符和类型 | 方法和说明 |
---|---|
RunCommandRequest |
build() |
RunCommandRequest.Builder |
clientToken(String clientToken)
The client token that is used to ensure the idempotence of the request.
|
RunCommandRequest.Builder |
commandContent(String commandContent)
The content of the command.
|
RunCommandRequest.Builder |
containerId(String containerId)
The ID of the container.
|
RunCommandRequest.Builder |
containerName(String containerName)
The name of the container.
|
RunCommandRequest.Builder |
contentEncoding(String contentEncoding)
The encoding mode of command content (`CommandContent`).
|
RunCommandRequest.Builder |
description(String description)
The description of the command.
|
RunCommandRequest.Builder |
enableParameter(Boolean enableParameter)
Specifies whether to include custom parameters in the command.
|
RunCommandRequest.Builder |
frequency(String frequency)
The schedule on which to run the command.
|
RunCommandRequest.Builder |
instanceId(List<String> instanceId)
The IDs of instances on which to run the command.
|
RunCommandRequest.Builder |
keepCommand(Boolean keepCommand)
Specifies whether to retain the command after the command is run.
|
RunCommandRequest.Builder |
launcher(String launcher)
The launcher for script execution.
|
RunCommandRequest.Builder |
name(String name)
The name of the command.
|
RunCommandRequest.Builder |
ownerAccount(String ownerAccount)
OwnerAccount.
|
RunCommandRequest.Builder |
ownerId(Long ownerId)
OwnerId.
|
RunCommandRequest.Builder |
parameters(Map<String,?> parameters)
The key-value pairs of the custom parameters that are passed in when the command that can include custom parameters is run.
|
RunCommandRequest.Builder |
regionId(String regionId)
The region ID of the command.
|
RunCommandRequest.Builder |
repeatMode(String repeatMode)
Specifies how to run the command.
|
RunCommandRequest.Builder |
resourceGroupId(String resourceGroupId)
The ID of the resource group to which to assign the command executions.
|
RunCommandRequest.Builder |
resourceOwnerAccount(String resourceOwnerAccount)
ResourceOwnerAccount.
|
RunCommandRequest.Builder |
resourceOwnerId(Long resourceOwnerId)
ResourceOwnerId.
|
RunCommandRequest.Builder |
resourceTag(List<RunCommandRequest.ResourceTag> resourceTag)
The tags of the instance.
|
RunCommandRequest.Builder |
sourceRegionId(String sourceRegionId)
SourceRegionId.
|
RunCommandRequest.Builder |
tag(List<RunCommandRequest.Tag> tag)
The description of the command.
|
RunCommandRequest.Builder |
terminationMode(String terminationMode)
Specifies how to stop the command task when a command execution is manually stopped or times out.
|
RunCommandRequest.Builder |
timed(Boolean timed)
> This parameter is no longer used and does not take effect.
|
RunCommandRequest.Builder |
timeout(Long timeout)
The timeout period for the command execution.
|
RunCommandRequest.Builder |
type(String type)
The language type of the command.
|
RunCommandRequest.Builder |
username(String username)
The username to use to run the command on the ECS instances.
|
RunCommandRequest.Builder |
windowsPasswordName(String windowsPasswordName)
The name of the password to use to run the command on a Windows instance.
|
RunCommandRequest.Builder |
workingDir(String workingDir)
The working directory of the command on the instance.
|
public RunCommandRequest.Builder sourceRegionId(String sourceRegionId)
public RunCommandRequest.Builder clientToken(String clientToken)
public RunCommandRequest.Builder commandContent(String commandContent)
* If you want to retain the command, make sure that the Base64-encoded command content does not exceed 18 KB in size. If you do not want to retain the command, make sure that the Base64-encoded command content does not exceed 24 KB in size. You can set the `KeepCommand` parameter to specify whether to retain the command. * If the command content is encoded in Base6, set `ContentEncoding` to Base64. * If you set the `EnableParameter` parameter to true, the custom parameter feature is enabled and you can configure custom parameters based on the following rules: * Specify custom parameters in the `{{}}` format. Within `{{}}`, the spaces and line feeds before and after the parameter names are ignored. * You can specify up to 20 custom parameters. * A custom parameter name can contain only letters, digits, underscores (\_), and hyphens (-). The name is case-insensitive. The ACS:: prefix cannot be used to specify non-built-in environment parameters. * Each custom parameter name cannot exceed 64 bytes in length. * You can specify built-in environment parameters as custom parameters. Then, when you run a command, the parameters are automatically specified by Cloud Assistant. You can specify the following built-in environment parameters: * `{{ACS::RegionId}}`: the region ID. * `{{ACS::AccountId}}`: the UID of the Alibaba Cloud account. * `{{ACS::InstanceId}}`: the instance ID. If you want to run the command on multiple instances and specify `{{ACS::InstanceId}}` as a built-in environment parameter, make sure that the Cloud Assistant Agent version is not earlier than the following ones: * Linux: 2.2.3.309 * Windows: 2.1.3.309 * `{{ACS::InstanceName}}`: the instance name. If you want to run the command on multiple instances and specify `{{ACS::InstanceName}}` as a built-in environment parameter, make sure that the Cloud Assistant Agent version is not earlier than the following ones: * Linux: 2.2.3.344 * Windows: 2.1.3.344 * `{{ACS::InvokeId}}`: the ID of the task. If you want to specify `{{ACS::InvokeId}}` as a built-in environment parameter, make sure that the Cloud Assistant Agent version is not earlier than the following ones: * Linux: 2.2.3.309 * Windows: 2.1.3.309 * `{{ACS::CommandId}}`: the ID of the command. If you want to specify `{{ACS::CommandId}}` as a built-in environment parameter, make sure that the Cloud Assistant Agent version is not earlier than the following ones: * Linux: 2.2.3.309 * Windows: 2.1.3.309
public RunCommandRequest.Builder containerId(String containerId)
Take note of the following items: * If this parameter is specified, Cloud Assistant runs the command in the specified container of the instance. * If this parameter is specified, the command can run only on Linux instances on which Cloud Assistant Agent 2.2.3.344 or later is installed. * If this parameter is specified, the specified `Username` and `WorkingDir` parameters do not take effect. You can run the command in the default working directory of the container only by using the default user of the container. For more information, see [Use Cloud Assistant to run commands in containers](~~456641~~). * If this parameter is specified, only shell scripts can be run in Linux containers. You cannot add a command in the format similar to `#!/usr/bin/python` at the beginning of a script to specify a script interpreter. For more information, see [Use Cloud Assistant to run commands in containers](~~456641~~).
public RunCommandRequest.Builder containerName(String containerName)
Take note of the following items: * If this parameter is specified, Cloud Assistant runs the command in the specified container of the instance. * If this parameter is specified, the command can run only on Linux instances on which Cloud Assistant Agent 2.2.3.344 or later is installed. * If this parameter is specified, the specified `Username` and `WorkingDir` parameters do not take effect. You can run the command in the default working directory of the container only by using the default user of the container. For more information, see [Use Cloud Assistant to run commands in containers](~~456641~~). * If this parameter is specified, only shell scripts can be run in Linux containers. You cannot add a command in the format similar to `#!/usr/bin/python` at the beginning of a script to specify a script interpreter. For more information, see [Use Cloud Assistant to run commands in containers](~~456641~~).
public RunCommandRequest.Builder contentEncoding(String contentEncoding)
* PlainText: The command content is not encoded. * Base64: The command content is encoded in Base64. Default value: PlainText. If the specified value of this parameter is invalid, PlainText is used by default.
public RunCommandRequest.Builder description(String description)
public RunCommandRequest.Builder enableParameter(Boolean enableParameter)
Default value: false.
public RunCommandRequest.Builder frequency(String frequency)
* To run a command at a fixed interval, use a rate expression to specify the interval. You can specify the interval in seconds, minutes, hours, or days. This option is suitable for scenarios in which tasks need to be executed at a fixed interval. Specify the interval in the following format: `rate(
public RunCommandRequest.Builder instanceId(List<String> instanceId)
If one of the specified instances does not meet the conditions for running the command, the call fails. To ensure that the call is successful, specify only the IDs of instances that meet the conditions. You can apply for a quota increase in the Quota Center console. The quota name is Maximum number of instances supported for command execution.
public RunCommandRequest.Builder keepCommand(Boolean keepCommand)
* true: retains the command. Then, you can call the InvokeCommand operation to rerun the command. The retained command counts against the quota of Cloud Assistant commands. * false: does not retain the command. The command is automatically deleted after it is run and does not count against the quota of Cloud Assistant commands. Default value: false.
public RunCommandRequest.Builder launcher(String launcher)
public RunCommandRequest.Builder name(String name)
public RunCommandRequest.Builder ownerAccount(String ownerAccount)
public RunCommandRequest.Builder ownerId(Long ownerId)
public RunCommandRequest.Builder parameters(Map<String,?> parameters)
You can specify up to 10 custom parameters. Take note of the following items: * The key cannot be an empty string. It can be up to 64 characters in length. * The value can be an empty string. * If you want to retain the command, make sure that the command after Base64 encoding, including custom parameters and original command content, does not exceed 18 KB in size. If you do not want to retain the command, make sure that the command after Base64-encoding does not exceed 24 KB in size. You can set `KeepCommand` to specify whether to retain the command. * The custom parameter names that are specified by Parameters must be included in the custom parameter names that you specified when you created the command. You can use empty strings to represent the parameters that are not passed in. This parameter is empty by default. You can leave this parameter empty to disable the custom parameter feature.
public RunCommandRequest.Builder regionId(String regionId)
public RunCommandRequest.Builder repeatMode(String repeatMode)
* Once: immediately runs the command. * Period: runs the command on a schedule. If you set this parameter to `Period`, you must specify `Frequency`. * NextRebootOnly: runs the command the next time the instance is started. * EveryReboot: runs the command every time the instance is started. Default values: * If you do not specify the `Frequency` parameter, the default value is `Once`. * If you specify the `Frequency` parameter, `Period` is used as the value of RepeatMode regardless of whether RepeatMode is set to Period. Take note of the following items: * You can call the [StopInvocation](~~64838~~) operation to stop the pending or scheduled executions of the command. * If you set this parameter to `Period` or `EveryReboot`, you can call the [DescribeInvocationResults](~~64845~~) operation with `IncludeHistory` set to true to query the results of historical scheduled executions.
public RunCommandRequest.Builder resourceGroupId(String resourceGroupId)
* The instances specified by InstanceId.N must belong to the specified resource group. * After the command is run, you can set this parameter to call the [DescribeInvocations](~~64840~~) or [DescribeInvocationResults](~~64845~~) operation to query the execution results in the specified resource group.
public RunCommandRequest.Builder resourceOwnerAccount(String resourceOwnerAccount)
public RunCommandRequest.Builder resourceOwnerId(Long resourceOwnerId)
public RunCommandRequest.Builder resourceTag(List<RunCommandRequest.ResourceTag> resourceTag)
public RunCommandRequest.Builder tag(List<RunCommandRequest.Tag> tag)
public RunCommandRequest.Builder terminationMode(String terminationMode)
* Process: stops the process of the command. * ProcessTree: stops the process tree of the command. In this case, the process of the command and all subprocesses of the process are stopped.
public RunCommandRequest.Builder timed(Boolean timed)
public RunCommandRequest.Builder timeout(Long timeout)
A timeout error occurs if the command cannot be run because the process slows down or because a specific module or Cloud Assistant Agent does not exist. When an execution times out, the command process is forcefully terminated. Default value: 60.
public RunCommandRequest.Builder type(String type)
* RunBatScript: batch command, applicable to Windows instances. * RunPowerShellScript: PowerShell command, applicable to Windows instances. * RunShellScript: shell command, applicable to Linux instances.
public RunCommandRequest.Builder username(String username)
* For Linux instances, the root username is used by default. * For Windows instances, the System username is used by default. You can also specify other usernames that already exist in the instances to run the command. For security purposes, we recommend that you run Cloud Assistant commands as a regular user. For more information, see [Run Cloud Assistant commands as a regular user](~~203771~~).
public RunCommandRequest.Builder windowsPasswordName(String windowsPasswordName)
If you do not want to use the default System user to run the command on Windows instances, specify both WindowsPasswordName and `Username`. To mitigate the risk of password leaks, the password is stored in plaintext in CloudOps Orchestration Service (OOS) Parameter Store, and only the name of the password is passed in by using WindowsPasswordName. For more information, see [Manage encryption parameters](~~186828~~) and [Run Cloud Assistant commands as a regular user](~~203771~~). > If you use the root username for Linux instances or the System username for Windows instances to run the command, you do not need to specify WindowsPasswordName.
public RunCommandRequest.Builder workingDir(String workingDir)
Default values: * For Linux instances, the default value is `/root`, which is the home directory of the administrator (the root user). * For Windows instances, the default value is the directory where the Cloud Assistant Agent process resides, such as `C:\Windows\System32`.
public RunCommandRequest build()
Copyright © 2024. All rights reserved.