diff --git a/gen/models/managementV1Cloud.ts b/gen/models/managementV1Cloud.ts new file mode 100644 index 0000000..27e6f28 --- /dev/null +++ b/gen/models/managementV1Cloud.ts @@ -0,0 +1,46 @@ +/** + * Api + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: master + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { ManagementV1MaintenanceWindow } from '../models/managementV1MaintenanceWindow'; + + +export class ManagementV1Cloud { + 'maintenanceWindow'?: ManagementV1MaintenanceWindow; + /** + * ReleaseChannel specifies the release channel for the cloud configuration. This can be used to determine which updates or versions are applied. + */ + 'releaseChannel'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "maintenanceWindow", + "baseName": "maintenanceWindow", + "type": "ManagementV1MaintenanceWindow", + "format": "" + }, + { + "name": "releaseChannel", + "baseName": "releaseChannel", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return ManagementV1Cloud.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/gen/models/managementV1ConfigStatus.ts b/gen/models/managementV1ConfigStatus.ts index e3aaa53..cc51181 100644 --- a/gen/models/managementV1ConfigStatus.ts +++ b/gen/models/managementV1ConfigStatus.ts @@ -13,6 +13,7 @@ import { ManagementV1Apps } from '../models/managementV1Apps'; import { ManagementV1Audit } from '../models/managementV1Audit'; import { ManagementV1Authentication } from '../models/managementV1Authentication'; +import { ManagementV1Cloud } from '../models/managementV1Cloud'; import { ManagementV1OIDC } from '../models/managementV1OIDC'; import { StorageV1VaultIntegrationSpec } from '../models/storageV1VaultIntegrationSpec'; import { UiV1UISettingsConfig } from '../models/uiV1UISettingsConfig'; @@ -25,6 +26,7 @@ export class ManagementV1ConfigStatus { 'apps'?: ManagementV1Apps; 'audit'?: ManagementV1Audit; 'auth'?: ManagementV1Authentication; + 'cloud'?: ManagementV1Cloud; /** * DevPodSubDomain holds a subdomain in the following form *.workspace.my-domain.com */ @@ -66,6 +68,12 @@ export class ManagementV1ConfigStatus { "type": "ManagementV1Authentication", "format": "" }, + { + "name": "cloud", + "baseName": "cloud", + "type": "ManagementV1Cloud", + "format": "" + }, { "name": "devPodSubDomain", "baseName": "devPodSubDomain", diff --git a/gen/models/managementV1DevPodEnvironmentTemplateSpec.ts b/gen/models/managementV1DevPodEnvironmentTemplateSpec.ts index 89adc9c..eb276b7 100644 --- a/gen/models/managementV1DevPodEnvironmentTemplateSpec.ts +++ b/gen/models/managementV1DevPodEnvironmentTemplateSpec.ts @@ -11,8 +11,8 @@ */ import { StorageV1Access } from '../models/storageV1Access'; +import { StorageV1DevPodEnvironmentTemplateDefinition } from '../models/storageV1DevPodEnvironmentTemplateDefinition'; import { StorageV1DevPodEnvironmentTemplateVersion } from '../models/storageV1DevPodEnvironmentTemplateVersion'; -import { StorageV1GitEnvironmentTemplate } from '../models/storageV1GitEnvironmentTemplate'; import { StorageV1UserOrTeam } from '../models/storageV1UserOrTeam'; @@ -25,11 +25,15 @@ export class ManagementV1DevPodEnvironmentTemplateSpec { */ 'access'?: Array; /** + * Description describes the environment template + */ + 'description'?: string; + /** * DisplayName is the name that should be displayed in the UI */ 'displayName'?: string; - 'git'?: StorageV1GitEnvironmentTemplate; 'owner'?: StorageV1UserOrTeam; + 'template'?: StorageV1DevPodEnvironmentTemplateDefinition; /** * Versions are different versions of the template that can be referenced as well */ @@ -45,15 +49,15 @@ export class ManagementV1DevPodEnvironmentTemplateSpec { "format": "" }, { - "name": "displayName", - "baseName": "displayName", + "name": "description", + "baseName": "description", "type": "string", "format": "" }, { - "name": "git", - "baseName": "git", - "type": "StorageV1GitEnvironmentTemplate", + "name": "displayName", + "baseName": "displayName", + "type": "string", "format": "" }, { @@ -62,6 +66,12 @@ export class ManagementV1DevPodEnvironmentTemplateSpec { "type": "StorageV1UserOrTeam", "format": "" }, + { + "name": "template", + "baseName": "template", + "type": "StorageV1DevPodEnvironmentTemplateDefinition", + "format": "" + }, { "name": "versions", "baseName": "versions", diff --git a/gen/models/managementV1DevPodWorkspaceInstanceSpec.ts b/gen/models/managementV1DevPodWorkspaceInstanceSpec.ts index 88b01df..def5f04 100644 --- a/gen/models/managementV1DevPodWorkspaceInstanceSpec.ts +++ b/gen/models/managementV1DevPodWorkspaceInstanceSpec.ts @@ -13,6 +13,7 @@ import { StorageV1Access } from '../models/storageV1Access'; import { StorageV1DevPodWorkspaceTemplateDefinition } from '../models/storageV1DevPodWorkspaceTemplateDefinition'; import { StorageV1EnvironmentRef } from '../models/storageV1EnvironmentRef'; +import { StorageV1PresetRef } from '../models/storageV1PresetRef'; import { StorageV1RunnerRef } from '../models/storageV1RunnerRef'; import { StorageV1TemplateRef } from '../models/storageV1TemplateRef'; import { StorageV1UserOrTeam } from '../models/storageV1UserOrTeam'; @@ -40,6 +41,7 @@ export class ManagementV1DevPodWorkspaceInstanceSpec { * Parameters are values to pass to the template. The values should be encoded as YAML string where each parameter is represented as a top-level field key. */ 'parameters'?: string; + 'presetRef'?: StorageV1PresetRef; /** * PreventWakeUpOnConnection is used to prevent workspace that uses sleep mode from waking up on incomming ssh connection. */ @@ -87,6 +89,12 @@ export class ManagementV1DevPodWorkspaceInstanceSpec { "type": "string", "format": "" }, + { + "name": "presetRef", + "baseName": "presetRef", + "type": "StorageV1PresetRef", + "format": "" + }, { "name": "preventWakeUpOnConnection", "baseName": "preventWakeUpOnConnection", diff --git a/gen/models/managementV1DevPodWorkspacePreset.ts b/gen/models/managementV1DevPodWorkspacePreset.ts new file mode 100644 index 0000000..220a36a --- /dev/null +++ b/gen/models/managementV1DevPodWorkspacePreset.ts @@ -0,0 +1,77 @@ +/** + * Api + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: master + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { ManagementV1DevPodWorkspacePresetSpec } from '../models/managementV1DevPodWorkspacePresetSpec'; +import { V1ObjectMeta } from '../models/V1ObjectMeta'; + + +/** +* DevPodWorkspacePreset +*/ +export class ManagementV1DevPodWorkspacePreset { + /** + * APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + */ + 'apiVersion'?: string; + /** + * Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + */ + 'kind'?: string; + 'metadata'?: V1ObjectMeta; + 'spec'?: ManagementV1DevPodWorkspacePresetSpec; + /** + * DevPodWorkspacePresetStatus holds the status + */ + 'status'?: any; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "apiVersion", + "baseName": "apiVersion", + "type": "string", + "format": "" + }, + { + "name": "kind", + "baseName": "kind", + "type": "string", + "format": "" + }, + { + "name": "metadata", + "baseName": "metadata", + "type": "V1ObjectMeta", + "format": "" + }, + { + "name": "spec", + "baseName": "spec", + "type": "ManagementV1DevPodWorkspacePresetSpec", + "format": "" + }, + { + "name": "status", + "baseName": "status", + "type": "any", + "format": "" + } ]; + + static getAttributeTypeMap() { + return ManagementV1DevPodWorkspacePreset.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/gen/models/managementV1DevPodWorkspacePresetList.ts b/gen/models/managementV1DevPodWorkspacePresetList.ts new file mode 100644 index 0000000..10a0101 --- /dev/null +++ b/gen/models/managementV1DevPodWorkspacePresetList.ts @@ -0,0 +1,64 @@ +/** + * Api + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: master + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { ManagementV1DevPodWorkspacePreset } from '../models/managementV1DevPodWorkspacePreset'; +import { V1ListMeta } from '../models/V1ListMeta'; + + +export class ManagementV1DevPodWorkspacePresetList { + /** + * APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + */ + 'apiVersion'?: string; + 'items': Array; + /** + * Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + */ + 'kind'?: string; + 'metadata'?: V1ListMeta; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "apiVersion", + "baseName": "apiVersion", + "type": "string", + "format": "" + }, + { + "name": "items", + "baseName": "items", + "type": "Array", + "format": "" + }, + { + "name": "kind", + "baseName": "kind", + "type": "string", + "format": "" + }, + { + "name": "metadata", + "baseName": "metadata", + "type": "V1ListMeta", + "format": "" + } ]; + + static getAttributeTypeMap() { + return ManagementV1DevPodWorkspacePresetList.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/gen/models/managementV1DevPodWorkspacePresetSpec.ts b/gen/models/managementV1DevPodWorkspacePresetSpec.ts new file mode 100644 index 0000000..88afa70 --- /dev/null +++ b/gen/models/managementV1DevPodWorkspacePresetSpec.ts @@ -0,0 +1,105 @@ +/** + * Api + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: master + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { StorageV1Access } from '../models/storageV1Access'; +import { StorageV1DevPodWorkspacePresetSource } from '../models/storageV1DevPodWorkspacePresetSource'; +import { StorageV1DevPodWorkspacePresetVersion } from '../models/storageV1DevPodWorkspacePresetVersion'; +import { StorageV1EnvironmentRef } from '../models/storageV1EnvironmentRef'; +import { StorageV1TemplateRef } from '../models/storageV1TemplateRef'; +import { StorageV1UserOrTeam } from '../models/storageV1UserOrTeam'; + + +/** +* DevPodWorkspacePresetSpec holds the specification +*/ +export class ManagementV1DevPodWorkspacePresetSpec { + /** + * Access to the DevPod machine instance object itself + */ + 'access'?: Array; + /** + * DisplayName is the name that should be displayed in the UI + */ + 'displayName'?: string; + 'environmentRef'?: StorageV1EnvironmentRef; + 'infrastructureRef': StorageV1TemplateRef; + 'owner'?: StorageV1UserOrTeam; + 'source': StorageV1DevPodWorkspacePresetSource; + /** + * UseProjectGitCredentials specifies if the project git credentials should be used instead of local ones for this environment + */ + 'useProjectGitCredentials'?: boolean; + /** + * Versions are different versions of the template that can be referenced as well + */ + 'versions'?: Array; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "access", + "baseName": "access", + "type": "Array", + "format": "" + }, + { + "name": "displayName", + "baseName": "displayName", + "type": "string", + "format": "" + }, + { + "name": "environmentRef", + "baseName": "environmentRef", + "type": "StorageV1EnvironmentRef", + "format": "" + }, + { + "name": "infrastructureRef", + "baseName": "infrastructureRef", + "type": "StorageV1TemplateRef", + "format": "" + }, + { + "name": "owner", + "baseName": "owner", + "type": "StorageV1UserOrTeam", + "format": "" + }, + { + "name": "source", + "baseName": "source", + "type": "StorageV1DevPodWorkspacePresetSource", + "format": "" + }, + { + "name": "useProjectGitCredentials", + "baseName": "useProjectGitCredentials", + "type": "boolean", + "format": "" + }, + { + "name": "versions", + "baseName": "versions", + "type": "Array", + "format": "" + } ]; + + static getAttributeTypeMap() { + return ManagementV1DevPodWorkspacePresetSpec.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/gen/models/managementV1MaintenanceWindow.ts b/gen/models/managementV1MaintenanceWindow.ts new file mode 100644 index 0000000..51c5cd8 --- /dev/null +++ b/gen/models/managementV1MaintenanceWindow.ts @@ -0,0 +1,48 @@ +/** + * Api + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: master + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + + +export class ManagementV1MaintenanceWindow { + /** + * DayOfWeek specifies the day of the week for the maintenance window. It should be a string representing the day, e.g., \"Monday\", \"Tuesday\", etc. + */ + 'dayOfWeek'?: string; + /** + * TimeWindow specifies the time window for the maintenance. It should be a string representing the time range in 24-hour format, in UTC, e.g., \"02:00-03:00\". + */ + 'timeWindow'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "dayOfWeek", + "baseName": "dayOfWeek", + "type": "string", + "format": "" + }, + { + "name": "timeWindow", + "baseName": "timeWindow", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return ManagementV1MaintenanceWindow.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/gen/models/managementV1ProjectSpec.ts b/gen/models/managementV1ProjectSpec.ts index 15af19c..5fcd525 100644 --- a/gen/models/managementV1ProjectSpec.ts +++ b/gen/models/managementV1ProjectSpec.ts @@ -20,6 +20,7 @@ import { StorageV1Member } from '../models/storageV1Member'; import { StorageV1NamespacePattern } from '../models/storageV1NamespacePattern'; import { StorageV1Quotas } from '../models/storageV1Quotas'; import { StorageV1RancherIntegrationSpec } from '../models/storageV1RancherIntegrationSpec'; +import { StorageV1RequirePreset } from '../models/storageV1RequirePreset'; import { StorageV1RequireTemplate } from '../models/storageV1RequireTemplate'; import { StorageV1UserOrTeam } from '../models/storageV1UserOrTeam'; import { StorageV1VaultIntegrationSpec } from '../models/storageV1VaultIntegrationSpec'; @@ -63,6 +64,7 @@ export class ManagementV1ProjectSpec { 'owner'?: StorageV1UserOrTeam; 'quotas'?: StorageV1Quotas; 'rancher'?: StorageV1RancherIntegrationSpec; + 'requirePreset'?: StorageV1RequirePreset; 'requireTemplate'?: StorageV1RequireTemplate; 'vault'?: StorageV1VaultIntegrationSpec; @@ -147,6 +149,12 @@ export class ManagementV1ProjectSpec { "type": "StorageV1RancherIntegrationSpec", "format": "" }, + { + "name": "requirePreset", + "baseName": "requirePreset", + "type": "StorageV1RequirePreset", + "format": "" + }, { "name": "requireTemplate", "baseName": "requireTemplate", diff --git a/gen/models/managementV1ProjectTemplates.ts b/gen/models/managementV1ProjectTemplates.ts index be5ec13..11d9f2b 100644 --- a/gen/models/managementV1ProjectTemplates.ts +++ b/gen/models/managementV1ProjectTemplates.ts @@ -11,6 +11,7 @@ */ import { ManagementV1DevPodEnvironmentTemplate } from '../models/managementV1DevPodEnvironmentTemplate'; +import { ManagementV1DevPodWorkspacePreset } from '../models/managementV1DevPodWorkspacePreset'; import { ManagementV1DevPodWorkspaceTemplate } from '../models/managementV1DevPodWorkspaceTemplate'; import { ManagementV1SpaceTemplate } from '../models/managementV1SpaceTemplate'; import { ManagementV1VirtualClusterTemplate } from '../models/managementV1VirtualClusterTemplate'; @@ -43,6 +44,10 @@ export class ManagementV1ProjectTemplates { */ 'devPodEnvironmentTemplates'?: Array; /** + * DevPodWorkspacePresets holds all the allowed workspace presets + */ + 'devPodWorkspacePresets'?: Array; + /** * DevPodWorkspaceTemplates holds all the allowed space templates */ 'devPodWorkspaceTemplates'?: Array; @@ -99,6 +104,12 @@ export class ManagementV1ProjectTemplates { "type": "Array", "format": "" }, + { + "name": "devPodWorkspacePresets", + "baseName": "devPodWorkspacePresets", + "type": "Array", + "format": "" + }, { "name": "devPodWorkspaceTemplates", "baseName": "devPodWorkspaceTemplates", diff --git a/gen/models/managementV1VirtualClusterExternalDatabase.ts b/gen/models/managementV1VirtualClusterExternalDatabase.ts new file mode 100644 index 0000000..4fbc230 --- /dev/null +++ b/gen/models/managementV1VirtualClusterExternalDatabase.ts @@ -0,0 +1,75 @@ +/** + * Api + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: master + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { ManagementV1VirtualClusterExternalDatabaseSpec } from '../models/managementV1VirtualClusterExternalDatabaseSpec'; +import { ManagementV1VirtualClusterExternalDatabaseStatus } from '../models/managementV1VirtualClusterExternalDatabaseStatus'; +import { V1ObjectMeta } from '../models/V1ObjectMeta'; + + +/** +* VirtualClusterExternalDatabase holds kube config request and response data for virtual clusters +*/ +export class ManagementV1VirtualClusterExternalDatabase { + /** + * APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + */ + 'apiVersion'?: string; + /** + * Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + */ + 'kind'?: string; + 'metadata'?: V1ObjectMeta; + 'spec'?: ManagementV1VirtualClusterExternalDatabaseSpec; + 'status'?: ManagementV1VirtualClusterExternalDatabaseStatus; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "apiVersion", + "baseName": "apiVersion", + "type": "string", + "format": "" + }, + { + "name": "kind", + "baseName": "kind", + "type": "string", + "format": "" + }, + { + "name": "metadata", + "baseName": "metadata", + "type": "V1ObjectMeta", + "format": "" + }, + { + "name": "spec", + "baseName": "spec", + "type": "ManagementV1VirtualClusterExternalDatabaseSpec", + "format": "" + }, + { + "name": "status", + "baseName": "status", + "type": "ManagementV1VirtualClusterExternalDatabaseStatus", + "format": "" + } ]; + + static getAttributeTypeMap() { + return ManagementV1VirtualClusterExternalDatabase.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/gen/models/managementV1VirtualClusterExternalDatabaseSpec.ts b/gen/models/managementV1VirtualClusterExternalDatabaseSpec.ts new file mode 100644 index 0000000..99547b4 --- /dev/null +++ b/gen/models/managementV1VirtualClusterExternalDatabaseSpec.ts @@ -0,0 +1,38 @@ +/** + * Api + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: master + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + + +export class ManagementV1VirtualClusterExternalDatabaseSpec { + /** + * Connector specifies the secret that should be used to connect to an external database server. The connection is used to manage a user and database for the vCluster. A data source endpoint constructed from the created user and database is returned on status. The secret specified by connector should contain the following fields: endpoint - the endpoint where the database server can be accessed user - the database username password - the password for the database username port - the port to be used in conjunction with the endpoint to connect to the databse server. This is commonly 3306 + */ + 'connector'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "connector", + "baseName": "connector", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return ManagementV1VirtualClusterExternalDatabaseSpec.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/gen/models/managementV1VirtualClusterExternalDatabaseStatus.ts b/gen/models/managementV1VirtualClusterExternalDatabaseStatus.ts new file mode 100644 index 0000000..9cdfc92 --- /dev/null +++ b/gen/models/managementV1VirtualClusterExternalDatabaseStatus.ts @@ -0,0 +1,38 @@ +/** + * Api + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: master + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + + +export class ManagementV1VirtualClusterExternalDatabaseStatus { + /** + * DataSource holds a datasource endpoint constructed from the vCluster\'s designated user and database. The user and database are created from the given connector. + */ + 'dataSource'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "dataSource", + "baseName": "dataSource", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return ManagementV1VirtualClusterExternalDatabaseStatus.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/gen/models/storageV1DevPodEnvironmentTemplateDefinition.ts b/gen/models/storageV1DevPodEnvironmentTemplateDefinition.ts new file mode 100644 index 0000000..98b1328 --- /dev/null +++ b/gen/models/storageV1DevPodEnvironmentTemplateDefinition.ts @@ -0,0 +1,46 @@ +/** + * Api + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: master + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { StorageV1GitEnvironmentTemplate } from '../models/storageV1GitEnvironmentTemplate'; + + +export class StorageV1DevPodEnvironmentTemplateDefinition { + 'git'?: StorageV1GitEnvironmentTemplate; + /** + * Inline holds an inline devcontainer.json definition + */ + 'inline'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "git", + "baseName": "git", + "type": "StorageV1GitEnvironmentTemplate", + "format": "" + }, + { + "name": "inline", + "baseName": "inline", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return StorageV1DevPodEnvironmentTemplateDefinition.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/gen/models/storageV1DevPodEnvironmentTemplateVersion.ts b/gen/models/storageV1DevPodEnvironmentTemplateVersion.ts index 0620e24..58f2a5d 100644 --- a/gen/models/storageV1DevPodEnvironmentTemplateVersion.ts +++ b/gen/models/storageV1DevPodEnvironmentTemplateVersion.ts @@ -10,11 +10,11 @@ * Do not edit the class manually. */ -import { StorageV1GitEnvironmentTemplate } from '../models/storageV1GitEnvironmentTemplate'; +import { StorageV1DevPodEnvironmentTemplateDefinition } from '../models/storageV1DevPodEnvironmentTemplateDefinition'; export class StorageV1DevPodEnvironmentTemplateVersion { - 'git'?: StorageV1GitEnvironmentTemplate; + 'template'?: StorageV1DevPodEnvironmentTemplateDefinition; /** * Version is the version. Needs to be in X.X.X format. */ @@ -24,9 +24,9 @@ export class StorageV1DevPodEnvironmentTemplateVersion { static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { - "name": "git", - "baseName": "git", - "type": "StorageV1GitEnvironmentTemplate", + "name": "template", + "baseName": "template", + "type": "StorageV1DevPodEnvironmentTemplateDefinition", "format": "" }, { diff --git a/gen/models/storageV1DevPodWorkspacePresetSource.ts b/gen/models/storageV1DevPodWorkspacePresetSource.ts new file mode 100644 index 0000000..dd7c9c2 --- /dev/null +++ b/gen/models/storageV1DevPodWorkspacePresetSource.ts @@ -0,0 +1,48 @@ +/** + * Api + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: master + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + + +export class StorageV1DevPodWorkspacePresetSource { + /** + * Git stores path to git repo to use as workspace source + */ + 'git'?: string; + /** + * Image stores container image to use as workspace source + */ + 'image'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "git", + "baseName": "git", + "type": "string", + "format": "" + }, + { + "name": "image", + "baseName": "image", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return StorageV1DevPodWorkspacePresetSource.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/gen/models/storageV1DevPodWorkspacePresetVersion.ts b/gen/models/storageV1DevPodWorkspacePresetVersion.ts new file mode 100644 index 0000000..ce5c33c --- /dev/null +++ b/gen/models/storageV1DevPodWorkspacePresetVersion.ts @@ -0,0 +1,72 @@ +/** + * Api + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: master + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { StorageV1DevPodWorkspacePresetSource } from '../models/storageV1DevPodWorkspacePresetSource'; +import { StorageV1EnvironmentRef } from '../models/storageV1EnvironmentRef'; +import { StorageV1TemplateRef } from '../models/storageV1TemplateRef'; + + +export class StorageV1DevPodWorkspacePresetVersion { + 'environmentRef'?: StorageV1EnvironmentRef; + 'infrastructureRef'?: StorageV1TemplateRef; + 'source'?: StorageV1DevPodWorkspacePresetSource; + /** + * UseProjectGitCredentials specifies if the project git credentials should be used instead of local ones for this environment + */ + 'useProjectGitCredentials'?: boolean; + /** + * Version is the version. Needs to be in X.X.X format. + */ + 'version'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "environmentRef", + "baseName": "environmentRef", + "type": "StorageV1EnvironmentRef", + "format": "" + }, + { + "name": "infrastructureRef", + "baseName": "infrastructureRef", + "type": "StorageV1TemplateRef", + "format": "" + }, + { + "name": "source", + "baseName": "source", + "type": "StorageV1DevPodWorkspacePresetSource", + "format": "" + }, + { + "name": "useProjectGitCredentials", + "baseName": "useProjectGitCredentials", + "type": "boolean", + "format": "" + }, + { + "name": "version", + "baseName": "version", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return StorageV1DevPodWorkspacePresetVersion.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/gen/models/storageV1EnvironmentRef.ts b/gen/models/storageV1EnvironmentRef.ts index be53f63..9238fac 100644 --- a/gen/models/storageV1EnvironmentRef.ts +++ b/gen/models/storageV1EnvironmentRef.ts @@ -17,6 +17,10 @@ export class StorageV1EnvironmentRef { * Name is the name of DevPodEnvironmentTemplate this references */ 'name': string; + /** + * Version is the version of DevPodEnvironmentTemplate this references + */ + 'version'?: string; static readonly discriminator: string | undefined = undefined; @@ -26,6 +30,12 @@ export class StorageV1EnvironmentRef { "baseName": "name", "type": "string", "format": "" + }, + { + "name": "version", + "baseName": "version", + "type": "string", + "format": "" } ]; static getAttributeTypeMap() { diff --git a/gen/models/storageV1PresetRef.ts b/gen/models/storageV1PresetRef.ts new file mode 100644 index 0000000..d565090 --- /dev/null +++ b/gen/models/storageV1PresetRef.ts @@ -0,0 +1,48 @@ +/** + * Api + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: master + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + + +export class StorageV1PresetRef { + /** + * Name is the name of DevPodWorkspacePreset + */ + 'name': string; + /** + * Version holds the preset version to use. Version is expected to be in semantic versioning format. Alternatively, you can also exchange major, minor or patch with an \'x\' to tell Loft to automatically select the latest major, minor or patch version. + */ + 'version'?: string; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "name", + "baseName": "name", + "type": "string", + "format": "" + }, + { + "name": "version", + "baseName": "version", + "type": "string", + "format": "" + } ]; + + static getAttributeTypeMap() { + return StorageV1PresetRef.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/gen/models/storageV1RequirePreset.ts b/gen/models/storageV1RequirePreset.ts new file mode 100644 index 0000000..a490471 --- /dev/null +++ b/gen/models/storageV1RequirePreset.ts @@ -0,0 +1,38 @@ +/** + * Api + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * OpenAPI spec version: master + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + + +export class StorageV1RequirePreset { + /** + * If true, all users within the project will not be allowed to create a new instance without a preset. By default, all users are allowed to create a new instance without a preset. + */ + 'disabled'?: boolean; + + static readonly discriminator: string | undefined = undefined; + + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ + { + "name": "disabled", + "baseName": "disabled", + "type": "boolean", + "format": "" + } ]; + + static getAttributeTypeMap() { + return StorageV1RequirePreset.attributeTypeMap; + } + + public constructor() { + } +} + diff --git a/gen/models/uiV1UISettingsSpec.ts b/gen/models/uiV1UISettingsSpec.ts index f02e15e..86c078f 100644 --- a/gen/models/uiV1UISettingsSpec.ts +++ b/gen/models/uiV1UISettingsSpec.ts @@ -34,7 +34,7 @@ export class UiV1UISettingsSpec { */ 'defaultVClusterVersion'?: string; /** - * HasHelmRelease indicates whether loft has been installed via Helm + * HasHelmRelease indicates whether the vCluster Platform instance has been installed via Helm */ 'hasHelmRelease'?: boolean; /** @@ -42,6 +42,10 @@ export class UiV1UISettingsSpec { */ 'legalTemplate'?: string; /** + * LoftHosted indicates whether the vCluster Platform instance is hosted and operated by Loft Labs Inc. + */ + 'loftHosted'?: boolean; + /** * LoftVersion holds the current loft version */ 'loftVersion'?: string; @@ -113,6 +117,12 @@ export class UiV1UISettingsSpec { "type": "string", "format": "" }, + { + "name": "loftHosted", + "baseName": "loftHosted", + "type": "boolean", + "format": "" + }, { "name": "loftVersion", "baseName": "loftVersion", diff --git a/gen/resources.ts b/gen/resources.ts index a887689..a91c355 100644 --- a/gen/resources.ts +++ b/gen/resources.ts @@ -22,6 +22,7 @@ import {ManagementV1ConvertVirtualClusterConfig} from "./models/managementV1Conv import {ManagementV1DevPodEnvironmentTemplate} from "./models/managementV1DevPodEnvironmentTemplate" import {ManagementV1DevPodWorkspaceInstanceState} from "./models/managementV1DevPodWorkspaceInstanceState" import {ManagementV1DevPodWorkspaceInstance} from "./models/managementV1DevPodWorkspaceInstance" +import {ManagementV1DevPodWorkspacePreset} from "./models/managementV1DevPodWorkspacePreset" import {ManagementV1DevPodWorkspaceTemplate} from "./models/managementV1DevPodWorkspaceTemplate" import {ManagementV1DirectClusterEndpointToken} from "./models/managementV1DirectClusterEndpointToken" import {ManagementV1Event} from "./models/managementV1Event" @@ -69,6 +70,7 @@ import {ManagementV1UserPermissions} from "./models/managementV1UserPermissions" import {ManagementV1UserProfile} from "./models/managementV1UserProfile" import {ManagementV1User} from "./models/managementV1User" import {ManagementV1VirtualClusterAccessKey} from "./models/managementV1VirtualClusterAccessKey" +import {ManagementV1VirtualClusterExternalDatabase} from "./models/managementV1VirtualClusterExternalDatabase" import {ManagementV1VirtualClusterInstanceKubeConfig} from "./models/managementV1VirtualClusterInstanceKubeConfig" import {ManagementV1VirtualClusterInstanceLog} from "./models/managementV1VirtualClusterInstanceLog" import {ManagementV1VirtualClusterInstance} from "./models/managementV1VirtualClusterInstance" @@ -97,6 +99,7 @@ export type TGenResources = { ManagementV1DevPodEnvironmentTemplate: GroupVersionResource ManagementV1DevPodWorkspaceInstance: GroupVersionResource ManagementV1DevPodWorkspaceInstanceState: GroupVersionResource + ManagementV1DevPodWorkspacePreset: GroupVersionResource ManagementV1DevPodWorkspaceTemplate: GroupVersionResource ManagementV1DirectClusterEndpointToken: GroupVersionResource ManagementV1Event: GroupVersionResource @@ -144,6 +147,7 @@ export type TGenResources = { ManagementV1UserPermissions: GroupVersionResource ManagementV1UserProfile: GroupVersionResource ManagementV1VirtualClusterAccessKey: GroupVersionResource + ManagementV1VirtualClusterExternalDatabase: GroupVersionResource ManagementV1VirtualClusterInstance: GroupVersionResource ManagementV1VirtualClusterInstanceKubeConfig: GroupVersionResource ManagementV1VirtualClusterInstanceLog: GroupVersionResource @@ -327,6 +331,14 @@ export const GenResources: TGenResources = { namespaced: true, kind: "DevPodWorkspaceInstanceState", }, + ManagementV1DevPodWorkspacePreset: { + group: "management.loft.sh", + version: "v1", + resource: "devpodworkspacepresets", + subResource: "", + namespaced: false, + kind: "DevPodWorkspacePreset", + }, ManagementV1DevPodWorkspaceTemplate: { group: "management.loft.sh", version: "v1", @@ -703,6 +715,14 @@ export const GenResources: TGenResources = { namespaced: true, kind: "VirtualClusterAccessKey", }, + ManagementV1VirtualClusterExternalDatabase: { + group: "management.loft.sh", + version: "v1", + resource: "virtualclusterinstances", + subResource: "externaldatabase", + namespaced: true, + kind: "VirtualClusterExternalDatabase", + }, ManagementV1VirtualClusterInstance: { group: "management.loft.sh", version: "v1", diff --git a/lib/index.d.ts b/lib/index.d.ts index 3695f56..eca096e 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -5070,6 +5070,51 @@ declare class ManagementV1Authentication { }[]; constructor(); } +declare class ManagementV1MaintenanceWindow { + /** + * DayOfWeek specifies the day of the week for the maintenance window. It should be a string representing the day, e.g., \"Monday\", \"Tuesday\", etc. + */ + "dayOfWeek"?: string; + /** + * TimeWindow specifies the time window for the maintenance. It should be a string representing the time range in 24-hour format, in UTC, e.g., \"02:00-03:00\". + */ + "timeWindow"?: string; + static readonly discriminator: string | undefined; + static readonly attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + format: string; + }>; + static getAttributeTypeMap(): { + name: string; + baseName: string; + type: string; + format: string; + }[]; + constructor(); +} +declare class ManagementV1Cloud { + "maintenanceWindow"?: ManagementV1MaintenanceWindow; + /** + * ReleaseChannel specifies the release channel for the cloud configuration. This can be used to determine which updates or versions are applied. + */ + "releaseChannel"?: string; + static readonly discriminator: string | undefined; + static readonly attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + format: string; + }>; + static getAttributeTypeMap(): { + name: string; + baseName: string; + type: string; + format: string; + }[]; + constructor(); +} declare class ManagementV1OIDCClientSpec { /** * The client id of the client @@ -5308,6 +5353,7 @@ declare class ManagementV1ConfigStatus { "apps"?: ManagementV1Apps; "audit"?: ManagementV1Audit; "auth"?: ManagementV1Authentication; + "cloud"?: ManagementV1Cloud; /** * DevPodSubDomain holds a subdomain in the following form *.workspace.my-domain.com */ @@ -5482,9 +5528,30 @@ declare class StorageV1GitEnvironmentTemplate { }[]; constructor(); } -declare class StorageV1DevPodEnvironmentTemplateVersion { +declare class StorageV1DevPodEnvironmentTemplateDefinition { "git"?: StorageV1GitEnvironmentTemplate; /** + * Inline holds an inline devcontainer.json definition + */ + "inline"?: string; + static readonly discriminator: string | undefined; + static readonly attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + format: string; + }>; + static getAttributeTypeMap(): { + name: string; + baseName: string; + type: string; + format: string; + }[]; + constructor(); +} +declare class StorageV1DevPodEnvironmentTemplateVersion { + "template"?: StorageV1DevPodEnvironmentTemplateDefinition; + /** * Version is the version. Needs to be in X.X.X format. */ "version"?: string; @@ -5509,11 +5576,15 @@ declare class ManagementV1DevPodEnvironmentTemplateSpec { */ "access"?: Array; /** + * Description describes the environment template + */ + "description"?: string; + /** * DisplayName is the name that should be displayed in the UI */ "displayName"?: string; - "git"?: StorageV1GitEnvironmentTemplate; "owner"?: StorageV1UserOrTeam; + "template"?: StorageV1DevPodEnvironmentTemplateDefinition; /** * Versions are different versions of the template that can be referenced as well */ @@ -5876,6 +5947,34 @@ declare class StorageV1EnvironmentRef { * Name is the name of DevPodEnvironmentTemplate this references */ "name": string; + /** + * Version is the version of DevPodEnvironmentTemplate this references + */ + "version"?: string; + static readonly discriminator: string | undefined; + static readonly attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + format: string; + }>; + static getAttributeTypeMap(): { + name: string; + baseName: string; + type: string; + format: string; + }[]; + constructor(); +} +declare class StorageV1PresetRef { + /** + * Name is the name of DevPodWorkspacePreset + */ + "name": string; + /** + * Version holds the preset version to use. Version is expected to be in semantic versioning format. Alternatively, you can also exchange major, minor or patch with an \'x\' to tell Loft to automatically select the latest major, minor or patch version. + */ + "version"?: string; static readonly discriminator: string | undefined; static readonly attributeTypeMap: Array<{ name: string; @@ -5930,6 +6029,7 @@ declare class ManagementV1DevPodWorkspaceInstanceSpec { * Parameters are values to pass to the template. The values should be encoded as YAML string where each parameter is represented as a top-level field key. */ "parameters"?: string; + "presetRef"?: StorageV1PresetRef; /** * PreventWakeUpOnConnection is used to prevent workspace that uses sleep mode from waking up on incomming ssh connection. */ @@ -6086,6 +6186,123 @@ declare class ManagementV1DevPodWorkspaceInstance { }[]; constructor(); } +declare class StorageV1DevPodWorkspacePresetSource { + /** + * Git stores path to git repo to use as workspace source + */ + "git"?: string; + /** + * Image stores container image to use as workspace source + */ + "image"?: string; + static readonly discriminator: string | undefined; + static readonly attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + format: string; + }>; + static getAttributeTypeMap(): { + name: string; + baseName: string; + type: string; + format: string; + }[]; + constructor(); +} +declare class StorageV1DevPodWorkspacePresetVersion { + "environmentRef"?: StorageV1EnvironmentRef; + "infrastructureRef"?: StorageV1TemplateRef; + "source"?: StorageV1DevPodWorkspacePresetSource; + /** + * UseProjectGitCredentials specifies if the project git credentials should be used instead of local ones for this environment + */ + "useProjectGitCredentials"?: boolean; + /** + * Version is the version. Needs to be in X.X.X format. + */ + "version"?: string; + static readonly discriminator: string | undefined; + static readonly attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + format: string; + }>; + static getAttributeTypeMap(): { + name: string; + baseName: string; + type: string; + format: string; + }[]; + constructor(); +} +declare class ManagementV1DevPodWorkspacePresetSpec { + /** + * Access to the DevPod machine instance object itself + */ + "access"?: Array; + /** + * DisplayName is the name that should be displayed in the UI + */ + "displayName"?: string; + "environmentRef"?: StorageV1EnvironmentRef; + "infrastructureRef": StorageV1TemplateRef; + "owner"?: StorageV1UserOrTeam; + "source": StorageV1DevPodWorkspacePresetSource; + /** + * UseProjectGitCredentials specifies if the project git credentials should be used instead of local ones for this environment + */ + "useProjectGitCredentials"?: boolean; + /** + * Versions are different versions of the template that can be referenced as well + */ + "versions"?: Array; + static readonly discriminator: string | undefined; + static readonly attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + format: string; + }>; + static getAttributeTypeMap(): { + name: string; + baseName: string; + type: string; + format: string; + }[]; + constructor(); +} +declare class ManagementV1DevPodWorkspacePreset { + /** + * APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + */ + "apiVersion"?: string; + /** + * Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + */ + "kind"?: string; + "metadata"?: V1ObjectMeta; + "spec"?: ManagementV1DevPodWorkspacePresetSpec; + /** + * DevPodWorkspacePresetStatus holds the status + */ + "status"?: any; + static readonly discriminator: string | undefined; + static readonly attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + format: string; + }>; + static getAttributeTypeMap(): { + name: string; + baseName: string; + type: string; + format: string; + }[]; + constructor(); +} declare class StorageV1DevPodWorkspaceTemplateVersion { /** * Parameters define additional app parameters that will set provider values @@ -7378,7 +7595,7 @@ declare class UiV1UISettingsSpec { */ "defaultVClusterVersion"?: string; /** - * HasHelmRelease indicates whether loft has been installed via Helm + * HasHelmRelease indicates whether the vCluster Platform instance has been installed via Helm */ "hasHelmRelease"?: boolean; /** @@ -7386,6 +7603,10 @@ declare class UiV1UISettingsSpec { */ "legalTemplate"?: string; /** + * LoftHosted indicates whether the vCluster Platform instance is hosted and operated by Loft Labs Inc. + */ + "loftHosted"?: boolean; + /** * LoftVersion holds the current loft version */ "loftVersion"?: string; @@ -11443,6 +11664,10 @@ declare class ManagementV1ProjectTemplates { */ "devPodEnvironmentTemplates"?: Array; /** + * DevPodWorkspacePresets holds all the allowed workspace presets + */ + "devPodWorkspacePresets"?: Array; + /** * DevPodWorkspaceTemplates holds all the allowed space templates */ "devPodWorkspaceTemplates"?: Array; @@ -11972,6 +12197,26 @@ declare class StorageV1RancherIntegrationSpec { }[]; constructor(); } +declare class StorageV1RequirePreset { + /** + * If true, all users within the project will not be allowed to create a new instance without a preset. By default, all users are allowed to create a new instance without a preset. + */ + "disabled"?: boolean; + static readonly discriminator: string | undefined; + static readonly attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + format: string; + }>; + static getAttributeTypeMap(): { + name: string; + baseName: string; + type: string; + format: string; + }[]; + constructor(); +} declare class StorageV1RequireTemplate { /** * If true, all users within the project will be allowed to create a new instance without a template. By default, only admins are allowed to create a new instance without a template. @@ -12027,6 +12272,7 @@ declare class ManagementV1ProjectSpec { "owner"?: StorageV1UserOrTeam; "quotas"?: StorageV1Quotas; "rancher"?: StorageV1RancherIntegrationSpec; + "requirePreset"?: StorageV1RequirePreset; "requireTemplate"?: StorageV1RequireTemplate; "vault"?: StorageV1VaultIntegrationSpec; static readonly discriminator: string | undefined; @@ -14513,6 +14759,73 @@ declare class ManagementV1VirtualClusterAccessKey { }[]; constructor(); } +declare class ManagementV1VirtualClusterExternalDatabaseSpec { + /** + * Connector specifies the secret that should be used to connect to an external database server. The connection is used to manage a user and database for the vCluster. A data source endpoint constructed from the created user and database is returned on status. The secret specified by connector should contain the following fields: endpoint - the endpoint where the database server can be accessed user - the database username password - the password for the database username port - the port to be used in conjunction with the endpoint to connect to the databse server. This is commonly 3306 + */ + "connector"?: string; + static readonly discriminator: string | undefined; + static readonly attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + format: string; + }>; + static getAttributeTypeMap(): { + name: string; + baseName: string; + type: string; + format: string; + }[]; + constructor(); +} +declare class ManagementV1VirtualClusterExternalDatabaseStatus { + /** + * DataSource holds a datasource endpoint constructed from the vCluster\'s designated user and database. The user and database are created from the given connector. + */ + "dataSource"?: string; + static readonly discriminator: string | undefined; + static readonly attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + format: string; + }>; + static getAttributeTypeMap(): { + name: string; + baseName: string; + type: string; + format: string; + }[]; + constructor(); +} +declare class ManagementV1VirtualClusterExternalDatabase { + /** + * APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + */ + "apiVersion"?: string; + /** + * Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + */ + "kind"?: string; + "metadata"?: V1ObjectMeta; + "spec"?: ManagementV1VirtualClusterExternalDatabaseSpec; + "status"?: ManagementV1VirtualClusterExternalDatabaseStatus; + static readonly discriminator: string | undefined; + static readonly attributeTypeMap: Array<{ + name: string; + baseName: string; + type: string; + format: string; + }>; + static getAttributeTypeMap(): { + name: string; + baseName: string; + type: string; + format: string; + }[]; + constructor(); +} declare class ManagementV1VirtualClusterInstanceKubeConfigSpec { /** * CertificateTTL holds the ttl (in seconds) to set for the certificate associated with the returned kubeconfig. This field is optional, if no value is provided, the certificate TTL will be set to one day. If set to zero, this will cause loft to pass nil to the certificate signing request, which will result in the certificate being valid for the clusters `cluster-signing-duration` value which is typically one year. @@ -14791,6 +15104,7 @@ export type TGenResources = { ManagementV1DevPodEnvironmentTemplate: GroupVersionResource; ManagementV1DevPodWorkspaceInstance: GroupVersionResource; ManagementV1DevPodWorkspaceInstanceState: GroupVersionResource; + ManagementV1DevPodWorkspacePreset: GroupVersionResource; ManagementV1DevPodWorkspaceTemplate: GroupVersionResource; ManagementV1DirectClusterEndpointToken: GroupVersionResource; ManagementV1Event: GroupVersionResource; @@ -14838,6 +15152,7 @@ export type TGenResources = { ManagementV1UserPermissions: GroupVersionResource; ManagementV1UserProfile: GroupVersionResource; ManagementV1VirtualClusterAccessKey: GroupVersionResource; + ManagementV1VirtualClusterExternalDatabase: GroupVersionResource; ManagementV1VirtualClusterInstance: GroupVersionResource; ManagementV1VirtualClusterInstanceKubeConfig: GroupVersionResource; ManagementV1VirtualClusterInstanceLog: GroupVersionResource; diff --git a/lib/index.esm.js b/lib/index.esm.js index 7a76b71..870bf07 100644 --- a/lib/index.esm.js +++ b/lib/index.esm.js @@ -1 +1 @@ -import p from"js-cookie";import te from"json-merge-patch";var M={loftAccessKeyIdentifier:"loft_access_key",loftImpersonateSubjectIdentifier:"loft_impersonate_subject",loftImpersonateJoinedGroupIdentifier:"loft_impersonate_joined_group",platformAccessKeyNotFound:"platform access key not found. Please login again"};function h(a){return a||[]}var D={ManagementV1AgentAuditEvent:{group:"management.loft.sh",version:"v1",resource:"agentauditevents",subResource:"",namespaced:!1,kind:"AgentAuditEvent"},ManagementV1Announcement:{group:"management.loft.sh",version:"v1",resource:"announcements",subResource:"",namespaced:!1,kind:"Announcement"},ManagementV1App:{group:"management.loft.sh",version:"v1",resource:"apps",subResource:"",namespaced:!1,kind:"App"},ManagementV1AppCredentials:{group:"management.loft.sh",version:"v1",resource:"apps",subResource:"credentials",namespaced:!1,kind:"AppCredentials"},ManagementV1Backup:{group:"management.loft.sh",version:"v1",resource:"backups",subResource:"",namespaced:!1,kind:"Backup"},ManagementV1BackupApply:{group:"management.loft.sh",version:"v1",resource:"backups",subResource:"apply",namespaced:!1,kind:"BackupApply"},ManagementV1Cluster:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"",namespaced:!1,kind:"Cluster"},ManagementV1ClusterAccess:{group:"management.loft.sh",version:"v1",resource:"clusteraccesses",subResource:"",namespaced:!1,kind:"ClusterAccess"},ManagementV1ClusterAccessKey:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"accesskey",namespaced:!1,kind:"ClusterAccessKey"},ManagementV1ClusterAgentConfig:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"agentconfig",namespaced:!1,kind:"ClusterAgentConfig"},ManagementV1ClusterCharts:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"charts",namespaced:!1,kind:"ClusterCharts"},ManagementV1ClusterDomain:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"domain",namespaced:!1,kind:"ClusterDomain"},ManagementV1ClusterMemberAccess:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"memberaccess",namespaced:!1,kind:"ClusterMemberAccess"},ManagementV1ClusterMembers:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"members",namespaced:!1,kind:"ClusterMembers"},ManagementV1ClusterReset:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"reset",namespaced:!1,kind:"ClusterReset"},ManagementV1ClusterRoleTemplate:{group:"management.loft.sh",version:"v1",resource:"clusterroletemplates",subResource:"",namespaced:!1,kind:"ClusterRoleTemplate"},ManagementV1ClusterVirtualClusterDefaults:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"virtualclusterdefaults",namespaced:!1,kind:"ClusterVirtualClusterDefaults"},ManagementV1Config:{group:"management.loft.sh",version:"v1",resource:"configs",subResource:"",namespaced:!1,kind:"Config"},ManagementV1ConvertVirtualClusterConfig:{group:"management.loft.sh",version:"v1",resource:"convertvirtualclusterconfig",subResource:"",namespaced:!1,kind:"ConvertVirtualClusterConfig"},ManagementV1DevPodEnvironmentTemplate:{group:"management.loft.sh",version:"v1",resource:"devpodenvironmenttemplates",subResource:"",namespaced:!1,kind:"DevPodEnvironmentTemplate"},ManagementV1DevPodWorkspaceInstance:{group:"management.loft.sh",version:"v1",resource:"devpodworkspaceinstances",subResource:"",namespaced:!0,kind:"DevPodWorkspaceInstance"},ManagementV1DevPodWorkspaceInstanceState:{group:"management.loft.sh",version:"v1",resource:"devpodworkspaceinstances",subResource:"state",namespaced:!0,kind:"DevPodWorkspaceInstanceState"},ManagementV1DevPodWorkspaceTemplate:{group:"management.loft.sh",version:"v1",resource:"devpodworkspacetemplates",subResource:"",namespaced:!1,kind:"DevPodWorkspaceTemplate"},ManagementV1DirectClusterEndpointToken:{group:"management.loft.sh",version:"v1",resource:"directclusterendpointtokens",subResource:"",namespaced:!1,kind:"DirectClusterEndpointToken"},ManagementV1Event:{group:"management.loft.sh",version:"v1",resource:"events",subResource:"",namespaced:!1,kind:"Event"},ManagementV1Feature:{group:"management.loft.sh",version:"v1",resource:"features",subResource:"",namespaced:!1,kind:"Feature"},ManagementV1IngressAuthToken:{group:"management.loft.sh",version:"v1",resource:"ingressauthtokens",subResource:"",namespaced:!1,kind:"IngressAuthToken"},ManagementV1Kiosk:{group:"management.loft.sh",version:"v1",resource:"kiosk",subResource:"",namespaced:!1,kind:"Kiosk"},ManagementV1License:{group:"management.loft.sh",version:"v1",resource:"licenses",subResource:"",namespaced:!1,kind:"License"},ManagementV1LicenseRequest:{group:"management.loft.sh",version:"v1",resource:"licenses",subResource:"request",namespaced:!1,kind:"LicenseRequest"},ManagementV1LicenseToken:{group:"management.loft.sh",version:"v1",resource:"licensetokens",subResource:"",namespaced:!1,kind:"LicenseToken"},ManagementV1LoftUpgrade:{group:"management.loft.sh",version:"v1",resource:"loftupgrades",subResource:"",namespaced:!1,kind:"LoftUpgrade"},ManagementV1OIDCClient:{group:"management.loft.sh",version:"v1",resource:"oidcclients",subResource:"",namespaced:!1,kind:"OIDCClient"},ManagementV1OwnedAccessKey:{group:"management.loft.sh",version:"v1",resource:"ownedaccesskeys",subResource:"",namespaced:!1,kind:"OwnedAccessKey"},ManagementV1Project:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"",namespaced:!1,kind:"Project"},ManagementV1ProjectChartInfo:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"chartinfo",namespaced:!1,kind:"ProjectChartInfo"},ManagementV1ProjectCharts:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"charts",namespaced:!1,kind:"ProjectCharts"},ManagementV1ProjectClusters:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"clusters",namespaced:!1,kind:"ProjectClusters"},ManagementV1ProjectImportSpace:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"importspace",namespaced:!1,kind:"ProjectImportSpace"},ManagementV1ProjectMembers:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"members",namespaced:!1,kind:"ProjectMembers"},ManagementV1ProjectMigrateSpaceInstance:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"migratespaceinstance",namespaced:!1,kind:"ProjectMigrateSpaceInstance"},ManagementV1ProjectMigrateVirtualClusterInstance:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"migratevirtualclusterinstance",namespaced:!1,kind:"ProjectMigrateVirtualClusterInstance"},ManagementV1ProjectRunners:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"runners",namespaced:!1,kind:"ProjectRunners"},ManagementV1ProjectSecret:{group:"management.loft.sh",version:"v1",resource:"projectsecrets",subResource:"",namespaced:!0,kind:"ProjectSecret"},ManagementV1ProjectTemplates:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"templates",namespaced:!1,kind:"ProjectTemplates"},ManagementV1RedirectToken:{group:"management.loft.sh",version:"v1",resource:"redirecttokens",subResource:"",namespaced:!1,kind:"RedirectToken"},ManagementV1RegisterVirtualCluster:{group:"management.loft.sh",version:"v1",resource:"registervirtualclusters",subResource:"",namespaced:!1,kind:"RegisterVirtualCluster"},ManagementV1ResetAccessKey:{group:"management.loft.sh",version:"v1",resource:"resetaccesskeys",subResource:"",namespaced:!1,kind:"ResetAccessKey"},ManagementV1Runner:{group:"management.loft.sh",version:"v1",resource:"runners",subResource:"",namespaced:!1,kind:"Runner"},ManagementV1RunnerAccessKey:{group:"management.loft.sh",version:"v1",resource:"runners",subResource:"accesskey",namespaced:!1,kind:"RunnerAccessKey"},ManagementV1RunnerConfig:{group:"management.loft.sh",version:"v1",resource:"runners",subResource:"config",namespaced:!1,kind:"RunnerConfig"},ManagementV1Self:{group:"management.loft.sh",version:"v1",resource:"selves",subResource:"",namespaced:!1,kind:"Self"},ManagementV1SelfSubjectAccessReview:{group:"management.loft.sh",version:"v1",resource:"selfsubjectaccessreviews",subResource:"",namespaced:!1,kind:"SelfSubjectAccessReview"},ManagementV1SharedSecret:{group:"management.loft.sh",version:"v1",resource:"sharedsecrets",subResource:"",namespaced:!0,kind:"SharedSecret"},ManagementV1SpaceInstance:{group:"management.loft.sh",version:"v1",resource:"spaceinstances",subResource:"",namespaced:!0,kind:"SpaceInstance"},ManagementV1SpaceTemplate:{group:"management.loft.sh",version:"v1",resource:"spacetemplates",subResource:"",namespaced:!1,kind:"SpaceTemplate"},ManagementV1SubjectAccessReview:{group:"management.loft.sh",version:"v1",resource:"subjectaccessreviews",subResource:"",namespaced:!1,kind:"SubjectAccessReview"},ManagementV1Task:{group:"management.loft.sh",version:"v1",resource:"tasks",subResource:"",namespaced:!1,kind:"Task"},ManagementV1TaskLog:{group:"management.loft.sh",version:"v1",resource:"tasks",subResource:"log",namespaced:!1,kind:"TaskLog"},ManagementV1Team:{group:"management.loft.sh",version:"v1",resource:"teams",subResource:"",namespaced:!1,kind:"Team"},ManagementV1TeamAccessKeys:{group:"management.loft.sh",version:"v1",resource:"teams",subResource:"accesskeys",namespaced:!1,kind:"TeamAccessKeys"},ManagementV1TeamClusters:{group:"management.loft.sh",version:"v1",resource:"teams",subResource:"clusters",namespaced:!1,kind:"TeamClusters"},ManagementV1TranslateVClusterResourceName:{group:"management.loft.sh",version:"v1",resource:"translatevclusterresourcenames",subResource:"",namespaced:!1,kind:"TranslateVClusterResourceName"},ManagementV1User:{group:"management.loft.sh",version:"v1",resource:"users",subResource:"",namespaced:!1,kind:"User"},ManagementV1UserAccessKeys:{group:"management.loft.sh",version:"v1",resource:"users",subResource:"accesskeys",namespaced:!1,kind:"UserAccessKeys"},ManagementV1UserClusters:{group:"management.loft.sh",version:"v1",resource:"users",subResource:"clusters",namespaced:!1,kind:"UserClusters"},ManagementV1UserPermissions:{group:"management.loft.sh",version:"v1",resource:"users",subResource:"permissions",namespaced:!1,kind:"UserPermissions"},ManagementV1UserProfile:{group:"management.loft.sh",version:"v1",resource:"users",subResource:"profile",namespaced:!1,kind:"UserProfile"},ManagementV1VirtualClusterAccessKey:{group:"management.loft.sh",version:"v1",resource:"virtualclusterinstances",subResource:"accesskey",namespaced:!0,kind:"VirtualClusterAccessKey"},ManagementV1VirtualClusterInstance:{group:"management.loft.sh",version:"v1",resource:"virtualclusterinstances",subResource:"",namespaced:!0,kind:"VirtualClusterInstance"},ManagementV1VirtualClusterInstanceKubeConfig:{group:"management.loft.sh",version:"v1",resource:"virtualclusterinstances",subResource:"kubeconfig",namespaced:!0,kind:"VirtualClusterInstanceKubeConfig"},ManagementV1VirtualClusterInstanceLog:{group:"management.loft.sh",version:"v1",resource:"virtualclusterinstances",subResource:"log",namespaced:!0,kind:"VirtualClusterInstanceLog"},ManagementV1VirtualClusterTemplate:{group:"management.loft.sh",version:"v1",resource:"virtualclustertemplates",subResource:"",namespaced:!1,kind:"VirtualClusterTemplate"}};var N="virtualcluster.loft.sh",q="v1",me="virtualcluster.loft.sh/v1",S="cluster.loft.sh",P="v1",pe="cluster.loft.sh/v1",ge="management.loft.sh",F="v1",de="management.loft.sh/v1",Ve="storage.loft.sh",fe="v1",he="storage.loft.sh/v1",B="apiextensions.k8s.io",H="v1",Re="apiextensions.k8s.io/v1",U=class{};var c={...D,ClusterV1SleepModeConfig:{group:S,version:P,resource:"sleepmodeconfigs",kind:"SleepModeConfig",namespaced:!0},ClusterV1HelmRelease:{group:S,version:P,resource:"helmreleases",kind:"HelmRelease",namespaced:!0},ClusterV1ChartInfo:{group:S,version:P,resource:"chartinfos",kind:"ChartInfo"},VirtualclusterV1HelmRelease:{group:N,version:q,resource:"helmreleases",kind:"HelmRelease",namespaced:!0},CustomResourceDefinition:{group:B,version:H,resource:"customresourcedefinitions",kind:"CustomResourceDefinition"},StorageV1ClusterQuota:{group:"storage.loft.sh",version:F,resource:"clusterquotas",kind:"ClusterQuota"},NetworkingV1Ingress:{group:"networking.k8s.io",version:"v1",resource:"ingresses",kind:"Ingress",namespaced:!0},V1StatefulSet:{group:"apps",version:"v1",resource:"statefulsets",kind:"StatefulSet",namespaced:!0},V1Deployment:{group:"apps",version:"v1",resource:"deployments",kind:"Deployment",namespaced:!0},V1Event:{group:"",version:"v1",resource:"events",kind:"Event",namespaced:!0},V1Pod:{group:"",version:"v1",resource:"pods",kind:"Pod",namespaced:!0},V1Node:{group:"",version:"v1",resource:"nodes",kind:"Node"},V1Namespace:{group:"",version:"v1",resource:"namespaces",kind:"Namespace"},V1SelfSubjectAccessReview:{group:"authorization.k8s.io",version:"v1",resource:"selfsubjectaccessreviews",kind:"SelfSubjectAccessReview"},V1ClusterRole:{group:"rbac.authorization.k8s.io",version:"v1",resource:"clusterroles",kind:"ClusterRole"},V1ClusterRoleBinding:{group:"rbac.authorization.k8s.io",version:"v1",resource:"clusterrolebindings",kind:"ClusterRoleBinding"},V1Role:{group:"rbac.authorization.k8s.io",version:"v1",resource:"roles",kind:"Role",namespaced:!0},V1RoleBinding:{group:"rbac.authorization.k8s.io",version:"v1",resource:"rolebindings",kind:"RoleBinding",namespaced:!0},V1Secret:{group:"",version:"v1",resource:"secrets",kind:"Secret",namespaced:!0},V1ConfigMap:{group:"",version:"v1",resource:"configmaps",kind:"ConfigMap",namespaced:!0},V1Service:{group:"",version:"v1",resource:"services",kind:"Service",namespaced:!0},V1User:{group:"",version:"v1",resource:"users",kind:"User",namespaced:!1},V1StorageClassList:{group:"storage.k8s.io",version:"v1",resource:"storageclasses",kind:"StorageClass",namespaced:!1},V1Beta1PodMetrics:{group:"metrics.k8s.io",version:"v1beta1",resource:"pods",kind:"PodMetrics",namespaced:!0}};function f(a,e,s){return{apiVersion:a.group?a.group+"/"+a.version:a.version,kind:a.kind,metadata:{name:e},...s}}var T=class{constructor(e,s=void 0){this.val=e;this.extra=s;this.ok=!1;this.err=!0}},w=class{constructor(e,s=void 0){this.val=e;this.extra=s;this.ok=!0;this.err=!1}};function Pe(a){return"ok"in a&&typeof a.ok=="boolean"&&"err"in a&&typeof a.err=="boolean"}var O="",L="Network",Q="Forbidden",X="BadRequest",K="NotFound",A="Unauthorized",Y="AlreadyExists",Z="InternalServerError",ee="NotImplemented",se="BadGateway",I="ServiceUnavailable",re="GatewayTimeout",b=a=>{switch(a){case 400:return X;case 401:return A;case 403:return Q;case 404:return K;case 409:return Y;case 500:return Z;case 501:return ee;case 502:return se;case 503:return I;case 504:return re}return O},o=class{static Ok(){return new w(void 0)}static Value(e){return new w(e)}static Failed(e,s="",r=O,t=void 0){return new T(new x(e,r,s),t)}static Error(e){return new T(e)}static WithExtra(e,s=void 0){return e.extra=s,e}},x=class{constructor(e,s=O,r=""){this.message=e;this.type=s;this.reason=r}};var k={secure:!0,expires:365*10,sameSite:"strict"},d=M.loftAccessKeyIdentifier,R=M.loftImpersonateSubjectIdentifier,y=M.loftImpersonateJoinedGroupIdentifier,ne=["v4.channel.k8s.io","v3.channel.k8s.io","v2.channel.k8s.io","channel.k8s.io"];function oe(){return typeof window<"u"&&window.location.href.startsWith("http://localhost:3000")?"https://localhost:9898":""}function ae(){return typeof window>"u"||window.location.host==="localhost:3000"?"wss://localhost:8080":`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}`}function W(a){return[a.virtualCluster?"loft:vcluster:main":`loft:space:${a.project}:${a.space}`]}var $="/kubernetes/management",j="/kubernetes/cluster/",J="/kubernetes/virtualcluster/",_="/kubernetes/project/";function Le(a,e){return a?e&&e.endsWith("-")?`${e}${a}`:e===""?`${a}`:e?`${e}-${a}`:`p-${a}`:"p-"}function Ke(a,e){if(a)return e?e.endsWith("-")?a.replace(new RegExp(`^${e}`),""):a.replace(new RegExp(`^${e}-`),""):a.replace(/^p-/,"")}var C=class{constructor(e,s,r){this.apiHost="";this.wsHost="";this.accessKey="";this.managementNonResource=()=>new l(this,{basePath:$,headers:this.impersonationHeaders()});this.cluster=(e,s)=>new l(this,{basePath:j+e,groupVersionResource:s,headers:this.impersonationHeaders()});this.clusterNonResource=e=>new l(this,{basePath:j+e,headers:this.impersonationHeaders()});this.project=(e,s)=>new l(this,{basePath:_+e.project+"/"+(e.space?"space/"+e.space:"virtualcluster/"+e.virtualCluster),groupVersionResource:s,project:e,headers:this.impersonationHeaders(W(e))});this.projectNonResource=e=>new l(this,{basePath:_+e.project+"/"+(e.space?"space/"+e.space:"virtualcluster/"+e.virtualCluster),project:e,headers:this.impersonationHeaders(W(e))});this.apiHost=s||oe(),this.wsHost=r||ae(),this.accessKey=e||C.getAccessKey()}static getAccessKey(){return localStorage.getItem(d)}static tryCastToStatus(e){if(e.kind){if(e.kind!=="Status"||e.apiVersion!=="v1")return o.Value(null)}else return o.Value(null);return o.Value(e)}async getUser(){let e=await this.management(c.ManagementV1Self).Create(f(c.ManagementV1Self));return e.err?e:e.val.status?.user?(typeof window<"u"&&(window.loft||(window.loft={}),window.loft.instanceID=e.val.status.instanceID,window.loft.chatAuthToken=e.val.status.chatAuthToken,window.loft.user=e.val.status.user),o.Value(e.val.status.user.name)):o.Failed("no user found")}getAccessKey(){return this.accessKey}async loftVersion(e){try{let s=this.apiHost+"/version";e&&(s+="?refresh=true");let t=await(await fetch(s)).json();return o.Value(t)}catch(s){return console.error(s),o.Failed("error during version retrieval")}}impersonatedUser(){try{let e=localStorage.getItem(R);if(e)return JSON.parse(e)}catch(e){console.error(e)}}impersonate(e,s,r){s?(localStorage.setItem(R,JSON.stringify({name:e,subject:s,groups:r})),s&&p.set(R,s,k),r?.forEach(t=>{let n=p.get(y);n?(n+=", "+t,p.set(y,n,k)):p.set(y,t,k)})):(localStorage.removeItem(R),p.remove(R),p.remove(y))}async login(e,s){let r=await this.request("/auth/password/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:s})});if(r.err)return r;let t=r.val;return this.setAccessKey(t.accessKey),o.Ok()}async loginWithAccessKey(e){this.isLoggedIn()&&await this.logout(),this.accessKey=e;let s=await this.management(c.ManagementV1Self).Create(f(c.ManagementV1Self));return s.err?(this.clearStorage(),s):(this.setAccessKey(e),o.Ok())}isLoggedIn(){return!!this.accessKey}setAccessKey(e){this.accessKey=e,localStorage.setItem(d,e),p.set(d,e,k)}async stream(e,s){try{let r=await fetch(this.apiHost+e,s);return r.status>=400||!r.body?await this.parseResponse(e,r):o.Value(r.body.getReader())}catch(r){return o.Failed(r+"","NetworkError",L)}}async request(e,s){try{let r=await fetch(this.apiHost+e,{...s,credentials:"same-origin"});if(!r.ok){let n=await r.clone().text();if(r.status===401)try{let i=JSON.parse(n);if(i?.message===M.platformAccessKeyNotFound)return window.location.href=`/login?error=${i?.message}&errorType=${i?.reason}`,o.Failed(i.message||"Unauthorized",i.reason,A)}catch{}}return await this.parseResponse(e,r)}catch(r){let t=r;return t.message===M.platformAccessKeyNotFound&&(window.location.href=`/login?error=${t.message}&errorType=${t.reason}`),o.Failed(r+"","NetworkError",L)}}async socket(e,s){return this.refreshCookie(),new Promise((r,t)=>{let n=new WebSocket(`${this.wsHost}${e}`,s),i=!1;n.onopen=()=>{i=!0,r(n)},n.onerror=u=>{if(!i){let m=p.get(d)!="";t(m?u:new Error("Web socket is not authenticated. Please log in again"))}}})}async parseResponse(e,s){let r=await s.text(),t;try{t=JSON.parse(r)}catch{if(s.status===404)return o.Failed("page not found","NotFound",K);if(s.status===503){if(e.includes("kiosk.sh")||e.includes("cluster.loft.sh")){let u=e.split("/");return u.length>=4&&u[0]===""&&u[1]==="kubernetes"&&u[2]==="cluster"?o.Failed(`Agent seems to be currently unavailable, it is maybe just starting up. Click here for more information`,"LoftAgentUnavailable",I):o.Failed("Agent seems to be currently unavailable, it is maybe just starting up","LoftAgentUnavailable",I)}}else if(s.status===200)return o.Value(r);return console.info("Unexpected Server Response",r),o.Failed("Unexpected server response",b(s.status),b(s.status))}let n=C.tryCastToStatus(t);return n.err?n:n.val!==null&&n.val.status==="Failure"?n.val.code===500&&(n.val.message?.indexOf("vcluster secret not found")!==-1||n.val.message.indexOf("no ready pod for virtual cluster")!==-1)?o.Failed("vcluster seems to be not ready. Please refresh in a second",n.val.reason,b(n.val.code)):o.Failed(n.val.message,n.val.reason,b(n.val.code)):s.status>=400?o.Failed("unknown error","Unknown",b(s.status)):o.Value(t)}management(e){return new l(this,{basePath:$,groupVersionResource:e,headers:this.impersonationHeaders()})}vCluster(e,s){return new l(this,{basePath:J+e.cluster+"/"+e.namespace+"/"+e.name,groupVersionResource:s,vCluster:e,headers:this.impersonationHeaders()})}vClusterNonResource(e){return new l(this,{basePath:J+e.cluster+"/"+e.namespace+"/"+e.name,vCluster:e,headers:this.impersonationHeaders()})}auto(e,s,r,t){return r?this.project(r,t):s?this.vCluster(s,t):e?this.cluster(e,t):this.management(t)}autoNonResource(e,s,r){return r?this.projectNonResource(r):s?this.vClusterNonResource(s):e?this.clusterNonResource(e):this.managementNonResource()}async doRawSocket(e,s){try{return o.Value(await this.socket(e,s))}catch(r){return console.error(r),o.Failed(r.message||JSON.stringify(r))}}async doRawStream(e,s,r){return this.doRawInternal(e,s,r,!0)}async doRaw(e,s,r){return this.doRawInternal(e,s,r)}async doRawInternal(e,s,r,t){let n=this.accessKey,i=n?new Headers({...r,Authorization:"bearer "+n,"X-Sleep-Mode-Ignore":"true","X-Platform-Client":"true"}):new Headers({...r,"X-Sleep-Mode-Ignore":"true","X-Platform-Client":"true"}),u=t?await this.stream(e,{...s,headers:i}):await this.request(e,{...s,headers:i});return u.err&&u.val.type===A&&(u.val.message==="Access key not found. Please login again"||u.val.message==="invalid bearer token")&&(this.clearStorage(),typeof window<"u"&&(window.location.href="/"),await new Promise(()=>{})),u}impersonationHeaders(e){let s=this.impersonatedUser(),r={};return s&&(s.subject&&(r["Impersonate-User"]=s.subject),[...h(s.groups),...h(e)].forEach(t=>{r["Impersonate-Joined-Group"]?r["Impersonate-Joined-Group"]+=", "+t:r["Impersonate-Joined-Group"]=t})),r}clearStorage(){this.accessKey=null,localStorage.removeItem(d),localStorage.removeItem(R),p.remove(d,{secure:!0}),p.remove(R,{secure:!0}),p.remove(y,{secure:!0})}refreshCookie(){let e=this.accessKey||localStorage.getItem(d),s=p.get(d);e&&e!=s&&p.set(d,e,k)}async logout(){let e=await this.management(c.ManagementV1Self).Create(f(c.ManagementV1Self));if(e.err)return this.clearStorage(),e;if(!e.val.status?.accessKey)return this.clearStorage(),o.Ok();let s=await this.management(c.ManagementV1OwnedAccessKey).Delete(e.val.status.accessKey);return s.err?(this.clearStorage(),s):(this.clearStorage(),o.Ok())}},l=class{constructor(e,s){this.client=e,this.options=s}Name(e){return new l(this.client,{...this.options,name:e})}Namespace(e){return e?new l(this.client,{...this.options,namespace:e}):new l(this.client,{...this.options})}Resource(e){return new l(this.client,{...this.options,groupVersionResource:e})}buildPath(e){if(this.options.groupVersionResource)if(this.options.basePath){if(!this.options.name&&this.options.groupVersionResource.subResource)return o.Failed("resource name required when subresource is used")}else return o.Failed("basePath is missing");else return o.Failed("groupVersionResource is missing");let s=[this.options.basePath];this.options.groupVersionResource.group?s.push("apis",this.options.groupVersionResource.group):s.push("api"),s.push(this.options.groupVersionResource.version),this.options.namespace&&s.push("namespaces",this.options.namespace),s.push(this.options.groupVersionResource.resource),this.options.name&&s.push(this.options.name),this.options.groupVersionResource.subResource&&s.push(this.options.groupVersionResource.subResource);let r="";if(e){let t=[];for(let n of Object.keys(e))e[n]&&(Array.isArray(e[n])?e[n].forEach(i=>{t.push(n+"="+encodeURIComponent(i))}):t.push(n+"="+encodeURIComponent(e[n])));t.length>0&&(r="?"+t.join("&"))}else r="?timeout=180s";return o.Value(s.join("/")+r)}parseResourceList(e,s,r,t,n,i){for(let u=0;u1||n&&t.find(v=>v.group===e&&v.resource===V)||t.push({resource:V,subResource:g.length>1?g[1]:void 0,group:e,version:s,kind:m.kind,namespaced:m.namespaced,verbs:m.verbs})}}async ApiResources(e,s){let r=[],t=await this.client.doRaw([this.options.basePath,"api"].join("/"));if(t.err)return t;let n=[];for(let u=0;u{let g=t.val.versions[m];if(g===void 0)return;let V=await this.client.doRaw([this.options.basePath,"api",g].join("/"));if(V.err){console.error(V.val.message);return}this.parseResourceList("",g,V.val,r,e,s)})(u)),n.length>20&&(await Promise.all(n),n=[]);n.length>0&&(await Promise.all(n),n=[]);let i=await this.client.doRaw([this.options.basePath,"apis"].join("/"));if(i.err)return i;for(let u=0;u{let G=v.versions[V];if(G===void 0)return;let E=await this.client.doRaw([this.options.basePath,"apis",v.name,G.version].join("/"));if(E.err){console.error(E.val.message);return}this.parseResourceList(v.name,G.version,E.val,r,e,s)})(g,m)),n.length>20&&(await Promise.all(n),n=[])}return n.length>0&&await Promise.all(n),o.Value(r)}async Version(){let e=[this.options.basePath,"version"];return await this.client.doRaw(e.join("/"))}async VirtualClusterInstanceLogs(e,s,r){let t=[this.options.basePath,`apis/management.loft.sh/v1/namespaces/${e}/virtualclusterinstances/${s}/log`].join("/"),n=[];if(r)for(let i of Object.keys(r))n.push(`${i}=${encodeURIComponent(r[i])}`);return n.length>0&&(t+="?"+n.join("&")),await this.client.doRawStream(t,void 0,this.options.headers)}async TaskLogs(e,s){let r=[this.options.basePath,`apis/management.loft.sh/v1/tasks/${e}/log`].join("/"),t=[];if(s)for(let n of Object.keys(s))t.push(`${n}=${encodeURIComponent(s[n])}`);return t.length>0&&(r+="?"+t.join("&")),await this.client.doRawStream(r,void 0,this.options.headers)}async Logs(e,s,r){let t=[this.options.basePath,`api/v1/namespaces/${e}/pods/${s}/log`].join("/"),n=z(r);return n.length>0&&(t+="?"+n),await this.client.doRawStream(t,void 0,this.options.headers)}async Exec(e,s,r){let t=[this.options.basePath,`api/v1/namespaces/${e}/pods/${s}/exec`].join("/"),n=z(r);return n.length>0&&(t+="?"+n),await this.client.doRawSocket(t,ne)}async Path(e,s,r){let t=[this.options.basePath,e];return await this.client.doRaw(t.join("/"),s,{...r,...this.options.headers})}ResolvePath(e){return e&&(this.options.name=e),this.buildPath()}async Get(e,s){this.options.name=e;let r=this.buildPath(s);return r.err?r:o.WithExtra(await this.client.doRaw(r.val,void 0,this.options.headers),this.options)}async List(e){if(this.options.name)return o.Failed("name is set on a list request");let s=this.buildPath(e);return s.err?s:o.WithExtra(await this.client.doRaw(s.val,void 0,this.options.headers),this.options)}async ListTable(e){if(this.options.name)return o.Failed("name is set on a list request");let s=this.buildPath(e);return s.err?s:o.WithExtra(await this.client.doRaw(s.val,void 0,{...this.options.headers,Accept:"application/json;as=Table;v=v1;g=meta.k8s.io,application/json;as=Table;v=v1beta1;g=meta.k8s.io,application/json"}),this.options)}async Create(e,s){let r=this.buildPath(s);return r.err?r:o.WithExtra(await this.client.doRaw(r.val,{method:"POST",body:JSON.stringify(e)},{...this.options.headers,"Content-Type":"application/json"}),this.options)}async PatchObject(e,s,r,t){let n=te.generate(e,s);return this.Patch(s.metadata?.name,n,r,t)}async Patch(e,s,r,t){this.options.name=e;let n=this.buildPath(t);return n.err?n:o.WithExtra(await this.client.doRaw(n.val,{method:"PATCH",body:JSON.stringify(s,function(i,u){return u===void 0?null:u})},{...this.options.headers,"Content-Type":r||"application/merge-patch+json"}),this.options)}async Update(e,s,r){this.options.name=e;let t=this.buildPath(r);return t.err?t:o.WithExtra(await this.client.doRaw(t.val,{method:"PUT",body:JSON.stringify(s)},{...this.options.headers,"Content-Type":"application/json"}),this.options)}async Delete(e,s){this.options.name=e;let r=this.buildPath(s);return r.err?r:o.WithExtra(await this.client.doRaw(r.val,{method:"DELETE"},this.options.headers),this.options)}async CanI(e){let s=this.options.groupVersionResource,r=this.options.basePath?.indexOf(j)===0?this.options.basePath.substring(j.length):void 0,t,n;this.options.project?(t=this.client.project(this.options.project,c.V1SelfSubjectAccessReview),n=f(c.V1SelfSubjectAccessReview)):this.options.vCluster?(t=this.client.vCluster(this.options.vCluster,c.V1SelfSubjectAccessReview),n=f(c.V1SelfSubjectAccessReview)):r?(t=this.client.cluster(r,c.V1SelfSubjectAccessReview),n=f(c.V1SelfSubjectAccessReview)):(t=this.client.management(c.ManagementV1SelfSubjectAccessReview),n=f(c.ManagementV1SelfSubjectAccessReview)),n.spec={resourceAttributes:{verb:e,name:this.options.name,namespace:this.options.namespace,group:s.group,version:s.version,resource:s.resource,subresource:s.subResource}};let i=await t.Create(n);return i.err?i:o.Value(!!(i.val.status?.allowed&&!i.val.status.denied))}};function z(a){let e=new URLSearchParams;for(let[s,r]of Object.entries(a))Array.isArray(r)?r.forEach(t=>{e.append(s,t)}):e.append(s,r);return e.toString()}var ie=C;export{B as APIExtensionsGroup,Re as APIExtensionsGroupVersion,H as APIExtensionsVersion,ie as Client,j as ClusterBasePath,T as Err,Y as ErrorTypeAlreadyExists,se as ErrorTypeBadGateway,X as ErrorTypeBadRequest,Q as ErrorTypeForbidden,re as ErrorTypeGatewayTimeout,Z as ErrorTypeInternalError,L as ErrorTypeNetwork,K as ErrorTypeNotFound,ee as ErrorTypeNotImplemented,I as ErrorTypeServiceUnavailable,A as ErrorTypeUnauthorized,O as ErrorTypeUnknown,x as Failed,U as List,ge as LoftSchemeGroup,S as LoftSchemeGroupCluster,Ve as LoftSchemeGroupStorage,de as LoftSchemeGroupVersion,pe as LoftSchemeGroupVersionCluster,he as LoftSchemeGroupVersionStorage,me as LoftSchemeGroupVersionVirtualCluster,N as LoftSchemeGroupVirtualCluster,F as LoftSchemeVersion,P as LoftSchemeVersionCluster,fe as LoftSchemeVersionStorage,q as LoftSchemeVersionVirtualCluster,$ as ManagementBasePath,b as MapErrorCode,f as NewResource,w as Ok,_ as ProjectBasePath,c as Resources,o as Return,J as VClusterBasePath,oe as getApiHost,Ke as getProjectFromNamespace,Le as getProjectNamespace,Pe as isResult}; +import p from"js-cookie";import te from"json-merge-patch";var M={loftAccessKeyIdentifier:"loft_access_key",loftImpersonateSubjectIdentifier:"loft_impersonate_subject",loftImpersonateJoinedGroupIdentifier:"loft_impersonate_joined_group",platformAccessKeyNotFound:"platform access key not found. Please login again"};function h(a){return a||[]}var K={ManagementV1AgentAuditEvent:{group:"management.loft.sh",version:"v1",resource:"agentauditevents",subResource:"",namespaced:!1,kind:"AgentAuditEvent"},ManagementV1Announcement:{group:"management.loft.sh",version:"v1",resource:"announcements",subResource:"",namespaced:!1,kind:"Announcement"},ManagementV1App:{group:"management.loft.sh",version:"v1",resource:"apps",subResource:"",namespaced:!1,kind:"App"},ManagementV1AppCredentials:{group:"management.loft.sh",version:"v1",resource:"apps",subResource:"credentials",namespaced:!1,kind:"AppCredentials"},ManagementV1Backup:{group:"management.loft.sh",version:"v1",resource:"backups",subResource:"",namespaced:!1,kind:"Backup"},ManagementV1BackupApply:{group:"management.loft.sh",version:"v1",resource:"backups",subResource:"apply",namespaced:!1,kind:"BackupApply"},ManagementV1Cluster:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"",namespaced:!1,kind:"Cluster"},ManagementV1ClusterAccess:{group:"management.loft.sh",version:"v1",resource:"clusteraccesses",subResource:"",namespaced:!1,kind:"ClusterAccess"},ManagementV1ClusterAccessKey:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"accesskey",namespaced:!1,kind:"ClusterAccessKey"},ManagementV1ClusterAgentConfig:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"agentconfig",namespaced:!1,kind:"ClusterAgentConfig"},ManagementV1ClusterCharts:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"charts",namespaced:!1,kind:"ClusterCharts"},ManagementV1ClusterDomain:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"domain",namespaced:!1,kind:"ClusterDomain"},ManagementV1ClusterMemberAccess:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"memberaccess",namespaced:!1,kind:"ClusterMemberAccess"},ManagementV1ClusterMembers:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"members",namespaced:!1,kind:"ClusterMembers"},ManagementV1ClusterReset:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"reset",namespaced:!1,kind:"ClusterReset"},ManagementV1ClusterRoleTemplate:{group:"management.loft.sh",version:"v1",resource:"clusterroletemplates",subResource:"",namespaced:!1,kind:"ClusterRoleTemplate"},ManagementV1ClusterVirtualClusterDefaults:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"virtualclusterdefaults",namespaced:!1,kind:"ClusterVirtualClusterDefaults"},ManagementV1Config:{group:"management.loft.sh",version:"v1",resource:"configs",subResource:"",namespaced:!1,kind:"Config"},ManagementV1ConvertVirtualClusterConfig:{group:"management.loft.sh",version:"v1",resource:"convertvirtualclusterconfig",subResource:"",namespaced:!1,kind:"ConvertVirtualClusterConfig"},ManagementV1DevPodEnvironmentTemplate:{group:"management.loft.sh",version:"v1",resource:"devpodenvironmenttemplates",subResource:"",namespaced:!1,kind:"DevPodEnvironmentTemplate"},ManagementV1DevPodWorkspaceInstance:{group:"management.loft.sh",version:"v1",resource:"devpodworkspaceinstances",subResource:"",namespaced:!0,kind:"DevPodWorkspaceInstance"},ManagementV1DevPodWorkspaceInstanceState:{group:"management.loft.sh",version:"v1",resource:"devpodworkspaceinstances",subResource:"state",namespaced:!0,kind:"DevPodWorkspaceInstanceState"},ManagementV1DevPodWorkspacePreset:{group:"management.loft.sh",version:"v1",resource:"devpodworkspacepresets",subResource:"",namespaced:!1,kind:"DevPodWorkspacePreset"},ManagementV1DevPodWorkspaceTemplate:{group:"management.loft.sh",version:"v1",resource:"devpodworkspacetemplates",subResource:"",namespaced:!1,kind:"DevPodWorkspaceTemplate"},ManagementV1DirectClusterEndpointToken:{group:"management.loft.sh",version:"v1",resource:"directclusterendpointtokens",subResource:"",namespaced:!1,kind:"DirectClusterEndpointToken"},ManagementV1Event:{group:"management.loft.sh",version:"v1",resource:"events",subResource:"",namespaced:!1,kind:"Event"},ManagementV1Feature:{group:"management.loft.sh",version:"v1",resource:"features",subResource:"",namespaced:!1,kind:"Feature"},ManagementV1IngressAuthToken:{group:"management.loft.sh",version:"v1",resource:"ingressauthtokens",subResource:"",namespaced:!1,kind:"IngressAuthToken"},ManagementV1Kiosk:{group:"management.loft.sh",version:"v1",resource:"kiosk",subResource:"",namespaced:!1,kind:"Kiosk"},ManagementV1License:{group:"management.loft.sh",version:"v1",resource:"licenses",subResource:"",namespaced:!1,kind:"License"},ManagementV1LicenseRequest:{group:"management.loft.sh",version:"v1",resource:"licenses",subResource:"request",namespaced:!1,kind:"LicenseRequest"},ManagementV1LicenseToken:{group:"management.loft.sh",version:"v1",resource:"licensetokens",subResource:"",namespaced:!1,kind:"LicenseToken"},ManagementV1LoftUpgrade:{group:"management.loft.sh",version:"v1",resource:"loftupgrades",subResource:"",namespaced:!1,kind:"LoftUpgrade"},ManagementV1OIDCClient:{group:"management.loft.sh",version:"v1",resource:"oidcclients",subResource:"",namespaced:!1,kind:"OIDCClient"},ManagementV1OwnedAccessKey:{group:"management.loft.sh",version:"v1",resource:"ownedaccesskeys",subResource:"",namespaced:!1,kind:"OwnedAccessKey"},ManagementV1Project:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"",namespaced:!1,kind:"Project"},ManagementV1ProjectChartInfo:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"chartinfo",namespaced:!1,kind:"ProjectChartInfo"},ManagementV1ProjectCharts:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"charts",namespaced:!1,kind:"ProjectCharts"},ManagementV1ProjectClusters:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"clusters",namespaced:!1,kind:"ProjectClusters"},ManagementV1ProjectImportSpace:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"importspace",namespaced:!1,kind:"ProjectImportSpace"},ManagementV1ProjectMembers:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"members",namespaced:!1,kind:"ProjectMembers"},ManagementV1ProjectMigrateSpaceInstance:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"migratespaceinstance",namespaced:!1,kind:"ProjectMigrateSpaceInstance"},ManagementV1ProjectMigrateVirtualClusterInstance:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"migratevirtualclusterinstance",namespaced:!1,kind:"ProjectMigrateVirtualClusterInstance"},ManagementV1ProjectRunners:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"runners",namespaced:!1,kind:"ProjectRunners"},ManagementV1ProjectSecret:{group:"management.loft.sh",version:"v1",resource:"projectsecrets",subResource:"",namespaced:!0,kind:"ProjectSecret"},ManagementV1ProjectTemplates:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"templates",namespaced:!1,kind:"ProjectTemplates"},ManagementV1RedirectToken:{group:"management.loft.sh",version:"v1",resource:"redirecttokens",subResource:"",namespaced:!1,kind:"RedirectToken"},ManagementV1RegisterVirtualCluster:{group:"management.loft.sh",version:"v1",resource:"registervirtualclusters",subResource:"",namespaced:!1,kind:"RegisterVirtualCluster"},ManagementV1ResetAccessKey:{group:"management.loft.sh",version:"v1",resource:"resetaccesskeys",subResource:"",namespaced:!1,kind:"ResetAccessKey"},ManagementV1Runner:{group:"management.loft.sh",version:"v1",resource:"runners",subResource:"",namespaced:!1,kind:"Runner"},ManagementV1RunnerAccessKey:{group:"management.loft.sh",version:"v1",resource:"runners",subResource:"accesskey",namespaced:!1,kind:"RunnerAccessKey"},ManagementV1RunnerConfig:{group:"management.loft.sh",version:"v1",resource:"runners",subResource:"config",namespaced:!1,kind:"RunnerConfig"},ManagementV1Self:{group:"management.loft.sh",version:"v1",resource:"selves",subResource:"",namespaced:!1,kind:"Self"},ManagementV1SelfSubjectAccessReview:{group:"management.loft.sh",version:"v1",resource:"selfsubjectaccessreviews",subResource:"",namespaced:!1,kind:"SelfSubjectAccessReview"},ManagementV1SharedSecret:{group:"management.loft.sh",version:"v1",resource:"sharedsecrets",subResource:"",namespaced:!0,kind:"SharedSecret"},ManagementV1SpaceInstance:{group:"management.loft.sh",version:"v1",resource:"spaceinstances",subResource:"",namespaced:!0,kind:"SpaceInstance"},ManagementV1SpaceTemplate:{group:"management.loft.sh",version:"v1",resource:"spacetemplates",subResource:"",namespaced:!1,kind:"SpaceTemplate"},ManagementV1SubjectAccessReview:{group:"management.loft.sh",version:"v1",resource:"subjectaccessreviews",subResource:"",namespaced:!1,kind:"SubjectAccessReview"},ManagementV1Task:{group:"management.loft.sh",version:"v1",resource:"tasks",subResource:"",namespaced:!1,kind:"Task"},ManagementV1TaskLog:{group:"management.loft.sh",version:"v1",resource:"tasks",subResource:"log",namespaced:!1,kind:"TaskLog"},ManagementV1Team:{group:"management.loft.sh",version:"v1",resource:"teams",subResource:"",namespaced:!1,kind:"Team"},ManagementV1TeamAccessKeys:{group:"management.loft.sh",version:"v1",resource:"teams",subResource:"accesskeys",namespaced:!1,kind:"TeamAccessKeys"},ManagementV1TeamClusters:{group:"management.loft.sh",version:"v1",resource:"teams",subResource:"clusters",namespaced:!1,kind:"TeamClusters"},ManagementV1TranslateVClusterResourceName:{group:"management.loft.sh",version:"v1",resource:"translatevclusterresourcenames",subResource:"",namespaced:!1,kind:"TranslateVClusterResourceName"},ManagementV1User:{group:"management.loft.sh",version:"v1",resource:"users",subResource:"",namespaced:!1,kind:"User"},ManagementV1UserAccessKeys:{group:"management.loft.sh",version:"v1",resource:"users",subResource:"accesskeys",namespaced:!1,kind:"UserAccessKeys"},ManagementV1UserClusters:{group:"management.loft.sh",version:"v1",resource:"users",subResource:"clusters",namespaced:!1,kind:"UserClusters"},ManagementV1UserPermissions:{group:"management.loft.sh",version:"v1",resource:"users",subResource:"permissions",namespaced:!1,kind:"UserPermissions"},ManagementV1UserProfile:{group:"management.loft.sh",version:"v1",resource:"users",subResource:"profile",namespaced:!1,kind:"UserProfile"},ManagementV1VirtualClusterAccessKey:{group:"management.loft.sh",version:"v1",resource:"virtualclusterinstances",subResource:"accesskey",namespaced:!0,kind:"VirtualClusterAccessKey"},ManagementV1VirtualClusterExternalDatabase:{group:"management.loft.sh",version:"v1",resource:"virtualclusterinstances",subResource:"externaldatabase",namespaced:!0,kind:"VirtualClusterExternalDatabase"},ManagementV1VirtualClusterInstance:{group:"management.loft.sh",version:"v1",resource:"virtualclusterinstances",subResource:"",namespaced:!0,kind:"VirtualClusterInstance"},ManagementV1VirtualClusterInstanceKubeConfig:{group:"management.loft.sh",version:"v1",resource:"virtualclusterinstances",subResource:"kubeconfig",namespaced:!0,kind:"VirtualClusterInstanceKubeConfig"},ManagementV1VirtualClusterInstanceLog:{group:"management.loft.sh",version:"v1",resource:"virtualclusterinstances",subResource:"log",namespaced:!0,kind:"VirtualClusterInstanceLog"},ManagementV1VirtualClusterTemplate:{group:"management.loft.sh",version:"v1",resource:"virtualclustertemplates",subResource:"",namespaced:!1,kind:"VirtualClusterTemplate"}};var N="virtualcluster.loft.sh",q="v1",me="virtualcluster.loft.sh/v1",P="cluster.loft.sh",S="v1",pe="cluster.loft.sh/v1",ge="management.loft.sh",F="v1",de="management.loft.sh/v1",Ve="storage.loft.sh",fe="v1",he="storage.loft.sh/v1",W="apiextensions.k8s.io",B="v1",Re="apiextensions.k8s.io/v1",U=class{};var c={...K,ClusterV1SleepModeConfig:{group:P,version:S,resource:"sleepmodeconfigs",kind:"SleepModeConfig",namespaced:!0},ClusterV1HelmRelease:{group:P,version:S,resource:"helmreleases",kind:"HelmRelease",namespaced:!0},ClusterV1ChartInfo:{group:P,version:S,resource:"chartinfos",kind:"ChartInfo"},VirtualclusterV1HelmRelease:{group:N,version:q,resource:"helmreleases",kind:"HelmRelease",namespaced:!0},CustomResourceDefinition:{group:W,version:B,resource:"customresourcedefinitions",kind:"CustomResourceDefinition"},StorageV1ClusterQuota:{group:"storage.loft.sh",version:F,resource:"clusterquotas",kind:"ClusterQuota"},NetworkingV1Ingress:{group:"networking.k8s.io",version:"v1",resource:"ingresses",kind:"Ingress",namespaced:!0},V1StatefulSet:{group:"apps",version:"v1",resource:"statefulsets",kind:"StatefulSet",namespaced:!0},V1Deployment:{group:"apps",version:"v1",resource:"deployments",kind:"Deployment",namespaced:!0},V1Event:{group:"",version:"v1",resource:"events",kind:"Event",namespaced:!0},V1Pod:{group:"",version:"v1",resource:"pods",kind:"Pod",namespaced:!0},V1Node:{group:"",version:"v1",resource:"nodes",kind:"Node"},V1Namespace:{group:"",version:"v1",resource:"namespaces",kind:"Namespace"},V1SelfSubjectAccessReview:{group:"authorization.k8s.io",version:"v1",resource:"selfsubjectaccessreviews",kind:"SelfSubjectAccessReview"},V1ClusterRole:{group:"rbac.authorization.k8s.io",version:"v1",resource:"clusterroles",kind:"ClusterRole"},V1ClusterRoleBinding:{group:"rbac.authorization.k8s.io",version:"v1",resource:"clusterrolebindings",kind:"ClusterRoleBinding"},V1Role:{group:"rbac.authorization.k8s.io",version:"v1",resource:"roles",kind:"Role",namespaced:!0},V1RoleBinding:{group:"rbac.authorization.k8s.io",version:"v1",resource:"rolebindings",kind:"RoleBinding",namespaced:!0},V1Secret:{group:"",version:"v1",resource:"secrets",kind:"Secret",namespaced:!0},V1ConfigMap:{group:"",version:"v1",resource:"configmaps",kind:"ConfigMap",namespaced:!0},V1Service:{group:"",version:"v1",resource:"services",kind:"Service",namespaced:!0},V1User:{group:"",version:"v1",resource:"users",kind:"User",namespaced:!1},V1StorageClassList:{group:"storage.k8s.io",version:"v1",resource:"storageclasses",kind:"StorageClass",namespaced:!1},V1Beta1PodMetrics:{group:"metrics.k8s.io",version:"v1beta1",resource:"pods",kind:"PodMetrics",namespaced:!0}};function f(a,e,s){return{apiVersion:a.group?a.group+"/"+a.version:a.version,kind:a.kind,metadata:{name:e},...s}}var T=class{constructor(e,s=void 0){this.val=e;this.extra=s;this.ok=!1;this.err=!0}},w=class{constructor(e,s=void 0){this.val=e;this.extra=s;this.ok=!0;this.err=!1}};function Se(a){return"ok"in a&&typeof a.ok=="boolean"&&"err"in a&&typeof a.err=="boolean"}var O="",L="Network",Q="Forbidden",X="BadRequest",D="NotFound",A="Unauthorized",Y="AlreadyExists",Z="InternalServerError",ee="NotImplemented",se="BadGateway",I="ServiceUnavailable",re="GatewayTimeout",b=a=>{switch(a){case 400:return X;case 401:return A;case 403:return Q;case 404:return D;case 409:return Y;case 500:return Z;case 501:return ee;case 502:return se;case 503:return I;case 504:return re}return O},o=class{static Ok(){return new w(void 0)}static Value(e){return new w(e)}static Failed(e,s="",r=O,t=void 0){return new T(new x(e,r,s),t)}static Error(e){return new T(e)}static WithExtra(e,s=void 0){return e.extra=s,e}},x=class{constructor(e,s=O,r=""){this.message=e;this.type=s;this.reason=r}};var k={secure:!0,expires:365*10,sameSite:"strict"},d=M.loftAccessKeyIdentifier,R=M.loftImpersonateSubjectIdentifier,y=M.loftImpersonateJoinedGroupIdentifier,ne=["v4.channel.k8s.io","v3.channel.k8s.io","v2.channel.k8s.io","channel.k8s.io"];function oe(){return typeof window<"u"&&window.location.href.startsWith("http://localhost:3000")?"https://localhost:9898":""}function ae(){return typeof window>"u"||window.location.host==="localhost:3000"?"wss://localhost:8080":`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}`}function H(a){return[a.virtualCluster?"loft:vcluster:main":`loft:space:${a.project}:${a.space}`]}var $="/kubernetes/management",j="/kubernetes/cluster/",J="/kubernetes/virtualcluster/",_="/kubernetes/project/";function Le(a,e){return a?e&&e.endsWith("-")?`${e}${a}`:e===""?`${a}`:e?`${e}-${a}`:`p-${a}`:"p-"}function De(a,e){if(a)return e?e.endsWith("-")?a.replace(new RegExp(`^${e}`),""):a.replace(new RegExp(`^${e}-`),""):a.replace(/^p-/,"")}var C=class{constructor(e,s,r){this.apiHost="";this.wsHost="";this.accessKey="";this.managementNonResource=()=>new l(this,{basePath:$,headers:this.impersonationHeaders()});this.cluster=(e,s)=>new l(this,{basePath:j+e,groupVersionResource:s,headers:this.impersonationHeaders()});this.clusterNonResource=e=>new l(this,{basePath:j+e,headers:this.impersonationHeaders()});this.project=(e,s)=>new l(this,{basePath:_+e.project+"/"+(e.space?"space/"+e.space:"virtualcluster/"+e.virtualCluster),groupVersionResource:s,project:e,headers:this.impersonationHeaders(H(e))});this.projectNonResource=e=>new l(this,{basePath:_+e.project+"/"+(e.space?"space/"+e.space:"virtualcluster/"+e.virtualCluster),project:e,headers:this.impersonationHeaders(H(e))});this.apiHost=s||oe(),this.wsHost=r||ae(),this.accessKey=e||C.getAccessKey()}static getAccessKey(){return localStorage.getItem(d)}static tryCastToStatus(e){if(e.kind){if(e.kind!=="Status"||e.apiVersion!=="v1")return o.Value(null)}else return o.Value(null);return o.Value(e)}async getUser(){let e=await this.management(c.ManagementV1Self).Create(f(c.ManagementV1Self));return e.err?e:e.val.status?.user?(typeof window<"u"&&(window.loft||(window.loft={}),window.loft.instanceID=e.val.status.instanceID,window.loft.chatAuthToken=e.val.status.chatAuthToken,window.loft.user=e.val.status.user),o.Value(e.val.status.user.name)):o.Failed("no user found")}getAccessKey(){return this.accessKey}async loftVersion(e){try{let s=this.apiHost+"/version";e&&(s+="?refresh=true");let t=await(await fetch(s)).json();return o.Value(t)}catch(s){return console.error(s),o.Failed("error during version retrieval")}}impersonatedUser(){try{let e=localStorage.getItem(R);if(e)return JSON.parse(e)}catch(e){console.error(e)}}impersonate(e,s,r){s?(localStorage.setItem(R,JSON.stringify({name:e,subject:s,groups:r})),s&&p.set(R,s,k),r?.forEach(t=>{let n=p.get(y);n?(n+=", "+t,p.set(y,n,k)):p.set(y,t,k)})):(localStorage.removeItem(R),p.remove(R),p.remove(y))}async login(e,s){let r=await this.request("/auth/password/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:s})});if(r.err)return r;let t=r.val;return this.setAccessKey(t.accessKey),o.Ok()}async loginWithAccessKey(e){this.isLoggedIn()&&await this.logout(),this.accessKey=e;let s=await this.management(c.ManagementV1Self).Create(f(c.ManagementV1Self));return s.err?(this.clearStorage(),s):(this.setAccessKey(e),o.Ok())}isLoggedIn(){return!!this.accessKey}setAccessKey(e){this.accessKey=e,localStorage.setItem(d,e),p.set(d,e,k)}async stream(e,s){try{let r=await fetch(this.apiHost+e,s);return r.status>=400||!r.body?await this.parseResponse(e,r):o.Value(r.body.getReader())}catch(r){return o.Failed(r+"","NetworkError",L)}}async request(e,s){try{let r=await fetch(this.apiHost+e,{...s,credentials:"same-origin"});if(!r.ok){let n=await r.clone().text();if(r.status===401)try{let i=JSON.parse(n);if(i?.message===M.platformAccessKeyNotFound)return window.location.href=`/login?error=${i?.message}&errorType=${i?.reason}`,o.Failed(i.message||"Unauthorized",i.reason,A)}catch{}}return await this.parseResponse(e,r)}catch(r){let t=r;return t.message===M.platformAccessKeyNotFound&&(window.location.href=`/login?error=${t.message}&errorType=${t.reason}`),o.Failed(r+"","NetworkError",L)}}async socket(e,s){return this.refreshCookie(),new Promise((r,t)=>{let n=new WebSocket(`${this.wsHost}${e}`,s),i=!1;n.onopen=()=>{i=!0,r(n)},n.onerror=u=>{if(!i){let m=p.get(d)!="";t(m?u:new Error("Web socket is not authenticated. Please log in again"))}}})}async parseResponse(e,s){let r=await s.text(),t;try{t=JSON.parse(r)}catch{if(s.status===404)return o.Failed("page not found","NotFound",D);if(s.status===503){if(e.includes("kiosk.sh")||e.includes("cluster.loft.sh")){let u=e.split("/");return u.length>=4&&u[0]===""&&u[1]==="kubernetes"&&u[2]==="cluster"?o.Failed(`Agent seems to be currently unavailable, it is maybe just starting up. Click here for more information`,"LoftAgentUnavailable",I):o.Failed("Agent seems to be currently unavailable, it is maybe just starting up","LoftAgentUnavailable",I)}}else if(s.status===200)return o.Value(r);return console.info("Unexpected Server Response",r),o.Failed("Unexpected server response",b(s.status),b(s.status))}let n=C.tryCastToStatus(t);return n.err?n:n.val!==null&&n.val.status==="Failure"?n.val.code===500&&(n.val.message?.indexOf("vcluster secret not found")!==-1||n.val.message.indexOf("no ready pod for virtual cluster")!==-1)?o.Failed("vcluster seems to be not ready. Please refresh in a second",n.val.reason,b(n.val.code)):o.Failed(n.val.message,n.val.reason,b(n.val.code)):s.status>=400?o.Failed("unknown error","Unknown",b(s.status)):o.Value(t)}management(e){return new l(this,{basePath:$,groupVersionResource:e,headers:this.impersonationHeaders()})}vCluster(e,s){return new l(this,{basePath:J+e.cluster+"/"+e.namespace+"/"+e.name,groupVersionResource:s,vCluster:e,headers:this.impersonationHeaders()})}vClusterNonResource(e){return new l(this,{basePath:J+e.cluster+"/"+e.namespace+"/"+e.name,vCluster:e,headers:this.impersonationHeaders()})}auto(e,s,r,t){return r?this.project(r,t):s?this.vCluster(s,t):e?this.cluster(e,t):this.management(t)}autoNonResource(e,s,r){return r?this.projectNonResource(r):s?this.vClusterNonResource(s):e?this.clusterNonResource(e):this.managementNonResource()}async doRawSocket(e,s){try{return o.Value(await this.socket(e,s))}catch(r){return console.error(r),o.Failed(r.message||JSON.stringify(r))}}async doRawStream(e,s,r){return this.doRawInternal(e,s,r,!0)}async doRaw(e,s,r){return this.doRawInternal(e,s,r)}async doRawInternal(e,s,r,t){let n=this.accessKey,i=n?new Headers({...r,Authorization:"bearer "+n,"X-Sleep-Mode-Ignore":"true","X-Platform-Client":"true"}):new Headers({...r,"X-Sleep-Mode-Ignore":"true","X-Platform-Client":"true"}),u=t?await this.stream(e,{...s,headers:i}):await this.request(e,{...s,headers:i});return u.err&&u.val.type===A&&(u.val.message==="Access key not found. Please login again"||u.val.message==="invalid bearer token")&&(this.clearStorage(),typeof window<"u"&&(window.location.href="/"),await new Promise(()=>{})),u}impersonationHeaders(e){let s=this.impersonatedUser(),r={};return s&&(s.subject&&(r["Impersonate-User"]=s.subject),[...h(s.groups),...h(e)].forEach(t=>{r["Impersonate-Joined-Group"]?r["Impersonate-Joined-Group"]+=", "+t:r["Impersonate-Joined-Group"]=t})),r}clearStorage(){this.accessKey=null,localStorage.removeItem(d),localStorage.removeItem(R),p.remove(d,{secure:!0}),p.remove(R,{secure:!0}),p.remove(y,{secure:!0})}refreshCookie(){let e=this.accessKey||localStorage.getItem(d),s=p.get(d);e&&e!=s&&p.set(d,e,k)}async logout(){let e=await this.management(c.ManagementV1Self).Create(f(c.ManagementV1Self));if(e.err)return this.clearStorage(),e;if(!e.val.status?.accessKey)return this.clearStorage(),o.Ok();let s=await this.management(c.ManagementV1OwnedAccessKey).Delete(e.val.status.accessKey);return s.err?(this.clearStorage(),s):(this.clearStorage(),o.Ok())}},l=class{constructor(e,s){this.client=e,this.options=s}Name(e){return new l(this.client,{...this.options,name:e})}Namespace(e){return e?new l(this.client,{...this.options,namespace:e}):new l(this.client,{...this.options})}Resource(e){return new l(this.client,{...this.options,groupVersionResource:e})}buildPath(e){if(this.options.groupVersionResource)if(this.options.basePath){if(!this.options.name&&this.options.groupVersionResource.subResource)return o.Failed("resource name required when subresource is used")}else return o.Failed("basePath is missing");else return o.Failed("groupVersionResource is missing");let s=[this.options.basePath];this.options.groupVersionResource.group?s.push("apis",this.options.groupVersionResource.group):s.push("api"),s.push(this.options.groupVersionResource.version),this.options.namespace&&s.push("namespaces",this.options.namespace),s.push(this.options.groupVersionResource.resource),this.options.name&&s.push(this.options.name),this.options.groupVersionResource.subResource&&s.push(this.options.groupVersionResource.subResource);let r="";if(e){let t=[];for(let n of Object.keys(e))e[n]&&(Array.isArray(e[n])?e[n].forEach(i=>{t.push(n+"="+encodeURIComponent(i))}):t.push(n+"="+encodeURIComponent(e[n])));t.length>0&&(r="?"+t.join("&"))}else r="?timeout=180s";return o.Value(s.join("/")+r)}parseResourceList(e,s,r,t,n,i){for(let u=0;u1||n&&t.find(v=>v.group===e&&v.resource===V)||t.push({resource:V,subResource:g.length>1?g[1]:void 0,group:e,version:s,kind:m.kind,namespaced:m.namespaced,verbs:m.verbs})}}async ApiResources(e,s){let r=[],t=await this.client.doRaw([this.options.basePath,"api"].join("/"));if(t.err)return t;let n=[];for(let u=0;u{let g=t.val.versions[m];if(g===void 0)return;let V=await this.client.doRaw([this.options.basePath,"api",g].join("/"));if(V.err){console.error(V.val.message);return}this.parseResourceList("",g,V.val,r,e,s)})(u)),n.length>20&&(await Promise.all(n),n=[]);n.length>0&&(await Promise.all(n),n=[]);let i=await this.client.doRaw([this.options.basePath,"apis"].join("/"));if(i.err)return i;for(let u=0;u{let G=v.versions[V];if(G===void 0)return;let E=await this.client.doRaw([this.options.basePath,"apis",v.name,G.version].join("/"));if(E.err){console.error(E.val.message);return}this.parseResourceList(v.name,G.version,E.val,r,e,s)})(g,m)),n.length>20&&(await Promise.all(n),n=[])}return n.length>0&&await Promise.all(n),o.Value(r)}async Version(){let e=[this.options.basePath,"version"];return await this.client.doRaw(e.join("/"))}async VirtualClusterInstanceLogs(e,s,r){let t=[this.options.basePath,`apis/management.loft.sh/v1/namespaces/${e}/virtualclusterinstances/${s}/log`].join("/"),n=[];if(r)for(let i of Object.keys(r))n.push(`${i}=${encodeURIComponent(r[i])}`);return n.length>0&&(t+="?"+n.join("&")),await this.client.doRawStream(t,void 0,this.options.headers)}async TaskLogs(e,s){let r=[this.options.basePath,`apis/management.loft.sh/v1/tasks/${e}/log`].join("/"),t=[];if(s)for(let n of Object.keys(s))t.push(`${n}=${encodeURIComponent(s[n])}`);return t.length>0&&(r+="?"+t.join("&")),await this.client.doRawStream(r,void 0,this.options.headers)}async Logs(e,s,r){let t=[this.options.basePath,`api/v1/namespaces/${e}/pods/${s}/log`].join("/"),n=z(r);return n.length>0&&(t+="?"+n),await this.client.doRawStream(t,void 0,this.options.headers)}async Exec(e,s,r){let t=[this.options.basePath,`api/v1/namespaces/${e}/pods/${s}/exec`].join("/"),n=z(r);return n.length>0&&(t+="?"+n),await this.client.doRawSocket(t,ne)}async Path(e,s,r){let t=[this.options.basePath,e];return await this.client.doRaw(t.join("/"),s,{...r,...this.options.headers})}ResolvePath(e){return e&&(this.options.name=e),this.buildPath()}async Get(e,s){this.options.name=e;let r=this.buildPath(s);return r.err?r:o.WithExtra(await this.client.doRaw(r.val,void 0,this.options.headers),this.options)}async List(e){if(this.options.name)return o.Failed("name is set on a list request");let s=this.buildPath(e);return s.err?s:o.WithExtra(await this.client.doRaw(s.val,void 0,this.options.headers),this.options)}async ListTable(e){if(this.options.name)return o.Failed("name is set on a list request");let s=this.buildPath(e);return s.err?s:o.WithExtra(await this.client.doRaw(s.val,void 0,{...this.options.headers,Accept:"application/json;as=Table;v=v1;g=meta.k8s.io,application/json;as=Table;v=v1beta1;g=meta.k8s.io,application/json"}),this.options)}async Create(e,s){let r=this.buildPath(s);return r.err?r:o.WithExtra(await this.client.doRaw(r.val,{method:"POST",body:JSON.stringify(e)},{...this.options.headers,"Content-Type":"application/json"}),this.options)}async PatchObject(e,s,r,t){let n=te.generate(e,s);return this.Patch(s.metadata?.name,n,r,t)}async Patch(e,s,r,t){this.options.name=e;let n=this.buildPath(t);return n.err?n:o.WithExtra(await this.client.doRaw(n.val,{method:"PATCH",body:JSON.stringify(s,function(i,u){return u===void 0?null:u})},{...this.options.headers,"Content-Type":r||"application/merge-patch+json"}),this.options)}async Update(e,s,r){this.options.name=e;let t=this.buildPath(r);return t.err?t:o.WithExtra(await this.client.doRaw(t.val,{method:"PUT",body:JSON.stringify(s)},{...this.options.headers,"Content-Type":"application/json"}),this.options)}async Delete(e,s){this.options.name=e;let r=this.buildPath(s);return r.err?r:o.WithExtra(await this.client.doRaw(r.val,{method:"DELETE"},this.options.headers),this.options)}async CanI(e){let s=this.options.groupVersionResource,r=this.options.basePath?.indexOf(j)===0?this.options.basePath.substring(j.length):void 0,t,n;this.options.project?(t=this.client.project(this.options.project,c.V1SelfSubjectAccessReview),n=f(c.V1SelfSubjectAccessReview)):this.options.vCluster?(t=this.client.vCluster(this.options.vCluster,c.V1SelfSubjectAccessReview),n=f(c.V1SelfSubjectAccessReview)):r?(t=this.client.cluster(r,c.V1SelfSubjectAccessReview),n=f(c.V1SelfSubjectAccessReview)):(t=this.client.management(c.ManagementV1SelfSubjectAccessReview),n=f(c.ManagementV1SelfSubjectAccessReview)),n.spec={resourceAttributes:{verb:e,name:this.options.name,namespace:this.options.namespace,group:s.group,version:s.version,resource:s.resource,subresource:s.subResource}};let i=await t.Create(n);return i.err?i:o.Value(!!(i.val.status?.allowed&&!i.val.status.denied))}};function z(a){let e=new URLSearchParams;for(let[s,r]of Object.entries(a))Array.isArray(r)?r.forEach(t=>{e.append(s,t)}):e.append(s,r);return e.toString()}var ie=C;export{W as APIExtensionsGroup,Re as APIExtensionsGroupVersion,B as APIExtensionsVersion,ie as Client,j as ClusterBasePath,T as Err,Y as ErrorTypeAlreadyExists,se as ErrorTypeBadGateway,X as ErrorTypeBadRequest,Q as ErrorTypeForbidden,re as ErrorTypeGatewayTimeout,Z as ErrorTypeInternalError,L as ErrorTypeNetwork,D as ErrorTypeNotFound,ee as ErrorTypeNotImplemented,I as ErrorTypeServiceUnavailable,A as ErrorTypeUnauthorized,O as ErrorTypeUnknown,x as Failed,U as List,ge as LoftSchemeGroup,P as LoftSchemeGroupCluster,Ve as LoftSchemeGroupStorage,de as LoftSchemeGroupVersion,pe as LoftSchemeGroupVersionCluster,he as LoftSchemeGroupVersionStorage,me as LoftSchemeGroupVersionVirtualCluster,N as LoftSchemeGroupVirtualCluster,F as LoftSchemeVersion,S as LoftSchemeVersionCluster,fe as LoftSchemeVersionStorage,q as LoftSchemeVersionVirtualCluster,$ as ManagementBasePath,b as MapErrorCode,f as NewResource,w as Ok,_ as ProjectBasePath,c as Resources,o as Return,J as VClusterBasePath,oe as getApiHost,De as getProjectFromNamespace,Le as getProjectNamespace,Se as isResult}; diff --git a/lib/index.js b/lib/index.js index 2e475a8..aa0360f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1 +1 @@ -"use strict";var ce=Object.create;var G=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var me=Object.getOwnPropertyNames;var pe=Object.getPrototypeOf,ge=Object.prototype.hasOwnProperty;var de=(o,e)=>{for(var s in e)G(o,s,{get:e[s],enumerable:!0})},_=(o,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of me(e))!ge.call(o,t)&&t!==s&&G(o,t,{get:()=>e[t],enumerable:!(r=le(e,t))||r.enumerable});return o};var z=(o,e,s)=>(s=o!=null?ce(pe(o)):{},_(e||!o||!o.__esModule?G(s,"default",{value:o,enumerable:!0}):s,o)),Ve=o=>_(G({},"__esModule",{value:!0}),o);var Ae={};de(Ae,{APIExtensionsGroup:()=>B,APIExtensionsGroupVersion:()=>ke,APIExtensionsVersion:()=>H,Client:()=>ue,ClusterBasePath:()=>j,Err:()=>S,ErrorTypeAlreadyExists:()=>Z,ErrorTypeBadGateway:()=>re,ErrorTypeBadRequest:()=>Y,ErrorTypeForbidden:()=>X,ErrorTypeGatewayTimeout:()=>te,ErrorTypeInternalError:()=>ee,ErrorTypeNetwork:()=>O,ErrorTypeNotFound:()=>L,ErrorTypeNotImplemented:()=>se,ErrorTypeServiceUnavailable:()=>w,ErrorTypeUnauthorized:()=>T,ErrorTypeUnknown:()=>x,Failed:()=>E,List:()=>U,LoftSchemeGroup:()=>Re,LoftSchemeGroupCluster:()=>k,LoftSchemeGroupStorage:()=>Me,LoftSchemeGroupVersion:()=>ve,LoftSchemeGroupVersionCluster:()=>he,LoftSchemeGroupVersionStorage:()=>Ce,LoftSchemeGroupVersionVirtualCluster:()=>fe,LoftSchemeGroupVirtualCluster:()=>N,LoftSchemeVersion:()=>F,LoftSchemeVersionCluster:()=>y,LoftSchemeVersionStorage:()=>be,LoftSchemeVersionVirtualCluster:()=>q,ManagementBasePath:()=>W,MapErrorCode:()=>R,NewResource:()=>d,Ok:()=>P,ProjectBasePath:()=>J,Resources:()=>c,Return:()=>a,VClusterBasePath:()=>$,getApiHost:()=>ie,getProjectFromNamespace:()=>we,getProjectNamespace:()=>Te,isResult:()=>ye});module.exports=Ve(Ae);var m=z(require("js-cookie")),ae=z(require("json-merge-patch"));var b={loftAccessKeyIdentifier:"loft_access_key",loftImpersonateSubjectIdentifier:"loft_impersonate_subject",loftImpersonateJoinedGroupIdentifier:"loft_impersonate_joined_group",platformAccessKeyNotFound:"platform access key not found. Please login again"};function h(o){return o||[]}var Q={ManagementV1AgentAuditEvent:{group:"management.loft.sh",version:"v1",resource:"agentauditevents",subResource:"",namespaced:!1,kind:"AgentAuditEvent"},ManagementV1Announcement:{group:"management.loft.sh",version:"v1",resource:"announcements",subResource:"",namespaced:!1,kind:"Announcement"},ManagementV1App:{group:"management.loft.sh",version:"v1",resource:"apps",subResource:"",namespaced:!1,kind:"App"},ManagementV1AppCredentials:{group:"management.loft.sh",version:"v1",resource:"apps",subResource:"credentials",namespaced:!1,kind:"AppCredentials"},ManagementV1Backup:{group:"management.loft.sh",version:"v1",resource:"backups",subResource:"",namespaced:!1,kind:"Backup"},ManagementV1BackupApply:{group:"management.loft.sh",version:"v1",resource:"backups",subResource:"apply",namespaced:!1,kind:"BackupApply"},ManagementV1Cluster:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"",namespaced:!1,kind:"Cluster"},ManagementV1ClusterAccess:{group:"management.loft.sh",version:"v1",resource:"clusteraccesses",subResource:"",namespaced:!1,kind:"ClusterAccess"},ManagementV1ClusterAccessKey:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"accesskey",namespaced:!1,kind:"ClusterAccessKey"},ManagementV1ClusterAgentConfig:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"agentconfig",namespaced:!1,kind:"ClusterAgentConfig"},ManagementV1ClusterCharts:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"charts",namespaced:!1,kind:"ClusterCharts"},ManagementV1ClusterDomain:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"domain",namespaced:!1,kind:"ClusterDomain"},ManagementV1ClusterMemberAccess:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"memberaccess",namespaced:!1,kind:"ClusterMemberAccess"},ManagementV1ClusterMembers:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"members",namespaced:!1,kind:"ClusterMembers"},ManagementV1ClusterReset:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"reset",namespaced:!1,kind:"ClusterReset"},ManagementV1ClusterRoleTemplate:{group:"management.loft.sh",version:"v1",resource:"clusterroletemplates",subResource:"",namespaced:!1,kind:"ClusterRoleTemplate"},ManagementV1ClusterVirtualClusterDefaults:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"virtualclusterdefaults",namespaced:!1,kind:"ClusterVirtualClusterDefaults"},ManagementV1Config:{group:"management.loft.sh",version:"v1",resource:"configs",subResource:"",namespaced:!1,kind:"Config"},ManagementV1ConvertVirtualClusterConfig:{group:"management.loft.sh",version:"v1",resource:"convertvirtualclusterconfig",subResource:"",namespaced:!1,kind:"ConvertVirtualClusterConfig"},ManagementV1DevPodEnvironmentTemplate:{group:"management.loft.sh",version:"v1",resource:"devpodenvironmenttemplates",subResource:"",namespaced:!1,kind:"DevPodEnvironmentTemplate"},ManagementV1DevPodWorkspaceInstance:{group:"management.loft.sh",version:"v1",resource:"devpodworkspaceinstances",subResource:"",namespaced:!0,kind:"DevPodWorkspaceInstance"},ManagementV1DevPodWorkspaceInstanceState:{group:"management.loft.sh",version:"v1",resource:"devpodworkspaceinstances",subResource:"state",namespaced:!0,kind:"DevPodWorkspaceInstanceState"},ManagementV1DevPodWorkspaceTemplate:{group:"management.loft.sh",version:"v1",resource:"devpodworkspacetemplates",subResource:"",namespaced:!1,kind:"DevPodWorkspaceTemplate"},ManagementV1DirectClusterEndpointToken:{group:"management.loft.sh",version:"v1",resource:"directclusterendpointtokens",subResource:"",namespaced:!1,kind:"DirectClusterEndpointToken"},ManagementV1Event:{group:"management.loft.sh",version:"v1",resource:"events",subResource:"",namespaced:!1,kind:"Event"},ManagementV1Feature:{group:"management.loft.sh",version:"v1",resource:"features",subResource:"",namespaced:!1,kind:"Feature"},ManagementV1IngressAuthToken:{group:"management.loft.sh",version:"v1",resource:"ingressauthtokens",subResource:"",namespaced:!1,kind:"IngressAuthToken"},ManagementV1Kiosk:{group:"management.loft.sh",version:"v1",resource:"kiosk",subResource:"",namespaced:!1,kind:"Kiosk"},ManagementV1License:{group:"management.loft.sh",version:"v1",resource:"licenses",subResource:"",namespaced:!1,kind:"License"},ManagementV1LicenseRequest:{group:"management.loft.sh",version:"v1",resource:"licenses",subResource:"request",namespaced:!1,kind:"LicenseRequest"},ManagementV1LicenseToken:{group:"management.loft.sh",version:"v1",resource:"licensetokens",subResource:"",namespaced:!1,kind:"LicenseToken"},ManagementV1LoftUpgrade:{group:"management.loft.sh",version:"v1",resource:"loftupgrades",subResource:"",namespaced:!1,kind:"LoftUpgrade"},ManagementV1OIDCClient:{group:"management.loft.sh",version:"v1",resource:"oidcclients",subResource:"",namespaced:!1,kind:"OIDCClient"},ManagementV1OwnedAccessKey:{group:"management.loft.sh",version:"v1",resource:"ownedaccesskeys",subResource:"",namespaced:!1,kind:"OwnedAccessKey"},ManagementV1Project:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"",namespaced:!1,kind:"Project"},ManagementV1ProjectChartInfo:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"chartinfo",namespaced:!1,kind:"ProjectChartInfo"},ManagementV1ProjectCharts:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"charts",namespaced:!1,kind:"ProjectCharts"},ManagementV1ProjectClusters:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"clusters",namespaced:!1,kind:"ProjectClusters"},ManagementV1ProjectImportSpace:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"importspace",namespaced:!1,kind:"ProjectImportSpace"},ManagementV1ProjectMembers:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"members",namespaced:!1,kind:"ProjectMembers"},ManagementV1ProjectMigrateSpaceInstance:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"migratespaceinstance",namespaced:!1,kind:"ProjectMigrateSpaceInstance"},ManagementV1ProjectMigrateVirtualClusterInstance:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"migratevirtualclusterinstance",namespaced:!1,kind:"ProjectMigrateVirtualClusterInstance"},ManagementV1ProjectRunners:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"runners",namespaced:!1,kind:"ProjectRunners"},ManagementV1ProjectSecret:{group:"management.loft.sh",version:"v1",resource:"projectsecrets",subResource:"",namespaced:!0,kind:"ProjectSecret"},ManagementV1ProjectTemplates:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"templates",namespaced:!1,kind:"ProjectTemplates"},ManagementV1RedirectToken:{group:"management.loft.sh",version:"v1",resource:"redirecttokens",subResource:"",namespaced:!1,kind:"RedirectToken"},ManagementV1RegisterVirtualCluster:{group:"management.loft.sh",version:"v1",resource:"registervirtualclusters",subResource:"",namespaced:!1,kind:"RegisterVirtualCluster"},ManagementV1ResetAccessKey:{group:"management.loft.sh",version:"v1",resource:"resetaccesskeys",subResource:"",namespaced:!1,kind:"ResetAccessKey"},ManagementV1Runner:{group:"management.loft.sh",version:"v1",resource:"runners",subResource:"",namespaced:!1,kind:"Runner"},ManagementV1RunnerAccessKey:{group:"management.loft.sh",version:"v1",resource:"runners",subResource:"accesskey",namespaced:!1,kind:"RunnerAccessKey"},ManagementV1RunnerConfig:{group:"management.loft.sh",version:"v1",resource:"runners",subResource:"config",namespaced:!1,kind:"RunnerConfig"},ManagementV1Self:{group:"management.loft.sh",version:"v1",resource:"selves",subResource:"",namespaced:!1,kind:"Self"},ManagementV1SelfSubjectAccessReview:{group:"management.loft.sh",version:"v1",resource:"selfsubjectaccessreviews",subResource:"",namespaced:!1,kind:"SelfSubjectAccessReview"},ManagementV1SharedSecret:{group:"management.loft.sh",version:"v1",resource:"sharedsecrets",subResource:"",namespaced:!0,kind:"SharedSecret"},ManagementV1SpaceInstance:{group:"management.loft.sh",version:"v1",resource:"spaceinstances",subResource:"",namespaced:!0,kind:"SpaceInstance"},ManagementV1SpaceTemplate:{group:"management.loft.sh",version:"v1",resource:"spacetemplates",subResource:"",namespaced:!1,kind:"SpaceTemplate"},ManagementV1SubjectAccessReview:{group:"management.loft.sh",version:"v1",resource:"subjectaccessreviews",subResource:"",namespaced:!1,kind:"SubjectAccessReview"},ManagementV1Task:{group:"management.loft.sh",version:"v1",resource:"tasks",subResource:"",namespaced:!1,kind:"Task"},ManagementV1TaskLog:{group:"management.loft.sh",version:"v1",resource:"tasks",subResource:"log",namespaced:!1,kind:"TaskLog"},ManagementV1Team:{group:"management.loft.sh",version:"v1",resource:"teams",subResource:"",namespaced:!1,kind:"Team"},ManagementV1TeamAccessKeys:{group:"management.loft.sh",version:"v1",resource:"teams",subResource:"accesskeys",namespaced:!1,kind:"TeamAccessKeys"},ManagementV1TeamClusters:{group:"management.loft.sh",version:"v1",resource:"teams",subResource:"clusters",namespaced:!1,kind:"TeamClusters"},ManagementV1TranslateVClusterResourceName:{group:"management.loft.sh",version:"v1",resource:"translatevclusterresourcenames",subResource:"",namespaced:!1,kind:"TranslateVClusterResourceName"},ManagementV1User:{group:"management.loft.sh",version:"v1",resource:"users",subResource:"",namespaced:!1,kind:"User"},ManagementV1UserAccessKeys:{group:"management.loft.sh",version:"v1",resource:"users",subResource:"accesskeys",namespaced:!1,kind:"UserAccessKeys"},ManagementV1UserClusters:{group:"management.loft.sh",version:"v1",resource:"users",subResource:"clusters",namespaced:!1,kind:"UserClusters"},ManagementV1UserPermissions:{group:"management.loft.sh",version:"v1",resource:"users",subResource:"permissions",namespaced:!1,kind:"UserPermissions"},ManagementV1UserProfile:{group:"management.loft.sh",version:"v1",resource:"users",subResource:"profile",namespaced:!1,kind:"UserProfile"},ManagementV1VirtualClusterAccessKey:{group:"management.loft.sh",version:"v1",resource:"virtualclusterinstances",subResource:"accesskey",namespaced:!0,kind:"VirtualClusterAccessKey"},ManagementV1VirtualClusterInstance:{group:"management.loft.sh",version:"v1",resource:"virtualclusterinstances",subResource:"",namespaced:!0,kind:"VirtualClusterInstance"},ManagementV1VirtualClusterInstanceKubeConfig:{group:"management.loft.sh",version:"v1",resource:"virtualclusterinstances",subResource:"kubeconfig",namespaced:!0,kind:"VirtualClusterInstanceKubeConfig"},ManagementV1VirtualClusterInstanceLog:{group:"management.loft.sh",version:"v1",resource:"virtualclusterinstances",subResource:"log",namespaced:!0,kind:"VirtualClusterInstanceLog"},ManagementV1VirtualClusterTemplate:{group:"management.loft.sh",version:"v1",resource:"virtualclustertemplates",subResource:"",namespaced:!1,kind:"VirtualClusterTemplate"}};var N="virtualcluster.loft.sh",q="v1",fe="virtualcluster.loft.sh/v1",k="cluster.loft.sh",y="v1",he="cluster.loft.sh/v1",Re="management.loft.sh",F="v1",ve="management.loft.sh/v1",Me="storage.loft.sh",be="v1",Ce="storage.loft.sh/v1",B="apiextensions.k8s.io",H="v1",ke="apiextensions.k8s.io/v1",U=class{};var c={...Q,ClusterV1SleepModeConfig:{group:k,version:y,resource:"sleepmodeconfigs",kind:"SleepModeConfig",namespaced:!0},ClusterV1HelmRelease:{group:k,version:y,resource:"helmreleases",kind:"HelmRelease",namespaced:!0},ClusterV1ChartInfo:{group:k,version:y,resource:"chartinfos",kind:"ChartInfo"},VirtualclusterV1HelmRelease:{group:N,version:q,resource:"helmreleases",kind:"HelmRelease",namespaced:!0},CustomResourceDefinition:{group:B,version:H,resource:"customresourcedefinitions",kind:"CustomResourceDefinition"},StorageV1ClusterQuota:{group:"storage.loft.sh",version:F,resource:"clusterquotas",kind:"ClusterQuota"},NetworkingV1Ingress:{group:"networking.k8s.io",version:"v1",resource:"ingresses",kind:"Ingress",namespaced:!0},V1StatefulSet:{group:"apps",version:"v1",resource:"statefulsets",kind:"StatefulSet",namespaced:!0},V1Deployment:{group:"apps",version:"v1",resource:"deployments",kind:"Deployment",namespaced:!0},V1Event:{group:"",version:"v1",resource:"events",kind:"Event",namespaced:!0},V1Pod:{group:"",version:"v1",resource:"pods",kind:"Pod",namespaced:!0},V1Node:{group:"",version:"v1",resource:"nodes",kind:"Node"},V1Namespace:{group:"",version:"v1",resource:"namespaces",kind:"Namespace"},V1SelfSubjectAccessReview:{group:"authorization.k8s.io",version:"v1",resource:"selfsubjectaccessreviews",kind:"SelfSubjectAccessReview"},V1ClusterRole:{group:"rbac.authorization.k8s.io",version:"v1",resource:"clusterroles",kind:"ClusterRole"},V1ClusterRoleBinding:{group:"rbac.authorization.k8s.io",version:"v1",resource:"clusterrolebindings",kind:"ClusterRoleBinding"},V1Role:{group:"rbac.authorization.k8s.io",version:"v1",resource:"roles",kind:"Role",namespaced:!0},V1RoleBinding:{group:"rbac.authorization.k8s.io",version:"v1",resource:"rolebindings",kind:"RoleBinding",namespaced:!0},V1Secret:{group:"",version:"v1",resource:"secrets",kind:"Secret",namespaced:!0},V1ConfigMap:{group:"",version:"v1",resource:"configmaps",kind:"ConfigMap",namespaced:!0},V1Service:{group:"",version:"v1",resource:"services",kind:"Service",namespaced:!0},V1User:{group:"",version:"v1",resource:"users",kind:"User",namespaced:!1},V1StorageClassList:{group:"storage.k8s.io",version:"v1",resource:"storageclasses",kind:"StorageClass",namespaced:!1},V1Beta1PodMetrics:{group:"metrics.k8s.io",version:"v1beta1",resource:"pods",kind:"PodMetrics",namespaced:!0}};function d(o,e,s){return{apiVersion:o.group?o.group+"/"+o.version:o.version,kind:o.kind,metadata:{name:e},...s}}var S=class{constructor(e,s=void 0){this.val=e;this.extra=s;this.ok=!1;this.err=!0}},P=class{constructor(e,s=void 0){this.val=e;this.extra=s;this.ok=!0;this.err=!1}};function ye(o){return"ok"in o&&typeof o.ok=="boolean"&&"err"in o&&typeof o.err=="boolean"}var x="",O="Network",X="Forbidden",Y="BadRequest",L="NotFound",T="Unauthorized",Z="AlreadyExists",ee="InternalServerError",se="NotImplemented",re="BadGateway",w="ServiceUnavailable",te="GatewayTimeout",R=o=>{switch(o){case 400:return Y;case 401:return T;case 403:return X;case 404:return L;case 409:return Z;case 500:return ee;case 501:return se;case 502:return re;case 503:return w;case 504:return te}return x},a=class{static Ok(){return new P(void 0)}static Value(e){return new P(e)}static Failed(e,s="",r=x,t=void 0){return new S(new E(e,r,s),t)}static Error(e){return new S(e)}static WithExtra(e,s=void 0){return e.extra=s,e}},E=class{constructor(e,s=x,r=""){this.message=e;this.type=s;this.reason=r}};var A={secure:!0,expires:365*10,sameSite:"strict"},V=b.loftAccessKeyIdentifier,v=b.loftImpersonateSubjectIdentifier,I=b.loftImpersonateJoinedGroupIdentifier,Se=["v4.channel.k8s.io","v3.channel.k8s.io","v2.channel.k8s.io","channel.k8s.io"];function ie(){return typeof window<"u"&&window.location.href.startsWith("http://localhost:3000")?"https://localhost:9898":""}function Pe(){return typeof window>"u"||window.location.host==="localhost:3000"?"wss://localhost:8080":`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}`}function ne(o){return[o.virtualCluster?"loft:vcluster:main":`loft:space:${o.project}:${o.space}`]}var W="/kubernetes/management",j="/kubernetes/cluster/",$="/kubernetes/virtualcluster/",J="/kubernetes/project/";function Te(o,e){return o?e&&e.endsWith("-")?`${e}${o}`:e===""?`${o}`:e?`${e}-${o}`:`p-${o}`:"p-"}function we(o,e){if(o)return e?e.endsWith("-")?o.replace(new RegExp(`^${e}`),""):o.replace(new RegExp(`^${e}-`),""):o.replace(/^p-/,"")}var C=class{constructor(e,s,r){this.apiHost="";this.wsHost="";this.accessKey="";this.managementNonResource=()=>new l(this,{basePath:W,headers:this.impersonationHeaders()});this.cluster=(e,s)=>new l(this,{basePath:j+e,groupVersionResource:s,headers:this.impersonationHeaders()});this.clusterNonResource=e=>new l(this,{basePath:j+e,headers:this.impersonationHeaders()});this.project=(e,s)=>new l(this,{basePath:J+e.project+"/"+(e.space?"space/"+e.space:"virtualcluster/"+e.virtualCluster),groupVersionResource:s,project:e,headers:this.impersonationHeaders(ne(e))});this.projectNonResource=e=>new l(this,{basePath:J+e.project+"/"+(e.space?"space/"+e.space:"virtualcluster/"+e.virtualCluster),project:e,headers:this.impersonationHeaders(ne(e))});this.apiHost=s||ie(),this.wsHost=r||Pe(),this.accessKey=e||C.getAccessKey()}static getAccessKey(){return localStorage.getItem(V)}static tryCastToStatus(e){if(e.kind){if(e.kind!=="Status"||e.apiVersion!=="v1")return a.Value(null)}else return a.Value(null);return a.Value(e)}async getUser(){let e=await this.management(c.ManagementV1Self).Create(d(c.ManagementV1Self));return e.err?e:e.val.status?.user?(typeof window<"u"&&(window.loft||(window.loft={}),window.loft.instanceID=e.val.status.instanceID,window.loft.chatAuthToken=e.val.status.chatAuthToken,window.loft.user=e.val.status.user),a.Value(e.val.status.user.name)):a.Failed("no user found")}getAccessKey(){return this.accessKey}async loftVersion(e){try{let s=this.apiHost+"/version";e&&(s+="?refresh=true");let t=await(await fetch(s)).json();return a.Value(t)}catch(s){return console.error(s),a.Failed("error during version retrieval")}}impersonatedUser(){try{let e=localStorage.getItem(v);if(e)return JSON.parse(e)}catch(e){console.error(e)}}impersonate(e,s,r){s?(localStorage.setItem(v,JSON.stringify({name:e,subject:s,groups:r})),s&&m.default.set(v,s,A),r?.forEach(t=>{let n=m.default.get(I);n?(n+=", "+t,m.default.set(I,n,A)):m.default.set(I,t,A)})):(localStorage.removeItem(v),m.default.remove(v),m.default.remove(I))}async login(e,s){let r=await this.request("/auth/password/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:s})});if(r.err)return r;let t=r.val;return this.setAccessKey(t.accessKey),a.Ok()}async loginWithAccessKey(e){this.isLoggedIn()&&await this.logout(),this.accessKey=e;let s=await this.management(c.ManagementV1Self).Create(d(c.ManagementV1Self));return s.err?(this.clearStorage(),s):(this.setAccessKey(e),a.Ok())}isLoggedIn(){return!!this.accessKey}setAccessKey(e){this.accessKey=e,localStorage.setItem(V,e),m.default.set(V,e,A)}async stream(e,s){try{let r=await fetch(this.apiHost+e,s);return r.status>=400||!r.body?await this.parseResponse(e,r):a.Value(r.body.getReader())}catch(r){return a.Failed(r+"","NetworkError",O)}}async request(e,s){try{let r=await fetch(this.apiHost+e,{...s,credentials:"same-origin"});if(!r.ok){let n=await r.clone().text();if(r.status===401)try{let i=JSON.parse(n);if(i?.message===b.platformAccessKeyNotFound)return window.location.href=`/login?error=${i?.message}&errorType=${i?.reason}`,a.Failed(i.message||"Unauthorized",i.reason,T)}catch{}}return await this.parseResponse(e,r)}catch(r){let t=r;return t.message===b.platformAccessKeyNotFound&&(window.location.href=`/login?error=${t.message}&errorType=${t.reason}`),a.Failed(r+"","NetworkError",O)}}async socket(e,s){return this.refreshCookie(),new Promise((r,t)=>{let n=new WebSocket(`${this.wsHost}${e}`,s),i=!1;n.onopen=()=>{i=!0,r(n)},n.onerror=u=>{if(!i){let p=m.default.get(V)!="";t(p?u:new Error("Web socket is not authenticated. Please log in again"))}}})}async parseResponse(e,s){let r=await s.text(),t;try{t=JSON.parse(r)}catch{if(s.status===404)return a.Failed("page not found","NotFound",L);if(s.status===503){if(e.includes("kiosk.sh")||e.includes("cluster.loft.sh")){let u=e.split("/");return u.length>=4&&u[0]===""&&u[1]==="kubernetes"&&u[2]==="cluster"?a.Failed(`Agent seems to be currently unavailable, it is maybe just starting up. Click here for more information`,"LoftAgentUnavailable",w):a.Failed("Agent seems to be currently unavailable, it is maybe just starting up","LoftAgentUnavailable",w)}}else if(s.status===200)return a.Value(r);return console.info("Unexpected Server Response",r),a.Failed("Unexpected server response",R(s.status),R(s.status))}let n=C.tryCastToStatus(t);return n.err?n:n.val!==null&&n.val.status==="Failure"?n.val.code===500&&(n.val.message?.indexOf("vcluster secret not found")!==-1||n.val.message.indexOf("no ready pod for virtual cluster")!==-1)?a.Failed("vcluster seems to be not ready. Please refresh in a second",n.val.reason,R(n.val.code)):a.Failed(n.val.message,n.val.reason,R(n.val.code)):s.status>=400?a.Failed("unknown error","Unknown",R(s.status)):a.Value(t)}management(e){return new l(this,{basePath:W,groupVersionResource:e,headers:this.impersonationHeaders()})}vCluster(e,s){return new l(this,{basePath:$+e.cluster+"/"+e.namespace+"/"+e.name,groupVersionResource:s,vCluster:e,headers:this.impersonationHeaders()})}vClusterNonResource(e){return new l(this,{basePath:$+e.cluster+"/"+e.namespace+"/"+e.name,vCluster:e,headers:this.impersonationHeaders()})}auto(e,s,r,t){return r?this.project(r,t):s?this.vCluster(s,t):e?this.cluster(e,t):this.management(t)}autoNonResource(e,s,r){return r?this.projectNonResource(r):s?this.vClusterNonResource(s):e?this.clusterNonResource(e):this.managementNonResource()}async doRawSocket(e,s){try{return a.Value(await this.socket(e,s))}catch(r){return console.error(r),a.Failed(r.message||JSON.stringify(r))}}async doRawStream(e,s,r){return this.doRawInternal(e,s,r,!0)}async doRaw(e,s,r){return this.doRawInternal(e,s,r)}async doRawInternal(e,s,r,t){let n=this.accessKey,i=n?new Headers({...r,Authorization:"bearer "+n,"X-Sleep-Mode-Ignore":"true","X-Platform-Client":"true"}):new Headers({...r,"X-Sleep-Mode-Ignore":"true","X-Platform-Client":"true"}),u=t?await this.stream(e,{...s,headers:i}):await this.request(e,{...s,headers:i});return u.err&&u.val.type===T&&(u.val.message==="Access key not found. Please login again"||u.val.message==="invalid bearer token")&&(this.clearStorage(),typeof window<"u"&&(window.location.href="/"),await new Promise(()=>{})),u}impersonationHeaders(e){let s=this.impersonatedUser(),r={};return s&&(s.subject&&(r["Impersonate-User"]=s.subject),[...h(s.groups),...h(e)].forEach(t=>{r["Impersonate-Joined-Group"]?r["Impersonate-Joined-Group"]+=", "+t:r["Impersonate-Joined-Group"]=t})),r}clearStorage(){this.accessKey=null,localStorage.removeItem(V),localStorage.removeItem(v),m.default.remove(V,{secure:!0}),m.default.remove(v,{secure:!0}),m.default.remove(I,{secure:!0})}refreshCookie(){let e=this.accessKey||localStorage.getItem(V),s=m.default.get(V);e&&e!=s&&m.default.set(V,e,A)}async logout(){let e=await this.management(c.ManagementV1Self).Create(d(c.ManagementV1Self));if(e.err)return this.clearStorage(),e;if(!e.val.status?.accessKey)return this.clearStorage(),a.Ok();let s=await this.management(c.ManagementV1OwnedAccessKey).Delete(e.val.status.accessKey);return s.err?(this.clearStorage(),s):(this.clearStorage(),a.Ok())}},l=class{constructor(e,s){this.client=e,this.options=s}Name(e){return new l(this.client,{...this.options,name:e})}Namespace(e){return e?new l(this.client,{...this.options,namespace:e}):new l(this.client,{...this.options})}Resource(e){return new l(this.client,{...this.options,groupVersionResource:e})}buildPath(e){if(this.options.groupVersionResource)if(this.options.basePath){if(!this.options.name&&this.options.groupVersionResource.subResource)return a.Failed("resource name required when subresource is used")}else return a.Failed("basePath is missing");else return a.Failed("groupVersionResource is missing");let s=[this.options.basePath];this.options.groupVersionResource.group?s.push("apis",this.options.groupVersionResource.group):s.push("api"),s.push(this.options.groupVersionResource.version),this.options.namespace&&s.push("namespaces",this.options.namespace),s.push(this.options.groupVersionResource.resource),this.options.name&&s.push(this.options.name),this.options.groupVersionResource.subResource&&s.push(this.options.groupVersionResource.subResource);let r="";if(e){let t=[];for(let n of Object.keys(e))e[n]&&(Array.isArray(e[n])?e[n].forEach(i=>{t.push(n+"="+encodeURIComponent(i))}):t.push(n+"="+encodeURIComponent(e[n])));t.length>0&&(r="?"+t.join("&"))}else r="?timeout=180s";return a.Value(s.join("/")+r)}parseResourceList(e,s,r,t,n,i){for(let u=0;u1||n&&t.find(M=>M.group===e&&M.resource===f)||t.push({resource:f,subResource:g.length>1?g[1]:void 0,group:e,version:s,kind:p.kind,namespaced:p.namespaced,verbs:p.verbs})}}async ApiResources(e,s){let r=[],t=await this.client.doRaw([this.options.basePath,"api"].join("/"));if(t.err)return t;let n=[];for(let u=0;u{let g=t.val.versions[p];if(g===void 0)return;let f=await this.client.doRaw([this.options.basePath,"api",g].join("/"));if(f.err){console.error(f.val.message);return}this.parseResourceList("",g,f.val,r,e,s)})(u)),n.length>20&&(await Promise.all(n),n=[]);n.length>0&&(await Promise.all(n),n=[]);let i=await this.client.doRaw([this.options.basePath,"apis"].join("/"));if(i.err)return i;for(let u=0;u{let K=M.versions[f];if(K===void 0)return;let D=await this.client.doRaw([this.options.basePath,"apis",M.name,K.version].join("/"));if(D.err){console.error(D.val.message);return}this.parseResourceList(M.name,K.version,D.val,r,e,s)})(g,p)),n.length>20&&(await Promise.all(n),n=[])}return n.length>0&&await Promise.all(n),a.Value(r)}async Version(){let e=[this.options.basePath,"version"];return await this.client.doRaw(e.join("/"))}async VirtualClusterInstanceLogs(e,s,r){let t=[this.options.basePath,`apis/management.loft.sh/v1/namespaces/${e}/virtualclusterinstances/${s}/log`].join("/"),n=[];if(r)for(let i of Object.keys(r))n.push(`${i}=${encodeURIComponent(r[i])}`);return n.length>0&&(t+="?"+n.join("&")),await this.client.doRawStream(t,void 0,this.options.headers)}async TaskLogs(e,s){let r=[this.options.basePath,`apis/management.loft.sh/v1/tasks/${e}/log`].join("/"),t=[];if(s)for(let n of Object.keys(s))t.push(`${n}=${encodeURIComponent(s[n])}`);return t.length>0&&(r+="?"+t.join("&")),await this.client.doRawStream(r,void 0,this.options.headers)}async Logs(e,s,r){let t=[this.options.basePath,`api/v1/namespaces/${e}/pods/${s}/log`].join("/"),n=oe(r);return n.length>0&&(t+="?"+n),await this.client.doRawStream(t,void 0,this.options.headers)}async Exec(e,s,r){let t=[this.options.basePath,`api/v1/namespaces/${e}/pods/${s}/exec`].join("/"),n=oe(r);return n.length>0&&(t+="?"+n),await this.client.doRawSocket(t,Se)}async Path(e,s,r){let t=[this.options.basePath,e];return await this.client.doRaw(t.join("/"),s,{...r,...this.options.headers})}ResolvePath(e){return e&&(this.options.name=e),this.buildPath()}async Get(e,s){this.options.name=e;let r=this.buildPath(s);return r.err?r:a.WithExtra(await this.client.doRaw(r.val,void 0,this.options.headers),this.options)}async List(e){if(this.options.name)return a.Failed("name is set on a list request");let s=this.buildPath(e);return s.err?s:a.WithExtra(await this.client.doRaw(s.val,void 0,this.options.headers),this.options)}async ListTable(e){if(this.options.name)return a.Failed("name is set on a list request");let s=this.buildPath(e);return s.err?s:a.WithExtra(await this.client.doRaw(s.val,void 0,{...this.options.headers,Accept:"application/json;as=Table;v=v1;g=meta.k8s.io,application/json;as=Table;v=v1beta1;g=meta.k8s.io,application/json"}),this.options)}async Create(e,s){let r=this.buildPath(s);return r.err?r:a.WithExtra(await this.client.doRaw(r.val,{method:"POST",body:JSON.stringify(e)},{...this.options.headers,"Content-Type":"application/json"}),this.options)}async PatchObject(e,s,r,t){let n=ae.default.generate(e,s);return this.Patch(s.metadata?.name,n,r,t)}async Patch(e,s,r,t){this.options.name=e;let n=this.buildPath(t);return n.err?n:a.WithExtra(await this.client.doRaw(n.val,{method:"PATCH",body:JSON.stringify(s,function(i,u){return u===void 0?null:u})},{...this.options.headers,"Content-Type":r||"application/merge-patch+json"}),this.options)}async Update(e,s,r){this.options.name=e;let t=this.buildPath(r);return t.err?t:a.WithExtra(await this.client.doRaw(t.val,{method:"PUT",body:JSON.stringify(s)},{...this.options.headers,"Content-Type":"application/json"}),this.options)}async Delete(e,s){this.options.name=e;let r=this.buildPath(s);return r.err?r:a.WithExtra(await this.client.doRaw(r.val,{method:"DELETE"},this.options.headers),this.options)}async CanI(e){let s=this.options.groupVersionResource,r=this.options.basePath?.indexOf(j)===0?this.options.basePath.substring(j.length):void 0,t,n;this.options.project?(t=this.client.project(this.options.project,c.V1SelfSubjectAccessReview),n=d(c.V1SelfSubjectAccessReview)):this.options.vCluster?(t=this.client.vCluster(this.options.vCluster,c.V1SelfSubjectAccessReview),n=d(c.V1SelfSubjectAccessReview)):r?(t=this.client.cluster(r,c.V1SelfSubjectAccessReview),n=d(c.V1SelfSubjectAccessReview)):(t=this.client.management(c.ManagementV1SelfSubjectAccessReview),n=d(c.ManagementV1SelfSubjectAccessReview)),n.spec={resourceAttributes:{verb:e,name:this.options.name,namespace:this.options.namespace,group:s.group,version:s.version,resource:s.resource,subresource:s.subResource}};let i=await t.Create(n);return i.err?i:a.Value(!!(i.val.status?.allowed&&!i.val.status.denied))}};function oe(o){let e=new URLSearchParams;for(let[s,r]of Object.entries(o))Array.isArray(r)?r.forEach(t=>{e.append(s,t)}):e.append(s,r);return e.toString()}var ue=C;0&&(module.exports={APIExtensionsGroup,APIExtensionsGroupVersion,APIExtensionsVersion,Client,ClusterBasePath,Err,ErrorTypeAlreadyExists,ErrorTypeBadGateway,ErrorTypeBadRequest,ErrorTypeForbidden,ErrorTypeGatewayTimeout,ErrorTypeInternalError,ErrorTypeNetwork,ErrorTypeNotFound,ErrorTypeNotImplemented,ErrorTypeServiceUnavailable,ErrorTypeUnauthorized,ErrorTypeUnknown,Failed,List,LoftSchemeGroup,LoftSchemeGroupCluster,LoftSchemeGroupStorage,LoftSchemeGroupVersion,LoftSchemeGroupVersionCluster,LoftSchemeGroupVersionStorage,LoftSchemeGroupVersionVirtualCluster,LoftSchemeGroupVirtualCluster,LoftSchemeVersion,LoftSchemeVersionCluster,LoftSchemeVersionStorage,LoftSchemeVersionVirtualCluster,ManagementBasePath,MapErrorCode,NewResource,Ok,ProjectBasePath,Resources,Return,VClusterBasePath,getApiHost,getProjectFromNamespace,getProjectNamespace,isResult}); +"use strict";var ce=Object.create;var G=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var me=Object.getOwnPropertyNames;var pe=Object.getPrototypeOf,ge=Object.prototype.hasOwnProperty;var de=(o,e)=>{for(var s in e)G(o,s,{get:e[s],enumerable:!0})},_=(o,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of me(e))!ge.call(o,t)&&t!==s&&G(o,t,{get:()=>e[t],enumerable:!(r=le(e,t))||r.enumerable});return o};var z=(o,e,s)=>(s=o!=null?ce(pe(o)):{},_(e||!o||!o.__esModule?G(s,"default",{value:o,enumerable:!0}):s,o)),Ve=o=>_(G({},"__esModule",{value:!0}),o);var Ae={};de(Ae,{APIExtensionsGroup:()=>W,APIExtensionsGroupVersion:()=>ke,APIExtensionsVersion:()=>B,Client:()=>ue,ClusterBasePath:()=>j,Err:()=>P,ErrorTypeAlreadyExists:()=>Z,ErrorTypeBadGateway:()=>re,ErrorTypeBadRequest:()=>Y,ErrorTypeForbidden:()=>X,ErrorTypeGatewayTimeout:()=>te,ErrorTypeInternalError:()=>ee,ErrorTypeNetwork:()=>O,ErrorTypeNotFound:()=>L,ErrorTypeNotImplemented:()=>se,ErrorTypeServiceUnavailable:()=>w,ErrorTypeUnauthorized:()=>T,ErrorTypeUnknown:()=>x,Failed:()=>E,List:()=>U,LoftSchemeGroup:()=>Re,LoftSchemeGroupCluster:()=>k,LoftSchemeGroupStorage:()=>Me,LoftSchemeGroupVersion:()=>ve,LoftSchemeGroupVersionCluster:()=>he,LoftSchemeGroupVersionStorage:()=>Ce,LoftSchemeGroupVersionVirtualCluster:()=>fe,LoftSchemeGroupVirtualCluster:()=>N,LoftSchemeVersion:()=>F,LoftSchemeVersionCluster:()=>y,LoftSchemeVersionStorage:()=>be,LoftSchemeVersionVirtualCluster:()=>q,ManagementBasePath:()=>H,MapErrorCode:()=>R,NewResource:()=>d,Ok:()=>S,ProjectBasePath:()=>J,Resources:()=>c,Return:()=>a,VClusterBasePath:()=>$,getApiHost:()=>ie,getProjectFromNamespace:()=>we,getProjectNamespace:()=>Te,isResult:()=>ye});module.exports=Ve(Ae);var m=z(require("js-cookie")),ae=z(require("json-merge-patch"));var b={loftAccessKeyIdentifier:"loft_access_key",loftImpersonateSubjectIdentifier:"loft_impersonate_subject",loftImpersonateJoinedGroupIdentifier:"loft_impersonate_joined_group",platformAccessKeyNotFound:"platform access key not found. Please login again"};function h(o){return o||[]}var Q={ManagementV1AgentAuditEvent:{group:"management.loft.sh",version:"v1",resource:"agentauditevents",subResource:"",namespaced:!1,kind:"AgentAuditEvent"},ManagementV1Announcement:{group:"management.loft.sh",version:"v1",resource:"announcements",subResource:"",namespaced:!1,kind:"Announcement"},ManagementV1App:{group:"management.loft.sh",version:"v1",resource:"apps",subResource:"",namespaced:!1,kind:"App"},ManagementV1AppCredentials:{group:"management.loft.sh",version:"v1",resource:"apps",subResource:"credentials",namespaced:!1,kind:"AppCredentials"},ManagementV1Backup:{group:"management.loft.sh",version:"v1",resource:"backups",subResource:"",namespaced:!1,kind:"Backup"},ManagementV1BackupApply:{group:"management.loft.sh",version:"v1",resource:"backups",subResource:"apply",namespaced:!1,kind:"BackupApply"},ManagementV1Cluster:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"",namespaced:!1,kind:"Cluster"},ManagementV1ClusterAccess:{group:"management.loft.sh",version:"v1",resource:"clusteraccesses",subResource:"",namespaced:!1,kind:"ClusterAccess"},ManagementV1ClusterAccessKey:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"accesskey",namespaced:!1,kind:"ClusterAccessKey"},ManagementV1ClusterAgentConfig:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"agentconfig",namespaced:!1,kind:"ClusterAgentConfig"},ManagementV1ClusterCharts:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"charts",namespaced:!1,kind:"ClusterCharts"},ManagementV1ClusterDomain:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"domain",namespaced:!1,kind:"ClusterDomain"},ManagementV1ClusterMemberAccess:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"memberaccess",namespaced:!1,kind:"ClusterMemberAccess"},ManagementV1ClusterMembers:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"members",namespaced:!1,kind:"ClusterMembers"},ManagementV1ClusterReset:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"reset",namespaced:!1,kind:"ClusterReset"},ManagementV1ClusterRoleTemplate:{group:"management.loft.sh",version:"v1",resource:"clusterroletemplates",subResource:"",namespaced:!1,kind:"ClusterRoleTemplate"},ManagementV1ClusterVirtualClusterDefaults:{group:"management.loft.sh",version:"v1",resource:"clusters",subResource:"virtualclusterdefaults",namespaced:!1,kind:"ClusterVirtualClusterDefaults"},ManagementV1Config:{group:"management.loft.sh",version:"v1",resource:"configs",subResource:"",namespaced:!1,kind:"Config"},ManagementV1ConvertVirtualClusterConfig:{group:"management.loft.sh",version:"v1",resource:"convertvirtualclusterconfig",subResource:"",namespaced:!1,kind:"ConvertVirtualClusterConfig"},ManagementV1DevPodEnvironmentTemplate:{group:"management.loft.sh",version:"v1",resource:"devpodenvironmenttemplates",subResource:"",namespaced:!1,kind:"DevPodEnvironmentTemplate"},ManagementV1DevPodWorkspaceInstance:{group:"management.loft.sh",version:"v1",resource:"devpodworkspaceinstances",subResource:"",namespaced:!0,kind:"DevPodWorkspaceInstance"},ManagementV1DevPodWorkspaceInstanceState:{group:"management.loft.sh",version:"v1",resource:"devpodworkspaceinstances",subResource:"state",namespaced:!0,kind:"DevPodWorkspaceInstanceState"},ManagementV1DevPodWorkspacePreset:{group:"management.loft.sh",version:"v1",resource:"devpodworkspacepresets",subResource:"",namespaced:!1,kind:"DevPodWorkspacePreset"},ManagementV1DevPodWorkspaceTemplate:{group:"management.loft.sh",version:"v1",resource:"devpodworkspacetemplates",subResource:"",namespaced:!1,kind:"DevPodWorkspaceTemplate"},ManagementV1DirectClusterEndpointToken:{group:"management.loft.sh",version:"v1",resource:"directclusterendpointtokens",subResource:"",namespaced:!1,kind:"DirectClusterEndpointToken"},ManagementV1Event:{group:"management.loft.sh",version:"v1",resource:"events",subResource:"",namespaced:!1,kind:"Event"},ManagementV1Feature:{group:"management.loft.sh",version:"v1",resource:"features",subResource:"",namespaced:!1,kind:"Feature"},ManagementV1IngressAuthToken:{group:"management.loft.sh",version:"v1",resource:"ingressauthtokens",subResource:"",namespaced:!1,kind:"IngressAuthToken"},ManagementV1Kiosk:{group:"management.loft.sh",version:"v1",resource:"kiosk",subResource:"",namespaced:!1,kind:"Kiosk"},ManagementV1License:{group:"management.loft.sh",version:"v1",resource:"licenses",subResource:"",namespaced:!1,kind:"License"},ManagementV1LicenseRequest:{group:"management.loft.sh",version:"v1",resource:"licenses",subResource:"request",namespaced:!1,kind:"LicenseRequest"},ManagementV1LicenseToken:{group:"management.loft.sh",version:"v1",resource:"licensetokens",subResource:"",namespaced:!1,kind:"LicenseToken"},ManagementV1LoftUpgrade:{group:"management.loft.sh",version:"v1",resource:"loftupgrades",subResource:"",namespaced:!1,kind:"LoftUpgrade"},ManagementV1OIDCClient:{group:"management.loft.sh",version:"v1",resource:"oidcclients",subResource:"",namespaced:!1,kind:"OIDCClient"},ManagementV1OwnedAccessKey:{group:"management.loft.sh",version:"v1",resource:"ownedaccesskeys",subResource:"",namespaced:!1,kind:"OwnedAccessKey"},ManagementV1Project:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"",namespaced:!1,kind:"Project"},ManagementV1ProjectChartInfo:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"chartinfo",namespaced:!1,kind:"ProjectChartInfo"},ManagementV1ProjectCharts:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"charts",namespaced:!1,kind:"ProjectCharts"},ManagementV1ProjectClusters:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"clusters",namespaced:!1,kind:"ProjectClusters"},ManagementV1ProjectImportSpace:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"importspace",namespaced:!1,kind:"ProjectImportSpace"},ManagementV1ProjectMembers:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"members",namespaced:!1,kind:"ProjectMembers"},ManagementV1ProjectMigrateSpaceInstance:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"migratespaceinstance",namespaced:!1,kind:"ProjectMigrateSpaceInstance"},ManagementV1ProjectMigrateVirtualClusterInstance:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"migratevirtualclusterinstance",namespaced:!1,kind:"ProjectMigrateVirtualClusterInstance"},ManagementV1ProjectRunners:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"runners",namespaced:!1,kind:"ProjectRunners"},ManagementV1ProjectSecret:{group:"management.loft.sh",version:"v1",resource:"projectsecrets",subResource:"",namespaced:!0,kind:"ProjectSecret"},ManagementV1ProjectTemplates:{group:"management.loft.sh",version:"v1",resource:"projects",subResource:"templates",namespaced:!1,kind:"ProjectTemplates"},ManagementV1RedirectToken:{group:"management.loft.sh",version:"v1",resource:"redirecttokens",subResource:"",namespaced:!1,kind:"RedirectToken"},ManagementV1RegisterVirtualCluster:{group:"management.loft.sh",version:"v1",resource:"registervirtualclusters",subResource:"",namespaced:!1,kind:"RegisterVirtualCluster"},ManagementV1ResetAccessKey:{group:"management.loft.sh",version:"v1",resource:"resetaccesskeys",subResource:"",namespaced:!1,kind:"ResetAccessKey"},ManagementV1Runner:{group:"management.loft.sh",version:"v1",resource:"runners",subResource:"",namespaced:!1,kind:"Runner"},ManagementV1RunnerAccessKey:{group:"management.loft.sh",version:"v1",resource:"runners",subResource:"accesskey",namespaced:!1,kind:"RunnerAccessKey"},ManagementV1RunnerConfig:{group:"management.loft.sh",version:"v1",resource:"runners",subResource:"config",namespaced:!1,kind:"RunnerConfig"},ManagementV1Self:{group:"management.loft.sh",version:"v1",resource:"selves",subResource:"",namespaced:!1,kind:"Self"},ManagementV1SelfSubjectAccessReview:{group:"management.loft.sh",version:"v1",resource:"selfsubjectaccessreviews",subResource:"",namespaced:!1,kind:"SelfSubjectAccessReview"},ManagementV1SharedSecret:{group:"management.loft.sh",version:"v1",resource:"sharedsecrets",subResource:"",namespaced:!0,kind:"SharedSecret"},ManagementV1SpaceInstance:{group:"management.loft.sh",version:"v1",resource:"spaceinstances",subResource:"",namespaced:!0,kind:"SpaceInstance"},ManagementV1SpaceTemplate:{group:"management.loft.sh",version:"v1",resource:"spacetemplates",subResource:"",namespaced:!1,kind:"SpaceTemplate"},ManagementV1SubjectAccessReview:{group:"management.loft.sh",version:"v1",resource:"subjectaccessreviews",subResource:"",namespaced:!1,kind:"SubjectAccessReview"},ManagementV1Task:{group:"management.loft.sh",version:"v1",resource:"tasks",subResource:"",namespaced:!1,kind:"Task"},ManagementV1TaskLog:{group:"management.loft.sh",version:"v1",resource:"tasks",subResource:"log",namespaced:!1,kind:"TaskLog"},ManagementV1Team:{group:"management.loft.sh",version:"v1",resource:"teams",subResource:"",namespaced:!1,kind:"Team"},ManagementV1TeamAccessKeys:{group:"management.loft.sh",version:"v1",resource:"teams",subResource:"accesskeys",namespaced:!1,kind:"TeamAccessKeys"},ManagementV1TeamClusters:{group:"management.loft.sh",version:"v1",resource:"teams",subResource:"clusters",namespaced:!1,kind:"TeamClusters"},ManagementV1TranslateVClusterResourceName:{group:"management.loft.sh",version:"v1",resource:"translatevclusterresourcenames",subResource:"",namespaced:!1,kind:"TranslateVClusterResourceName"},ManagementV1User:{group:"management.loft.sh",version:"v1",resource:"users",subResource:"",namespaced:!1,kind:"User"},ManagementV1UserAccessKeys:{group:"management.loft.sh",version:"v1",resource:"users",subResource:"accesskeys",namespaced:!1,kind:"UserAccessKeys"},ManagementV1UserClusters:{group:"management.loft.sh",version:"v1",resource:"users",subResource:"clusters",namespaced:!1,kind:"UserClusters"},ManagementV1UserPermissions:{group:"management.loft.sh",version:"v1",resource:"users",subResource:"permissions",namespaced:!1,kind:"UserPermissions"},ManagementV1UserProfile:{group:"management.loft.sh",version:"v1",resource:"users",subResource:"profile",namespaced:!1,kind:"UserProfile"},ManagementV1VirtualClusterAccessKey:{group:"management.loft.sh",version:"v1",resource:"virtualclusterinstances",subResource:"accesskey",namespaced:!0,kind:"VirtualClusterAccessKey"},ManagementV1VirtualClusterExternalDatabase:{group:"management.loft.sh",version:"v1",resource:"virtualclusterinstances",subResource:"externaldatabase",namespaced:!0,kind:"VirtualClusterExternalDatabase"},ManagementV1VirtualClusterInstance:{group:"management.loft.sh",version:"v1",resource:"virtualclusterinstances",subResource:"",namespaced:!0,kind:"VirtualClusterInstance"},ManagementV1VirtualClusterInstanceKubeConfig:{group:"management.loft.sh",version:"v1",resource:"virtualclusterinstances",subResource:"kubeconfig",namespaced:!0,kind:"VirtualClusterInstanceKubeConfig"},ManagementV1VirtualClusterInstanceLog:{group:"management.loft.sh",version:"v1",resource:"virtualclusterinstances",subResource:"log",namespaced:!0,kind:"VirtualClusterInstanceLog"},ManagementV1VirtualClusterTemplate:{group:"management.loft.sh",version:"v1",resource:"virtualclustertemplates",subResource:"",namespaced:!1,kind:"VirtualClusterTemplate"}};var N="virtualcluster.loft.sh",q="v1",fe="virtualcluster.loft.sh/v1",k="cluster.loft.sh",y="v1",he="cluster.loft.sh/v1",Re="management.loft.sh",F="v1",ve="management.loft.sh/v1",Me="storage.loft.sh",be="v1",Ce="storage.loft.sh/v1",W="apiextensions.k8s.io",B="v1",ke="apiextensions.k8s.io/v1",U=class{};var c={...Q,ClusterV1SleepModeConfig:{group:k,version:y,resource:"sleepmodeconfigs",kind:"SleepModeConfig",namespaced:!0},ClusterV1HelmRelease:{group:k,version:y,resource:"helmreleases",kind:"HelmRelease",namespaced:!0},ClusterV1ChartInfo:{group:k,version:y,resource:"chartinfos",kind:"ChartInfo"},VirtualclusterV1HelmRelease:{group:N,version:q,resource:"helmreleases",kind:"HelmRelease",namespaced:!0},CustomResourceDefinition:{group:W,version:B,resource:"customresourcedefinitions",kind:"CustomResourceDefinition"},StorageV1ClusterQuota:{group:"storage.loft.sh",version:F,resource:"clusterquotas",kind:"ClusterQuota"},NetworkingV1Ingress:{group:"networking.k8s.io",version:"v1",resource:"ingresses",kind:"Ingress",namespaced:!0},V1StatefulSet:{group:"apps",version:"v1",resource:"statefulsets",kind:"StatefulSet",namespaced:!0},V1Deployment:{group:"apps",version:"v1",resource:"deployments",kind:"Deployment",namespaced:!0},V1Event:{group:"",version:"v1",resource:"events",kind:"Event",namespaced:!0},V1Pod:{group:"",version:"v1",resource:"pods",kind:"Pod",namespaced:!0},V1Node:{group:"",version:"v1",resource:"nodes",kind:"Node"},V1Namespace:{group:"",version:"v1",resource:"namespaces",kind:"Namespace"},V1SelfSubjectAccessReview:{group:"authorization.k8s.io",version:"v1",resource:"selfsubjectaccessreviews",kind:"SelfSubjectAccessReview"},V1ClusterRole:{group:"rbac.authorization.k8s.io",version:"v1",resource:"clusterroles",kind:"ClusterRole"},V1ClusterRoleBinding:{group:"rbac.authorization.k8s.io",version:"v1",resource:"clusterrolebindings",kind:"ClusterRoleBinding"},V1Role:{group:"rbac.authorization.k8s.io",version:"v1",resource:"roles",kind:"Role",namespaced:!0},V1RoleBinding:{group:"rbac.authorization.k8s.io",version:"v1",resource:"rolebindings",kind:"RoleBinding",namespaced:!0},V1Secret:{group:"",version:"v1",resource:"secrets",kind:"Secret",namespaced:!0},V1ConfigMap:{group:"",version:"v1",resource:"configmaps",kind:"ConfigMap",namespaced:!0},V1Service:{group:"",version:"v1",resource:"services",kind:"Service",namespaced:!0},V1User:{group:"",version:"v1",resource:"users",kind:"User",namespaced:!1},V1StorageClassList:{group:"storage.k8s.io",version:"v1",resource:"storageclasses",kind:"StorageClass",namespaced:!1},V1Beta1PodMetrics:{group:"metrics.k8s.io",version:"v1beta1",resource:"pods",kind:"PodMetrics",namespaced:!0}};function d(o,e,s){return{apiVersion:o.group?o.group+"/"+o.version:o.version,kind:o.kind,metadata:{name:e},...s}}var P=class{constructor(e,s=void 0){this.val=e;this.extra=s;this.ok=!1;this.err=!0}},S=class{constructor(e,s=void 0){this.val=e;this.extra=s;this.ok=!0;this.err=!1}};function ye(o){return"ok"in o&&typeof o.ok=="boolean"&&"err"in o&&typeof o.err=="boolean"}var x="",O="Network",X="Forbidden",Y="BadRequest",L="NotFound",T="Unauthorized",Z="AlreadyExists",ee="InternalServerError",se="NotImplemented",re="BadGateway",w="ServiceUnavailable",te="GatewayTimeout",R=o=>{switch(o){case 400:return Y;case 401:return T;case 403:return X;case 404:return L;case 409:return Z;case 500:return ee;case 501:return se;case 502:return re;case 503:return w;case 504:return te}return x},a=class{static Ok(){return new S(void 0)}static Value(e){return new S(e)}static Failed(e,s="",r=x,t=void 0){return new P(new E(e,r,s),t)}static Error(e){return new P(e)}static WithExtra(e,s=void 0){return e.extra=s,e}},E=class{constructor(e,s=x,r=""){this.message=e;this.type=s;this.reason=r}};var A={secure:!0,expires:365*10,sameSite:"strict"},V=b.loftAccessKeyIdentifier,v=b.loftImpersonateSubjectIdentifier,I=b.loftImpersonateJoinedGroupIdentifier,Pe=["v4.channel.k8s.io","v3.channel.k8s.io","v2.channel.k8s.io","channel.k8s.io"];function ie(){return typeof window<"u"&&window.location.href.startsWith("http://localhost:3000")?"https://localhost:9898":""}function Se(){return typeof window>"u"||window.location.host==="localhost:3000"?"wss://localhost:8080":`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}`}function ne(o){return[o.virtualCluster?"loft:vcluster:main":`loft:space:${o.project}:${o.space}`]}var H="/kubernetes/management",j="/kubernetes/cluster/",$="/kubernetes/virtualcluster/",J="/kubernetes/project/";function Te(o,e){return o?e&&e.endsWith("-")?`${e}${o}`:e===""?`${o}`:e?`${e}-${o}`:`p-${o}`:"p-"}function we(o,e){if(o)return e?e.endsWith("-")?o.replace(new RegExp(`^${e}`),""):o.replace(new RegExp(`^${e}-`),""):o.replace(/^p-/,"")}var C=class{constructor(e,s,r){this.apiHost="";this.wsHost="";this.accessKey="";this.managementNonResource=()=>new l(this,{basePath:H,headers:this.impersonationHeaders()});this.cluster=(e,s)=>new l(this,{basePath:j+e,groupVersionResource:s,headers:this.impersonationHeaders()});this.clusterNonResource=e=>new l(this,{basePath:j+e,headers:this.impersonationHeaders()});this.project=(e,s)=>new l(this,{basePath:J+e.project+"/"+(e.space?"space/"+e.space:"virtualcluster/"+e.virtualCluster),groupVersionResource:s,project:e,headers:this.impersonationHeaders(ne(e))});this.projectNonResource=e=>new l(this,{basePath:J+e.project+"/"+(e.space?"space/"+e.space:"virtualcluster/"+e.virtualCluster),project:e,headers:this.impersonationHeaders(ne(e))});this.apiHost=s||ie(),this.wsHost=r||Se(),this.accessKey=e||C.getAccessKey()}static getAccessKey(){return localStorage.getItem(V)}static tryCastToStatus(e){if(e.kind){if(e.kind!=="Status"||e.apiVersion!=="v1")return a.Value(null)}else return a.Value(null);return a.Value(e)}async getUser(){let e=await this.management(c.ManagementV1Self).Create(d(c.ManagementV1Self));return e.err?e:e.val.status?.user?(typeof window<"u"&&(window.loft||(window.loft={}),window.loft.instanceID=e.val.status.instanceID,window.loft.chatAuthToken=e.val.status.chatAuthToken,window.loft.user=e.val.status.user),a.Value(e.val.status.user.name)):a.Failed("no user found")}getAccessKey(){return this.accessKey}async loftVersion(e){try{let s=this.apiHost+"/version";e&&(s+="?refresh=true");let t=await(await fetch(s)).json();return a.Value(t)}catch(s){return console.error(s),a.Failed("error during version retrieval")}}impersonatedUser(){try{let e=localStorage.getItem(v);if(e)return JSON.parse(e)}catch(e){console.error(e)}}impersonate(e,s,r){s?(localStorage.setItem(v,JSON.stringify({name:e,subject:s,groups:r})),s&&m.default.set(v,s,A),r?.forEach(t=>{let n=m.default.get(I);n?(n+=", "+t,m.default.set(I,n,A)):m.default.set(I,t,A)})):(localStorage.removeItem(v),m.default.remove(v),m.default.remove(I))}async login(e,s){let r=await this.request("/auth/password/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:s})});if(r.err)return r;let t=r.val;return this.setAccessKey(t.accessKey),a.Ok()}async loginWithAccessKey(e){this.isLoggedIn()&&await this.logout(),this.accessKey=e;let s=await this.management(c.ManagementV1Self).Create(d(c.ManagementV1Self));return s.err?(this.clearStorage(),s):(this.setAccessKey(e),a.Ok())}isLoggedIn(){return!!this.accessKey}setAccessKey(e){this.accessKey=e,localStorage.setItem(V,e),m.default.set(V,e,A)}async stream(e,s){try{let r=await fetch(this.apiHost+e,s);return r.status>=400||!r.body?await this.parseResponse(e,r):a.Value(r.body.getReader())}catch(r){return a.Failed(r+"","NetworkError",O)}}async request(e,s){try{let r=await fetch(this.apiHost+e,{...s,credentials:"same-origin"});if(!r.ok){let n=await r.clone().text();if(r.status===401)try{let i=JSON.parse(n);if(i?.message===b.platformAccessKeyNotFound)return window.location.href=`/login?error=${i?.message}&errorType=${i?.reason}`,a.Failed(i.message||"Unauthorized",i.reason,T)}catch{}}return await this.parseResponse(e,r)}catch(r){let t=r;return t.message===b.platformAccessKeyNotFound&&(window.location.href=`/login?error=${t.message}&errorType=${t.reason}`),a.Failed(r+"","NetworkError",O)}}async socket(e,s){return this.refreshCookie(),new Promise((r,t)=>{let n=new WebSocket(`${this.wsHost}${e}`,s),i=!1;n.onopen=()=>{i=!0,r(n)},n.onerror=u=>{if(!i){let p=m.default.get(V)!="";t(p?u:new Error("Web socket is not authenticated. Please log in again"))}}})}async parseResponse(e,s){let r=await s.text(),t;try{t=JSON.parse(r)}catch{if(s.status===404)return a.Failed("page not found","NotFound",L);if(s.status===503){if(e.includes("kiosk.sh")||e.includes("cluster.loft.sh")){let u=e.split("/");return u.length>=4&&u[0]===""&&u[1]==="kubernetes"&&u[2]==="cluster"?a.Failed(`Agent seems to be currently unavailable, it is maybe just starting up. Click here for more information`,"LoftAgentUnavailable",w):a.Failed("Agent seems to be currently unavailable, it is maybe just starting up","LoftAgentUnavailable",w)}}else if(s.status===200)return a.Value(r);return console.info("Unexpected Server Response",r),a.Failed("Unexpected server response",R(s.status),R(s.status))}let n=C.tryCastToStatus(t);return n.err?n:n.val!==null&&n.val.status==="Failure"?n.val.code===500&&(n.val.message?.indexOf("vcluster secret not found")!==-1||n.val.message.indexOf("no ready pod for virtual cluster")!==-1)?a.Failed("vcluster seems to be not ready. Please refresh in a second",n.val.reason,R(n.val.code)):a.Failed(n.val.message,n.val.reason,R(n.val.code)):s.status>=400?a.Failed("unknown error","Unknown",R(s.status)):a.Value(t)}management(e){return new l(this,{basePath:H,groupVersionResource:e,headers:this.impersonationHeaders()})}vCluster(e,s){return new l(this,{basePath:$+e.cluster+"/"+e.namespace+"/"+e.name,groupVersionResource:s,vCluster:e,headers:this.impersonationHeaders()})}vClusterNonResource(e){return new l(this,{basePath:$+e.cluster+"/"+e.namespace+"/"+e.name,vCluster:e,headers:this.impersonationHeaders()})}auto(e,s,r,t){return r?this.project(r,t):s?this.vCluster(s,t):e?this.cluster(e,t):this.management(t)}autoNonResource(e,s,r){return r?this.projectNonResource(r):s?this.vClusterNonResource(s):e?this.clusterNonResource(e):this.managementNonResource()}async doRawSocket(e,s){try{return a.Value(await this.socket(e,s))}catch(r){return console.error(r),a.Failed(r.message||JSON.stringify(r))}}async doRawStream(e,s,r){return this.doRawInternal(e,s,r,!0)}async doRaw(e,s,r){return this.doRawInternal(e,s,r)}async doRawInternal(e,s,r,t){let n=this.accessKey,i=n?new Headers({...r,Authorization:"bearer "+n,"X-Sleep-Mode-Ignore":"true","X-Platform-Client":"true"}):new Headers({...r,"X-Sleep-Mode-Ignore":"true","X-Platform-Client":"true"}),u=t?await this.stream(e,{...s,headers:i}):await this.request(e,{...s,headers:i});return u.err&&u.val.type===T&&(u.val.message==="Access key not found. Please login again"||u.val.message==="invalid bearer token")&&(this.clearStorage(),typeof window<"u"&&(window.location.href="/"),await new Promise(()=>{})),u}impersonationHeaders(e){let s=this.impersonatedUser(),r={};return s&&(s.subject&&(r["Impersonate-User"]=s.subject),[...h(s.groups),...h(e)].forEach(t=>{r["Impersonate-Joined-Group"]?r["Impersonate-Joined-Group"]+=", "+t:r["Impersonate-Joined-Group"]=t})),r}clearStorage(){this.accessKey=null,localStorage.removeItem(V),localStorage.removeItem(v),m.default.remove(V,{secure:!0}),m.default.remove(v,{secure:!0}),m.default.remove(I,{secure:!0})}refreshCookie(){let e=this.accessKey||localStorage.getItem(V),s=m.default.get(V);e&&e!=s&&m.default.set(V,e,A)}async logout(){let e=await this.management(c.ManagementV1Self).Create(d(c.ManagementV1Self));if(e.err)return this.clearStorage(),e;if(!e.val.status?.accessKey)return this.clearStorage(),a.Ok();let s=await this.management(c.ManagementV1OwnedAccessKey).Delete(e.val.status.accessKey);return s.err?(this.clearStorage(),s):(this.clearStorage(),a.Ok())}},l=class{constructor(e,s){this.client=e,this.options=s}Name(e){return new l(this.client,{...this.options,name:e})}Namespace(e){return e?new l(this.client,{...this.options,namespace:e}):new l(this.client,{...this.options})}Resource(e){return new l(this.client,{...this.options,groupVersionResource:e})}buildPath(e){if(this.options.groupVersionResource)if(this.options.basePath){if(!this.options.name&&this.options.groupVersionResource.subResource)return a.Failed("resource name required when subresource is used")}else return a.Failed("basePath is missing");else return a.Failed("groupVersionResource is missing");let s=[this.options.basePath];this.options.groupVersionResource.group?s.push("apis",this.options.groupVersionResource.group):s.push("api"),s.push(this.options.groupVersionResource.version),this.options.namespace&&s.push("namespaces",this.options.namespace),s.push(this.options.groupVersionResource.resource),this.options.name&&s.push(this.options.name),this.options.groupVersionResource.subResource&&s.push(this.options.groupVersionResource.subResource);let r="";if(e){let t=[];for(let n of Object.keys(e))e[n]&&(Array.isArray(e[n])?e[n].forEach(i=>{t.push(n+"="+encodeURIComponent(i))}):t.push(n+"="+encodeURIComponent(e[n])));t.length>0&&(r="?"+t.join("&"))}else r="?timeout=180s";return a.Value(s.join("/")+r)}parseResourceList(e,s,r,t,n,i){for(let u=0;u1||n&&t.find(M=>M.group===e&&M.resource===f)||t.push({resource:f,subResource:g.length>1?g[1]:void 0,group:e,version:s,kind:p.kind,namespaced:p.namespaced,verbs:p.verbs})}}async ApiResources(e,s){let r=[],t=await this.client.doRaw([this.options.basePath,"api"].join("/"));if(t.err)return t;let n=[];for(let u=0;u{let g=t.val.versions[p];if(g===void 0)return;let f=await this.client.doRaw([this.options.basePath,"api",g].join("/"));if(f.err){console.error(f.val.message);return}this.parseResourceList("",g,f.val,r,e,s)})(u)),n.length>20&&(await Promise.all(n),n=[]);n.length>0&&(await Promise.all(n),n=[]);let i=await this.client.doRaw([this.options.basePath,"apis"].join("/"));if(i.err)return i;for(let u=0;u{let D=M.versions[f];if(D===void 0)return;let K=await this.client.doRaw([this.options.basePath,"apis",M.name,D.version].join("/"));if(K.err){console.error(K.val.message);return}this.parseResourceList(M.name,D.version,K.val,r,e,s)})(g,p)),n.length>20&&(await Promise.all(n),n=[])}return n.length>0&&await Promise.all(n),a.Value(r)}async Version(){let e=[this.options.basePath,"version"];return await this.client.doRaw(e.join("/"))}async VirtualClusterInstanceLogs(e,s,r){let t=[this.options.basePath,`apis/management.loft.sh/v1/namespaces/${e}/virtualclusterinstances/${s}/log`].join("/"),n=[];if(r)for(let i of Object.keys(r))n.push(`${i}=${encodeURIComponent(r[i])}`);return n.length>0&&(t+="?"+n.join("&")),await this.client.doRawStream(t,void 0,this.options.headers)}async TaskLogs(e,s){let r=[this.options.basePath,`apis/management.loft.sh/v1/tasks/${e}/log`].join("/"),t=[];if(s)for(let n of Object.keys(s))t.push(`${n}=${encodeURIComponent(s[n])}`);return t.length>0&&(r+="?"+t.join("&")),await this.client.doRawStream(r,void 0,this.options.headers)}async Logs(e,s,r){let t=[this.options.basePath,`api/v1/namespaces/${e}/pods/${s}/log`].join("/"),n=oe(r);return n.length>0&&(t+="?"+n),await this.client.doRawStream(t,void 0,this.options.headers)}async Exec(e,s,r){let t=[this.options.basePath,`api/v1/namespaces/${e}/pods/${s}/exec`].join("/"),n=oe(r);return n.length>0&&(t+="?"+n),await this.client.doRawSocket(t,Pe)}async Path(e,s,r){let t=[this.options.basePath,e];return await this.client.doRaw(t.join("/"),s,{...r,...this.options.headers})}ResolvePath(e){return e&&(this.options.name=e),this.buildPath()}async Get(e,s){this.options.name=e;let r=this.buildPath(s);return r.err?r:a.WithExtra(await this.client.doRaw(r.val,void 0,this.options.headers),this.options)}async List(e){if(this.options.name)return a.Failed("name is set on a list request");let s=this.buildPath(e);return s.err?s:a.WithExtra(await this.client.doRaw(s.val,void 0,this.options.headers),this.options)}async ListTable(e){if(this.options.name)return a.Failed("name is set on a list request");let s=this.buildPath(e);return s.err?s:a.WithExtra(await this.client.doRaw(s.val,void 0,{...this.options.headers,Accept:"application/json;as=Table;v=v1;g=meta.k8s.io,application/json;as=Table;v=v1beta1;g=meta.k8s.io,application/json"}),this.options)}async Create(e,s){let r=this.buildPath(s);return r.err?r:a.WithExtra(await this.client.doRaw(r.val,{method:"POST",body:JSON.stringify(e)},{...this.options.headers,"Content-Type":"application/json"}),this.options)}async PatchObject(e,s,r,t){let n=ae.default.generate(e,s);return this.Patch(s.metadata?.name,n,r,t)}async Patch(e,s,r,t){this.options.name=e;let n=this.buildPath(t);return n.err?n:a.WithExtra(await this.client.doRaw(n.val,{method:"PATCH",body:JSON.stringify(s,function(i,u){return u===void 0?null:u})},{...this.options.headers,"Content-Type":r||"application/merge-patch+json"}),this.options)}async Update(e,s,r){this.options.name=e;let t=this.buildPath(r);return t.err?t:a.WithExtra(await this.client.doRaw(t.val,{method:"PUT",body:JSON.stringify(s)},{...this.options.headers,"Content-Type":"application/json"}),this.options)}async Delete(e,s){this.options.name=e;let r=this.buildPath(s);return r.err?r:a.WithExtra(await this.client.doRaw(r.val,{method:"DELETE"},this.options.headers),this.options)}async CanI(e){let s=this.options.groupVersionResource,r=this.options.basePath?.indexOf(j)===0?this.options.basePath.substring(j.length):void 0,t,n;this.options.project?(t=this.client.project(this.options.project,c.V1SelfSubjectAccessReview),n=d(c.V1SelfSubjectAccessReview)):this.options.vCluster?(t=this.client.vCluster(this.options.vCluster,c.V1SelfSubjectAccessReview),n=d(c.V1SelfSubjectAccessReview)):r?(t=this.client.cluster(r,c.V1SelfSubjectAccessReview),n=d(c.V1SelfSubjectAccessReview)):(t=this.client.management(c.ManagementV1SelfSubjectAccessReview),n=d(c.ManagementV1SelfSubjectAccessReview)),n.spec={resourceAttributes:{verb:e,name:this.options.name,namespace:this.options.namespace,group:s.group,version:s.version,resource:s.resource,subresource:s.subResource}};let i=await t.Create(n);return i.err?i:a.Value(!!(i.val.status?.allowed&&!i.val.status.denied))}};function oe(o){let e=new URLSearchParams;for(let[s,r]of Object.entries(o))Array.isArray(r)?r.forEach(t=>{e.append(s,t)}):e.append(s,r);return e.toString()}var ue=C;0&&(module.exports={APIExtensionsGroup,APIExtensionsGroupVersion,APIExtensionsVersion,Client,ClusterBasePath,Err,ErrorTypeAlreadyExists,ErrorTypeBadGateway,ErrorTypeBadRequest,ErrorTypeForbidden,ErrorTypeGatewayTimeout,ErrorTypeInternalError,ErrorTypeNetwork,ErrorTypeNotFound,ErrorTypeNotImplemented,ErrorTypeServiceUnavailable,ErrorTypeUnauthorized,ErrorTypeUnknown,Failed,List,LoftSchemeGroup,LoftSchemeGroupCluster,LoftSchemeGroupStorage,LoftSchemeGroupVersion,LoftSchemeGroupVersionCluster,LoftSchemeGroupVersionStorage,LoftSchemeGroupVersionVirtualCluster,LoftSchemeGroupVirtualCluster,LoftSchemeVersion,LoftSchemeVersionCluster,LoftSchemeVersionStorage,LoftSchemeVersionVirtualCluster,ManagementBasePath,MapErrorCode,NewResource,Ok,ProjectBasePath,Resources,Return,VClusterBasePath,getApiHost,getProjectFromNamespace,getProjectNamespace,isResult}); diff --git a/package.json b/package.json index 68c2b6b..77758ab 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ }, "description": "loft-enterprise js client", "dependencies": { - "@kubernetes/client-node": "0.20.0", + "@kubernetes/client-node": "0.22.1", "js-cookie": "3.0.1", "json-merge-patch": "1.0.2" },