-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '242-new-api---qlik-cloud-data-integratio'
- Loading branch information
Showing
7 changed files
with
368 additions
and
152 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { QlikSaaSClient } from "qlik-rest-api"; | ||
import { DiProjectTasks } from "./DiProjectTasks"; | ||
|
||
export interface IDiProject { | ||
id: string; | ||
name: string; | ||
ownerId: string; | ||
spaceId: string; | ||
description: string; | ||
} | ||
|
||
export class DiProject { | ||
#id: string; | ||
#saasClient: QlikSaaSClient; | ||
details: IDiProject; | ||
tasks: DiProjectTasks; | ||
constructor(saasClient: QlikSaaSClient, id: string, details?: IDiProject) { | ||
if (!id) throw new Error(`diProject.get: "id" parameter is required`); | ||
|
||
this.details = details ?? ({} as IDiProject); | ||
this.#id = id; | ||
this.#saasClient = saasClient; | ||
this.tasks = new DiProjectTasks(saasClient, id); | ||
} | ||
|
||
async init(arg?: { force: boolean }) { | ||
if ( | ||
!this.details || | ||
Object.keys(this.details).length == 0 || | ||
arg?.force == true | ||
) { | ||
this.details = await this.#saasClient | ||
.Get<IDiProject>(`di-projects/${this.#id}`) | ||
.then((res) => res.data); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { QlikSaaSClient } from "qlik-rest-api"; | ||
|
||
export interface IDiProjectTask { | ||
id: string; | ||
name: string; | ||
type: | ||
| "LANDING" | ||
| "STORAGE" | ||
| "QVD_STORAGE" | ||
| "TRANSFORM" | ||
| "DATAMART" | ||
| "REGISTERED_DATA" | ||
| "REPLICATION" | ||
| "DISTRIBUTION" | ||
| "LAKE_LANDING" | ||
| string; | ||
ownerId: string; | ||
spaceId: string; | ||
description: string; | ||
} | ||
|
||
export interface IDataTaskInstanceState { | ||
lastRun: { | ||
state: "STARTING" | "RUNNING" | "COMPLETED" | "FAILED" | "CANCELED"; | ||
message: string; | ||
}; | ||
runReadiness: { | ||
state: "READY_TO_RUN" | "ALREADY_RUNNING" | "NOT_RUNNABLE"; | ||
message: string; | ||
}; | ||
} | ||
|
||
export class DiProjectTask { | ||
#id: string; | ||
#projectId: string; | ||
#saasClient: QlikSaaSClient; | ||
details: IDiProjectTask; | ||
constructor( | ||
saasClient: QlikSaaSClient, | ||
id: string, | ||
projectId: string, | ||
details?: IDiProjectTask | ||
) { | ||
if (!id) throw new Error(`diProjectTask.get: "id" parameter is required`); | ||
if (!projectId) | ||
throw new Error(`diProjectTask.projectId: "id" parameter is required`); | ||
|
||
this.details = details ?? ({} as IDiProjectTask); | ||
this.#id = id; | ||
this.#projectId = projectId; | ||
this.#saasClient = saasClient; | ||
} | ||
|
||
async init(arg?: { force: boolean }) { | ||
if ( | ||
!this.details || | ||
Object.keys(this.details).length == 0 || | ||
arg?.force == true | ||
) { | ||
this.details = await this.#saasClient | ||
.Get<IDiProjectTask>( | ||
`di-projects/${this.#projectId}/di-tasks/${this.#id}` | ||
) | ||
.then((res) => res.data); | ||
} | ||
} | ||
|
||
async start() { | ||
return await this.#saasClient | ||
.Post<IDiProjectTask>( | ||
`di-projects/${this.#projectId}/di-tasks/${this.#id}/start`, | ||
{} | ||
) | ||
.then((res) => res.status); | ||
} | ||
|
||
async stop() { | ||
return await this.#saasClient | ||
.Post<IDiProjectTask>( | ||
`di-projects/${this.#projectId}/di-tasks/${this.#id}/stop`, | ||
{} | ||
) | ||
.then((res) => res.status); | ||
} | ||
|
||
async state() { | ||
return await this.#saasClient | ||
.Get<IDataTaskInstanceState>( | ||
`di-projects/${this.#projectId}/di-tasks/${this.#id}/state` | ||
) | ||
.then((res) => res.data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { QlikSaaSClient } from "qlik-rest-api"; | ||
import { DiProjectTask, IDiProjectTask } from "./DiProjectTask"; | ||
|
||
export class DiProjectTasks { | ||
#saasClient: QlikSaaSClient; | ||
#projectId: string; | ||
constructor(saasClient: QlikSaaSClient, projectId: string) { | ||
this.#saasClient = saasClient; | ||
this.#projectId = projectId; | ||
} | ||
|
||
/** | ||
* Returns instance of single data integration task | ||
*/ | ||
async get(arg: { id: string; projectId: string }) { | ||
if (!arg.id) | ||
throw new Error(`diProjectTasks.get: "id" parameter is required`); | ||
if (!arg.projectId) | ||
throw new Error( | ||
`diProjectTasks.projectId: "projectId" parameter is required` | ||
); | ||
|
||
const diTask: DiProjectTask = new DiProjectTask( | ||
this.#saasClient, | ||
arg.id, | ||
arg.projectId | ||
); | ||
await diTask.init(); | ||
|
||
return diTask; | ||
} | ||
|
||
/** | ||
* Returns instances list of data integrations tasks | ||
*/ | ||
async getAll() { | ||
return await this.#saasClient | ||
.Get<IDiProjectTask[]>(`di-projects/${this.#projectId}/di-tasks?limit=50`) | ||
.then((res) => res.data) | ||
.then((data) => | ||
data.map( | ||
(t) => new DiProjectTask(this.#saasClient, t.id, this.#projectId, t) | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { QlikSaaSClient } from "qlik-rest-api"; | ||
import { DiProject, IDiProject } from "./DiProject"; | ||
|
||
export class DiProjects { | ||
#saasClient: QlikSaaSClient; | ||
constructor(saasClient: QlikSaaSClient) { | ||
this.#saasClient = saasClient; | ||
} | ||
|
||
/** | ||
* Returns instance of single data integration project | ||
*/ | ||
async get(arg: { id: string }) { | ||
if (!arg.id) throw new Error(`diProjects.get: "id" parameter is required`); | ||
|
||
const di: DiProject = new DiProject(this.#saasClient, arg.id); | ||
await di.init(); | ||
|
||
return di; | ||
} | ||
|
||
/** | ||
* Returns a list of data integrations as an instance | ||
*/ | ||
async getAll() { | ||
return await this.#saasClient | ||
.Get<IDiProject[]>(`di-projects?limit=50`) | ||
.then((res) => res.data) | ||
.then((data) => | ||
data.map((t) => new DiProject(this.#saasClient, t.id, t)) | ||
); | ||
} | ||
} |