@c8y/ngx-components
Version:
Angular modules for Cumulocity IoT applications
124 lines (120 loc) • 5.03 kB
TypeScript
import { CanActivateFn } from '@angular/router';
import { FetchClient, IManagedObject } from '@c8y/client';
import { ServiceRegistry } from '@c8y/ngx-components';
import { Observable } from 'rxjs';
import { SupportedIcons } from '@c8y/ngx-components/icon-selector/icons';
import * as i0 from '@angular/core';
interface RemoteAccessProtocolProvider {
readonly protocolName: string;
readonly protocolLabel: string;
readonly protocolDescription?: string;
readonly protocolIcon: SupportedIcons;
addEndpoint?(deviceId: string): Promise<RemoteAccessConfiguration>;
removeEndpoint(deviceId: string, currentEndpointConfig: RemoteAccessConfiguration): Promise<void>;
editEndpoint?(deviceId: string, currentEndpointConfig: RemoteAccessConfiguration): Promise<RemoteAccessConfiguration>;
connectEndpointHref?(deviceId: string, configuration: RemoteAccessConfiguration): Promise<string | null>;
getDefaultEndpointConfiguration?(): Promise<Partial<RemoteAccessConfiguration>>;
}
declare global {
namespace CumulocityServiceRegistry {
interface SpecificExtensionKeys {
remoteAccessProtocolHook: RemoteAccessProtocolProvider;
}
}
}
interface RemoteAccessConfiguration {
id: string;
name: string;
hostname: string;
port: number;
protocol: string;
attrs?: any;
credentials?: any;
credentialsType?: string;
}
declare const CREDENTIALS_TYPES: {
readonly NONE: {
readonly name: "NONE";
readonly value: "NONE";
readonly label: "No password";
};
readonly USER_PASS: {
readonly name: "USER_PASS";
readonly value: "USER_PASS";
readonly label: "Username and password";
};
readonly PASS_ONLY: {
readonly name: "PASS_ONLY";
readonly value: "PASS_ONLY";
readonly label: "Password only";
};
readonly KEY_PAIR: {
readonly name: "KEY_PAIR";
readonly value: "KEY_PAIR";
readonly label: "Public/private keys";
};
readonly CERTIFICATE: {
readonly name: "CERTIFICATE";
readonly value: "CERTIFICATE";
readonly label: "Certificate";
};
};
declare const canActivateRemoteAccess: CanActivateFn;
declare class RemoteAccessService {
private fetchClient;
private serviceRegistry;
private cachedIsAvailable$;
readonly baseUrl = "/service/remoteaccess";
constructor(fetchClient: FetchClient, serviceRegistry: ServiceRegistry);
/**
* Verifies if the remote access service is available by sending a HEAD request to is's health endpoint.
* @returns cached Observable that emits true if the service is available, false otherwise.
*/
isAvailable$(): Observable<boolean>;
/**
* misses the leading ? for the query params
*/
getAuthQueryParamsForWebsocketConnection(): string;
/**
* Returns the URI for the websocket connection to the remote access service.
*/
getWebSocketUri<K extends string, I extends string>(deviceId: K, configurationId: I): `ws://${string}/service/remoteaccess/client/${K}/configurations/${I}` | `wss://${string}/service/remoteaccess/client/${K}/configurations/${I}` | `ws://${string}/service/remoteaccess/client/${K}/configurations/${I}?${string}` | `wss://${string}/service/remoteaccess/client/${K}/configurations/${I}?${string}`;
/**
* Retrieves all configurations for a given device.
*/
listConfigurations(deviceId: string): Promise<RemoteAccessConfiguration[]>;
/**
* Deletes a configuration for a given device.
*/
deleteConfiguration(deviceId: string, configurationId: string): Promise<void>;
/**
* Retrieves all available remote access protocol providers.
*/
getProtocolProviders(): RemoteAccessProtocolProvider[];
/**
* Retrieves all supported protocol providers for a given device.
* Based on the declarations in the fragment c8y_RemoteAccessSupportedProtocols of the device managed object.
*/
getSupportedProtocolProvidersFor(device: IManagedObject): RemoteAccessProtocolProvider[];
/**
* Creates a new configuration for a given device.
*/
addConfiguration(deviceId: string, configuration: Omit<RemoteAccessConfiguration, 'id'>): Promise<RemoteAccessConfiguration>;
/**
* Updates a configuration for a given device.
*/
updateConfiguration(deviceId: string, configuration: RemoteAccessConfiguration): Promise<RemoteAccessConfiguration>;
/**
* Generates a SSH key pair for a given hostname.
*/
generateKeyPair(hostname: string): Promise<{
publicKey: string;
privateKey: string;
}>;
private healthEndpointAvailable;
static ɵfac: i0.ɵɵFactoryDeclaration<RemoteAccessService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<RemoteAccessService>;
}
export { CREDENTIALS_TYPES, RemoteAccessService, canActivateRemoteAccess };
export type { RemoteAccessConfiguration, RemoteAccessProtocolProvider };
//# sourceMappingURL=index.d.ts.map