Todos os produtos
Search
Central de documentação

CloudOps Orchestration Service:ACS::ExecuteAPI

Última atualização: Jun 28, 2026

Descrição

Use a ação ACS::ExecuteAPI para chamar uma operação de API de um serviço em nuvem, como o Elastic Compute Service (ECS). Se a chamada for assíncrona, use a ação ACS::WaitFor para aguardar até que o recurso especificado atinja o estado esperado.

Sintaxe

Nota

O atributo Tasks.Properties.API define a operação de API a ser chamada. Portanto, não especifique a operação novamente no atributo Tasks.Properties.Parameters.

Operações de API RPC

Tasks:
  - Name: executeAPITaskExample
    Action: ACS::ExecuteAPI
    Properties:
      Service: ECS # Required. The Alibaba Cloud Resource Name (ARN) of the cloud service in Resource Access Management (RAM). The name is not case-sensitive, such as ECS, RDS, or FC.
      API: DescribeInstances # Required. The name of an API operation of the cloud service. The name is not case-sensitive, such as DescribeInstances.
      AutoPaging: false # Optional. Specifies whether to automatically go through pages to obtain all results for API operations that return results on different pages. Default value: true.
      Parameters:  # The parameters that are required for calling the API operation. For more information, see the relevant documentation.
        Parameter1: Value1
        Parameter2: Value2
    Outputs: 
      OutputParameter1: 
        ValueSelector: 'jq selector' # The jQuery selector for selecting the data to return. The jQuery selector extracts information from the JSON data returned by the API operation. For more information about the jQuery syntax, visit https://stedolan.github.io/jq/.
        Type: String/Boolean/List(Array)/Number/Object
{
  "Tasks": [
    {
      "Name": "executeAPITaskExample",
      "Action": "ACS::ExecuteAPI",
      "Properties": {
        "Service": "ECS",
        "API": "DescribeInstances",
        "AutoPaging": false,
        "Parameters": {
          "Parameter1": "Value1",
          "Parameter2": "Value2"
        }
      },
      "Outputs": {
        "OutputParameter1": {
          "ValueSelector": "jq selector",
          "Type": "String/Boolean/List(Array)/Number/Object"
        }
      }
    }
  ]
}

Operações de API ROA

Tasks:
  - Name: executeAPITaskExample2
    Action: ACS::ExecuteAPI
    Properties:
      Service: OSS # Required. The ARN of the cloud service in RAM. The name is not case-sensitive, such as OSS, ECS, RDS, or FC.
      API: PutBucket # Required. The name of an API operation of the cloud service. The name is not case-sensitive, such as PutBucket. 
      Method: PUT  # Required. The HTTP request method of the API operation. 
      URI: ''  # The Uniform Resource Identifier (URI) that is used by the API operation. 
      Headers: # Optional. The request headers of the API operation. Specify this attribute in the following format: 
        requestHeader1: 'requestHeader1Value'
      Parameters: # Optional. The common parameters of the API operation. 
        commonParameter1: 'commonParameter1Value'
        commonParameter2: 'commonParameter2Value'
        # Optional. The request body of the API operation. Specify this attribute in the XML format. 
      Body: |
        <?xml version="1.0" encoding="UTF-8"?> <supKey1> <parameter1> Value1
        </parameter1> <parameter2> Value2 </parameter2> </supKey1>
{
  "Tasks": [
    {
      "Name": "executeAPITaskExample2",
      "Action": "ACS::ExecuteAPI",
      "Properties": {
        "Service": "OSS",
        "API": "PutBucket",
        "Method": "PUT",
        "URI": "",
        "Headers": {
          "requestHeader1": "requestHeader1Value"
        },
        "Parameters": {
          "commonParameter1": "commonParameter1Value",
          "commonParameter2": "commonParameter2Value"
        },
        "Body": "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <supKey1> <parameter1> Value1\n</parameter1> <parameter2> Value2 </parameter2> </supKey1>\n"
      }
    }
  ]
}

Exemplos

Chamar a operação DescribeInstances do ECS no estilo RPC

FormatVersion: OOS-2019-06-01
Description: Views the ECS instances by specifying instance status.
Parameters:
  status:
    Description: The ECS instances status for query instances.
    Type: String
Tasks:
  - Name: describeInstances
    Action: ACS::ExecuteAPI
    Description: Views the ECS instances by specifying instance status.
    Properties:
      Service: ECS
      API: DescribeInstances
      Parameters:
        Status: '{{ status }}'
  Outputs:
    instanceIds:
      Type: List
      ValueSelector: Instances.Instance[].InstanceId
