Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(API): add Custom Metadata endpoints #474

Merged
merged 36 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
b85b5e5
register Custom Metadata Labels to main yml
anthonyshchang Jul 10, 2023
882ef70
add custom metadata schema
anthonyshchang Jul 11, 2023
7f5fc17
add custom metadata index path
anthonyshchang Jul 11, 2023
6f2d259
compile json
anthonyshchang Jul 11, 2023
43729e1
add enum for data_type
anthonyshchang Jul 12, 2023
037c904
specify 2.9 cli version
anthonyshchang Jul 12, 2023
6b554f7
generalize custom metadata tag
anthonyshchang Jul 12, 2023
08891f7
correct path for index route
anthonyshchang Jul 12, 2023
dc31638
update path
anthonyshchang Jul 12, 2023
aedb4e6
update compiled json
anthonyshchang Jul 12, 2023
63c52fd
align Custom Metadata tag usage
anthonyshchang Jul 12, 2023
8bb7161
add project ids param to labels index
anthonyshchang Jul 13, 2023
3685a03
add sort and order to metadata label index
anthonyshchang Jul 13, 2023
d4a742f
update url params example
anthonyshchang Jul 13, 2023
e84fe71
make summary and description more clear and concise
anthonyshchang Jul 13, 2023
218eeb6
add endpoint availability notice
anthonyshchang Jul 13, 2023
033db1c
remove account ref from schema
anthonyshchang Jul 13, 2023
da0c66c
add projects to custom metadata label schema
anthonyshchang Jul 13, 2023
e22dae6
update label -> property
anthonyshchang Nov 30, 2023
9c0a121
rename CM paths folder
anthonyshchang Nov 30, 2023
a56a258
lint
anthonyshchang Nov 30, 2023
001effc
fix parameter definitions
anthonyshchang Nov 30, 2023
b56d328
feat(api): Add show API endpoint for custom_metadata_labels (#359)
anthonyshchang Dec 5, 2023
d4b469d
feat: add CM api update (#475)
anthonyshchang Dec 5, 2023
fcd8cbe
feat: add delete CM property doc (#477)
anthonyshchang Dec 6, 2023
0978091
rename data type to custom metadata data type
anthonyshchang Dec 6, 2023
7ca6c3d
nest create under collection
anthonyshchang Dec 6, 2023
08771e7
update routes to use properties instead of labels
anthonyshchang Dec 6, 2023
dcd320e
regen docs
anthonyshchang Dec 6, 2023
b400e82
fix project_id example
anthonyshchang Dec 6, 2023
7b636a6
update path CM route naming
anthonyshchang Dec 7, 2023
c42fbea
feat: update translation key create/update with custom metadata. Add …
anthonyshchang Dec 12, 2023
42e7a82
Make create CM example to be working with CURL
ildarsafin Dec 13, 2023
74275df
Make the data_type field to be not required
ildarsafin Dec 13, 2023
4fdbef0
extract custom metadata data type schema
jablan Dec 13, 2023
504fb40
fix
jablan Dec 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
580 changes: 576 additions & 4 deletions doc/compiled.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ tags:
- name: Comments
- name: Comment Reactions
- name: Comment Replies
- name: Custom Metadata
- name: Distributions
- name: Documents
- name: Figma Attachments
Expand Down Expand Up @@ -266,6 +267,7 @@ x-tagGroups:
- Translations
- Uploads
- Tags
- Custom Metadata Properties
- Blacklisted Keys
- Versions / History
- name: Workflows
Expand Down
8 changes: 8 additions & 0 deletions parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ account_id:
required: true
schema:
type: string
custom_metadata_data_type:
in: query
name: data_type
description: Data Type of Custom Metadata Property
required: false
schema:
"$ref": "./schemas/custom_metadata_data_type.yaml#/data_type"
example: boolean
query_account_id:
in: query
name: account_id
Expand Down
12 changes: 12 additions & 0 deletions paths.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@
"$ref": "./paths/styleguides/update.yaml"
delete:
"$ref": "./paths/styleguides/destroy.yaml"
"/accounts/{account_id}/custom_metadata/properties":
get:
"$ref": "./paths/custom_metadata_properties/index.yaml"
post:
jablan marked this conversation as resolved.
Show resolved Hide resolved
"$ref": "./paths/custom_metadata_properties/create.yaml"
"/accounts/{account_id}/custom_metadata/properties/{id}":
get:
"$ref": "./paths/custom_metadata_properties/show.yaml"
patch:
"$ref": "./paths/custom_metadata_properties/update.yaml"
delete:
"$ref": "./paths/custom_metadata_properties/destroy.yaml"
"/accounts/{account_id}/invitations":
get:
"$ref": "./paths/invitations/index.yaml"
Expand Down
88 changes: 88 additions & 0 deletions paths/custom_metadata_properties/create.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
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"
- description: name of the property
example:
- Fruit
name: name
in: query
required: true
schema:
type: string
- name: data_type
in: query
description: Data Type of Custom Metadata Property
required: true
schema:
"$ref": "../../schemas/custom_metadata_data_type.yaml#/data_type"
example: boolean
- 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/properties" \
-u USERNAME_OR_ACCESS_TOKEN \
-X POST \
-d '{"name":"Fruit","data_type":"multi_select","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 <account_id> \
--data '{"name":"Fruit","data_type":"multi_select","description":"A healthy snack for all ages","project_ids":["1","2","3"],"value_options":["apple","banana","coconut"]}' \
--access_token <token>
x-cli-version: '2.9'
36 changes: 36 additions & 0 deletions paths/custom_metadata_properties/destroy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
summary: Destroy property
description: |
Destroy a custom metadata property of an account.

This endpoint is only available to accounts with advanced plans or above.
operationId: custom_metadata_properties/delete
tags:
- Custom Metadata
parameters:
- "$ref": "../../parameters.yaml#/X-PhraseApp-OTP"
- "$ref": "../../parameters.yaml#/account_id"
- "$ref": "../../parameters.yaml#/id"
responses:
'204':
"$ref": "../../responses.yaml#/204"
'400':
"$ref": "../../responses.yaml#/400"
'404':
"$ref": "../../responses.yaml#/404"
'429':
"$ref": "../../responses.yaml#/429"
x-code-samples:
- lang: Curl
source: |-
curl "https://api.phrase.com/v2/accounts/:account_id/custom_metadata/properties/:id" \
-u USERNAME_OR_ACCESS_TOKEN
-X DELETE
-H 'Content-Type: application/json'
- lang: CLI v2
source: |-
phrase custom_metadata_properties delete \
--account_id <account_id> \
--id <id> \
--access_token <token>
x-cli-version: '2.9'
74 changes: 74 additions & 0 deletions paths/custom_metadata_properties/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
summary: List properties
description: |
List all custom metadata properties for an account.

This endpoint is only available to accounts with advanced plans or above.
operationId: custom_metadata_properties/list
tags:
- Custom Metadata
parameters:
- "$ref": "../../parameters.yaml#/X-PhraseApp-OTP"
- "$ref": "../../parameters.yaml#/account_id"
- "$ref": "../../parameters.yaml#/custom_metadata_data_type"
Copy link
Collaborator

@jablan jablan Dec 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious, why is there a data_type parameter? is it for filtering properties only for the given type? what was the use case for adding this?

in phrase code, I can see there's also q parameter (which makes more sense IMO), why has it been left out?

Copy link
Contributor Author

@anthonyshchang anthonyshchang Dec 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it for filtering properties only for the given type?

yep, believe so

what was the use case for adding this?

perhaps a convenience method of getting all date-related properties for mass update?

- description: id of project that the properties belong to
example: abcd1234cdef1234abcd1234cdef1234
name: project_id
in: query
schema:
type: string
- "$ref": "../../parameters.yaml#/page"
- "$ref": "../../parameters.yaml#/per_page"
- description: 'Sort criteria. Can be one of: name, data_type, created_at.'
example: updated_at
name: sort
in: query
schema:
type: string
- description: 'Order direction. Can be one of: asc, desc.'
example: desc
name: order
in: query
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
"$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"
Link:
"$ref": "../../headers.yaml#/Link"
'400':
"$ref": "../../responses.yaml#/400"
'404':
"$ref": "../../responses.yaml#/404"
'429':
"$ref": "../../responses.yaml#/429"
x-code-samples:
- lang: Curl
source: |-
curl "https://api.phrase.com/v2/accounts/:account_id/custom_metadata/properties?data_type=boolean&project_id=1&page=1&per_page=10&sort=created_at&order=desc" \
-u USERNAME_OR_ACCESS_TOKEN
- lang: CLI v2
source: |-
phrase custom_metadata_properties list \
--account_id <account_id> \
--data_type boolean \
--project_id 1 \
--page 1 \
--per_page 10 \
--sort created_at \
--order desc \
--access_token <token>
x-cli-version: '2.9'
42 changes: 42 additions & 0 deletions paths/custom_metadata_properties/show.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
summary: Get a single property
description: Get details of a single custom property.
operationId: custom_metadata_property/show
tags:
- Custom Metadata
parameters:
- "$ref": "../../parameters.yaml#/X-PhraseApp-OTP"
- "$ref": "../../parameters.yaml#/account_id"
- "$ref": "../../parameters.yaml#/id"
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"
'429':
"$ref": "../../responses.yaml#/429"
x-code-samples:
- lang: Curl
source: |-
curl "https://api.phrase.com/v2/accounts/:account_id/custom_metadata/properties/:id" \
-u USERNAME_OR_ACCESS_TOKEN
- lang: CLI v2
source: |-
phrase custom_metadata_properties show \
--account_id <account_id> \
--id <id> \
--access_token <token>
x-cli-version: '2.9'
80 changes: 80 additions & 0 deletions paths/custom_metadata_properties/update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
summary: Update a property
description: Update an existing custom metadata property.
operationId: custom_metadata_property/update
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
- 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"
'429':
"$ref": "../../responses.yaml#/429"
x-code-samples:
- lang: Curl
source: |-
curl "https://api.phrase.com/v2/accounts/:account_id/custom_metadata/properties/:id" \
-u USERNAME_OR_ACCESS_TOKEN \
-X PATCH \
-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 update \
--account_id <account_id> \
--id <id> \
--data '{"name":"Fruit","description":"A healthy snack for all ages","project_ids":["1","2","3"],"value_options":["apple","banana","coconut"]}' \
--access_token <token>
x-cli-version: '2.9'
Loading
Loading