diff --git a/__integrations__/__mocks__/server/io-functions-service-messages.mock.ts b/__integrations__/__mocks__/server/io-functions-service-messages.mock.ts index fbf30b41..1d9e1ed0 100644 --- a/__integrations__/__mocks__/server/io-functions-service-messages.mock.ts +++ b/__integrations__/__mocks__/server/io-functions-service-messages.mock.ts @@ -10,14 +10,14 @@ export const startServer = async ( console.log("remote-contents", _.url); if ( _.url?.startsWith( - "/service-messages/manage/api/v1/remote-contents/configurations/01HQRD0YCVDXF1XDW634N87XCG" + "/api/v1/messages-sending/remote-contents/configurations/01HQRD0YCVDXF1XDW634N87XCG" ) ) { console.log("matched call with existing configuration"); mockGetRCConfiguration(response); } else if ( _.url?.startsWith( - "/service-messages/manage/api/v1/remote-contents/configurations/01HQRD0YCVDXF1XDW634N87XCF" + "/api/v1/messages-sending/remote-contents/configurations/01HQRD0YCVDXF1XDW634N87XCF" ) ) { console.log("matched call with not existing configuration"); diff --git a/openapi/index.yaml b/openapi/index.yaml index 2a05a48b..2319ca7a 100644 --- a/openapi/index.yaml +++ b/openapi/index.yaml @@ -1052,6 +1052,296 @@ paths: description: Internal server error schema: $ref: '#/definitions/ProblemJson' + /messages-sending/remote-contents/configurations: + post: + tags: + - remote-content + operationId: createRCConfiguration + security: + - ManageSubscriptionKey: [] + summary: Create a new remote-content configuration + description: Create a new remote-content configuration using the provided payload + parameters: + - in: body + name: body + required: true + schema: + $ref: '#/definitions/NewRCConfigurationPublic' + x-examples: + text/json: | + "name": "Descriptive congiguration name", + "description": "Configuration description", + "has_precondition": "NEVER", + "disable_lollipop_for": [ + "DIXDPZ44E08F367A" + ], + "is_lollipop_enabled": false, + "test_environment": { + "base_url": "string", + "details_authentication": { + "header_key_name": "string", + "key": "string", + "type": "API-KEY" + }, + "test_users": [ + "DIXDPZ44E08F367A" + ] + }, + "prod_environment": { + "base_url": "string", + "details_authentication": { + "header_key_name": "string", + "key": "string", + "type": "API-KEY", + } + } + responses: + '201': + description: Configuration created + schema: + $ref: '#/definitions/RCConfigurationPublic' + examples: + text/json: | + "configuration_id": "01ARZ3NDEKTSV4RRFFQ69G5FAV", + "name": "Configuration name", + "description": "Configuration description", + "has_precondition": "NEVER", + "disable_lollipop_for": [ + "DIXDPZ44E08F367A" + ], + "is_lollipop_enabled": false, + "test_environment": { + "base_url": "string", + "details_authentication": { + "header_key_name": "string", + "key": "string", + "type": "API-KEY" + }, + "test_users": [ + "DIXDPZ44E08F367A" + ] + }, + "prod_environment": { + "base_url": "string", + "details_authentication": { + "header_key_name": "string", + "key": "string", + "type": "API-KEY", + } + } + '400': + description: Bad request + schema: + $ref: '#/definitions/ProblemJson' + '500': + description: There was an error creating the configuration. + schema: + $ref: '#/definitions/ProblemJson' + consumes: + - application/json + produces: + - application/json + get: + tags: + - remote-content + operationId: listRCConfiguration + security: + - ManageSubscriptionKey: [] + summary: Get all the owned remote-content configurations + description: Get all the owned remote-content configurations + responses: + '200': + description: Return the configurations + schema: + $ref: '#/definitions/RCConfigurationListResponse' + examples: + text/json: | + rcConfigList: [ + { + "configuration_id": "01ARZ3NDEKTSV4RRFFQ69G5FAV", + "name": "Configuration name", + "description": "Configuration description", + "has_precondition": "NEVER", + "disable_lollipop_for": [ + "DIXDPZ44E08F367A" + ], + "is_lollipop_enabled": false, + "test_environment": { + "base_url": "string", + "details_authentication": { + "header_key_name": "string", + "key": "string", + "type": "API-KEY" + }, + "test_users": [ + "DIXDPZ44E08F367A" + ] + }, + "prod_environment": { + "base_url": "string", + "details_authentication": { + "header_key_name": "string", + "key": "string", + "type": "API-KEY", + } + } + } + ] + '400': + description: Bad request + schema: + $ref: '#/definitions/ProblemJson' + '403': + description: Request not authorized. + '404': + description: Resource not found. + '500': + description: There was an error trying to get the configurations. + schema: + $ref: '#/definitions/ProblemJson' + consumes: + - application/json + produces: + - application/json + /messages-sending/remote-contents/configurations/{configurationId}: + get: + tags: + - remote-content + operationId: getRCConfiguration + security: + - ManageSubscriptionKey: [] + summary: Get the remote-content configuration identified by the configurationId + description: >- + Get the remote-content configuration using the provided configurationId + passed as path param + parameters: + - in: path + name: configurationId + required: true + type: string + description: Ulid string. + format: Ulid + x-import: '@pagopa/ts-commons/lib/strings' + responses: + '200': + description: Return the configuration + schema: + $ref: '#/definitions/RCConfigurationResponse' + examples: + text/json: | + "configuration_id": "01ARZ3NDEKTSV4RRFFQ69G5FAV", + "name": "Configuration name", + "description": "Configuration description", + "has_precondition": "NEVER", + "disable_lollipop_for": [ + "DIXDPZ44E08F367A" + ], + "is_lollipop_enabled": false, + "test_environment": { + "base_url": "string", + "details_authentication": { + "header_key_name": "string", + "key": "string", + "type": "API-KEY" + }, + "test_users": [ + "DIXDPZ44E08F367A" + ] + }, + "prod_environment": { + "base_url": "string", + "details_authentication": { + "header_key_name": "string", + "key": "string", + "type": "API-KEY", + } + } + '400': + description: Bad request + schema: + $ref: '#/definitions/ProblemJson' + '403': + description: Request not authorized. + '404': + description: Resource not found. + '500': + description: There was an error trying to get the configuration. + schema: + $ref: '#/definitions/ProblemJson' + consumes: + - application/json + produces: + - application/json + put: + tags: + - remote-content + operationId: updateRCConfiguration + security: + - ManageSubscriptionKey: [] + summary: Update an existing remote-content configuration + description: >- + Update an existing remote-content configuration using the provided + payload + parameters: + - in: body + name: body + required: true + schema: + $ref: '#/definitions/NewRCConfigurationPublic' + x-examples: + text/json: | + "name": "Descriptive congiguration name", + "description": "Configuration description", + "has_precondition": "NEVER", + "disable_lollipop_for": [ + "DIXDPZ44E08F367A" + ], + "is_lollipop_enabled": false, + "test_environment": { + "base_url": "string", + "details_authentication": { + "header_key_name": "string", + "key": "string", + "type": "API-KEY" + }, + "test_users": [ + "DIXDPZ44E08F367A" + ] + }, + "prod_environment": { + "base_url": "string", + "details_authentication": { + "header_key_name": "string", + "key": "string", + "type": "API-KEY", + } + } + - in: path + name: configurationId + required: true + type: string + description: Ulid string. + format: Ulid + x-import: '@pagopa/ts-commons/lib/strings' + responses: + '204': + description: Configuration updated + '400': + description: Bad request + schema: + $ref: '#/definitions/ProblemJson' + '403': + description: Request not authorized. + '404': + description: Resource not found. + '500': + description: There was an error updating the configuration. + schema: + $ref: '#/definitions/ProblemJson' + consumes: + - application/json + produces: + - application/json definitions: ActivationStatus: type: string @@ -2249,6 +2539,129 @@ definitions: - deleted - published - unpublished + RCConfigurationId: + type: string + description: Ulid string. + format: Ulid + x-import: '@pagopa/ts-commons/lib/strings' + example: 01ARZ3NDEKTSV4RRFFQ69G5FAV + RCConfigurationPublic: + allOf: + - $ref: '#/definitions/RCConfigurationBase' + - $ref: '#/definitions/RCConfigurationEnvironment' + NewRCConfigurationBase: + type: object + properties: + name: + type: string + minLength: 1 + description: Configuration name. + description: + type: string + minLength: 1 + description: Configuration description. + has_precondition: + $ref: '#/definitions/HasPrecondition' + disable_lollipop_for: + type: array + items: + type: string + description: User's fiscal code. + format: FiscalCode + x-import: '@pagopa/ts-commons/lib/strings' + example: SPNDNL80R13C555X + is_lollipop_enabled: + type: boolean + description: Flag to check if lollipop is enabled + required: + - name + - description + - has_precondition + - disable_lollipop_for + - is_lollipop_enabled + NewRCConfigurationPublic: + allOf: + - $ref: '#/definitions/NewRCConfigurationBase' + - $ref: '#/definitions/RCConfigurationEnvironment' + RCConfigurationBase: + allOf: + - $ref: '#/definitions/NewRCConfigurationBase' + - type: object + properties: + configuration_id: + type: string + description: Ulid string. + format: Ulid + x-import: '@pagopa/ts-commons/lib/strings' + example: 01ARZ3NDEKTSV4RRFFQ69G5FAV + required: + - configuration_id + RCConfigurationEnvironment: + type: object + properties: + test_environment: + $ref: '#/definitions/RCConfigurationTestEnvironment' + prod_environment: + $ref: '#/definitions/RCConfigurationProdEnvironment' + RCConfigurationProdEnvironment: + type: object + properties: + base_url: + type: string + minLength: 1 + description: Base url of the server. + details_authentication: + $ref: '#/definitions/RCAuthenticationConfig' + required: + - base_url + - details_authentication + RCAuthenticationConfig: + type: object + properties: + header_key_name: + type: string + minLength: 1 + description: header key name + key: + type: string + minLength: 1 + description: authentication config key + type: + type: string + minLength: 1 + description: authentication config type + required: + - header_key_name + - key + - type + RCConfigurationTestEnvironment: + allOf: + - $ref: '#/definitions/RCConfigurationProdEnvironment' + - type: object + properties: + test_users: + type: array + items: + $ref: '#/definitions/FiscalCode' + required: + - test_users + RCConfigurationListResponse: + type: object + properties: + rcConfigList: + type: array + items: + $ref: '#/definitions/RCConfigurationResponse' + RCConfigurationResponse: + allOf: + - $ref: '#/definitions/RCConfigurationPublic' + - type: object + properties: + user_id: + type: string + minLength: 1 + required: + - user_id responses: {} parameters: LegalMail: diff --git a/openapi/index.yaml.template b/openapi/index.yaml.template index 815faa5a..edb3e923 100644 --- a/openapi/index.yaml.template +++ b/openapi/index.yaml.template @@ -99,7 +99,7 @@ info: the message has been notified to the recipient. host: api.io.pagopa.it -basePath: "/api/v1" +basePath: /api/v1 schemes: - https paths: @@ -994,6 +994,298 @@ paths: description: Internal server error schema: $ref: "#/definitions/ProblemJson" + + "/messages-sending/remote-contents/configurations": + post: + tags: + - remote-content + operationId: createRCConfiguration + security: + - ManageSubscriptionKey: [] + summary: Create a new remote-content configuration + description: Create a new remote-content configuration using the provided payload + parameters: + - in: body + name: body + required: true + schema: + $ref: "#/definitions/NewRCConfigurationPublic" + x-examples: + text/json: | + "name": "Descriptive congiguration name", + "description": "Configuration description", + "has_precondition": "NEVER", + "disable_lollipop_for": [ + "DIXDPZ44E08F367A" + ], + "is_lollipop_enabled": false, + "test_environment": { + "base_url": "string", + "details_authentication": { + "header_key_name": "string", + "key": "string", + "type": "API-KEY" + }, + "test_users": [ + "DIXDPZ44E08F367A" + ] + }, + "prod_environment": { + "base_url": "string", + "details_authentication": { + "header_key_name": "string", + "key": "string", + "type": "API-KEY", + } + } + responses: + "201": + description: Configuration created + schema: + $ref: "#/definitions/RCConfigurationPublic" + examples: + text/json: | + "configuration_id": "01ARZ3NDEKTSV4RRFFQ69G5FAV", + "name": "Configuration name", + "description": "Configuration description", + "has_precondition": "NEVER", + "disable_lollipop_for": [ + "DIXDPZ44E08F367A" + ], + "is_lollipop_enabled": false, + "test_environment": { + "base_url": "string", + "details_authentication": { + "header_key_name": "string", + "key": "string", + "type": "API-KEY" + }, + "test_users": [ + "DIXDPZ44E08F367A" + ] + }, + "prod_environment": { + "base_url": "string", + "details_authentication": { + "header_key_name": "string", + "key": "string", + "type": "API-KEY", + } + } + "400": + description: Bad request + schema: + $ref: "#/definitions/ProblemJson" + "500": + description: >- + There was an error creating the configuration. + schema: + $ref: "#/definitions/ProblemJson" + consumes: + - application/json + produces: + - application/json + get: + tags: + - remote-content + operationId: listRCConfiguration + security: + - ManageSubscriptionKey: [] + summary: Get all the owned remote-content configurations + description: Get all the owned remote-content configurations + responses: + "200": + description: Return the configurations + schema: + $ref: "#/definitions/RCConfigurationListResponse" + examples: + text/json: | + rcConfigList: [ + { + "configuration_id": "01ARZ3NDEKTSV4RRFFQ69G5FAV", + "name": "Configuration name", + "description": "Configuration description", + "has_precondition": "NEVER", + "disable_lollipop_for": [ + "DIXDPZ44E08F367A" + ], + "is_lollipop_enabled": false, + "test_environment": { + "base_url": "string", + "details_authentication": { + "header_key_name": "string", + "key": "string", + "type": "API-KEY" + }, + "test_users": [ + "DIXDPZ44E08F367A" + ] + }, + "prod_environment": { + "base_url": "string", + "details_authentication": { + "header_key_name": "string", + "key": "string", + "type": "API-KEY", + } + } + } + ] + "400": + description: Bad request + schema: + $ref: "#/definitions/ProblemJson" + "403": + description: Request not authorized. + "404": + description: Resource not found. + "500": + description: >- + There was an error trying to get the configurations. + schema: + $ref: "#/definitions/ProblemJson" + consumes: + - application/json + produces: + - application/json + "/messages-sending/remote-contents/configurations/{configurationId}": + get: + tags: + - remote-content + operationId: getRCConfiguration + security: + - ManageSubscriptionKey: [] + summary: Get the remote-content configuration identified by the configurationId + description: Get the remote-content configuration using the provided configurationId passed as path param + parameters: + - in: path + name: configurationId + required: true + type: string + description: Ulid string. + format: Ulid + x-import: "@pagopa/ts-commons/lib/strings" + responses: + "200": + description: Return the configuration + schema: + $ref: "#/definitions/RCConfigurationResponse" + examples: + text/json: | + "configuration_id": "01ARZ3NDEKTSV4RRFFQ69G5FAV", + "name": "Configuration name", + "description": "Configuration description", + "has_precondition": "NEVER", + "disable_lollipop_for": [ + "DIXDPZ44E08F367A" + ], + "is_lollipop_enabled": false, + "test_environment": { + "base_url": "string", + "details_authentication": { + "header_key_name": "string", + "key": "string", + "type": "API-KEY" + }, + "test_users": [ + "DIXDPZ44E08F367A" + ] + }, + "prod_environment": { + "base_url": "string", + "details_authentication": { + "header_key_name": "string", + "key": "string", + "type": "API-KEY", + } + } + "400": + description: Bad request + schema: + $ref: "#/definitions/ProblemJson" + "403": + description: Request not authorized. + "404": + description: Resource not found. + "500": + description: >- + There was an error trying to get the configuration. + schema: + $ref: "#/definitions/ProblemJson" + consumes: + - application/json + produces: + - application/json + put: + tags: + - remote-content + operationId: updateRCConfiguration + security: + - ManageSubscriptionKey: [] + summary: Update an existing remote-content configuration + description: Update an existing remote-content configuration using the provided payload + parameters: + - in: body + name: body + required: true + schema: + $ref: "#/definitions/NewRCConfigurationPublic" + x-examples: + text/json: | + "name": "Descriptive congiguration name", + "description": "Configuration description", + "has_precondition": "NEVER", + "disable_lollipop_for": [ + "DIXDPZ44E08F367A" + ], + "is_lollipop_enabled": false, + "test_environment": { + "base_url": "string", + "details_authentication": { + "header_key_name": "string", + "key": "string", + "type": "API-KEY" + }, + "test_users": [ + "DIXDPZ44E08F367A" + ] + }, + "prod_environment": { + "base_url": "string", + "details_authentication": { + "header_key_name": "string", + "key": "string", + "type": "API-KEY", + } + } + - in: path + name: configurationId + required: true + type: string + description: Ulid string. + format: Ulid + x-import: "@pagopa/ts-commons/lib/strings" + responses: + "204": + description: Configuration updated + "400": + description: Bad request + schema: + $ref: "#/definitions/ProblemJson" + "403": + description: Request not authorized. + "404": + description: Resource not found. + "500": + description: >- + There was an error updating the configuration. + schema: + $ref: "#/definitions/ProblemJson" + consumes: + - application/json + produces: + - application/json + definitions: ActivationStatus: $ref: "../node_modules/@pagopa/io-functions-commons/openapi/definitions.yaml#/ActivationStatus" @@ -1499,6 +1791,129 @@ definitions: A Service History record contains either publication or lifecycle items, so can have a combination of Service lifecycle status and publication status
type: string enum: [draft, submitted, approved, rejected, deleted, published, unpublished] + RCConfigurationId: + type: string + description: Ulid string. + format: Ulid + x-import: '@pagopa/ts-commons/lib/strings' + example: 01ARZ3NDEKTSV4RRFFQ69G5FAV + RCConfigurationPublic: + allOf: + - $ref: '#/definitions/RCConfigurationBase' + - $ref: '#/definitions/RCConfigurationEnvironment' + NewRCConfigurationBase: + type: object + properties: + name: + type: string + minLength: 1 + description: Configuration name. + description: + type: string + minLength: 1 + description: Configuration description. + has_precondition: + $ref: '#/definitions/HasPrecondition' + disable_lollipop_for: + type: array + items: + type: string + description: User's fiscal code. + format: FiscalCode + x-import: '@pagopa/ts-commons/lib/strings' + example: SPNDNL80R13C555X + is_lollipop_enabled: + type: boolean + description: Flag to check if lollipop is enabled + required: + - name + - description + - has_precondition + - disable_lollipop_for + - is_lollipop_enabled + NewRCConfigurationPublic: + allOf: + - $ref: '#/definitions/NewRCConfigurationBase' + - $ref: '#/definitions/RCConfigurationEnvironment' + RCConfigurationBase: + allOf: + - $ref: '#/definitions/NewRCConfigurationBase' + - type: object + properties: + configuration_id: + type: string + description: Ulid string. + format: Ulid + x-import: '@pagopa/ts-commons/lib/strings' + example: 01ARZ3NDEKTSV4RRFFQ69G5FAV + required: + - configuration_id + RCConfigurationEnvironment: + type: object + properties: + test_environment: + $ref: '#/definitions/RCConfigurationTestEnvironment' + prod_environment: + $ref: '#/definitions/RCConfigurationProdEnvironment' + RCConfigurationProdEnvironment: + type: object + properties: + base_url: + type: string + minLength: 1 + description: Base url of the server. + details_authentication: + $ref: '#/definitions/RCAuthenticationConfig' + required: + - base_url + - details_authentication + RCAuthenticationConfig: + type: object + properties: + header_key_name: + type: string + minLength: 1 + description: header key name + key: + type: string + minLength: 1 + description: authentication config key + type: + type: string + minLength: 1 + description: authentication config type + required: + - header_key_name + - key + - type + RCConfigurationTestEnvironment: + allOf: + - $ref: '#/definitions/RCConfigurationProdEnvironment' + - type: object + properties: + test_users: + type: array + items: + $ref: '#/definitions/FiscalCode' + required: + - test_users + RCConfigurationListResponse: + type: object + properties: + rcConfigList: + type: array + items: + $ref: '#/definitions/RCConfigurationResponse' + RCConfigurationResponse: + allOf: + - $ref: '#/definitions/RCConfigurationPublic' + - type: object + properties: + user_id: + type: string + minLength: 1 + required: + - user_id responses: {} parameters: diff --git a/package.json b/package.json index a6b6c8bf..d9b2e683 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "generate:definitions": "rimraf ./generated/definitions && shx mkdir -p ./generated/definitions && gen-api-models --api-spec ./openapi/index.yaml --no-strict --out-dir ./generated/definitions", "generate:payment-updater": "rimraf generated/payment-updater && shx mkdir -p generated/payment-updater && gen-api-models --api-spec ./openapi/payment-updater.yaml --no-strict --out-dir ./generated/payment-updater --request-types --response-decoders --client", "generate:templates:messagepreview": "shx rm -rf generated/templates/messagepreview && shx mkdir -p generated/templates/messagepreview && ts-node template_reduced_script.ts v1.0.10 \"generated/templates/messagepreview/index\"", - "generate:messages-services-api": "rimraf generated/messages-services-api && gen-api-models --api-spec https://raw.githubusercontent.com/pagopa/io-functions-service-messages/master/openapi/index_external.yaml --no-strict --out-dir generated/messages-services-api --request-types --response-decoders --client", + "generate:messages-services-api": "rimraf generated/messages-services-api && gen-api-models --api-spec https://raw.githubusercontent.com/pagopa/io-functions-services-messages/master/openapi/index_external.yaml --no-strict --out-dir generated/messages-services-api --request-types --response-decoders --client", "openapi:bundle": "bundle-api-spec -i openapi/index.yaml.template -o openapi/index.yaml -V $npm_package_version", "openapi:validate": "oval validate -p openapi/index.yaml", "dist:modules": "modclean -r -n default:safe && yarn install --production",