apollo api调用初始化配置

5个月前 (12-07) 0 点赞 0 收藏 0 评论 8 已阅读

1、登录(apollo/admin 超管) 获取登录的Cookies,手动存起来

curl -u apollo:admin --X POST 'http://$apollo-portal:8070'

2、创建项目(目的: 生成默认的application和用户的App)

curl --location --request POST --X POST 'http://$apollo-portal:8070/apps' \
--header 'User-Agent: Apipost client Runtime/+https://www.apipost.cn/' \
--header 'Cookie: NG_TRANSLATE_LANG_KEY=zh-CN; JSESSIONID=BD705E7B2B7C61BF5277E6857421E5DE' \
--header 'Content-Type: application/json' \
--data '{
"appId": "tianzehao123",
"name": "tianzehao123",
"orgId": "TZH",
"orgName": "大数据与区块链研发中心",
"ownerName": "apollo",
"admins": []
}'

3、创建第三方应用(目的: 注册Apollo的开放平台,获得token)

curl --location --request POST --X POST 'http://$apollo-portal:8070/consumers' \
--header 'User-Agent: Apipost client Runtime/+https://www.apipost.cn/' \
--header 'Cookie: NG_TRANSLATE_LANG_KEY=zh-CN; JSESSIONID=B75B99ECEEFCBFF64D07FC6625295D59' \
--header 'Content-Type: application/json' \
--data '{
"appId": "tainzehao123",
"name": "tainzehao123",
"orgId": "TZH",
"orgName": "大数据与区块链研发中心",
"ownerName": "apollo"
}'

4、赋权 【Namespace级别权限包括: 修改、发布Namespace。应用级别权限包括: 创建Namespace、修改或发布应用下任何Namespace】(这里我们采用应用级别权限)Namespace级别权限:

curl --location --request POST --X POST 'http://$apollo-portal:8070/consumers/df7c0b67fb0ac60326080d97937c881a039560cc/assign-role?type=NamespaceRole' \
--header 'User-Agent: Apipost client Runtime/+https://www.apipost.cn/' \
--header 'Cookie: NG_TRANSLATE_LANG_KEY=zh-CN; JSESSIONID=B75B99ECEEFCBFF64D07FC6625295D59' \
--header 'Content-Type: application/json' \
--data '{
"appId": "tainzehao123",
"namespaceName": "application"
}'

5、项目配置

5.1、创建NameSpace
curl --location --request POST --X POST 'http://$apollo-portal:8070/openapi/v1/apps/tainzehao123/appnamespaces' \
--header 'User-Agent: Apipost client Runtime/+https://www.apipost.cn/' \
--header 'Authorization: df7c0b67fb0ac60326080d97937c881a039560cc' \
--header 'Content-Type: application/json' \
--data '{
"appId": "tainzehao123",
"name": "TZH.fc.sssoo",
"comment": "吞吞吐吐",
"isPublic": false,
"format": "properties",
"dataChangeCreatedBy":"apollo"
}'
5.2、关联namespace(目的: 使用公共配置) 使用cookie
curl --location --request POST --X POST 'http://$apollo-portal:8070/apps/tianzehao123/namespaces' \
--header 'User-Agent: Apipost client Runtime/+https://www.apipost.cn/' \
--header 'Cookie: NG_TRANSLATE_LANG_KEY=zh-CN; JSESSIONID=BD705E7B2B7C61BF5277E6857421E5DE' \
--header 'Content-Type: application/json' \
--data '[
    {
        "env": "PRO",
        "namespace": {
            "appId": "tianzehao123",
            "clusterName": "default",
            "namespaceName": "TZH.TZH.fc.sssoo"
            }
        }
]'
5.3、新增配置接口
curl --location --request POST --X POST 'http://$apollo-portal:8070/openapi/v1/envs/PRO/apps/tainzehao123/clusters/default/namespaces/TZH.fc.sssoo/items' \
--header 'User-Agent: Apipost client Runtime/+https://www.apipost.cn/' \
--header 'Authorization: 7c3a748be5087b86795ecbe92f914bd3a2567683' \
--header 'Content-Type: application/json' \
--data '{
"key": "env11",
"value": "sit11",
"comment": "huanjing",
"dataChangeCreatedBy": "apollo"
}'
5.4、修改配置
curl --location --request PUT --X PUT 'http://$apollo-portal:8070/openapi/v1/envs/PRO/apps/inc-bst-sdp-exet-external/clusters/default/namespaces/TZH.TZH.fc.sssoo/items/asd' \
--header 'User-Agent: Apipost client Runtime/+https://www.apipost.cn/' \
--header 'Authorization: df7c0b67fb0ac60326080d97937c881a039560cc' \
--header 'Content-Type: application/json' \
--data '{
"key": "asd",
"value": "sit12",
"comment": "huanjing",
"dataChangeLastModifiedBy": "apollo",
"dataChangeCreatedBy": "apollo"
}'
5.4、发布配置接口
curl --location --request POST --X POST 'http://$apollo-portal:8070/openapi/v1/envs/PRO/apps/tainzehao123/clusters/default/namespaces/TZH.fc.sssoo/releases' \
--header 'User-Agent: Apipost client Runtime/+https://www.apipost.cn/' \
--header 'Authorization: df7c0b67fb0ac60326080d97937c881a039560cc' \
--header 'Content-Type: application/json' \
--data '{
"releaseTitle": "20220518174157-release",
"releaseComment": "发布",
"releasedBy": "apollo"
}'

6、sql删除project

    delete from ApolloConfigDB.App where AppId="asd-ctrl" or AppId="asd-authcenter" or AppId="asd-center";

    delete from ApolloConfigDB.AppNamespace where AppId="asd-ctrl" or AppId="asd-authcenter" or AppId="asd-center";

    delete from ApolloConfigDB.Namespace where AppId="asd-ctrl" or AppId="asd-authcenter" or AppId="asd-center";

    delete from ApolloConfigDB.Cluster where AppId="asd-ctrl" or AppId="asd-authcenter" or AppId="asd-center";

    delete from ApolloPortalDB.App where AppId="asd-ctrl" or AppId="asd-authcenter" or AppId="asd-center";

    delete from ApolloPortalDB.AppNamespace where AppId="asd-ctrl" or AppId="asd-authcenter" or AppId="asd-center";


apollo api调用初始化配置

本文收录在
0评论

登录

忘记密码 ?

切换登录

注册