Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
78 changes: 1 addition & 77 deletions src/lib/api/discovery.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,12 @@
import { throwError } from './errors';

import { clouditorize } from './util';

export interface GraphEdge {
id: string;
source: string;
target: string;
}

export interface StartDiscoveryResponse {
successful: boolean;
}

export interface QueryResponse {
results: Resource[];
}

export interface ListGraphEdgesResponse {
edges: GraphEdge[];
}

export interface ListResourcesRequest {
filter?: Filter;
orderBy?: string;
}

export interface Filter {
cloudServiceId?: string;
type?: string;
}

export interface HttpEndpoint {
transportEncryption?: TransportEncryption;
Expand All @@ -40,21 +19,6 @@ export interface TransportEncryption {
tlsVersion: string;
}

export interface ResourceProperties {
name: string;
raw: string;
type: string[];
serviceId: string;
id: string;
labels: object;
}

export interface Resource {
id: string;
cloudServiceId: string;
resourceType: string;
properties: ResourceProperties;
}

export async function startDiscovery(): Promise<boolean> {
const apiUrl = clouditorize(`/v1/discovery/start`);
Expand All @@ -71,44 +35,4 @@ export async function startDiscovery(): Promise<boolean> {
});
}

export async function listResources(
filteredServiceId?: string,
type = '',
fetch = window.fetch
): Promise<Resource[]> {
let apiUrl =
clouditorize(`/v1/discovery/resources?filter.cloudServiceId=${filteredServiceId}&pageSize=1500&orderBy=resource_type&asc=true
`);

if (type != '') {
apiUrl += `&filter.type=${type}`;
}

return fetch(apiUrl, {
method: 'GET',
headers: {
Authorization: `Bearer ${localStorage.token}`
}
})
.then(throwError)
.then((res) => res.json())
.then((response: QueryResponse) => {
return response.results;
});
}

export async function listGraphEdges(fetch = window.fetch): Promise<GraphEdge[]> {
const apiUrl = clouditorize(`/v1experimental/discovery/graph/edges?&pageSize=1500`);

return fetch(apiUrl, {
method: 'GET',
headers: {
Authorization: `Bearer ${localStorage.token}`
}
})
.then(throwError)
.then((res) => res.json())
.then((response: ListGraphEdgesResponse) => {
return response.edges;
});
}
12 changes: 7 additions & 5 deletions src/lib/api/evaluation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type ComplianceStatus =

export interface EvaluationResult {
id: string;
cloudServiceId: string;
targetOfEvaluationId: string;
status: ComplianceStatus;
controlCatalogId: string;
controlCategoryName?: string;
Expand All @@ -45,7 +45,7 @@ export async function startEvaluation(auditScope: AuditScope): Promise<StartEval

export async function stopEvaluation(auditScope: AuditScope): Promise<{}> {
const apiUrl = clouditorize(
`/v1/evaluation/evaluate/${auditScope.certificationTargetId}/${auditScope.catalogId}/stop`
`/v1/evaluation/evaluate/${auditScope.id}/stop`
);

return fetch(apiUrl, {
Expand All @@ -57,10 +57,12 @@ export async function stopEvaluation(auditScope: AuditScope): Promise<{}> {
}

export interface ListEvaluationResultsFilter {
cloudServiceId?: string;
targetOfEvaluationId?: string;
catalogId?: string;
controlId?: string;
subControls?: string;
parentsOnly?: boolean;
validManualOnly?: boolean;
}

export async function listEvaluationResults(
Expand All @@ -70,8 +72,8 @@ export async function listEvaluationResults(
): Promise<EvaluationResult[]> {
let apiUrl = clouditorize(`/v1/evaluation/results?`);

if (filter?.cloudServiceId != undefined) {
apiUrl += `&filter.certification_target_id=${filter?.cloudServiceId}`;
if (filter?.targetOfEvaluationId != undefined) {
apiUrl += `&filter.target_of_evaluation_id=${filter?.targetOfEvaluationId}`;
}
if (filter?.catalogId != undefined) {
apiUrl += `&filter.catalog_id=${filter?.catalogId}`;
Expand Down
93 changes: 93 additions & 0 deletions src/lib/api/evidence_store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { throwError } from './errors';
import { clouditorize } from './util';


export interface GraphEdge {
id: string;
source: string;
target: string;
type: string;
}

export interface ListGraphEdgesRequest {

orderBy?: string;
pageSize?: number;
asc?: boolean;
}
export interface ListGraphEdgesResponse {
edges: GraphEdge[];
}

export interface ListResourcesRequest {
filter?: Filter;
orderBy?: string;
}

export interface ListResourcesResponse {
results: Resource[];
}


export interface Filter {
targetOfEvaluationId?: string;
type?: string;
}

export interface ResourceProperties {
name: string;
raw: string;
type: string[];
serviceId: string;
id: string;
labels: object;
}

export interface Resource {
id: string;
targetOfEvaluationId: string;
resourceType: string;
properties: ResourceProperties;
}

export async function listResources(
filteredTargetOfEvaluationId?: string,
type = '',
fetch = window.fetch
): Promise<Resource[]> {
let apiUrl =
clouditorize(`/v1/evidence_store/resources?filter.targetOfEvaluationId=${filteredTargetOfEvaluationId}&pageSize=1500&orderBy=resource_type&asc=true
`);

if (type != '') {
apiUrl += `&filter.type=${type}`;
}

return fetch(apiUrl, {
method: 'GET',
headers: {
Authorization: `Bearer ${localStorage.token}`
}
})
.then(throwError)
.then((res) => res.json())
.then((response: ListResourcesResponse) => {
return response.results;
});
}

export async function listGraphEdges(fetch = window.fetch): Promise<GraphEdge[]> {
const apiUrl = clouditorize(`/v1experimental/evidence/graph/edges`);//?pageSize=1500`);

return fetch(apiUrl, {
method: 'GET',
headers: {
Authorization: `Bearer ${localStorage.token}`
}
})
.then(throwError)
.then((res) => res.json())
.then((response: ListGraphEdgesResponse) => {
return response.edges;
});
}
Loading