Skip to content

Commit d4b469d

Browse files
feat: add CM api update (#475)
* wip * add name and description * correct cli commands * add create api doc for CM properties (#476) * compile docs
1 parent b56d328 commit d4b469d

File tree

5 files changed

+427
-6
lines changed

5 files changed

+427
-6
lines changed

doc/compiled.json

Lines changed: 248 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,12 @@
733733
"$ref": "#/components/schemas/project_short"
734734
}
735735
},
736+
"value_options": {
737+
"type": "array",
738+
"items": {
739+
"type": "string"
740+
}
741+
},
736742
"created_at": {
737743
"type": "string",
738744
"format": "date-time"
@@ -744,9 +750,9 @@
744750
},
745751
"example": {
746752
"id": "abcd1234cdef1234abcd1234cdef1234",
747-
"name": "Character Age",
748-
"description": "Age of character in seconds",
749-
"data_type": "Text value",
753+
"name": "Nuts",
754+
"description": "A healthy snack for all ages",
755+
"data_type": "multi_select",
750756
"user": {
751757
"id": "abcd1234cdef1234abcd1234cdef1234",
752758
"username": "joe.doe",
@@ -762,6 +768,11 @@
762768
"created_at": "2015-01-28T09:52:53Z",
763769
"updated_at": "2015-01-28T09:52:53Z"
764770
}
771+
],
772+
"value_options": [
773+
"apple",
774+
"banana",
775+
"coconut"
765776
]
766777
}
767778
},
@@ -6228,6 +6239,240 @@
62286239
}
62296240
],
62306241
"x-cli-version": "2.9"
6242+
},
6243+
"post": {
6244+
"summary": "Create a property",
6245+
"description": "Create a new custom metadata property.",
6246+
"operationId": "custom_metadata_property/create",
6247+
"tags": [
6248+
"Custom Metadata"
6249+
],
6250+
"parameters": [
6251+
{
6252+
"$ref": "#/components/parameters/X-PhraseApp-OTP"
6253+
},
6254+
{
6255+
"$ref": "#/components/parameters/account_id"
6256+
},
6257+
{
6258+
"$ref": "#/components/parameters/id"
6259+
},
6260+
{
6261+
"description": "name of the property",
6262+
"example": [
6263+
"Fruit"
6264+
],
6265+
"name": "name",
6266+
"in": "query",
6267+
"schema": {
6268+
"type": "string"
6269+
}
6270+
},
6271+
{
6272+
"$ref": "#/components/parameters/data_type"
6273+
},
6274+
{
6275+
"description": "description of property",
6276+
"example": [
6277+
"A healthy snack for all ages"
6278+
],
6279+
"name": "description",
6280+
"in": "query",
6281+
"schema": {
6282+
"type": "string"
6283+
}
6284+
},
6285+
{
6286+
"description": "ids of projects that the property belongs to",
6287+
"example": [
6288+
"abcd1234cdef1234abcd1234cdef1234"
6289+
],
6290+
"name": "project_ids",
6291+
"in": "query",
6292+
"schema": {
6293+
"type": "array",
6294+
"items": {
6295+
"type": "string"
6296+
}
6297+
}
6298+
},
6299+
{
6300+
"description": "value options of property (only applies to single or multi select properties)",
6301+
"example": [
6302+
"Apple",
6303+
"Banana",
6304+
"Coconut"
6305+
],
6306+
"name": "value_options",
6307+
"in": "query",
6308+
"schema": {
6309+
"type": "array",
6310+
"items": {
6311+
"type": "string"
6312+
}
6313+
}
6314+
}
6315+
],
6316+
"responses": {
6317+
"200": {
6318+
"description": "OK",
6319+
"content": {
6320+
"application/json": {
6321+
"schema": {
6322+
"$ref": "#/components/schemas/custom_metadata_property"
6323+
}
6324+
}
6325+
},
6326+
"headers": {
6327+
"X-Rate-Limit-Limit": {
6328+
"$ref": "#/components/headers/X-Rate-Limit-Limit"
6329+
},
6330+
"X-Rate-Limit-Remaining": {
6331+
"$ref": "#/components/headers/X-Rate-Limit-Remaining"
6332+
},
6333+
"X-Rate-Limit-Reset": {
6334+
"$ref": "#/components/headers/X-Rate-Limit-Reset"
6335+
}
6336+
}
6337+
},
6338+
"400": {
6339+
"$ref": "#/components/responses/400"
6340+
},
6341+
"404": {
6342+
"$ref": "#/components/responses/404"
6343+
},
6344+
"422": {
6345+
"$ref": "#/components/responses/422"
6346+
},
6347+
"429": {
6348+
"$ref": "#/components/responses/429"
6349+
}
6350+
},
6351+
"x-code-samples": [
6352+
{
6353+
"lang": "Curl",
6354+
"source": "curl \"https://api.phrase.com/v2/accounts/:account_id/custom_metadata/labels/:id\" \\\n -u USERNAME_OR_ACCESS_TOKEN \\\n -X POST \\\n -d '{\"name\":\"Fruit\",\"description\":\"A healthy snack for all ages\",\"project_ids\":[\"1\",\"2\",\"3\"],\"value_options\":[\"apple\",\"banana\",\"coconut\"]}' \\\n -H 'Content-Type: application/json'"
6355+
},
6356+
{
6357+
"lang": "CLI v2",
6358+
"source": "phrase custom_metadata_properties create \\\n--account_id <account_id> \\\n--id <id> \\\n--data '{\"name\":\"Fruit\",\"description\":\"A healthy snack for all ages\",\"project_ids\":[\"1\",\"2\",\"3\"],\"value_options\":[\"apple\",\"banana\",\"coconut\"]}' \\\n--access_token <token>"
6359+
}
6360+
],
6361+
"x-cli-version": "2.9"
6362+
},
6363+
"patch": {
6364+
"summary": "Update a property",
6365+
"description": "Update an existing custom metadata property.",
6366+
"operationId": "custom_metadata_property/update",
6367+
"tags": [
6368+
"Custom Metadata"
6369+
],
6370+
"parameters": [
6371+
{
6372+
"$ref": "#/components/parameters/X-PhraseApp-OTP"
6373+
},
6374+
{
6375+
"$ref": "#/components/parameters/account_id"
6376+
},
6377+
{
6378+
"$ref": "#/components/parameters/id"
6379+
},
6380+
{
6381+
"description": "name of the property",
6382+
"example": [
6383+
"Fruit"
6384+
],
6385+
"name": "name",
6386+
"in": "query",
6387+
"schema": {
6388+
"type": "string"
6389+
}
6390+
},
6391+
{
6392+
"description": "description of property",
6393+
"example": [
6394+
"A healthy snack for all ages"
6395+
],
6396+
"name": "description",
6397+
"in": "query",
6398+
"schema": {
6399+
"type": "string"
6400+
}
6401+
},
6402+
{
6403+
"description": "ids of projects that the property belongs to",
6404+
"example": [
6405+
"abcd1234cdef1234abcd1234cdef1234"
6406+
],
6407+
"name": "project_ids",
6408+
"in": "query",
6409+
"schema": {
6410+
"type": "array",
6411+
"items": {
6412+
"type": "string"
6413+
}
6414+
}
6415+
},
6416+
{
6417+
"description": "value options of property (only applies to single or multi select properties)",
6418+
"example": [
6419+
"Apple",
6420+
"Banana",
6421+
"Coconut"
6422+
],
6423+
"name": "value_options",
6424+
"in": "query",
6425+
"schema": {
6426+
"type": "array",
6427+
"items": {
6428+
"type": "string"
6429+
}
6430+
}
6431+
}
6432+
],
6433+
"responses": {
6434+
"200": {
6435+
"description": "OK",
6436+
"content": {
6437+
"application/json": {
6438+
"schema": {
6439+
"$ref": "#/components/schemas/custom_metadata_property"
6440+
}
6441+
}
6442+
},
6443+
"headers": {
6444+
"X-Rate-Limit-Limit": {
6445+
"$ref": "#/components/headers/X-Rate-Limit-Limit"
6446+
},
6447+
"X-Rate-Limit-Remaining": {
6448+
"$ref": "#/components/headers/X-Rate-Limit-Remaining"
6449+
},
6450+
"X-Rate-Limit-Reset": {
6451+
"$ref": "#/components/headers/X-Rate-Limit-Reset"
6452+
}
6453+
}
6454+
},
6455+
"400": {
6456+
"$ref": "#/components/responses/400"
6457+
},
6458+
"404": {
6459+
"$ref": "#/components/responses/404"
6460+
},
6461+
"429": {
6462+
"$ref": "#/components/responses/429"
6463+
}
6464+
},
6465+
"x-code-samples": [
6466+
{
6467+
"lang": "Curl",
6468+
"source": "curl \"https://api.phrase.com/v2/accounts/:account_id/custom_metadata/labels/:id\" \\\n -u USERNAME_OR_ACCESS_TOKEN \\\n -X PATCH \\\n -d '{\"name\":\"Fruit\",\"description\":\"A healthy snack for all ages\",\"project_ids\":[\"1\",\"2\",\"3\"],\"value_options\":[\"apple\",\"banana\",\"coconut\"]}' \\\n -H 'Content-Type: application/json'"
6469+
},
6470+
{
6471+
"lang": "CLI v2",
6472+
"source": "phrase custom_metadata_properties update \\\n--account_id <account_id> \\\n--id <id> \\\n--data '{\"name\":\"Fruit\",\"description\":\"A healthy snack for all ages\",\"project_ids\":[\"1\",\"2\",\"3\"],\"value_options\":[\"apple\",\"banana\",\"coconut\"]}' \\\n--access_token <token>"
6473+
}
6474+
],
6475+
"x-cli-version": "2.9"
62316476
}
62326477
},
62336478
"/accounts/{account_id}/invitations": {

paths.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
"/accounts/{account_id}/custom_metadata/labels/{id}":
5454
get:
5555
"$ref": "./paths/custom_metadata_properties/show.yaml"
56+
post:
57+
"$ref": "./paths/custom_metadata_properties/create.yaml"
58+
patch:
59+
"$ref": "./paths/custom_metadata_properties/update.yaml"
5660
"/accounts/{account_id}/invitations":
5761
get:
5862
"$ref": "./paths/invitations/index.yaml"
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
summary: Create a property
3+
description: Create a new custom metadata property.
4+
operationId: custom_metadata_property/create
5+
tags:
6+
- Custom Metadata
7+
parameters:
8+
- "$ref": "../../parameters.yaml#/X-PhraseApp-OTP"
9+
- "$ref": "../../parameters.yaml#/account_id"
10+
- "$ref": "../../parameters.yaml#/id"
11+
- description: name of the property
12+
example:
13+
- Fruit
14+
name: name
15+
in: query
16+
schema:
17+
type: string
18+
- "$ref": "../../parameters.yaml#/data_type"
19+
- description: description of property
20+
example:
21+
- A healthy snack for all ages
22+
name: description
23+
in: query
24+
schema:
25+
type: string
26+
- description: ids of projects that the property belongs to
27+
example:
28+
- abcd1234cdef1234abcd1234cdef1234
29+
name: project_ids
30+
in: query
31+
schema:
32+
type: array
33+
items:
34+
type: string
35+
- description: value options of property (only applies to single or multi select properties)
36+
example:
37+
- Apple
38+
- Banana
39+
- Coconut
40+
name: value_options
41+
in: query
42+
schema:
43+
type: array
44+
items:
45+
type: string
46+
responses:
47+
'200':
48+
description: OK
49+
content:
50+
application/json:
51+
schema:
52+
"$ref": "../../schemas/custom_metadata_property.yaml#/custom_metadata_property"
53+
headers:
54+
X-Rate-Limit-Limit:
55+
"$ref": "../../headers.yaml#/X-Rate-Limit-Limit"
56+
X-Rate-Limit-Remaining:
57+
"$ref": "../../headers.yaml#/X-Rate-Limit-Remaining"
58+
X-Rate-Limit-Reset:
59+
"$ref": "../../headers.yaml#/X-Rate-Limit-Reset"
60+
'400':
61+
"$ref": "../../responses.yaml#/400"
62+
'404':
63+
"$ref": "../../responses.yaml#/404"
64+
'422':
65+
"$ref": "../../responses.yaml#/422"
66+
'429':
67+
"$ref": "../../responses.yaml#/429"
68+
x-code-samples:
69+
- lang: Curl
70+
source: |-
71+
curl "https://api.phrase.com/v2/accounts/:account_id/custom_metadata/labels/:id" \
72+
-u USERNAME_OR_ACCESS_TOKEN \
73+
-X POST \
74+
-d '{"name":"Fruit","description":"A healthy snack for all ages","project_ids":["1","2","3"],"value_options":["apple","banana","coconut"]}' \
75+
-H 'Content-Type: application/json'
76+
- lang: CLI v2
77+
source: |-
78+
phrase custom_metadata_properties create \
79+
--account_id <account_id> \
80+
--id <id> \
81+
--data '{"name":"Fruit","description":"A healthy snack for all ages","project_ids":["1","2","3"],"value_options":["apple","banana","coconut"]}' \
82+
--access_token <token>
83+
x-cli-version: '2.9'

0 commit comments

Comments
 (0)