Skip to content

Commit 19f86aa

Browse files
authored
Merge pull request #257 from Scalingo/feat/improve-data-consent
2 parents 98cf2c1 + 4309524 commit 19f86aa

File tree

10 files changed

+114
-112
lines changed

10 files changed

+114
-112
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
## 0.6.5 (unreleased)
1+
## 0.7.0 (unreleased)
22

33
* chore: bump dependencies
4+
* feat(data consent): update modelisation and signature calls (preview endpoint)
45

56
## 0.6.4
67

src/DataAccessConsent/index.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import {
2+
CreateParams,
3+
UpdateParams,
4+
} from "src/params/regional/data_access_consent";
5+
6+
import { Client } from "..";
7+
import { DataAccessConsent as DataAccessConsentModel } from "../models/regional";
8+
import { unpackData } from "../utils";
9+
10+
/**
11+
* Data Access Consent API Client
12+
*/
13+
export default class DataAccessConsent {
14+
/** Scalingo API Client */
15+
_client: Client;
16+
17+
/**
18+
* Create a new "thematic" client
19+
* @param client Scalingo API Client
20+
*/
21+
constructor(client: Client) {
22+
this._client = client;
23+
}
24+
25+
/**
26+
* Create a DataAccessConsent
27+
* @see https://developers.scalingo.com/data_access_consent#create-a-new-dataaccessconsent
28+
* @param appId ID of the app we're interested in
29+
*/
30+
create(appId: string, params: CreateParams): Promise<DataAccessConsentModel> {
31+
return unpackData(
32+
this._client.apiClient().post(`/apps/${appId}/data_access_consent`, {
33+
data_access_consent: params,
34+
}),
35+
"data_access_consent"
36+
);
37+
}
38+
39+
/**
40+
* Create a DataAccessConsent
41+
* @see https://developers.scalingo.com/data_access_consent#create-a-new-dataaccessconsent
42+
* @param appId ID of the app we're interested in
43+
*/
44+
update(appId: string, params: UpdateParams): Promise<DataAccessConsentModel> {
45+
return unpackData(
46+
this._client.apiClient().patch(`/apps/${appId}/data_access_consent`, {
47+
data_access_consent: params,
48+
}),
49+
"data_access_consent"
50+
);
51+
}
52+
}

src/DataAccessConsents/index.ts

Lines changed: 0 additions & 54 deletions
This file was deleted.

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Collaborators from "./Collaborators";
1010
import Containers from "./Containers";
1111
import Contracts from "./Contracts";
1212
import CronTasks from "./CronTasks";
13-
import DataAccessConsents from "./DataAccessConsents";
13+
import DataAccessConsent from "./DataAccessConsent";
1414
import Deployments from "./Deployments";
1515
import Domains from "./Domains";
1616
import Environment from "./Environment";
@@ -93,7 +93,7 @@ export class Client {
9393
Containers = new Containers(this);
9494
Contracts = new Contracts(this);
9595
CronTasks = new CronTasks(this);
96-
DataAccessConsents = new DataAccessConsents(this);
96+
DataAccessConsent = new DataAccessConsent(this);
9797
Deployments = new Deployments(this);
9898
Domains = new Domains(this);
9999
Environment = new Environment(this);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export interface DataAccessConsent {
2+
/** UUID of the related application */
3+
app_id: string;
4+
/** UUID of the person who granted the access */
5+
user_id: string;
6+
/** Databases access granted until */
7+
databases_until: string | null;
8+
/** Containers access granted until */
9+
containers_until: string | null;
10+
}

src/models/regional/data_access_consents.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/models/regional/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export * from "./autoscalers";
66
export * from "./collaborators";
77
export * from "./containers";
88
export * from "./cron_tasks";
9-
export * from "./data_access_consents";
9+
export * from "./data_access_consent";
1010
export * from "./deployments";
1111
export * from "./domains";
1212
export * from "./environment";
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { DataAccessConsent } from "src/models/regional";
2+
3+
export type CreateParams = Pick<
4+
DataAccessConsent,
5+
"containers_until" | "databases_until"
6+
>;
7+
8+
export type UpdateParams = CreateParams;

test/DataAccessConsent/index.test.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import DataAccessConsent from "../../src/DataAccessConsent";
2+
import { testPost, testUpdate } from "../utils/http";
3+
4+
describe("DataAccessConsent#create", () => {
5+
testPost(
6+
"https://api.osc-fr1.scalingo.com/v1/apps/test/data_access_consent",
7+
null,
8+
{
9+
data_access_consent: {
10+
containers_until: "2022-07-06T00:00:00.000+00:00",
11+
databases_until: "2022-07-08T00:00:00.000+00:00",
12+
},
13+
},
14+
"data_access_consent",
15+
(client) => {
16+
return new DataAccessConsent(client).create("test", {
17+
containers_until: "2022-07-06T00:00:00.000+00:00",
18+
databases_until: "2022-07-08T00:00:00.000+00:00",
19+
});
20+
}
21+
);
22+
});
23+
24+
describe("DataAccessConsent#update", () => {
25+
testUpdate(
26+
"https://api.osc-fr1.scalingo.com/v1/apps/test/data_access_consent",
27+
{
28+
data_access_consent: {
29+
containers_until: "2022-07-10T00:00:00.000+00:00",
30+
},
31+
},
32+
"data_access_consent",
33+
(client) => {
34+
return new DataAccessConsent(client).update("test", {
35+
containers_until: "2022-07-10T00:00:00.000+00:00",
36+
});
37+
}
38+
);
39+
});

test/DataAccessConsents/index.test.js

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)