From 1af5edac615e6c4624babb8742b111f426437f44 Mon Sep 17 00:00:00 2001 From: Anthony Chang Date: Sat, 2 Dec 2023 23:13:41 +0100 Subject: [PATCH] add create api doc for CM properties --- doc/compiled.json | 120 +++++++++++++++++++ paths.yaml | 2 + paths/custom_metadata_properties/create.yaml | 83 +++++++++++++ 3 files changed, 205 insertions(+) create mode 100644 paths/custom_metadata_properties/create.yaml diff --git a/doc/compiled.json b/doc/compiled.json index 17b9db7e3..3c20f4856 100644 --- a/doc/compiled.json +++ b/doc/compiled.json @@ -6178,6 +6178,126 @@ } }, "/accounts/{account_id}/custom_metadata/labels/{id}": { + "post": { + "summary": "Create a property", + "description": "Create a new custom metadata property.", + "operationId": "custom_metadata_property/create", + "tags": [ + "Custom Metadata" + ], + "parameters": [ + { + "$ref": "#/components/parameters/X-PhraseApp-OTP" + }, + { + "$ref": "#/components/parameters/account_id" + }, + { + "$ref": "#/components/parameters/id" + }, + { + "description": "name of the property", + "example": [ + "Fruit" + ], + "name": "name", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "$ref": "#/components/parameters/data_type" + }, + { + "description": "description of property", + "example": [ + "A healthy snack for all ages" + ], + "name": "description", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "description": "ids of projects that the property belongs to", + "example": [ + "abcd1234cdef1234abcd1234cdef1234" + ], + "name": "project_ids", + "in": "query", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + { + "description": "value options of property (only applies to single or multi select properties)", + "example": [ + "Apple", + "Banana", + "Coconut" + ], + "name": "value_options", + "in": "query", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/custom_metadata_property" + } + } + }, + "headers": { + "X-Rate-Limit-Limit": { + "$ref": "#/components/headers/X-Rate-Limit-Limit" + }, + "X-Rate-Limit-Remaining": { + "$ref": "#/components/headers/X-Rate-Limit-Remaining" + }, + "X-Rate-Limit-Reset": { + "$ref": "#/components/headers/X-Rate-Limit-Reset" + } + } + }, + "400": { + "$ref": "#/components/responses/400" + }, + "404": { + "$ref": "#/components/responses/404" + }, + "422": { + "$ref": "#/components/responses/422" + }, + "429": { + "$ref": "#/components/responses/429" + } + }, + "x-code-samples": [ + { + "lang": "Curl", + "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'" + }, + { + "lang": "CLI v2", + "source": "phrase custom_metadata_properties create \\\n--account_id \\\n--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 " + } + ], + "x-cli-version": "2.9" + }, "patch": { "summary": "Update a property", "description": "Update an existing custom metadata property.", diff --git a/paths.yaml b/paths.yaml index 73cac6cf9..ef148ebca 100644 --- a/paths.yaml +++ b/paths.yaml @@ -51,6 +51,8 @@ get: "$ref": "./paths/custom_metadata_properties/index.yaml" "/accounts/{account_id}/custom_metadata/labels/{id}": + post: + "$ref": "./paths/custom_metadata_properties/create.yaml" patch: "$ref": "./paths/custom_metadata_properties/update.yaml" "/accounts/{account_id}/invitations": diff --git a/paths/custom_metadata_properties/create.yaml b/paths/custom_metadata_properties/create.yaml new file mode 100644 index 000000000..ececb1ca4 --- /dev/null +++ b/paths/custom_metadata_properties/create.yaml @@ -0,0 +1,83 @@ +--- +summary: Create a property +description: Create a new custom metadata property. +operationId: custom_metadata_property/create +tags: +- Custom Metadata +parameters: +- "$ref": "../../parameters.yaml#/X-PhraseApp-OTP" +- "$ref": "../../parameters.yaml#/account_id" +- "$ref": "../../parameters.yaml#/id" +- description: name of the property + example: + - Fruit + name: name + in: query + schema: + type: string +- "$ref": "../../parameters.yaml#/data_type" +- description: description of property + example: + - A healthy snack for all ages + name: description + in: query + schema: + type: string +- description: ids of projects that the property belongs to + example: + - abcd1234cdef1234abcd1234cdef1234 + name: project_ids + in: query + schema: + type: array + items: + type: string +- description: value options of property (only applies to single or multi select properties) + example: + - Apple + - Banana + - Coconut + name: value_options + in: query + schema: + type: array + items: + type: string +responses: + '200': + description: OK + content: + application/json: + schema: + "$ref": "../../schemas/custom_metadata_property.yaml#/custom_metadata_property" + headers: + X-Rate-Limit-Limit: + "$ref": "../../headers.yaml#/X-Rate-Limit-Limit" + X-Rate-Limit-Remaining: + "$ref": "../../headers.yaml#/X-Rate-Limit-Remaining" + X-Rate-Limit-Reset: + "$ref": "../../headers.yaml#/X-Rate-Limit-Reset" + '400': + "$ref": "../../responses.yaml#/400" + '404': + "$ref": "../../responses.yaml#/404" + '422': + "$ref": "../../responses.yaml#/422" + '429': + "$ref": "../../responses.yaml#/429" +x-code-samples: +- lang: Curl + source: |- + curl "https://api.phrase.com/v2/accounts/:account_id/custom_metadata/labels/:id" \ + -u USERNAME_OR_ACCESS_TOKEN \ + -X POST \ + -d '{"name":"Fruit","description":"A healthy snack for all ages","project_ids":["1","2","3"],"value_options":["apple","banana","coconut"]}' \ + -H 'Content-Type: application/json' +- lang: CLI v2 + source: |- + phrase custom_metadata_properties create \ + --account_id \ + --id \ + --data '{"name":"Fruit","description":"A healthy snack for all ages","project_ids":["1","2","3"],"value_options":["apple","banana","coconut"]}' \ + --access_token +x-cli-version: '2.9'