File
|
labels
|
labels: literal type
|
Type : literal type
|
|
Optional
|
|
sourceContexts
|
sourceContexts: Array<literal type>
|
Type : Array<literal type>
|
|
Optional
|
import is from '@sindresorhus/is';
import {PackageInfo} from './client/stackdriver/debug';
import {StatusMessage} from './client/stackdriver/status-message';
// TODO: Determine how to get this interface to satisfy both the code and the
// docs
// In particular, the comments below state some of the properties are
// required but the default properties in the code is {}
export interface DebuggeeProperties {
project?: string;
uniquifier?: string;
description?: string;
agentVersion: string;
labels?: {
[key: string]: string;
};
sourceContexts?: Array<{[key: string]: {}}>;
statusMessage?: StatusMessage;
packageInfo?: PackageInfo;
}
export class Debuggee {
uniquifier?: string;
description?: string;
agentVersion?: string;
sourceContexts?: Array<{[key: string]: {}}>;
// Public to allow for testing
project?: string;
labels?: {
[key: string]: string;
};
statusMessage?: StatusMessage;
id!: string;
// TODO: This doesn't seem to ever be set but is referenced in the
// debuglet.ts file.
isDisabled?: boolean;
isInactive?: boolean;
/**
* Creates a Debuggee service object.
* @ref https://cloud.google.com/debugger/api/reference/rest/v2/Debuggee
*
* @param {object} properties - an object with properties to use for Debuggee
* initialization.
* @param {object} properties.project - Google Cloud Project ID
* @param {string} properties.uniquifier - Debuggee uniquifier within the
* project. Any string that identifies the application within the project
* can be used. Including environment and version or build IDs is
* recommended.
* @param {string} properties.description - A user specified string identifying
* this debuggable instance.
* @param {?string} properties.agentVersion - version ID of the agent. (default:
* the version of this module)
* @param {?object} labels - a set of custom properties about the debuggee that
* are reported to the service.
* @param {?array<object>} properties.sourceContexts
* @param {?StatusMessage} properties.statusMessage - A error string to register
* this as an erroring debuggable instance. This is useful if we have a
* problem starting the debugger support, and want to report to the API so
* that the user has a way of noticing.
* TODO(ofrobots): has this been renamed to `status` in the API?
*/
constructor(properties: DebuggeeProperties) {
if (!(this instanceof Debuggee)) {
return new Debuggee(properties);
}
properties = properties || {};
if (!is.string(properties.project)) {
throw new Error('properties.project must be a string');
}
if (!is.string(properties.uniquifier)) {
throw new Error('properties.uniquifier must be a string');
}
if (!is.string(properties.description)) {
throw new Error('properties.description must be a string');
}
this.project = properties.project;
this.uniquifier = properties.uniquifier;
this.description = properties.description;
this.agentVersion = properties.agentVersion;
if (properties.labels) {
this.labels = properties.labels;
}
if (properties.sourceContexts) {
this.sourceContexts = properties.sourceContexts;
}
if (properties.statusMessage) {
this.statusMessage = properties.statusMessage;
}
}
}