public static final class RunCommandRequest.Builder extends Object
限定符和类型 | 方法和说明 |
---|---|
RunCommandRequest |
build() |
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 the command content that is specified by the `CommandContent` parameter.
|
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 based on which the command is run.
|
RunCommandRequest.Builder |
instanceId(List<String> instanceId)
The ID of instance N on which you want to run the command.
|
RunCommandRequest.Builder |
keepCommand(Boolean keepCommand)
Specifies whether to retain the command after the command is run.
|
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 includes custom parameters.
|
RunCommandRequest.Builder |
regionId(String regionId)
The ID of the region.
|
RunCommandRequest.Builder |
repeatMode(String repeatMode)
Specifies the mode in which you want to run the command.
|
RunCommandRequest.Builder |
resourceGroupId(String resourceGroupId)
The ID of the resource group to which you want to assign the command executions.
|
RunCommandRequest.Builder |
resourceOwnerAccount(String resourceOwnerAccount)
ResourceOwnerAccount.
|
RunCommandRequest.Builder |
resourceOwnerId(Long resourceOwnerId)
ResourceOwnerId.
|
RunCommandRequest.Builder |
sourceRegionId(String sourceRegionId)
SourceRegionId.
|
RunCommandRequest.Builder |
tag(List<RunCommandRequest.Tag> tag)
The tags that you want to add to the command.
|
RunCommandRequest.Builder |
timed(Boolean timed)
Specifies whether to run the command based on a schedule.
|
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 that you use to run the command on instances.
|
RunCommandRequest.Builder |
windowsPasswordName(String windowsPasswordName)
The name of the password that you use to run the command on Windows instances.
|
RunCommandRequest.Builder |
workingDir(String workingDir)
The working directory of the command on the instance.
|
public RunCommandRequest.Builder sourceRegionId(String sourceRegionId)
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 use the `KeepCommand` parameter to specify whether to retain the command. * If the command content is Base64-encoded, set the `ContentEncoding` parameter to Base64. * If you set the `EnableParameter` parameter to true, the custom parameter feature is enabled and you can specify 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 not case-sensitive. * Each custom parameter name cannot exceed 64 bytes in length. * You can specify built-in environment parameters as custom parameters. Then, Cloud Assistant automatically specifies the parameters when you run the command. You can specify the following built-in environment parameters: * `{{ACS::RegionId}}`: the ID of the region. * `{{ACS::AccountId}}`: the UID of the Alibaba Cloud account. * `{{ACS::InstanceId}}`: the ID of the instance. If you want to run the command on multiple instances and specify `{{ACS::InstanceId}}` as a built-in environment parameter, make sure that the version of the Cloud Assistant client is not earlier than the following versions: * Linux: 2.2.3.309 * Windows: 2.1.3.309 * `{{ACS::InstanceName}}`: the name of the instance. If you want to run the command on multiple instances and specify `{{ACS::InstanceName}}` as a built-in environment parameter, make sure that the version of the Cloud Assistant client is not earlier than the following versions: * Linux: 2.2.3.344 * Windows: 2.1.3.344 * `{{ACS::InvokeId}}`: the ID of the command task. If you want to specify `{{ACS::InvokeId}}` as a built-in environment parameter, make sure that the version of the Cloud Assistant client is not earlier than the following versions: * 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 version of the Cloud Assistant client is not earlier than the following versions: * Linux: 2.2.3.309 * Windows: 2.1.3.309
public RunCommandRequest.Builder containerId(String containerId)
Take note of the following items: * If you specify this parameter, Cloud Assistant runs scripts in the specified container of the instance. * If you specify this parameter, scripts can be run only on Linux instances on which the Cloud Assistant client of version 2.2.3.344 or later is installed. * If you specify this parameter, the specified `Username` and `WorkingDir` parameters do not take effect. You can run the command in the default working directory of the container by using only the default user of the container. For more information, see [Use Cloud Assistant to run commands in containers](~~456641~~). * If you specify this parameter, only shell scripts can be run in Linux containers. You cannot specify a script interpreter by adding a command in a format that is similar to `#!/usr/bin/python` at the beginning of a script. 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 you specify this parameter, Cloud Assistant runs scripts in the specified container of the instance. * If you specify this parameter, scripts can be run only on Linux instances on which the Cloud Assistant client of version 2.2.3.344 or later is installed. * If you specify this parameter, the specified `Username` and `WorkingDir` parameters do not take effect. You can run the command in the default working directory of the container by using only the default user of the container. For more information, see [Use Cloud Assistant to run commands in containers](~~456641~~). * If you specify this parameter, only shell scripts can be run in Linux containers. You cannot specify a script interpreter by adding a command in a format that is similar to `#!/usr/bin/python` at the beginning of a script. 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 an invalid value is specified for this parameter, PlainText is used.
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.
public RunCommandRequest.Builder keepCommand(Boolean keepCommand)
* true: retains the command. 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 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 size of the command after Base64 encoding, including custom parameters and original command content, does not exceed 18 KB. If you do not want to retain the command, make sure that the size of the command after Base64-encoding does not exceed 24 KB. You can use the `KeepCommand` parameter to specify whether to retain the command. * The custom parameter names that are specified by the Parameters parameter must be included in the custom parameter names that you specify when you created the command. You can use empty strings to represent the parameters that are not passed in. By default, this parameter is left empty. If you want to disable the custom parameter feature, you can leave this parameter empty.
public RunCommandRequest.Builder regionId(String regionId)
public RunCommandRequest.Builder repeatMode(String repeatMode)
* Once: immediately runs the command. * Period: runs the command based on a schedule. If you set this parameter to `Period`, you must set the `Timed` parameter to true and specify the `Frequency` parameter. * NextRebootOnly: automatically runs the command the next time the instance is started. * EveryReboot: automatically runs the command every time the instance is started. Default value: * If you set the `Timed` parameter to false and do not specify the `Frequency` parameter, the default value of the RepeatMode parameter is `Once`. * If you set the `Timed` parameter to true and specify the `Frequency` parameter, `Period` is used as the value of the RepeatMode parameter regardless of whether you specify the RepeatMode parameter. Take note of the following items: * If you set this parameter to `Period`, `NextRebootOnly`, or `EveryReboot`, you can call the [StopInvocation](~~64838~~) operation to stop the pending or scheduled execution of the command. * If you set this parameter to `Period` or `EveryReboot`, you can call the [DescribeInvocationResults](~~64845~~) operation and set the `IncludeHistory` parameter to true to view the results of previous scheduled executions.
public RunCommandRequest.Builder resourceGroupId(String resourceGroupId)
* The instances that are specified by the InstanceId parameter must belong to the specified resource group. * You can specify this parameter to call the [DescribeInvocations](~~64840~~) or [DescribeInvocationResults](~~64845~~) operation to query execution results in the specified resource group.
public RunCommandRequest.Builder resourceOwnerAccount(String resourceOwnerAccount)
public RunCommandRequest.Builder resourceOwnerId(Long resourceOwnerId)
public RunCommandRequest.Builder tag(List<RunCommandRequest.Tag> tag)
public RunCommandRequest.Builder timed(Boolean timed)
* true: runs the command based on the schedule that is specified by the `Frequency` parameter. The results of a command execution do not affect the next command execution. * false: runs the command only once. Default value: false.
public RunCommandRequest.Builder timeout(Long timeout)
A timeout error occurs when a command cannot be run because the command process slows down or because a specific module or the Cloud Assistant client does not exist. When an execution times out, the command process is forcibly 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. * For Windows instances, the System username is used. You can also specify other usernames that already exist on 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 username System to run the command on Windows instances, you must specify the WindowsPasswordName and `Username` parameters. The password is stored in plaintext in the parameter repository of Operation Orchestration Service (OOS) to reduce the risk of password leaks. Only the name of the password is passed in by using the WindowsPasswordName parameter. For more information, see [Encrypt parameters](~~186828~~) and [Configure a regular user to run Cloud Assistant commands](~~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 the WindowsPasswordName parameter.
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 client process resides. Example: `C:\Windows\System32`.
public RunCommandRequest build()
Copyright © 2023. All rights reserved.