operationGrayReleasePlan.md 5.59 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
运维中心 /getGrayReleasePlan

# operation.getGrayReleasePlan

> 本接口应在服务器端调用,详细说明参见[服务端API](https://developers.weixin.qq.com/miniprogram/dev/framework/server-ability/backend-api.html)。

> 本接口支持[云调用](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/openapi/openapi.html)。需开发者工具版本 >= `1.02.1904090`(最新[稳定版下载](https://developers.weixin.qq.com/miniprogram/dev/devtools/stable.html)),`wx-server-sdk` >= `0.4.0`

查询当前分阶段发布详情

调用方式:

- [HTTPS 调用](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/operation/operation.getGrayReleasePlan.html#method-http)
- [云调用](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/operation/operation.getGrayReleasePlan.html#method-cloud)



## HTTPS 调用

### 请求地址

```text
GET https://api.weixin.qq.com/wxa/getgrayreleaseplan?access_token=ACCESS_TOKEN
```

### 请求参数

| 属性                                  | 类型   | 默认值 | 必填 | 说明                                                         |
| :------------------------------------ | :----- | :----- | :--- | :----------------------------------------------------------- |
| access_token / cloudbase_access_token | string |        | 是   | [接口调用凭证](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/access-token/auth.getAccessToken.html) |

### 返回值

### Object

| 属性              | 类型   | 说明               |
| :---------------- | :----- | :----------------- |
| errcode           | number | 错误码             |
| errmsg            | number | 错误信息           |
| gray_release_plan | Object | 分阶段发布计划详情 |

**errcode 的合法值**

| 值         | 说明             | 最低版本 |
| :--------- | :--------------- | :------- |
| 0          | 成功             |          |
| -1         | 系统失败         |          |
| 其他错误码 | 请查看全局错误码 |          |

**gray_release_plan 的结构**

| 属性                     | 类型   | 说明                                             |
| :----------------------- | :----- | :----------------------------------------------- |
| status                   | number | 0:初始状态 1:执行中 2:暂停中 3:执行完毕 4:被删除 |
| create_timestamp         | number | 分阶段发布计划的创建事件                         |
| gray_percentage          | number | 当前的灰度比例                                   |
| default_finish_timestamp | number | 预计全量时间                                     |

该接口用于查询当前分阶段发布详情。

### 返回示例

```json
{
  "errcode": 0,
  "errmsg": "ok",
  "gray_release_plan": {
     "status": 1,
     "create_timestamp": 1517553721,
     "default_finish_timestamp": 1517554721,
     "gray_percentage": 8
  }
}
```



## 云调用

> [云调用](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/openapi/openapi.html)是微信云开发提供的在云函数中调用微信开放接口的能力,需要在云函数中通过 `wx-server-sdk` 使用。

### 接口方法

```js
openapi.operation.getGrayReleasePlan
```

> 需在 `config.json` 中配置 `operation.getGrayReleasePlan` API 的权限,[详情](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/openapi/openapi.html#usage-3)

### 返回值

### Object

| 属性            | 类型   | 说明               |
| :-------------- | :----- | :----------------- |
| errCode         | number | 错误码             |
| errMsg          | number | 错误信息           |
| grayReleasePlan | Object | 分阶段发布计划详情 |

**errCode 的合法值**

| 值   | 说明 | 最低版本 |
| :--- | :--- | :------- |
| 0    | 成功 |          |

**grayReleasePlan 的结构**

| 属性                   | 类型   | 说明                                             |
| :--------------------- | :----- | :----------------------------------------------- |
| status                 | number | 0:初始状态 1:执行中 2:暂停中 3:执行完毕 4:被删除 |
| createTimestamp        | number | 分阶段发布计划的创建事件                         |
| grayPercentage         | number | 当前的灰度比例                                   |
| defaultFinishTimestamp | number | 预计全量时间                                     |

### 异常

### Object

抛出的异常

| 属性    | 类型   | 说明     |
| :------ | :----- | :------- |
| errCode | number | 错误码   |
| errMsg  | number | 错误信息 |

**errCode 的合法值**

| 值         | 说明             | 最低版本 |
| :--------- | :--------------- | :------- |
| -1         | 系统失败         |          |
| 其他错误码 | 请查看全局错误码 |          |

### 请求示例

```js
const cloud = require('wx-server-sdk')
cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV,
})
exports.main = async (event, context) => {
  try {
    const result = await cloud.openapi.operation.getGrayReleasePlan({})
    return result
  } catch (err) {
    return err
  }
}
```

### 返回示例

```json
const cloud = require('wx-server-sdk')
cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV,
})
exports.main = async (event, context) => {
  try {
    const result = await cloud.openapi.operation.getGrayReleasePlan({
        "errcode": 0,
        "errmsg": 'ok',
        "grayReleasePlan": {
          "status": 1,
          "createTimestamp": 1517553721,
          "defaultFinishTimestamp": 1517554721,
          "grayPercentage": 8
        }
      })
    return result
  } catch (err) {
    return err
  }
}
```