Skip to content

Commit

Permalink
Merge pull request #10 from unikorn-cloud/sk4
Browse files Browse the repository at this point in the history
Get Projects Working
  • Loading branch information
spjmurray authored Mar 5, 2024
2 parents 5a0ab52 + ad22d2b commit e9a2cd3
Show file tree
Hide file tree
Showing 11 changed files with 372 additions and 72 deletions.
52 changes: 19 additions & 33 deletions src/lib/StatusIcon.svelte
Original file line number Diff line number Diff line change
@@ -1,36 +1,22 @@
<script>
export let status = 'unknown';
</script>

{#if status == 'ok'}
<iconify-icon class="ok" icon="mdi:tick-circle-outline" />
{:else if status == 'warning'}
<iconify-icon class="warning" icon="mdi:warning-circle-outline" />
{:else if status == 'error'}
<iconify-icon class="error" icon="mdi:error-outline" />
{:else if status == 'progressing'}
<iconify-icon class="progressing" icon="svg-spinners:ring-resize" />
{:else}
<iconify-icon class="unknown" icon="mdi:question-mark" />
{/if}
<script lang="ts">
export let status: string;
<style>
.ok {
color: lightgreen;
}
.warning {
color: orange;
}
.error {
color: red;
}
.unknown {
color: var(--light-grey);
function getColor(status: string): string {
if (status == 'Provisioned') return 'text-success-500';
if (status == 'Errored') return 'text-error-500';
if (status == 'Unknown') return 'text-warning-500';
return 'text-surface-500';
}
.progressing {
color: var(--light-grey);
}
iconify-icon {
font-size: var(--icon-size);
function getIcon(status: string): string {
if (status == 'Provisioned') return 'mdi:tick-circle-outline';
if (status == 'Errored') return 'mdi:error-outline';
if (status == 'Unknown') return 'mdi:question-mark';
return 'svg-spinners:ring-resize';
}
</style>
$: color = getColor(status);
$: icon = getIcon(status);
</script>

<iconify-icon class="text-2xl {color}" {icon} />
1 change: 1 addition & 0 deletions src/lib/openapi/server/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ models/OpenstackProject.ts
models/OpenstackProjects.ts
models/OpenstackVolume.ts
models/Project.ts
models/Projects.ts
models/Region.ts
models/Regions.ts
models/TimeWindow.ts
Expand Down
140 changes: 128 additions & 12 deletions src/lib/openapi/server/apis/DefaultApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import type {
OpenstackFlavors,
OpenstackImages,
OpenstackKeyPairs,
Project,
Projects,
Regions,
} from '../models/index';
import {
Expand Down Expand Up @@ -54,6 +56,10 @@ import {
OpenstackImagesToJSON,
OpenstackKeyPairsFromJSON,
OpenstackKeyPairsToJSON,
ProjectFromJSON,
ProjectToJSON,
ProjectsFromJSON,
ProjectsToJSON,
RegionsFromJSON,
RegionsToJSON,
} from '../models/index';
Expand Down Expand Up @@ -105,6 +111,14 @@ export interface ApiV1ControlplanesPostRequest {
controlPlane: ControlPlane;
}

export interface ApiV1ProjectsPostRequest {
project: Project;
}

export interface ApiV1ProjectsProjectNameDeleteRequest {
projectName: string;
}

export interface ApiV1RegionsRegionNameAvailabilityZonesBlockStorageGetRequest {
regionName: string;
}
Expand Down Expand Up @@ -642,9 +656,9 @@ export class DefaultApi extends runtime.BaseAPI {
}

/**
* Deletes the project associated with the authenticated user\'s scoped authorisation token. This is a cascading operation and will delete all contained control planes and clusters.
* Deletes an organization and all its resources based on the access token claims.
*/
async apiV1ProjectDeleteRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
async apiV1OrganizationDeleteRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};
Expand All @@ -655,7 +669,7 @@ export class DefaultApi extends runtime.BaseAPI {
}

const response = await this.request({
path: `/api/v1/project`,
path: `/api/v1/organization`,
method: 'DELETE',
headers: headerParameters,
query: queryParameters,
Expand All @@ -665,40 +679,142 @@ export class DefaultApi extends runtime.BaseAPI {
}

/**
* Deletes the project associated with the authenticated user\'s scoped authorisation token. This is a cascading operation and will delete all contained control planes and clusters.
* Deletes an organization and all its resources based on the access token claims.
*/
async apiV1OrganizationDelete(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
await this.apiV1OrganizationDeleteRaw(initOverrides);
}

/**
* Creates a new organization based on the access token claims.
*/
async apiV1OrganizationPostRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.accessToken) {
// oauth required
headerParameters["Authorization"] = await this.configuration.accessToken("oauth2Authentication", []);
}

const response = await this.request({
path: `/api/v1/organization`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
}, initOverrides);

return new runtime.VoidApiResponse(response);
}

/**
* Creates a new organization based on the access token claims.
*/
async apiV1OrganizationPost(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
await this.apiV1OrganizationPostRaw(initOverrides);
}

/**
* List all projects for the organization.
*/
async apiV1ProjectsGetRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Projects>> {
const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.accessToken) {
// oauth required
headerParameters["Authorization"] = await this.configuration.accessToken("oauth2Authentication", []);
}

const response = await this.request({
path: `/api/v1/projects`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => ProjectsFromJSON(jsonValue));
}

/**
* List all projects for the organization.
*/
async apiV1ProjectDelete(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
await this.apiV1ProjectDeleteRaw(initOverrides);
async apiV1ProjectsGet(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Projects> {
const response = await this.apiV1ProjectsGetRaw(initOverrides);
return await response.value();
}

/**
* Creates a new project resource associated with the authenticated user\'s scoped authorisation token.
* Creates a new project resource for the user\'s organization.
*/
async apiV1ProjectPostRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
async apiV1ProjectsPostRaw(requestParameters: ApiV1ProjectsPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
if (requestParameters.project === null || requestParameters.project === undefined) {
throw new runtime.RequiredError('project','Required parameter requestParameters.project was null or undefined when calling apiV1ProjectsPost.');
}

const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

headerParameters['Content-Type'] = 'application/json';

if (this.configuration && this.configuration.accessToken) {
// oauth required
headerParameters["Authorization"] = await this.configuration.accessToken("oauth2Authentication", []);
}

const response = await this.request({
path: `/api/v1/project`,
path: `/api/v1/projects`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: ProjectToJSON(requestParameters.project),
}, initOverrides);

return new runtime.VoidApiResponse(response);
}

/**
* Creates a new project resource associated with the authenticated user\'s scoped authorisation token.
* Creates a new project resource for the user\'s organization.
*/
async apiV1ProjectsPost(requestParameters: ApiV1ProjectsPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
await this.apiV1ProjectsPostRaw(requestParameters, initOverrides);
}

/**
* Deletes the project associated with the authenticated user\'s scoped authorisation token. This is a cascading operation and will delete all contained control planes and clusters.
*/
async apiV1ProjectsProjectNameDeleteRaw(requestParameters: ApiV1ProjectsProjectNameDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
if (requestParameters.projectName === null || requestParameters.projectName === undefined) {
throw new runtime.RequiredError('projectName','Required parameter requestParameters.projectName was null or undefined when calling apiV1ProjectsProjectNameDelete.');
}

const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.accessToken) {
// oauth required
headerParameters["Authorization"] = await this.configuration.accessToken("oauth2Authentication", []);
}

const response = await this.request({
path: `/api/v1/projects/{projectName}`.replace(`{${"projectName"}}`, encodeURIComponent(String(requestParameters.projectName))),
method: 'DELETE',
headers: headerParameters,
query: queryParameters,
}, initOverrides);

return new runtime.VoidApiResponse(response);
}

/**
* Deletes the project associated with the authenticated user\'s scoped authorisation token. This is a cascading operation and will delete all contained control planes and clusters.
*/
async apiV1ProjectPost(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
await this.apiV1ProjectPostRaw(initOverrides);
async apiV1ProjectsProjectNameDelete(requestParameters: ApiV1ProjectsProjectNameDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
await this.apiV1ProjectsProjectNameDeleteRaw(requestParameters, initOverrides);
}

/**
Expand Down
9 changes: 9 additions & 0 deletions src/lib/openapi/server/models/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ import {
* @interface Project
*/
export interface Project {
/**
*
* @type {string}
* @memberof Project
*/
name: string;
/**
*
* @type {KubernetesResourceStatus}
Expand All @@ -39,6 +45,7 @@ export interface Project {
*/
export function instanceOfProject(value: object): boolean {
let isInstance = true;
isInstance = isInstance && "name" in value;

return isInstance;
}
Expand All @@ -53,6 +60,7 @@ export function ProjectFromJSONTyped(json: any, ignoreDiscriminator: boolean): P
}
return {

'name': json['name'],
'status': !exists(json, 'status') ? undefined : KubernetesResourceStatusFromJSON(json['status']),
};
}
Expand All @@ -66,6 +74,7 @@ export function ProjectToJSON(value?: Project | null): any {
}
return {

'name': value.name,
'status': KubernetesResourceStatusToJSON(value.status),
};
}
Expand Down
51 changes: 51 additions & 0 deletions src/lib/openapi/server/models/Projects.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* tslint:disable */
/* eslint-disable */
/**
* Kubernetes Service API
* The Kubernetes Service API provides services that allows provisioning and life cycle management of Kubernetes clusters. The API is logically composed of authentication services, platform provider specific calls to get a set of resource types that can be then used by abstract Kubernetes Service resources to create and manage Kubernetes clusters. Requests must specify the HTML content type header.
*
* The version of the OpenAPI document: 0.2.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

import { exists, mapValues } from '../runtime';
import type { Project } from './Project';
import {
ProjectFromJSON,
ProjectFromJSONTyped,
ProjectToJSON,
} from './Project';

/**
* A list of projects.
* @export
* @interface Projects
*/
export interface Projects extends Array<Project> {
}

/**
* Check if a given object implements the Projects interface.
*/
export function instanceOfProjects(value: object): boolean {
let isInstance = true;

return isInstance;
}

export function ProjectsFromJSON(json: any): Projects {
return ProjectsFromJSONTyped(json, false);
}

export function ProjectsFromJSONTyped(json: any, ignoreDiscriminator: boolean): Projects {
return json;
}

export function ProjectsToJSON(value?: Projects | null): any {
return value;
}

1 change: 1 addition & 0 deletions src/lib/openapi/server/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export * from './OpenstackProject';
export * from './OpenstackProjects';
export * from './OpenstackVolume';
export * from './Project';
export * from './Projects';
export * from './Region';
export * from './Regions';
export * from './TimeWindow';
2 changes: 1 addition & 1 deletion src/lib/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export function namedResourceNames(resources: any): Array<string> {

export function unique(needle: string, haystack: Array<string>): boolean {
if (haystack == null) return true;
return haystack.includes(needle);
return !haystack.includes(needle);
}
Loading

0 comments on commit e9a2cd3

Please sign in to comment.