ModifyInvocationAttribute

更新时间:
复制 MD 格式

Modifies the execution information of a Cloud Assistant scheduled command task, including modifying the content and execution frequency of the command and adding Elastic Compute Service (ECS) instances or Alibaba Cloud managed instances to the command task.

Operation description

  • Supports modifying tasks with the following execution modes (refer to the RepeatMode value returned by DescribeInvocations):
    • Period: Execute periodically.

    • NextRebootOnly: Automatically execute the command the next time the instance starts.

    • EveryReboot: Automatically execute the command every time the instance starts.

  • Supports modifying tasks in the following statuses (refer to the InvocationStatus value returned by DescribeInvocations):
    • Pending: The system is validating or sending the command. If at least one instance has a command execution status of Pending, the overall execution status is Pending.

    • Running: The command is running on an instance. If at least one instance has a command execution status of Running, the overall execution status is Running.

    • Scheduled: The scheduled command has been sent and is waiting to run. If at least one instance has a command execution status of Scheduled, the overall execution status is Scheduled.

    • Stopping: The task is being stopped. If at least one instance has a command execution status of Stopping, the overall execution status is Stopping.

  • Before modifying the execution information of a scheduled task (including command content, Custom Parameters, and execution frequency), the Cloud Assistant Agent version on the involved ECS instances or managed instances must be higher than the following versions:
    • Linux: 2.2.3.541

    • Windows: 2.1.3.541

    • If the response returns the error code InvalidOperation.CloudAssistantVersionUnsupported, update the Cloud Assistant Agent to the latest version.

  • When you execute a Cloud Assistant public command, you cannot modify the CommandContent.

  • If you modify the CommandContent and create a task by invoking InvokeCommand or RunCommand with KeepCommand set to true, a new command will be created and retained permanently, consuming your Cloud Assistant command quota. In each Region, you can retain between 500 and 50,000 Cloud Assistant commands. You can request a quota increase. For more information about how to query and increase your quota, see Quota Management.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ecs:ModifyInvocationAttribute

update

*Invocation

