pulumi/lib/lumi/resource.ts
joeduffy ff0eb81944 Export urnName constants
This avoids us needing to hard-code the urnName property in
various tools, in case we ever need to change it again down the road.
2017-08-05 08:32:50 -07:00

29 lines
1.2 KiB
TypeScript

// Copyright 2016-2017, Pulumi Corporation. All rights reserved.
export type ID = string;
export type URN = string;
// Resource represents a class whose CRUD operations are implemented by a provider plugin.
export abstract class Resource {
// id is the provider-assigned unique ID for this object. It is set during deployments.
public readonly id: ID;
// urn is the logical URN used to distinctly address an object, both before and after deployments. It is
// auto-generated by the system, however the urnName property (below) is used to programmatically control it.
public readonly urn: URN;
}
// NamedResource is a kind of resource that has a friendly resource name associated with it.
export abstract class NamedResource extends Resource {
// urnName is the logical name used to create a globally unique URN for an object. It is mixed with the resource's
// type, parent module, target deployment environment, and other information to help ensure that it is unique.
public readonly urnName: string;
constructor(urnName: string) {
super();
if (urnName === undefined || urnName === "") {
throw new Error("Named resources must have a name");
}
this.urnName = urnName;
}
}