标签Labels

api-version:1.0api-version: 1.0

“标签”资源的定义如下:The Label resource is defined as follows:

{
      "name": [string]             // Name of the label
}

支持以下操作:Supports the following operations:

  • 列出List

对于所有操作,name 为可选筛选器参数。For all operations name is an optional filter parameter. 如果省略,则暗指任何标签。If omitted it implies any label.

必备条件Prerequisites

  • 所有 HTTP 请求都必须经过身份验证。All HTTP requests must be authenticated. 请参阅身份验证部分。See the authentication section.
  • 所有 HTTP 请求都必须提供显式的 api-versionAll HTTP requests must provide explicit api-version. 请参阅版本控制部分。See the versioning section.

列出标签List Labels

GET /labels?api-version={api-version} HTTP/1.1

响应:Responses:

HTTP/1.1 200 OK
Content-Type: application/vnd.microsoft.appconfig.labelset+json; charset=utf-8"
{
    "items": [
        {
          "name": "{label-name}"
        },
        ...
    ],
    "@nextLink": "{relative uri}"
}

分页Pagination

如果返回的项数超过响应限制,则会对结果进行分页。The result is paginated if the number of items returned exceeds the response limit. 按照可选的 Link 响应标头进行操作并使用 rel="next" 进行导航。Follow the optional Link response headers and use rel="next" for navigation. 也可让内容以 @nextLink 属性的形式提供下一个链接。Alternatively the content provides a next link in form of the @nextLink property. 下一个链接包含 api-version 参数。The next link contains api-version parameter.

GET /labels?api-version={api-version} HTTP/1.1

响应:Response:

HTTP/1.1 OK
Content-Type: application/vnd.microsoft.appconfig.labelset+json; charset=utf-8
Accept-Ranges: items
Link: <{relative uri}>; rel="next"
{
    "items": [
        ...
    ],
    "@nextLink": "{relative uri}"
}

筛选Filtering

支持按 name 筛选。Filtering by name is supported.

GET /labels?name={label-name}&api-version={api-version}

支持的筛选器Supported filters

键筛选器Key Filter 效果Effect
省略 namename=*name is omitted or name=* 匹配任何标签Matches any label
name=abc 匹配名为“abc”的标签Matches a label named abc
name=abc* 匹配以“abc”开头的标签名称Matches label names that start with abc
name=abc,xyz 匹配标签名称“abc”或“xyz”(限制为 5 个 CSV) Matches label names abc or xyz (limited to 5 CSV)

保留字符Reserved characters

*, \, ,*, \, ,

如果保留字符是值的一部分,则必须使用 \{Reserved Character} 对其进行转义。If a reserved character is part of the value, then it must be escaped using \{Reserved Character}. 非保留字符也可以进行转义。Non-reserved characters can also be escaped.

筛选器验证Filter Validation

如果出现筛选器验证错误,则响应为“HTTP 400”,其中包含以下错误详细信息:If a filter validation error occurs, the response is HTTP 400 with error details:

HTTP/1.1 400 Bad Request
Content-Type: application/problem+json; charset=utf-8
{
  "type": "https://azconfig.io/errors/invalid-argument",
  "title": "Invalid request parameter 'name'",
  "name": "name",
  "detail": "name(2): Invalid character",
  "status": 400
}

示例Examples

  • 全部All

    GET /labels?api-version={api-version}
    
  • 标签名称以“abc”开头Label name starts with abc

    GET  /labels?name=abc*&api-version={api-version}
    
  • 标签名称为“abc”或“xyz”Label name is either abc or xyz

    GET /labels?name=abc,xyz&api-version={api-version}
    

请求特定字段Request specific fields

使用可选的 $select 查询字符串参数,并提供所请求字段的逗号分隔列表。Use the optional $select query string parameter and provide comma-separated list of requested fields. 如果省略 $select 参数,则响应会包含默认集。If the $select parameter is omitted, the response contains the default set.

GET /labels?$select=name&api-version={api-version} HTTP/1.1

基于时间的访问Time-Based Access

获得结果在过去的表现形式。Obtain a representation of the result as it was at a past time. 请参阅 2.1.1 部分See section 2.1.1

GET /labels&api-version={api-version} HTTP/1.1
Accept-Datetime: Sat, 12 May 2018 02:10:00 GMT

响应:Response:

HTTP/1.1 200 OK
Content-Type: application/vnd.microsoft.appconfig.labelset+json"
Memento-Datetime: Sat, 12 May 2018 02:10:00 GMT
Link: <{relative uri}>; rel="original"
{
    "items": [
        ....
    ]
}