@microsoft/windows-admin-center-sdk
Version:
Microsoft - Windows Admin Center Shell
258 lines (257 loc) • 7 kB
TypeScript
import { Observable } from 'rxjs';
import { AppContext } from './app-context';
/**
* Sharing file mode.
*/
export declare enum DeploymentShareMode {
/**
* Admin share.
*/
Admin = "adminshare",
/**
* User share.
*/
User = "usershare"
}
/**
* Download states.
*/
export declare enum DownloadState {
/**
* Download not started.
*/
NotStarted = "NotStarted",
/**
* Download is running.
*/
Running = "Running",
/**
* Download is cancelled.
*/
Cancelled = "Cancelled",
/**
* Download failed.
*/
Failed = "Failed",
/**
* Download completed.
*/
Completed = "Completed"
}
/**
* Result data of created deployment share.
*/
export interface DeploymentShareResult {
/**
* deployment share mode.
*/
mode: DeploymentShareMode;
/**
* Share name.
*/
name: string;
/**
* Created time (ISO time).
*/
createdTime: string;
}
/**
* Request data of download.
*/
export interface DownloadRequest {
/**
* URL to download.
*/
url: string;
/**
* Path to file to store.
*/
path: string;
/**
* Flag indicating if the file URL is trusted and signature validation can be skipped.
*/
trustedUrlOmitValidation?: boolean;
}
/**
* Result data of download.
*/
export interface DownloadResult {
/**
* Download identity.
*/
id: string;
/**
* Requested number of items.
*/
requested: number;
/**
* Remaining number of items.
*/
remaining: number;
/**
* Started time (ISO).
*/
startedTime: string;
}
/**
* Status data of download.
*/
export interface DownloadStatus {
/**
* Download identity.
*/
id: string;
/**
* Requested number of items.
*/
requested: number;
/**
* Remaining number of items.
*/
remaining: number;
/**
* Error number of items.
*/
errors: number;
/**
* Started time (ISO).
*/
startedTime: string;
/**
* Completed time (ISO).
*/
completedTime: string;
/**
* Last error message.
*/
lastError?: string;
/**
* Sharing mode.
*/
mode: DeploymentShareMode;
/**
* Name of network share.
*/
name: string;
/**
* State of the download.
*/
downloadState: DownloadState;
}
/**
* Status of file on the shared folder.
*/
export interface FileStatus {
/**
* Url of download source.
*/
url: string;
/**
* Timestamp when download completed (ISO).
*/
timestamp: string;
/**
* File path within the share folder.
*/
path: string;
}
/**
* Secure deployment share class.
*/
export declare class DeploymentShare {
private appContext;
private static deploymentShareUrl;
private static deploymentShareNameUrl;
private static deploymentShareDownloadUrl;
private static deploymentShareDownloadIdUrl;
private static deploymentShareDownloadCancelUrl;
private static deploymentShareStatusUrl;
private static deploymentShareFileUrl;
private static deploymentShareFilePathUrl;
private static deploymentCopyUrl;
/**
* Initializes a new instance of the DeploymentShare class.
*
* @param appContext the application context.
*/
constructor(appContext: AppContext);
/**
* Create a new deployment network share. (elevate the desktop gateway if required.)
*
* @param shareMode the sharing mode.
* @param shareName the name of share.
*/
createShare(shareMode: DeploymentShareMode, shareName: string): Observable<DeploymentShareResult>;
/**
* Delete the deployment network share. (elevate the desktop gateway if required.)
*
* @param shareMode the sharing mode.
* @param shareName the name of share.
*/
deleteShare(shareMode: DeploymentShareMode, shareName: string): Observable<void>;
/**
* List existing deployment network shares.
*
* @param shareMode the sharing mode.
*/
queryShares(shareMode: DeploymentShareMode): Observable<DeploymentShareResult[]>;
/**
* Download files from specified urls and store to the deployment network share folder.
*
* @param shareMode the sharing mode.
* @param shareName the name of share.
* @param request the request object.
* @param timeout the timeout for the download in milliseconds.
* @param cancelReady (Optional) the cancel ready callback. Retain the supplied ID to call cancelDownload().
* @param polling (Optional) the polling timer milliseconds (default is 2000, and minimum is 1000).
*/
downloadFiles(shareMode: DeploymentShareMode, shareName: string, request: DownloadRequest[], timeout?: number, cancelReady?: (id: string) => void, polling?: number): Observable<DownloadStatus>;
/**
* Cancel the download by ID.
*
* @param shareMode the sharing mode.
* @param shareName the name of share.
* @param id the identification of download call responded by cancelReady() call back.
*/
cancelDownload(shareMode: DeploymentShareMode, shareName: string, id: string): Observable<void>;
/**
* Query active downloads with filtering conditions.
*
* @param shareMode the sharing mode.
* @param shareName the name of share.
*/
queryDownloads(shareMode?: DeploymentShareMode, shareName?: string): Observable<DownloadStatus[]>;
/**
* Query files on the share.
*
* @param shareMode the sharing mode.
* @param shareName the name of share.
*/
queryFiles(shareMode: DeploymentShareMode, shareName: string): Observable<FileStatus[]>;
/**
* Delete a file or a directory on the share.
*
* @param shareMode the sharing mode.
* @param shareName the name of share.
* @param path the path to the file or the directory on the share.
*/
deleteItem(shareMode: DeploymentShareMode, shareName: string, path: string): Observable<void>;
/**
* Create a text/XML file in network share.
*
* @param shareMode the sharing mode.
* @param shareName the name of share.
* @param path the path to the file or the directory on the share.
* @param content the linese of content for the file to create.
*/
createTextFile(shareMode: DeploymentShareMode, shareName: string, path: string, content: string[]): Observable<void>;
/**
* Copy file or folder in network share.
* @param shareMode The share mode.
* @param shareName the name of the share.
* @param source The source path of the item to copy relative to the network share.
* @param destination The destination path of the item to copy relative to the network share.
*/
copyItem(shareMode: DeploymentShareMode, shareName: string, source: string, destination: string): Observable<void>;
private queryStatus;
}