应用运维管理 AOM-创建任务:请求示例

时间:2023-11-24 09:53:28

请求示例

  • 使用任务名称为"xxx"、模板名称为"CMS::ECS::BulkyStartECSInstances"、输入参数为"input"来创建启动ECS任务。

    https://{Endpoint}/v1/{project_id}/cms/workflow
    
    {
      "name" : "xxx",
      "template_name" : "CMS::ECS::BulkyStartECSInstances",
      "template_id" : "CMS::ECS::BulkyStartECSInstances",
      "tags" : { },
      "input" : {
        "get_instances" : {
          "type" : "manual",
          "group" : "ecs_instance",
          "ecs_id_list" : "[\"xxx\"]",
          "ecs_instance_status" : null,
          "ecs_instance_tags" : null,
          "ecs_instance_enterprise_project_id" : null,
          "vpc_id" : null,
          "subnet_id" : null,
          "frontend_info" : null,
          "selectedData" : null
        },
        "rate_control" : {
          "max" : "1",
          "timeDelay" : "10",
          "group" : "rate_control"
        },
        "approve" : {
          "need_approve" : "false",
          "topic_selected" : null,
          "group" : "approve"
        },
        "project_id" : "xxx",
        "region_id" : "cn-north-7"
      },
      "type" : "manual",
      "description" : "",
      "task_type" : "cloud"
    }
  • 使用任务名称为"xxx"、模板名称为"CMS::ECS::BulkyRunScript"、输入参数为"input"来创建定时执行脚本任务。

    https://{Endpoint}/v1/{project_id}/cms/workflow
    
    {
      "name" : "xxxxxshced",
      "template_name" : "CMS::ECS::BulkyRunScript",
      "tags" : { },
      "input" : {
        "project_id" : "2xxx487fxxxxxbffc1cf",
        "region_id" : "cn-north-7",
        "trigger" : {
          "scheduled_time" : "00:04:05",
          "time_zone" : "Asia/Riyadh",
          "policy" : "periodic",
          "cron" : null,
          "period" : "[\"0\",\"3\",\"4\",\"5\",\"6\"]",
          "group" : "trigger"
        },
        "notice" : {
          "interval" : null,
          "before_notice" : null,
          "succeed_notice" : null,
          "fail_notice" : null,
          "group" : "notice",
          "before_topic_selected" : null,
          "success_topic_selected" : null,
          "fail_topic_selected" : null
        },
        "get_instances" : {
          "type" : "manual",
          "group" : "ecs_instance",
          "ecs_id_list" : "[\"4bxxxxx-xxxx-4c92-xxxx-19469d40a51c\"]",
          "ecs_instance_status" : null,
          "ecs_instance_tags" : null,
          "ecs_instance_enterprise_project_id" : null,
          "vpc_id" : null,
          "subnet_id" : null,
          "frontend_info" : null,
          "selectedData" : null
        },
        "approve" : {
          "need_approve" : "false",
          "topic_selected" : null,
          "group" : "approve"
        },
        "rate_control" : {
          "max" : "0",
          "timeDelay" : "0",
          "group" : "rate_control"
        },
        "script_param" : {
          "name" : "zzy",
          "script_content" : "cd /xxx/xxx",
          "script_type" : "SHELL",
          "version_number" : "1.0",
          "cmd_user" : "xxxxx",
          "script_id" : "xxxx-7e9e-4eed-8xxf-5f1fxx6ebb7d",
          "scriptSelected" : "null",
          "script_args" : null,
          "sensitive_param" : false,
          "time_out" : "7200",
          "script_version_id" : "e005xxx4-1fcf-40xx-b1x6-8dxxxcae7b021",
          "sourceId" : "script",
          "group" : "script"
        }
      },
      "type" : "cron",
      "description" : "",
      "task_type" : "script",
      "template_id" : "CMS::ECS::BulkyRunScript"
    }
  • 使用任务名称为"xxx"、模板名称为"CMS::ECS::BulkyRunScript"、输入参数为"input"来创建执行脚本任务。

    https://{Endpoint}/v1/{project_id}/cms/workflow
    
    {
      "name" : "execute_task_demo",
      "template_name" : "CMS::ECS::BulkyRunScript",
      "template_id" : "CMS::ECS::BulkyRunScript",
      "tags" : { },
      "input" : {
        "script_param" : {
          "script_content" : "date",
          "script_type" : "SHELL",
          "version_number" : "1.0",
          "cmd_user" : "root",
          "script_id" : "6xxxx097-a4x4-4dxx-axa2-fef5xxxxdd55",
          "scriptSelected" : "null",
          "script_args" : "arg1 agr2",
          "sensitive_param" : "false",
          "time_out" : "7200",
          "script_version_id" : "47xxxd67-bxx5-45x9-860x-cb3d6xxxx745",
          "sourceId" : "script",
          "group" : "script"
        },
        "get_instances" : {
          "ecs_id_list" : "[\"4380xxx9-33xf-4xxe-axxx-7xxxxxx3fcd\"]",
          "type" : "manual",
          "group" : "ecs_instance",
          "vpc_id" : null,
          "subnet_id" : null
        },
        "approve" : {
          "need_approve" : "false",
          "topic_selected" : null,
          "group" : "approve"
        },
        "rate_control" : {
          "max" : "0",
          "timeDelay" : "0",
          "group" : "rate_control"
        },
        "project_id" : "2xxxxxxca5xx8373xxx1bffxxcf",
        "region_id" : "cn-north-7"
      },
      "type" : "manual",
      "description" : "",
      "task_type" : "script"
    }
  • 使用任务名称为"xxx"、模板名称为"CMS::RDS::RestartRDSInstance、输入参数为"input"来创建重启RDS任务。

    https://{Endpoint}/v1/{project_id}/cms/workflow
    
    {
      "name" : "xxx",
      "template_name" : "CMS::RDS::RestartRDSInstance",
      "template_id" : "CMS::RDS::RestartRDSInstance",
      "tags" : { },
      "input" : {
        "get_instances" : {
          "type" : "manual",
          "group" : "rds_instance",
          "rds_id_list" : "[\"xxx\"]",
          "rds_instance_tags" : null,
          "rds_instance_type" : null,
          "rds_instance_datastore_type" : null,
          "frontend_info" : null,
          "selectedData" : null
        },
        "rate_control" : {
          "max" : "0",
          "timeDelay" : "0",
          "group" : "rate_control"
        },
        "approve" : {
          "need_approve" : "false",
          "topic_selected" : null,
          "group" : "approve"
        },
        "project_id" : "xxx",
        "region_id" : "cn-north-7"
      },
      "type" : "manual",
      "description" : "",
      "task_type" : "cloud"
    }
  • 使用任务名称为"xxx"、模板名称为"CMS::ECS::Package"、输入参数为"input"来创建快速分发文件任务。

    https://{Endpoint}/v1/{project_id}/cms/workflow
    
    {
      "name" : "xxx",
      "template_name" : "CMS::ECS::Package",
      "template_id" : "CMS::ECS::Package",
      "tags" : { },
      "input" : {
        "project_id" : "xxx",
        "region_id" : "cn-north-7",
        "package" : {
          "package_version_id" : "xxx",
          "package_basic_id" : "xxx",
          "cmd_user" : "xxxxx",
          "install_file_dir" : "/",
          "package_name" : "77779956",
          "version_number" : "110",
          "operate_type" : "install",
          "group" : "package",
          "software_list" : "[{x}]",
          "time_out" : "7200",
          "pre_install_script" : "",
          "install_script" : "ls",
          "un_install_script" : "",
          "plat_form" : "Linux"
        },
        "get_instances" : {
          "type" : "manual",
          "group" : "ecs_instance",
          "ecs_id_list" : "[\"xxx\"]",
          "ecs_instance_status" : null,
          "ecs_instance_tags" : null,
          "ecs_instance_enterprise_project_id" : null,
          "vpc_id" : null,
          "subnet_id" : null,
          "frontend_info" : null,
          "selectedData" : null
        },
        "rate_control" : {
          "max" : "0",
          "timeDelay" : "0",
          "group" : "rate_control"
        },
        "approve" : {
          "need_approve" : "false",
          "topic_selected" : null,
          "group" : "approve"
        }
      },
      "type" : "manual",
      "description" : "",
      "task_type" : "package"
    }
  • 使用任务名称为"xxx"、模板名称为"CMS::ECS::BulkyStopECSInstances"、输入参数为"input"来创建关闭ECS任务。

    https://{Endpoint}/v1/{project_id}/cms/workflow
    
    {
      "name" : "xxx",
      "template_name" : "CMS::ECS::BulkyStopECSInstances",
      "template_id" : "CMS::ECS::BulkyStopECSInstances",
      "tags" : { },
      "input" : {
        "get_instances" : {
          "type" : "manual",
          "group" : "ecs_instance",
          "ecs_id_list" : "[\"xxx\"]",
          "ecs_instance_status" : null,
          "ecs_instance_tags" : null,
          "ecs_instance_enterprise_project_id" : null,
          "vpc_id" : null,
          "subnet_id" : null,
          "frontend_info" : null,
          "selectedData" : null
        },
        "stop_ecs_type" : {
          "group" : "stop_ecs_type",
          "stop_ecs_type" : "SOFT"
        },
        "rate_control" : {
          "max" : "0",
          "timeDelay" : "0",
          "group" : "rate_control"
        },
        "approve" : {
          "need_approve" : "false",
          "topic_selected" : null,
          "group" : "approve"
        },
        "project_id" : "xxx",
        "region_id" : "cn-north-7"
      },
      "type" : "manual",
      "description" : "",
      "task_type" : "cloud"
    }
  • 使用任务名称为"xxx"、模板名称为"CMS::ECS::BulkyCleanDisks"、输入参数为"input"来创建清理磁盘任务。

    https://{Endpoint}/v1/{project_id}/cms/workflow
    
    {
      "name" : "xxx",
      "template_name" : "CMS::ECS::BulkyCleanDisks",
      "template_id" : "CMS::ECS::BulkyCleanDisks",
      "tags" : { },
      "input" : {
        "get_instances" : {
          "type" : "manual",
          "group" : "ecs_instance",
          "ecs_id_list" : "[\"xxx\"]",
          "ecs_instance_status" : null,
          "ecs_instance_tags" : null,
          "ecs_instance_enterprise_project_id" : null,
          "vpc_id" : null,
          "subnet_id" : null,
          "frontend_info" : null,
          "selectedData" : null
        },
        "clean_disk" : {
          "path" : "[{\"path\":\"/xxx/\",\"fileName\":\"xxxx.xx\",\"date\":\"1\"}]",
          "group" : "clean_disk",
          "platform" : "linux"
        },
        "rate_control" : {
          "max" : "0",
          "timeDelay" : "0",
          "group" : "rate_control"
        },
        "approve" : {
          "need_approve" : "false",
          "topic_selected" : null,
          "group" : "approve"
        },
        "project_id" : "xxxxx",
        "region_id" : "cn-north-7"
      },
      "type" : "manual",
      "description" : "",
      "task_type" : "cloud"
    }
  • 使用任务名称为"xxx"、模板名称为"CMS::ECS::BulkyChangeECSPassword"、输入参数为"input"来创建修改ECS密码任务。

    https://{Endpoint}/v1/{project_id}/cms/workflow
    
    {
      "name" : "xxxxx",
      "template_name" : "CMS::ECS::BulkyChangeECSPassword",
      "template_id" : "CMS::ECS::BulkyChangeECSPassword",
      "tags" : { },
      "input" : {
        "get_instances" : {
          "type" : "manual",
          "group" : "ecs_instance",
          "ecs_id_list" : "[\"xxxxx\"]",
          "ecs_instance_status" : null,
          "ecs_instance_tags" : null,
          "ecs_instance_enterprise_project_id" : null,
          "vpc_id" : null,
          "subnet_id" : null,
          "frontend_info" : null,
          "selectedData" : null
        },
        "user_password" : {
          "username" : "xxx",
          "password" : "xxxxx",
          "group" : "user_password"
        },
        "rate_control" : {
          "max" : "0",
          "timeDelay" : "0",
          "group" : "rate_control"
        },
        "approve" : {
          "need_approve" : "false",
          "topic_selected" : null,
          "group" : "approve"
        },
        "project_id" : "xxxxx",
        "region_id" : "cn-north-7"
      },
      "type" : "manual",
      "description" : "",
      "task_type" : "cloud"
    }
  • 使用任务名称为"xxx"、模板名称为"job_1"、输入参数为"input"来创建作业任务。

    https://{Endpoint}/v1/{project_id}/cms/workflow
    
    {
      "name" : "xxx",
      "template_name" : "job_1",
      "template_id" : "xxx",
      "tags" : { },
      "input" : {
        "project_id" : "xxx",
        "region_id" : "cn-north-7",
        "isExist" : "false",
        "rate_control" : {
          "max" : "0",
          "timeDelay" : "0",
          "group" : "rate_control"
        },
        "approve" : {
          "need_approve" : "false",
          "topic_selected" : null,
          "reviewer_selected" : null,
          "group" : "approve"
        }
      },
      "type" : "manual",
      "description" : "",
      "task_type" : "job"
    }
  • 使用任务名称为"xxx"、模板名称为"CMS::CCE::RestartWorkloadInstance"、输入参数为"input"来创建重启工作负载任务。

    https://{Endpoint}/v1/{project_id}/cms/workflow
    
    {
      "name" : "xxx",
      "template_name" : "CMS::CCE::RestartWorkloadInstance",
      "template_id" : "CMS::CCE::RestartWorkloadInstance",
      "tags" : { },
      "input" : {
        "get_instances" : {
          "type" : "manual",
          "group" : "cce_workload_instance",
          "cce_workload_id_list" : "[\"xxx\"]",
          "cce_workload_type" : "deployments",
          "cce_workload_cluster" : "xxx",
          "cce_workload_namespace" : null,
          "frontend_info" : null,
          "selectedData" : null
        },
        "cce_workload_restart_info" : {
          "group" : "cce_workload_restart_info",
          "time_interval" : "300"
        },
        "rate_control" : {
          "max" : "2",
          "timeDelay" : "2",
          "group" : "rate_control"
        },
        "approve" : {
          "need_approve" : "false",
          "topic_selected" : null,
          "group" : "approve"
        },
        "project_id" : "xxx",
        "region_id" : "cn-north-7"
      },
      "type" : "manual",
      "description" : "",
      "task_type" : "cloud"
    }
support.huaweicloud.com/api-aom/CreateWorkflow.html