From e5759910beee59a7821aff3ae8ac23eb8e68a90c Mon Sep 17 00:00:00 2001 From: Anna Grancharova Date: Fri, 26 Jul 2024 12:38:58 +0300 Subject: [PATCH 1/3] added: Draft Annotations for FTA --- .circleci/config.yml | 2 +- config/schemas-api-config.json | 24 +++++++ handler/handler_test.go | 4 +- helm/draft-annotations-api/values.yaml | 2 +- schemas/draft-annotations-fta-add.json | 65 ++++++++++++++++++ schemas/draft-annotations-fta-replace.json | 65 ++++++++++++++++++ schemas/draft-annotations-fta-write.json | 74 +++++++++++++++++++++ schemas/draft-annotations-ftpc-replace.json | 2 +- 8 files changed, 233 insertions(+), 5 deletions(-) create mode 100644 schemas/draft-annotations-fta-add.json create mode 100644 schemas/draft-annotations-fta-replace.json create mode 100644 schemas/draft-annotations-fta-write.json diff --git a/.circleci/config.yml b/.circleci/config.yml index 29f1cb8..38eee43 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -14,7 +14,7 @@ executors: ANNOTATIONS_ENDPOINT: http://localhost:9000/content/%v/annotations INTERNAL_CONCORDANCES_ENDPOINT: http://localhost:9000/internalconcordances JSON_SCHEMAS_PATH: ./schemas - JSON_SCHEMA_NAME: draft-annotations-pac-add.json;draft-annotations-pac-replace.json;draft-annotations-pac-write.json;draft-annotations-sv-add.json;draft-annotations-sv-replace.json;draft-annotations-sv-write.json;draft-annotations-ftpc-add.json;draft-annotations-ftpc-replace.json;draft-annotations-ftpc-write.json + JSON_SCHEMA_NAME: draft-annotations-pac-add.json;draft-annotations-pac-replace.json;draft-annotations-pac-write.json;draft-annotations-sv-add.json;draft-annotations-sv-replace.json;draft-annotations-sv-write.json;draft-annotations-ftpc-add.json;draft-annotations-ftpc-replace.json;draft-annotations-ftpc-write.json; draft-annotations-fta-add.json;draft-annotations-fta-replace.json;draft-annotations-fta-write.json JSON_SCHEMAS_API_CONFIG_PATH: ./config/schemas-api-config.json OPA_ADDRESS: "http://localhost:8181" diff --git a/config/schemas-api-config.json b/config/schemas-api-config.json index c4ed0a8..170177c 100644 --- a/config/schemas-api-config.json +++ b/config/schemas-api-config.json @@ -23,6 +23,14 @@ ], "schema_file_name": "draft-annotations-ftpc-write.json" }, + { + "http_method": "PUT", + "url": "/draft-annotations/content/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/annotations.*$", + "publication": [ + "19d50190-8656-4e91-8d34-82e646ada9c9" + ], + "schema_file_name": "draft-annotations-fta-write.json" + }, { "http_method": "POST", "url": "/draft-annotations/content/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/annotations.*$", @@ -47,6 +55,14 @@ ], "schema_file_name": "draft-annotations-ftpc-add.json" }, + { + "http_method": "POST", + "url": "/draft-annotations/content/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/annotations.*$", + "publication": [ + "19d50190-8656-4e91-8d34-82e646ada9c9" + ], + "schema_file_name": "draft-annotations-fta-add.json" + }, { "http_method": "PATCH", "url": "/draft-annotations/content/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/annotations/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}.*$", @@ -70,5 +86,13 @@ "724b5e36-6d45-4cf1-b1c2-3f676b21f21b" ], "schema_file_name": "draft-annotations-ftpc-replace.json" + }, + { + "http_method": "PATCH", + "url": "/draft-annotations/content/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/annotations/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}.*$", + "publication": [ + "19d50190-8656-4e91-8d34-82e646ada9c9" + ], + "schema_file_name": "draft-annotations-fta-replace.json" } ] \ No newline at end of file diff --git a/handler/handler_test.go b/handler/handler_test.go index fb3dbee..06d0940 100644 --- a/handler/handler_test.go +++ b/handler/handler_test.go @@ -3034,7 +3034,7 @@ func TestValidate(t *testing.T) { func TestListSchemas(t *testing.T) { _ = os.Setenv("JSON_SCHEMAS_PATH", "../schemas") _ = os.Setenv("JSON_SCHEMAS_API_CONFIG_PATH", "../config/schemas-api-config.json") - _ = os.Setenv("JSON_SCHEMA_NAME", "draft-annotations-pac-add.json;draft-annotations-pac-replace.json;draft-annotations-pac-write.json;draft-annotations-sv-add.json;draft-annotations-sv-replace.json;draft-annotations-sv-write.json") + _ = os.Setenv("JSON_SCHEMA_NAME", "draft-annotations-pac-add.json;draft-annotations-pac-replace.json;draft-annotations-pac-write.json;draft-annotations-ftpc-add.json;draft-annotations-ftpc-replace.json;draft-annotations-ftpc-write.json,;draft-annotations-fta-add.json;draft-annotations-fta-replace.json;draft-annotations-fta-write.json") tests := []struct { name string @@ -3042,7 +3042,7 @@ func TestListSchemas(t *testing.T) { }{ { "List schemas", - `{"_links":{"application/vnd.ft-upp-annotations-ftpc-add.json":[{"href":"/draft-annotations/schemas/draft-annotations-ftpc-add.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-ftpc-replace.json":[{"href":"/draft-annotations/schemas/draft-annotations-ftpc-replace.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-ftpc-write.json":[{"href":"/draft-annotations/schemas/draft-annotations-ftpc-write.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-pac-add.json":[{"href":"/draft-annotations/schemas/draft-annotations-pac-add.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-pac-replace.json":[{"href":"/draft-annotations/schemas/draft-annotations-pac-replace.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-pac-write.json":[{"href":"/draft-annotations/schemas/draft-annotations-pac-write.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-sv-add.json":[{"href":"/draft-annotations/schemas/draft-annotations-sv-add.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-sv-replace.json":[{"href":"/draft-annotations/schemas/draft-annotations-sv-replace.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-sv-write.json":[{"href":"/draft-annotations/schemas/draft-annotations-sv-write.json","name":"latest-version"}],"self":{"href":"/draft-annotations/schemas"}}}`, + `{"_links":{"application/vnd.ft-upp-annotations-fta-add.json":[{"href":"/draft-annotations/schemas/draft-annotations-fta-add.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-fta-replace.json":[{"href":"/draft-annotations/schemas/draft-annotations-fta-replace.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-fta-write.json":[{"href":"/draft-annotations/schemas/draft-annotations-fta-write.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-ftpc-add.json":[{"href":"/draft-annotations/schemas/draft-annotations-ftpc-add.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-ftpc-replace.json":[{"href":"/draft-annotations/schemas/draft-annotations-ftpc-replace.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-ftpc-write.json":[{"href":"/draft-annotations/schemas/draft-annotations-ftpc-write.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-pac-add.json":[{"href":"/draft-annotations/schemas/draft-annotations-pac-add.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-pac-replace.json":[{"href":"/draft-annotations/schemas/draft-annotations-pac-replace.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-pac-write.json":[{"href":"/draft-annotations/schemas/draft-annotations-pac-write.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-sv-add.json":[{"href":"/draft-annotations/schemas/draft-annotations-sv-add.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-sv-replace.json":[{"href":"/draft-annotations/schemas/draft-annotations-sv-replace.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-sv-write.json":[{"href":"/draft-annotations/schemas/draft-annotations-sv-write.json","name":"latest-version"}],"self":{"href":"/draft-annotations/schemas"}}}`, }, } diff --git a/helm/draft-annotations-api/values.yaml b/helm/draft-annotations-api/values.yaml index 66c83a7..c976cad 100644 --- a/helm/draft-annotations-api/values.yaml +++ b/helm/draft-annotations-api/values.yaml @@ -19,7 +19,7 @@ env: ANNOTATIONS_ENDPOINT: "" # This should be defined in the specific app-configs folder INTERNAL_CONCORDANCES_ENDPOINT: "" # This should be defined in the specific app-configs folder JSON_SCHEMAS_PATH: "/schemas" - JSON_SCHEMA_NAME: "draft-annotations-pac-add.json;draft-annotations-pac-replace.json;draft-annotations-pac-write.json;draft-annotations-sv-add.json;draft-annotations-sv-replace.json;draft-annotations-sv-write.json;draft-annotations-ftpc-add.json;draft-annotations-ftpc-replace.json;draft-annotations-ftpc-write.json" + JSON_SCHEMA_NAME: "draft-annotations-pac-add.json;draft-annotations-pac-replace.json;draft-annotations-pac-write.json;draft-annotations-sv-add.json;draft-annotations-sv-replace.json;draft-annotations-sv-write.json;draft-annotations-ftpc-add.json;draft-annotations-ftpc-replace.json;draft-annotations-ftpc-write.json;draft-annotations-fta-add.json;draft-annotations-fta-replace.json;draft-annotations-fta-write.json JSON_SCHEMAS_API_CONFIG_PATH: "/config/schemas-api-config.json" openPolicyAgentSidecar: name: open-policy-agent diff --git a/schemas/draft-annotations-fta-add.json b/schemas/draft-annotations-fta-add.json new file mode 100644 index 0000000..3f5fa6c --- /dev/null +++ b/schemas/draft-annotations-fta-add.json @@ -0,0 +1,65 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "http://upp-publishing-prod.ft.com/schema/draft-annotations-fta-add+json", + "title": "Draft FTA Annotations Add Endpoint", + "type": "object", + "description": "Schema for Draft FTA Annotations", + "properties": { + "annotation": { + "type": "object", + "description": "Schema for FTA Annotations", + "properties": { + "id": { + "type": "string", + "pattern": ".*/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$", + "description": "ID of the related concept" + }, + "predicate": { + "type": "string", + "description": "Predicate of the annotation", + "enum": [ + "http://www.ft.com/ontology/annotation/mentions", + "http://www.ft.com/ontology/classification/isClassifiedBy", + "http://www.ft.com/ontology/annotation/about", + "http://www.ft.com/ontology/hasDisplayTag", + "http://www.ft.com/ontology/annotation/isSponsoredBy" + ] + }, + "apiUrl": { + "type": "string", + "description": "API URL of the related concept" + }, + "type": { + "type": "string", + "description": "Type of the related concept" + }, + "prefLabel": { + "type": "string", + "description": "PrefLabel of the related concept" + }, + "isFTAuthor": { + "type": "boolean", + "description": "Indicates whether the related concept is an FT author" + } + }, + "required": [ + "id", + "predicate" + ], + "additionalProperties": false + }, + "publication": { + "type": "array", + "description": "Indicates which titles are aware of this content", + "items": { + "type": "string", + "pattern": "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}" + } + } + }, + "required": [ + "annotation", + "publication" + ], + "additionalProperties": false +} \ No newline at end of file diff --git a/schemas/draft-annotations-fta-replace.json b/schemas/draft-annotations-fta-replace.json new file mode 100644 index 0000000..de3bce7 --- /dev/null +++ b/schemas/draft-annotations-fta-replace.json @@ -0,0 +1,65 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "http://upp-publishing-prod.ft.com/schema/draft-annotations-fta-add+json", + "title": "Draft FTA Annotations Replace Endpoint", + "type": "object", + "description": "Schema for Draft FTA Annotations", + "properties": { + "annotation": { + "type": "object", + "description": "Schema for FTA Annotations", + "properties": { + "id": { + "type": "string", + "pattern": ".*/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$", + "description": "ID of the related concept" + }, + "predicate": { + "type": "string", + "description": "Predicate of the annotation", + "enum": [ + "http://www.ft.com/ontology/annotation/mentions", + "http://www.ft.com/ontology/classification/isClassifiedBy", + "http://www.ft.com/ontology/annotation/about", + "http://www.ft.com/ontology/hasDisplayTag", + "http://www.ft.com/ontology/annotation/isSponsoredBy" + ] + }, + "apiUrl": { + "type": "string", + "description": "API URL of the related concept" + }, + "type": { + "type": "string", + "description": "Type of the related concept" + }, + "prefLabel": { + "type": "string", + "description": "PrefLabel of the related concept" + }, + "isFTAuthor": { + "type": "boolean", + "description": "Indicates whether the related concept is an FT author" + } + }, + "required": [ + "id", + "predicate" + ], + "additionalProperties": false + }, + "publication": { + "type": "array", + "description": "Indicates which titles are aware of this content", + "items": { + "type": "string", + "pattern": "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}" + } + } + }, + "required": [ + "annotation", + "publication" + ], + "additionalProperties": false +} \ No newline at end of file diff --git a/schemas/draft-annotations-fta-write.json b/schemas/draft-annotations-fta-write.json new file mode 100644 index 0000000..c129637 --- /dev/null +++ b/schemas/draft-annotations-fta-write.json @@ -0,0 +1,74 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "http://upp-publishing-prod.ft.com/schema/draft-annotations-fta-write+json", + "title": "Draft FTA Annotations", + "type": "object", + "description": "Schema for Draft FTA Annotations", + "properties": { + "annotations": { + "type": "array", + "description": "Draft FTA annotations", + "items": { + "$ref": "#/$defs/annotation" + } + }, + "publication": { + "type": "array", + "description": "Indicates which titles are aware of this content", + "items": { + "type": "string", + "pattern": "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}" + } + } + }, + "required": [ + "annotations", + "publication" + ], + "additionalProperties": false, + "$defs": { + "annotation": { + "type": "object", + "description": "Schema for FTA Annotations", + "properties": { + "id": { + "type": "string", + "pattern": ".*/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$", + "description": "ID of the related concept" + }, + "predicate": { + "type": "string", + "description": "Predicate of the annotation", + "enum": [ + "http://www.ft.com/ontology/annotation/mentions", + "http://www.ft.com/ontology/classification/isClassifiedBy", + "http://www.ft.com/ontology/annotation/about", + "http://www.ft.com/ontology/hasDisplayTag", + "http://www.ft.com/ontology/annotation/isSponsoredBy" + ] + }, + "apiUrl": { + "type": "string", + "description": "API URL of the related concept" + }, + "type": { + "type": "string", + "description": "Type of the related concept" + }, + "prefLabel": { + "type": "string", + "description": "PrefLabel of the related concept" + }, + "isFTAuthor": { + "type": "boolean", + "description": "Indicates whether the related concept is an FT author" + } + }, + "required": [ + "id", + "predicate" + ], + "additionalProperties": false + } + } +} \ No newline at end of file diff --git a/schemas/draft-annotations-ftpc-replace.json b/schemas/draft-annotations-ftpc-replace.json index 54233b3..5fc016c 100644 --- a/schemas/draft-annotations-ftpc-replace.json +++ b/schemas/draft-annotations-ftpc-replace.json @@ -1,7 +1,7 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "http://upp-publishing-prod.ft.com/schema/draft-annotations-ftpc-add+json", - "title": "Draft FTPC Annotations Add Endpoint", + "title": "Draft FTPC Annotations Replace Endpoint", "type": "object", "description": "Schema for Draft FTPC Annotations", "properties": { From 7d6bbaaa4c156074c2ac81bc77c951917e0b5250 Mon Sep 17 00:00:00 2001 From: Anna Grancharova Date: Fri, 26 Jul 2024 12:47:15 +0300 Subject: [PATCH 2/3] fixed typo --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 38eee43..09dcf1b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -14,7 +14,7 @@ executors: ANNOTATIONS_ENDPOINT: http://localhost:9000/content/%v/annotations INTERNAL_CONCORDANCES_ENDPOINT: http://localhost:9000/internalconcordances JSON_SCHEMAS_PATH: ./schemas - JSON_SCHEMA_NAME: draft-annotations-pac-add.json;draft-annotations-pac-replace.json;draft-annotations-pac-write.json;draft-annotations-sv-add.json;draft-annotations-sv-replace.json;draft-annotations-sv-write.json;draft-annotations-ftpc-add.json;draft-annotations-ftpc-replace.json;draft-annotations-ftpc-write.json; draft-annotations-fta-add.json;draft-annotations-fta-replace.json;draft-annotations-fta-write.json + JSON_SCHEMA_NAME: draft-annotations-pac-add.json;draft-annotations-pac-replace.json;draft-annotations-pac-write.json;draft-annotations-sv-add.json;draft-annotations-sv-replace.json;draft-annotations-sv-write.json;draft-annotations-ftpc-add.json;draft-annotations-ftpc-replace.json;draft-annotations-ftpc-write.json;draft-annotations-fta-add.json;draft-annotations-fta-replace.json;draft-annotations-fta-write.json JSON_SCHEMAS_API_CONFIG_PATH: ./config/schemas-api-config.json OPA_ADDRESS: "http://localhost:8181" From 15a371f7c205dc8b9cf75a1460d0646b4387e706 Mon Sep 17 00:00:00 2001 From: Anna Grancharova Date: Fri, 26 Jul 2024 13:11:52 +0300 Subject: [PATCH 3/3] fixed: missing quotation mark --- helm/draft-annotations-api/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/draft-annotations-api/values.yaml b/helm/draft-annotations-api/values.yaml index c976cad..a7bbd1e 100644 --- a/helm/draft-annotations-api/values.yaml +++ b/helm/draft-annotations-api/values.yaml @@ -19,7 +19,7 @@ env: ANNOTATIONS_ENDPOINT: "" # This should be defined in the specific app-configs folder INTERNAL_CONCORDANCES_ENDPOINT: "" # This should be defined in the specific app-configs folder JSON_SCHEMAS_PATH: "/schemas" - JSON_SCHEMA_NAME: "draft-annotations-pac-add.json;draft-annotations-pac-replace.json;draft-annotations-pac-write.json;draft-annotations-sv-add.json;draft-annotations-sv-replace.json;draft-annotations-sv-write.json;draft-annotations-ftpc-add.json;draft-annotations-ftpc-replace.json;draft-annotations-ftpc-write.json;draft-annotations-fta-add.json;draft-annotations-fta-replace.json;draft-annotations-fta-write.json + JSON_SCHEMA_NAME: "draft-annotations-pac-add.json;draft-annotations-pac-replace.json;draft-annotations-pac-write.json;draft-annotations-sv-add.json;draft-annotations-sv-replace.json;draft-annotations-sv-write.json;draft-annotations-ftpc-add.json;draft-annotations-ftpc-replace.json;draft-annotations-ftpc-write.json;draft-annotations-fta-add.json;draft-annotations-fta-replace.json;draft-annotations-fta-write.json" JSON_SCHEMAS_API_CONFIG_PATH: "/config/schemas-api-config.json" openPolicyAgentSidecar: name: open-policy-agent