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

[#171211343] Adds user-data-processing API #584

Merged
merged 5 commits into from
Mar 4, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
148 changes: 110 additions & 38 deletions api_backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -645,84 +645,148 @@ paths:
description: Unavailable service
schema:
$ref: "#/definitions/ProblemJson"

"/user-data-processing":
x-swagger-router-controller: UserDataProcessingController
post:
operationId: upsertUserDataProcessing
summary: Set User's data processing choices
description: Let the authenticated user express his will to retrieve or delete his stored data.
parameters:
- in: body
name: body
schema:
$ref: "#/definitions/UserDataProcessingChoiceRequest"
required: true
responses:
'200':
description: User Data processing created / updated.
schema:
$ref: "#/definitions/UserDataProcessing"
"400":
description: Invalid payload.
schema:
$ref: "#/definitions/ProblemJson"
"401":
description: Bearer token null or expired.
"409":
description: Conflict.
schema:
$ref: "#/definitions/ProblemJson"
"429":
description: Too may requests
"500":
description: User Data processing choice cannot be taken in charge.
schema:
$ref: "#/definitions/ProblemJson"
"/user-data-processing/{choice}":
x-swagger-router-controller: UserDataProcessingController
get:
operationId: getUserDataProcessing
summary: Get User's data processing
description: Get the user's request to delete or download his stored data by providing a kind of choice.
parameters:
- $ref: "#/parameters/UserDataProcessingChoiceParam"
responses:
"200":
description: User data processing retrieved
schema:
$ref: "#/definitions/UserDataProcessing"
"401":
description: Bearer token null or expired.
"404":
description: Not found.
schema:
$ref: "#/definitions/ProblemJson"
"429":
Copy link
Contributor

Choose a reason for hiding this comment

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

it is not clear on why this may return 429 and upsertUserDataProcessing does not

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's my fault, this may return 429 as GetUserDataProcessing ( IResponseErrorTooManyRequests is provided by the controller's method )

description: Too many requests
definitions:
# Definitions from the digital citizenship APIs
AcceptedTosVersion:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/AcceptedTosVersion"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/AcceptedTosVersion"
BlockedInboxOrChannels:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/BlockedInboxOrChannels"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/BlockedInboxOrChannels"
DepartmentName:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/DepartmentName"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/DepartmentName"
EmailAddress:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/EmailAddress"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/EmailAddress"
Profile:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/Profile"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/Profile"
ExtendedProfile:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/ExtendedProfile"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/ExtendedProfile"
FiscalCode:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/FiscalCode"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/FiscalCode"
IsEmailEnabled:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/IsEmailEnabled"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/IsEmailEnabled"
IsInboxEnabled:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/IsInboxEnabled"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/IsInboxEnabled"
IsEmailValidated:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/IsEmailValidated"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/IsEmailValidated"
IsWebhookEnabled:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/IsWebhookEnabled"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/IsWebhookEnabled"
LimitedProfile:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/LimitedProfile"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/LimitedProfile"
MessageBodyMarkdown:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/MessageBodyMarkdown"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/MessageBodyMarkdown"
MessageContent:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/MessageContent"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/MessageContent"
MessageResponseNotificationStatus:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/MessageResponseNotificationStatus"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/MessageResponseNotificationStatus"
NotificationChannelStatusValue:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/NotificationChannelStatusValue"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/NotificationChannelStatusValue"
NotificationChannel:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/NotificationChannel"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/NotificationChannel"
MessageSubject:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/MessageSubject"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/MessageSubject"
OrganizationName:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/OrganizationName"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/OrganizationName"
PaginationResponse:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/PaginationResponse"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/PaginationResponse"
PreferredLanguage:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/PreferredLanguage"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/PreferredLanguage"
PreferredLanguages:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/PreferredLanguages"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/PreferredLanguages"
ProblemJson:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/ProblemJson"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/ProblemJson"
ServiceId:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/ServiceId"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/ServiceId"
ServiceName:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/ServiceName"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/ServiceName"
ServicePublic:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/ServicePublic"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/ServicePublic"
ServiceTuple:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/ServiceTuple"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/ServiceTuple"
PaginatedServiceTupleCollection:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/PaginatedServiceTupleCollection"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/PaginatedServiceTupleCollection"
Timestamp:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/Timestamp"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/Timestamp"
PaymentNoticeNumber:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/PaymentNoticeNumber"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/PaymentNoticeNumber"
PaymentAmount:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/PaymentAmount"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/PaymentAmount"
PaymentData:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/PaymentData"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/PaymentData"
TimeToLiveSeconds:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/TimeToLiveSeconds"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/TimeToLiveSeconds"
CreatedMessageWithContent:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/CreatedMessageWithContent"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/CreatedMessageWithContent"
CreatedMessageWithoutContent:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/CreatedMessageWithoutContent"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/CreatedMessageWithoutContent"
CreatedMessageWithoutContentCollection:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/CreatedMessageWithoutContentCollection"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/CreatedMessageWithoutContentCollection"
PaginatedCreatedMessageWithoutContentCollection:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/PaginatedCreatedMessageWithoutContentCollection"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/PaginatedCreatedMessageWithoutContentCollection"
UserDataProcessingStatus:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/UserDataProcessingStatus"
UserDataProcessingChoice:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/UserDataProcessingChoice"
UserDataProcessingChoiceRequest:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/UserDataProcessingChoiceRequest"
UserDataProcessing:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/UserDataProcessing"
MessageResponseWithContent:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.8.0/openapi/definitions.yaml#/MessageResponseWithContent"
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v1.12.1/openapi/definitions.yaml#/MessageResponseWithContent"