Outputs:
  instanceIds:
    Type: List
    Value: '{{ describeInstances.instanceIds }}'
{
  "FormatVersion": "OOS-2019-06-01",
  "Description": "Views the ECS instances by specifying instance status.",
  "Parameters": {
    "status": {
      "Description": "The ECS instances status for query instances.",
      "Type": "String"
    }
  },
  "Tasks": [
    {
      "Name": "describeInstances",
      "Action": "ACS::ExecuteAPI",
      "Description": "Views the ECS instances by specifying instance status.",
      "Properties": {
        "Service": "ECS",
        "API": "DescribeInstances",
        "Parameters": {
          "Status": "{{ status }}"
        }
      },
      "Outputs": {
        "instanceIds": {
          "Type": "List",
          "ValueSelector": "Instances.Instance[].InstanceId"
        }
      }
    }
  ],
  "Outputs": {
    "instanceIds": {
      "Type": "List",
      "Value": "{{ describeInstances.instanceIds }}"
    }
  }
}

Chamar a operação PutBucket do Object Storage Service (OSS) no estilo ROA

FormatVersion: OOS-2019-06-01
Description:
  en: Create multiple buckets in different region at the same time.
   
Parameters:
  Regions:
    Description:
      en: The region id..
       
    Type: List
  BucketName:
    Description:
      en: The bucket name.
       
    Type: String
  DataRedundancyType:
    Description:
      en: Specifies the data disaster tolerance type of the bucket.
       
    Type: String
    AllowedValues:
      - LRS
      - ZRS
  StorageClass:
    Description:
      en: Specify the bucket storage type.
       
    Type: String
    AllowedValues:
      - Standard
      - IA
      - Archive
  XOssAcl:
    Description:
      en: Specify bucket access rights.
       
    Type: String
    AllowedValues:
      - public-read-write
      - public-read
      - private
  RateControl:
    Description:
      en: Concurrency ratio of task execution.
       
    Type: Json
    AssociationProperty: RateControl
  OOSAssumeRole:
    Description: The RAM role to be assumed by OOS.
    Type: String
    Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: PutBucket
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Create buckets in different regions.
       
    Properties:
      Service: OSS
      API: PutBucket
      Method: PUT
      URI: ''
      Headers:
        x-oss-acl: '{{ XOssAcl }}'
      Parameters:
        BucketName: '{{ BucketName }}-{{ACS::TaskLoopItem}}'
        RegionId: '{{ACS::TaskLoopItem}}'
      Body: |
        <?xml version="1.0" encoding="UTF-8"?>
        <CreateBucketConfiguration>
          <StorageClass>{{ StorageClass }}</StorageClass>
          <DataRedundancyType>{{ DataRedundancyType }}</DataRedundancyType>
        </CreateBucketConfiguration>
    Loop:
      Items: '{{ Regions }}'
      RateControl: '{{ RateControl }}'
      Outputs:
        imageIds:
          AggregateType: 'Fn::ListJoin'
          AggregateField: imageIds
    Outputs:
      imageIds:
        Type: String
        ValueSelector: .
{
  "FormatVersion": "OOS-2019-06-01",
  "Description": {
    "en": "Create multiple buckets in different region at the same time.",
     
  },
  "Parameters": {
    "Regions": {
      "Description": {
        "en": "The region id..",
         
      },
      "Type": "List"
    },
    "BucketName": {
      "Description": {
        "en": "The bucket name.",
         
      },
      "Type": "String"
    },
    "DataRedundancyType": {
      "Description": {
        "en": "Specifies the data disaster tolerance type of the bucket.",
         
      },
      "Type": "String",
      "AllowedValues": [
        "LRS",
        "ZRS"
      ]
    },
    "StorageClass": {
      "Description": {
        "en": "Specify the bucket storage type.",
         
      },
      "Type": "String",
      "AllowedValues": [
        "Standard",
        "IA",
        "Archive"
      ]
    },
    "XOssAcl": {
      "Description": {
        "en": "Specify bucket access rights.",
         
      },
      "Type": "String",
      "AllowedValues": [
        "public-read-write",
        "public-read",
        "private"
      ]
    },
    "RateControl": {
      "Description": {
        "en": "Concurrency ratio of task execution.",
         
      },
      "Type": "Json",
      "AssociationProperty": "RateControl"
    },
    "OOSAssumeRole": {
      "Description": "The RAM role to be assumed by OOS.",
      "Type": "String",
      "Default": "OOSServiceRole"
    }
  },
  "RamRole": "{{ OOSAssumeRole }}",
  "Tasks": [
    {
      "Name": "PutBucket",
      "Action": "ACS::ExecuteAPI",
      "Description": {
        "en": "Create buckets in different regions.",
         
      },
      "Properties": {
        "Service": "OSS",
        "API": "PutBucket",
        "Method": "PUT",
        "URI": "",
        "Headers": {
          "x-oss-acl": "{{ XOssAcl }}"
        },
        "Parameters": {
          "BucketName": "{{ BucketName }}-{{ACS::TaskLoopItem}}",
          "RegionId": "{{ACS::TaskLoopItem}}"
        },
        "Body": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<CreateBucketConfiguration>\n  <StorageClass>{{ StorageClass }}</StorageClass>\n  <DataRedundancyType>{{ DataRedundancyType }}</DataRedundancyType>\n</CreateBucketConfiguration>\n"
      },
      "Loop": {
        "Items": "{{ Regions }}",
        "RateControl": "{{ RateControl }}",
        "Outputs": {
          "imageIds": {
            "AggregateType": "Fn::ListJoin",
            "AggregateField": "imageIds"
          }
        }
      },
      "Outputs": {
        "imageIds": {
          "Type": "String",
          "ValueSelector": "."
        }
      }
    }
  ]
}

