Skip to content

Commit

Permalink
Rename ToE and Cloud Service (#222)
Browse files Browse the repository at this point in the history
* Update toe and cloud_service
  • Loading branch information
anatheka authored Oct 9, 2024
1 parent 7b0d509 commit cc5eebc
Show file tree
Hide file tree
Showing 26 changed files with 480 additions and 377 deletions.
521 changes: 312 additions & 209 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"svelte": "^4.2.12",
"svelte-check": "^3.8.0",
"svelte-popperjs": "^1.3.2",
"tailwindcss": "^3.4.1",
"tailwindcss": "^3.4.13",
"tslib": "^2.6.2",
"typescript": "^5.4.4",
"vite": "^5.2.7"
Expand Down
10 changes: 5 additions & 5 deletions src/lib/api/evaluation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { clouditorize } from '$lib/api/util';
import { throwError } from './errors';
import type { TargetOfEvaluation } from './orchestrator';
import type { AuditScope } from './orchestrator';

export interface StartEvaluationResponse {
succesful: boolean;
Expand Down Expand Up @@ -32,9 +32,9 @@ export interface EvaluationResult {
validUntil?: string;
}

export async function startEvaluation(toe: TargetOfEvaluation): Promise<StartEvaluationResponse> {
export async function startEvaluation(auditScope: AuditScope): Promise<StartEvaluationResponse> {
const apiUrl = clouditorize(
`/v1/evaluation/evaluate/${toe.cloudServiceId}/${toe.catalogId}/start`
`/v1/evaluation/evaluate/${auditScope.certificationTargetId}/${auditScope.catalogId}/start`
);

return fetch(apiUrl, {
Expand All @@ -45,9 +45,9 @@ export async function startEvaluation(toe: TargetOfEvaluation): Promise<StartEva
}).then((res) => res.json());
}

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

return fetch(apiUrl, {
Expand Down
114 changes: 57 additions & 57 deletions src/lib/api/orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface Tag {
tag: object;
}

export interface CloudService {
export interface CertificationTarget {
id: string;
name: string;
description?: string;
Expand All @@ -33,16 +33,16 @@ export interface CloudService {
updatedAt: string;
}

export interface TargetOfEvaluation {
cloudServiceId: string;
export interface AuditScope {
certificationTargetId: string;
catalogId: string;
assuranceLevel?: string;
controlsInScope?: Control[];
}

export interface ControlInScope {
targetOfEvaluationCloudServiceId: string;
targetOfEvaluationCatalogId: string;
auditScopeCertificationTargetId: string;
auditScopeCatalogId: string;
controlId: string;
controlCategoryName: string;
controlCategoryCatalogId: string;
Expand Down Expand Up @@ -104,7 +104,7 @@ export interface ListMetricConfigurationsResponse {
export interface Certificate {
id: string;
name: string;
cloudServiceId: string;
certificationTargetId: string;
issueDate: string;
expirationDate: string;
standard: string;
Expand Down Expand Up @@ -138,12 +138,12 @@ export interface ListAssessmentResultsResponse {
results: AssessmentResult[];
}

export interface ListCloudServicesResponse {
services: CloudService[];
export interface ListCertificationTargetsResponse {
targets: CertificationTarget[];
}

export interface ListTargetsOfEvaluationResponse {
targetOfEvaluation: TargetOfEvaluation[];
export interface ListAuditScopesResponse {
auditScope: AuditScope[];
}

export interface ListControlsInScopeResponse {
Expand Down Expand Up @@ -202,12 +202,12 @@ export async function listAssessmentResults(
*
* @returns an array of {@link AssessmentResult}s.
*/
export async function listCloudServiceAssessmentResults(
export async function listCertificationTargetAssessmentResults(
serviceId: string,
fetch = window.fetch
): Promise<AssessmentResult[]> {
const apiUrl = clouditorize(
`/v1/orchestrator/assessment_results?pageSize=1000&filter.cloudServiceId=${serviceId}&orderBy=timestamp&asc=false`
`/v1/orchestrator/assessment_results?pageSize=1000&filter.certificationTargetId=${serviceId}&orderBy=timestamp&asc=false`
);

return fetch(apiUrl, {
Expand Down Expand Up @@ -270,7 +270,7 @@ export async function getMetricImplementation(id: string): Promise<MetricImpleme
/**
* Retrieves a particular metric configuration from the orchestrator service.
*
* @param serviceId the Cloud Service ID
* @param serviceId the Certification Target ID
* @param metricId the metric id
* @returns metric configuration
*/
Expand All @@ -279,7 +279,7 @@ export async function getMetricConfiguration(
metricId: string
): Promise<MetricConfiguration> {
const apiUrl = clouditorize(
`/v1/orchestrator/cloud_services/${serviceId}/metric_configurations/${metricId}`
`/v1/orchestrator/certification_targets/${serviceId}/metric_configurations/${metricId}`
);

return fetch(apiUrl, {
Expand All @@ -305,7 +305,7 @@ export async function listMetricConfigurations(
serviceId: string,
skipDefault = false
): Promise<Map<string, MetricConfiguration>> {
const apiUrl = clouditorize(`/v1/orchestrator/cloud_services/${serviceId}/metric_configurations`);
const apiUrl = clouditorize(`/v1/orchestrator/certification_targets/${serviceId}/metric_configurations`);

return fetch(apiUrl, {
method: 'GET',
Expand All @@ -329,10 +329,10 @@ export async function listMetricConfigurations(
}

/**
* Creates a new cloud service
* Creates a new certification target
*/
export async function registerCloudService(service: CloudService): Promise<CloudService> {
const apiUrl = clouditorize(`/v1/orchestrator/cloud_services`);
export async function registerCertificationTarget(service: CertificationTarget): Promise<CertificationTarget> {
const apiUrl = clouditorize(`/v1/orchestrator/certification_targets`);

return fetch(apiUrl, {
method: 'POST',
Expand All @@ -343,16 +343,16 @@ export async function registerCloudService(service: CloudService): Promise<Cloud
})
.then(throwError)
.then((res) => res.json())
.then((response: CloudService) => {
.then((response: CertificationTarget) => {
return response;
});
}

/**
* Removes a cloud service.
* Removes a certification target.
*/
export async function removeCloudService(serviceId: string): Promise<void> {
const apiUrl = clouditorize(`/v1/orchestrator/cloud_services/${serviceId}`);
export async function removeCertificationTarget(targetId: string): Promise<void> {
const apiUrl = clouditorize(`/v1/orchestrator/certification_targets/${targetId}`);

return fetch(apiUrl, {
method: 'DELETE',
Expand All @@ -365,12 +365,12 @@ export async function removeCloudService(serviceId: string): Promise<void> {
}

/**
* Retrieves a list of cloud services from the orchestrator service.
* Retrieves a list of certification targets from the orchestrator service.
*
* @returns an array of {@link CloudService}s.
* @returns an array of {@link CertificationTarget}s.
*/
export async function listCloudServices(fetch = window.fetch): Promise<CloudService[]> {
const apiUrl = clouditorize(`/v1/orchestrator/cloud_services`);
export async function listCertificationTargets(fetch = window.fetch): Promise<CertificationTarget[]> {
const apiUrl = clouditorize(`/v1/orchestrator/certification_targets`);

return fetch(apiUrl, {
method: 'GET',
Expand All @@ -380,18 +380,18 @@ export async function listCloudServices(fetch = window.fetch): Promise<CloudServ
})
.then(throwError)
.then((res) => res.json())
.then((response: ListCloudServicesResponse) => {
return response.services;
.then((response: ListCertificationTargetsResponse) => {
return response.targets;
});
}

/**
* Creates a new target of evaluation.
*/
export async function createTargetOfEvaluation(
target: TargetOfEvaluation
): Promise<TargetOfEvaluation> {
const apiUrl = clouditorize(`/v1/orchestrator/toes`);
export async function createAuditScope(
target: AuditScope
): Promise<AuditScope> {
const apiUrl = clouditorize(`/v1/orchestrator/audit_scopes`);

return fetch(apiUrl, {
method: 'POST',
Expand All @@ -407,11 +407,11 @@ export async function createTargetOfEvaluation(
/**
* Removes a target of evaluation.
*/
export async function removeTargetOfEvaluation(
target: TargetOfEvaluation
): Promise<TargetOfEvaluation> {
export async function removeAuditScope(
target: AuditScope
): Promise<AuditScope> {
const apiUrl = clouditorize(
`/v1/orchestrator/cloud_services/${target.cloudServiceId}/toes/${target.catalogId}`
`/v1/orchestrator/certification_targets/${target.certificationTargetId}/audit_scopes/${target.catalogId}`
);

return fetch(apiUrl, {
Expand All @@ -433,7 +433,7 @@ export async function addControlToScope(
fetch = window.fetch
): Promise<ControlInScope> {
const apiUrl = clouditorize(
`/v1/orchestrator/cloud_services/${scope.targetOfEvaluationCloudServiceId}/toes/${scope.targetOfEvaluationCatalogId}/controls_in_scope`
`/v1/orchestrator/certification_targets/${scope.auditScopeCertificationTargetId}/audit_scopes/${scope.auditScopeCatalogId}/controls_in_scope`
);

return fetch(apiUrl, {
Expand All @@ -458,7 +458,7 @@ export async function removeControlFromScope(
fetch = window.fetch
): Promise<ControlInScope> {
const apiUrl = clouditorize(
`/v1/orchestrator/cloud_services/${scope.targetOfEvaluationCloudServiceId}/toes/${scope.targetOfEvaluationCatalogId}/controls_in_scope/categories/${scope.controlCategoryName}/controls/${scope.controlId}`
`/v1/orchestrator/certification_targets/${scope.auditScopeCertificationTargetId}/audit_scopes/${scope.auditScopeCatalogId}/controls_in_scope/categories/${scope.controlCategoryName}/controls/${scope.controlId}`
);

return fetch(apiUrl, {
Expand All @@ -474,13 +474,13 @@ export async function removeControlFromScope(
/**
* Retrieves a list of targets of evaluation from the orchestrator service.
*
* @returns an array of {@link TargetOfEvaluation}s.
* @returns an array of {@link AuditScope}s.
*/
export async function listTargetsOfEvaluation(
export async function listAuditScopes(
serviceId: string,
fetch = window.fetch
): Promise<TargetOfEvaluation[]> {
const apiUrl = clouditorize(`/v1/orchestrator/cloud_services/${serviceId}/toes`);
): Promise<AuditScope[]> {
const apiUrl = clouditorize(`/v1/orchestrator/certification_targets/${serviceId}/audit_scopes`);

return fetch(apiUrl, {
method: 'GET',
Expand All @@ -490,8 +490,8 @@ export async function listTargetsOfEvaluation(
})
.then(throwError)
.then((res) => res.json())
.then((response: ListTargetsOfEvaluationResponse) => {
return response.targetOfEvaluation;
.then((response: ListAuditScopesResponse) => {
return response.auditScope;
});
}

Expand All @@ -506,7 +506,7 @@ export async function listControlsInScope(
fetch = window.fetch
): Promise<ControlInScope[]> {
const apiUrl = clouditorize(
`/v1/orchestrator/cloud_services/${serviceId}/toes/${catalogId}/controls_in_scope?pageSize=1500&orderBy=control_id&asc=true`
`/v1/orchestrator/certification_targets/${serviceId}/audit_scopes/${catalogId}/controls_in_scope?pageSize=1500&orderBy=control_id&asc=true`
);

return fetch(apiUrl, {
Expand Down Expand Up @@ -605,12 +605,12 @@ export async function listControls(
}

/**
* Retrieve a cloud service from the orchestrator service using its ID.
* Retrieve a certification target from the orchestrator service using its ID.
*
* @returns the cloud service
* @returns the certification target
*/
export async function getCloudService(id: string, fetch = window.fetch): Promise<CloudService> {
const apiUrl = clouditorize(`/v1/orchestrator/cloud_services/${id}`);
export async function getCertificationTarget(id: string, fetch = window.fetch): Promise<CertificationTarget> {
const apiUrl = clouditorize(`/v1/orchestrator/certification_targets/${id}`);

return fetch(apiUrl, {
method: 'GET',
Expand All @@ -622,11 +622,11 @@ export async function getCloudService(id: string, fetch = window.fetch): Promise
.then((res) => res.json());
}

export async function updateCloudService(
service: CloudService,
export async function updateCertificationTarget(
service: CertificationTarget,
fetch = window.fetch
): Promise<CloudService> {
const apiUrl = clouditorize(`/v1/orchestrator/cloud_services/${service.id}`);
): Promise<CertificationTarget> {
const apiUrl = clouditorize(`/v1/orchestrator/certification_targets/${service.id}`);

return fetch(apiUrl, {
method: 'PUT',
Expand All @@ -637,17 +637,17 @@ export async function updateCloudService(
})
.then(throwError)
.then((res) => res.json())
.then((response: CloudService) => {
.then((response: CertificationTarget) => {
return response;
});
}

export async function updateControlInScope(
scope: ControlInScope,
fetch = window.fetch
): Promise<CloudService> {
): Promise<CertificationTarget> {
const apiUrl = clouditorize(
`/v1/orchestrator/cloud_services/${scope.targetOfEvaluationCloudServiceId}/toes/${scope.targetOfEvaluationCatalogId}/controls_in_scope/categories/${scope.controlCategoryName}/controls/${scope.controlId}`
`/v1/orchestrator/certification_targets/${scope.auditScopeCertificationTargetId}/audit_scopes/${scope.auditScopeCatalogId}/controls_in_scope/categories/${scope.controlCategoryName}/controls/${scope.controlId}`
);

return fetch(apiUrl, {
Expand All @@ -659,7 +659,7 @@ export async function updateControlInScope(
})
.then(throwError)
.then((res) => res.json())
.then((response: CloudService) => {
.then((response: CertificationTarget) => {
return response;
});
}
Expand Down
Loading

0 comments on commit cc5eebc

Please sign in to comment.