# Definitions from pagopa-proxy
PaymentProblemJson:
$ref: "https://raw.githubusercontent.com/pagopa/io-pagopa-proxy/v0.8.6/api_pagopa.yaml#/definitions/PaymentProblemJson"
Expand Down Expand Up @@ -955,6 +1019,14 @@ parameters:
in: query
minimum: 1
description: An opaque identifier that points to the next item in the collection.
UserDataProcessingChoiceParam:
name: choice
in: path
type: string
enum: [DOWNLOAD, DELETE]
description: A representation of a user data processing choice
required: true
x-example: DOWNLOAD
consumes:
- application/json
produces:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"generate:proxy:notification-models": "rimraf generated/notifications && mkdir -p generated/notifications && gen-api-models --api-spec api_notifications.yaml --out-dir generated/notifications",
"generate:proxy:pagopa-models": "rimraf generated/pagopa && mkdir -p generated/pagopa && gen-api-models --api-spec api_pagopa.yaml --out-dir generated/pagopa",
"generate:proxy:public-models": "rimraf generated/public && mkdir -p generated/public && gen-api-models --api-spec api_public.yaml --out-dir generated/public",
"generate:api:io": "rimraf generated/io-api && mkdir -p generated/io-api && gen-api-models --api-spec https://raw.githubusercontent.com/pagopa/io-functions-app/v0.7.0/openapi/index.yaml --no-strict --out-dir generated/io-api --request-types --response-decoders",
"generate:api:io": "rimraf generated/io-api && mkdir -p generated/io-api && gen-api-models --api-spec https://raw.githubusercontent.com/pagopa/io-functions-app/v0.9.0/openapi/index.yaml --no-strict --out-dir generated/io-api --request-types --response-decoders",
"generate:api:pagopaproxy": "rimraf generated/pagopa-proxy && mkdir -p generated/pagopa-proxy && gen-api-models --api-spec https://raw.githubusercontent.com/pagopa/io-pagopa-proxy/v0.8.6/api_pagopa.yaml --no-strict --out-dir generated/pagopa-proxy --request-types --response-decoders",
"generate:test-certs": "./scripts/generate-test-certs.sh certs",
"postversion": "git push && git push --tags"
Expand Down
35 changes: 33 additions & 2 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@ import { withSpid } from "@pagopa/io-spid-commons";
import { toError } from "fp-ts/lib/Either";
import { tryCatch } from "fp-ts/lib/TaskEither";
import { VersionPerPlatform } from "../generated/public/VersionPerPlatform";
import UserDataProcessingController from "./controllers/userDataProcessingController";
import MessagesService from "./services/messagesService";
import PagoPAProxyService from "./services/pagoPAProxyService";
import ProfileService from "./services/profileService";
import RedisSessionStorage from "./services/redisSessionStorage";
import RedisUserMetadataStorage from "./services/redisUserMetadataStorage";
import TokenService from "./services/tokenService";
import UserDataProcessingService from "./services/userDataProcessingService";

const defaultModule = {
newApp
Expand Down Expand Up @@ -175,6 +177,11 @@ export function newApp(
// Create the profile service
const PROFILE_SERVICE = new ProfileService(API_CLIENT);

// Create the user data processing service
const USER_DATA_PROCESSING_SERVICE = new UserDataProcessingService(
API_CLIENT
);

const acsController: AuthenticationController = new AuthenticationController(
SESSION_STORAGE,
TOKEN_SERVICE,
Expand Down Expand Up @@ -204,7 +211,8 @@ export function newApp(
NOTIFICATION_SERVICE,
SESSION_STORAGE,
PAGOPA_PROXY_SERVICE,
USER_METADATA_STORAGE
USER_METADATA_STORAGE,
USER_DATA_PROCESSING_SERVICE
);
registerPagoPARoutes(
app,
Expand Down Expand Up @@ -268,7 +276,8 @@ function registerAPIRoutes(
notificationService: NotificationService,
sessionStorage: RedisSessionStorage,
pagoPaProxyService: PagoPAProxyService,
userMetadataStorage: RedisUserMetadataStorage
userMetadataStorage: RedisUserMetadataStorage,
userDataProcessingService: UserDataProcessingService
): void {
const bearerTokenAuth = passport.authenticate("bearer", { session: false });
const urlTokenAuth = passport.authenticate("authtoken", { session: false });
Expand Down Expand Up @@ -302,6 +311,10 @@ function registerAPIRoutes(
userMetadataStorage
);

const userDataProcessingController: UserDataProcessingController = new UserDataProcessingController(
userDataProcessingService
);

app.get(
`${basePath}/profile`,
bearerTokenAuth,
Expand Down Expand Up @@ -344,6 +357,24 @@ function registerAPIRoutes(
)
);

app.post(
`${basePath}/user-data-processing`,
bearerTokenAuth,
toExpressHandler(
userDataProcessingController.upsertUserDataProcessing,
userDataProcessingController
)
);

app.get(
`${basePath}/user-data-processing/:choice`,
bearerTokenAuth,
toExpressHandler(
userDataProcessingController.getUserDataProcessing,
userDataProcessingController
)
);

app.get(
`${basePath}/messages`,
bearerTokenAuth,
Expand Down
Loading