Chamar a operação PutLogs do Simple Log Service no estilo ROA

FormatVersion: OOS-2019-06-01
Description:
  en: Perform a single ExecuteApi operation.
   
  name-en: ACS-OOS-ExampleExecuteECSDescribeRegions
   
  categories:
    - ops
Parameters:
  regionId:
    Type: String
    AssociationProperty: RegionId
    Description: The ID of the region.
  projectName:
    Type: String
    Description: The name of the project.
  logstoreName:
    Type: String
    Description: The name of the Logstore.
  Contents:
    Type: String
    Description: The content of the logs.
    AssociationProperty: Json
    Default:
      - log1: value1
      - log2: value2
  Tags:
    Type: String
    Description: The tags that are added to the logs.
    AssociationProperty: Json
    Default: []
Tasks:
  - Name: SlsPutLogs
    Action: ACS::ExecuteApi
    Description: Ships logs to Simple Log Service.
    Properties:
      Service: log
      API: PutLogs
      URI: /logstores/{{ logstoreName }}/shards/lb
      Method: POST
      Parameters:
        RegionId: '{{ regionId }}'
        projectName: '{{ projectName }}'
        Logs:
          Contents: '{{ Contents }}'
        Tags: '{{ Tags }}'
{
  "FormatVersion": "OOS-2019-06-01",
  "Description": {
    "en": "Perform a single ExecuteApi operation.",
     
    "name-en": "ACS-OOS-ExampleExecuteECSDescribeRegions",
     
    "categories": [
      "ops"
    ]
  },
  "Parameters": {
    "regionId": {
      "Type": "String",
      "AssociationProperty": "RegionId",
      "Description": "The ID of the region"
    },
    "projectName": {
      "Type": "String",
      "Description": "The name of the project"
    },
    "logstoreName": {
      "Type": "String",
      "Description": "The name of the Logstore"
    },
    "Contents": {
      "Type": "String",
      "Description": "The content of the logs",
      "AssociationProperty": "Json",
      "Default": [
        {
          "log1": "value1"
        },
        {
          "log2": "value2"
        }
      ]
    },
    "Tags": {
      "Type": "String",
      "Description": "The tags that are added to the logs",
      "AssociationProperty": "Json",
      "Default": []
    }
  },
  "Tasks": [
    {
      "Name": "SlsPutLogs",
      "Action": "ACS::ExecuteApi",
      "Description": "Ships logs to Simple Log Service",
      "Properties": {
        "Service": "log",
        "API": "PutLogs",
        "URI": "/logstores/{{ logstoreName }}/shards/lb",
        "Method": "POST",
        "Parameters": {
          "RegionId": "{{ regionId }}",
          "projectName": "{{ projectName }}",
          "Logs": {
            "Contents": "{{ Contents }}"
          },
          "Tags": "{{ Tags }}"
        }
      }
    }
  ]
}

Apêndice: Configurações de paginação automática

  • O OOS oferece suporte à paginação automática para operações OpenAPI compatíveis com esse recurso. Configure a paginação automática especificando AutoPaging. Por padrão, a paginação automática está habilitada.

  • Defina o número de entradas por página conforme necessário.

  • Se a operação aceitar tanto (NextToken, MaxResults) quanto (PageNumber, PageSize), prefira usar (NextToken, MaxResults).

Modelo de exemplo: Configurações de paginação para DescribeInstances do ECS

FormatVersion: OOS-2019-06-01
Description: Runs one operation
Tasks:
  - Name: ExecuteApi
    Action: ACS::ExecuteApi
    Description:
      en: Perform a single ExecuteApi operation.
      zh-cn: the description in Chinese
    Properties:
      Service: ecs
      API: DescribeInstances
      Parameters:
        RegionId: cn-hangzhou
        MaxResults: 50 # The maximum number of entries per page
{
  "FormatVersion": "OOS-2019-06-01",
  "Description": "Runs one operation",
  "Tasks": [
    {
      "Name": "ExecuteApi",
      "Action": "ACS::ExecuteApi",
      "Description": {
        "en": "Perform a single ExecuteApi operation.",
        "zh-cn": "the description in Chinese"
      },
      "Properties": {
        "Service": "ecs",
        "API": "DescribeInstances",
        "Parameters": {
          "RegionId": "cn-hangzhou",
          "MaxResults": 50
        }
      }
    }
  ]
}