应用管理与运维平台 ServiceStage应用管理与运维平台 ServiceStage

更新时间:2021/06/25 GMT+08:00
分享

应用管理

场景描述

本章节指导用户通过API实现应用管理。API的调用方法请参见如何调用API

流程介绍

  1. 创建应用
  2. 为应用添加环境变量
  3. 查询应用

前提条件

  • 获取IAM的token,调用Token认证,并将token值设置为环境变量:export Token={token}。
  • 获取ServiceStage的endpoint,参考地区和终端节点,以下示例中以{servicestage_endpoint}代替。

操作步骤

  1. 创建应用。调用创建应用接口,请求示例如下。

    curl -k -H "Content-Type:application/json" -H "X-Auth-Token:$Token" -X POST "https://{servicestage_endpoint}/v2/{project_id}/cas/applications" -d '{
        "name": "TestApp", 
        "description": "application_description", 
        "enterprise_project_id": "0"
    }'

    返回结果:

    {
        "id": "06cf2fda-af45-44b4-9e22-6294c4804515", 
        "name": "TestApp", 
        "description": "application_description", 
        "creator": "string", 
        "project_id": "bf8523d898b64e4eb956e3be3555ca16", 
        "enterprise_project_id": "0", 
        "create_time": 1578984171041, 
        "update_time": 1578984171041
    }

    得到的id,后续示例中以{application_id}代替。

  2. 为应用添加环境变量,后续在该应用某环境下部署的组件都会继承该应用的环境变量。调用修改应用配置信息接口。请求示例如下。

    curl -k -H "Content-Type:application/json" -H "X-Auth-Token:$Token" -X PUT  "https://{servicestage_endpoint}/v2/{project_id}/cas/applications/{application_id}/configuration" -d '{
        "environment_id": "0fa75dfe-0d32-4bc1-848b-8008cf3f2567", 
        "configuration": {
            "env": [
                {
                    "name": "app-env", 
                    "value": "env"
                }
            ]
        }
    }'
    返回结果:
    {
        "application_id": "06cf2fda-af45-44b4-9e22-6294c4804515", 
        "environment_id": "0fa75dfe-0d32-4bc1-848b-8008cf3f2567", 
        "configuration": {
            "env": [
                {
                    "name": "app-env", 
                    "value": "env"
                }
            ]
        }
    }

  3. 根据应用ID查询应用详细信息。调用根据应用ID获取应用详细信息接口,去查询应用信息。请求示例如下。

    curl -k -H "Content-Type:application/json" -H "X-Auth-Token:$Token" -X GET "https://{servicestage_endpoint}/v2/{project_id}/cas/applications/{application_id}"

    返回结果:

    {
        "id": "06cf2fda-af45-44b4-9e22-6294c4804515", 
        "name": "TestApp", 
        "description": "description", 
        "creator": "xxx", 
        "project_id": "bf8523d898b64e4eb956e3be3555ca16", 
        "enterprise_project_id": "0", 
        "create_time": 1578984171041, 
        "update_time": 1578984171041
    }

分享:

    相关文档

    相关产品