acs:ecs:{#regionId}:{#accountId}:invocation/{#invocationId}

Instance

acs:ecs:{#regionId}:{#accountId}:instance/{#instanceId}

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID.

cn-hangzhou

InstanceId

array

No

The IDs of the ECS instances or managed instances that you want to add to the scheduled command task.

string

No

The ID of the ECS instance or managed instance that you want to add to the scheduled command task. The total number of instances in the scheduled command task after you add ECS instances or managed instances cannot exceed 100.

i-bp1i7gg30r52z2em****

RegionId

string

Yes

The region ID.

cn-hangzhou

InvokeId

string

Yes

The execution ID of the command.

t-hz0jdfwd9f****

CommandContent

string

No

The content of the command after modification. The command content can be plaintext or Base64-encoded. Take note of the following items:

  • You can specify whether to retain the command after the command is run when you created the command. If you specified to retain the command, the Base64-encoded command content cannot exceed 18 KB in size. If you specified not to retain the command, the Base64-encoded command content cannot exceed 24 KB in size.

  • If the command content is Base64-encoded, set ContentEncoding to Base64.

  • If you set EnableParameter to true, the custom parameter feature is enabled and you can configure custom parameters based on the following rules:

    • You can define custom parameters in the {{}} format. Within {{}}, the spaces and line feeds before and after the parameter names are ignored.

    • The number of custom parameters cannot exceed 20.

    • A custom parameter name can contain 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 the command, these 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 specify {{ACS::InstanceId}} as a built-in environment variable, 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. When the command is run on multiple instances, if you want to specify {{ACS::InstanceName}} as a built-in environment variable, 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 command ID. 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

ZWNobyAxMjM=

EnableParameter

boolean

No

Specifies whether to include custom parameters in the command.

  • If you want to enable the custom parameter feature, or configure Parameters to modify the custom parameters in the command, set EnableParameter to true.

  • If you do not want to configure Parameters to modify the custom parameters in the command, leave EnableParameter empty or set it to false.

false

Parameters

object

No

The key-value pairs of the custom parameters that are passed in if custom parameters are included in the command.

You can specify 0 to 10 custom parameters. Take note of the following items:

  • The key of a custom parameter can be up to 64 characters in length and cannot be an empty string.

  • The value of a custom parameter can be an empty string.

  • If you specified to retain the command when you create the command task, the total size of the custom parameters and original command content that are encoded in Base64 cannot exceed 18 KB. If you specified not to retain the command when you create the command task, the total size of the custom parameters and original command content that are encoded in Base64 cannot exceed 24 KB.

  • 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, which indicates not to modify the key-value pairs of the custom parameters.

{"name":"Jack", "accessKey":"LTAI*************"}

Frequency

string

No

The frequency at which to run the command. This parameter takes effect only when RepeatMode is set to Period. You can configure a command to run at a fixed interval based on a rate expression, run only once at a specific point in time, or run at designated points in time based on a cron expression.

  • To run the 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(<Execution interval value> <Execution interval unit>). For example, specify rate(5m) to run the command every 5 minutes. Take note of the following limits when you specify an interval:

    • The specified interval must be in the range of 60 seconds to 7 days and must be longer than the timeout period specified when you created the scheduled task.

    • The interval is the amount of time that elapses between two consecutive executions. The interval is irrelevant to the amount of time that is required to run the command once. For example, you set the interval to 5 minutes and the command requires 2 minutes to run once. Each time the command running is complete, the system waits 3 minutes instead of 5 minutes before the system runs the command again.

    • The point in time at which the command is run the next time is calculated based on the creation time of the task (the CreationTime value returned by the DescribeInvocations operation) and the modified execution interval.

  • To run a command only once at a specific time, specify a point in time and a time zone. Specify the point in time in the at(yyyy-MM-dd HH:mm:ss <Time zone>) format, which indicates at(Year-Month-Day Hours:Minutes:Seconds <Time zone>). If you do not specify a time zone, the Coordinated Universal Time (UTC) time zone is used by default. You can specify a time zone in the following forms:

    • The time zone name. Examples: Asia/Shanghai and America/Los_Angeles.

    • The time offset from GMT. Examples: GMT+8:00 (UTC+8) and GMT-7:00 (UTC-7). If you use the GMT format, you cannot add leading zeros to the hour value.

    • The time zone abbreviation. Only UTC is supported.

    For example, to configure a command to run only once at 13:15:30 on June 6, 2022 (Shanghai time), set the time to at(2022-06-06 13:15:30 Asia/Shanghai). To configure a command to run only once at 13:15:30 on June 6, 2022 (UTC-7), set the time to at(2022-06-06 13:15:30 GMT-7:00).

  • To run a command at designated points in time, use a cron expression to define the schedule. Specify a schedule in the <Cron expression> <Time zone> format. The cron expression is in the <Seconds> <Minutes> <Hours> <Day of the month> <Month> <Day of the week> <Year (optional)> format. The system calculates the execution times of the command based on the specified cron expression and time zone and runs the command as scheduled. If you do not specify a time zone, the system time zones of the instances on which you want to run the command are used by default. For information about cron expressions, see Cron expressions. You can specify the time zone in the following forms:

    • The time zone name. Examples: Asia/Shanghai and America/Los_Angeles.

    • The time offset from GMT. Examples: GMT+8:00 (UTC+8) and GMT-7:00 (UTC-7). If you use the GMT format, you cannot add leading zeros to the hour value.

    • The time zone abbreviation. Only UTC is supported. For example, to configure a command to run at 10:15:00 every day in 2022 (Shanghai time), set the schedule to 0 15 10 ? * * 2022 Asia/Shanghai. To configure a command to run every half an hour from 10:00:00 to 11:30:00 every day in 2022 (UTC+8), set the schedule to 0 0/30 10-11 * * ? 2022 GMT+8:00. To configure a command to run every 5 minutes from 14:00:00 to 14:55:00 every October every two years from 2022 in UTC, set the schedule to 0 0/5 14 * 10 ? 2022/2 UTC.

    **

    Note The minimum interval must be 10 seconds or longer and cannot be shorter than the timeout period of scheduled executions.

0 */20 * * * *

ContentEncoding

string

No

The encoding mode of the command content that is specified by CommandContent. Valid values (case-insensitive):

  • PlainText: The command content is not encoded.

  • Base64: The command content is encoded in Base64.

Default value: PlainText. If the value is invalid, the PlainText mode is used.

PlainText

ClientToken

string

No

Ensures the idempotence of the request. Generate a unique parameter value from your client to guarantee uniqueness across different requests. ClientToken supports only ASCII characters and cannot exceed 64 characters. For more information, see How to ensure idempotence.

123e4567-e89b-12d3-a456-426655440000

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3****

CommandId

string

The command ID.

  • A new command is added and the CommandId value of the new command is returned only when CommandContent is changed.

  • No new command is added and the CommandId value of the command that is running is returned if CommandContent is not changed.

  • If you set KeepCommand to true when you called the InvokeCommand or RunCommand operation, a new command is added and retained. Otherwise, commands related to the task are deleted after all executions of the task are complete or the task is manually stopped.

c-hz01272yr52****

Examples

Success response

JSON format

{
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
  "CommandId": "c-hz01272yr52****"
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidParameter.Frequency The specified parameter Frequency is not valid. The specified parameter Frequency is illegal.
400 InvalidParameters.KeyDuplicate The key in the parameter Parameters cannot be duplicated. Keys in parameter Parameters cannot be duplicated.
400 InvalidParameters.KeyNotMatch The key in the parameter Parameters do not match those defined when creating the command. The key in the parameter Parameters does not match the one defined when the command was created.
400 InvalidParameters.KeyMalformed The key in the parameter Parameters is not valid.
400 InvalidParameters.KeyEmpty The key in the parameter Parameters cannot be empty. The key in the parameter Parameters cannot be empty.
400 InvalidCommandContent.DecodeError The specified parameter CommandContent can not be Base64 decoded. Parameter CommandContent cannot be Base64 decoded.
400 InvalidClientToken.Malformed The specified parameter clientToken is not valid.
500 InternalError An error occurred when you dispatched the request. An error occurred while sending the request, please try again later.
403 InvalidInstanceId.OSTypeUnsupported The OS type of the instance corresponding to the parameter InstanceId does not support the specified command type.
403 InvalidOperation.RepeatModeUnsupported The operation is not supported for current repeat mode of invocation.
403 InvalidOperation.InvokeAlreadyFinished The operation is not supported for finished invocation. The operation is not supported for completed tasks.
403 InvalidOperation.CloudAssistantVersionUnsupported The operation is not supported for current CloudAssistant version of instance.
403 InvalidOperation.ModifyPublicCommandUnsupported Modification of the content of Public Command is not supported. Modifying the contents of public commands is not supported.
403 InvalidCommandContent.LengthLimitExceeded The length of the parameter CommandContent exceeds the limit of %s KB characters.
403 Operation.Forbidden The operation is not permitted. The operation is not supported.
403 InvalidParameters.CountLimitExceeded The count of the parameter Parameters exceeds the limit of 10. The number of parameter Parameters exceeds the limit of 10.
403 InvalidParameters.KeyLengthLimitExceeded The length of the key in the parameter Parameters exceeds the limit of 64 characters.
403 InvalidInstanceId.CountLimitExceeded The count of the parameter InstanceId exceeds the limit of %s.
403 CommandLimitExceeded The count of command in current region exceeds the limit of %s.
403 InvalidParameters.ValueTypeUnsupported The type of the value in the parameter Parameters is not supported. The type of the value Parameters the parameter is not supported.
403 IdempotentParameterMismatch The specified parameter has changed while using an already used clientToken.
403 IdempotentProcessing The previous idempotent request(s) is still processing. A previous idempotent request is being processed. Try again later.
404 InvalidInvokeId.NotFound The specified parameter InvokeId does not exist. The specified command execution ID does not exist.
404 InvalidInstanceId.NotFound The specified parameter InstanceId does not exist. The specified instance ID does not exist.
404 InvalidRegionId.NotFound The specified parameter RegionId does not exist.
404 InvalidCommandId.NotFound The specified CommandId does not exist.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.