-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathprivate-location.ts
More file actions
136 lines (120 loc) · 5.06 KB
/
private-location.ts
File metadata and controls
136 lines (120 loc) · 5.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import { Construct } from './construct'
import { InvalidPropertyValueDiagnostic } from './construct-diagnostics'
import { Diagnostics } from './diagnostics'
import { Session } from './project'
export type PrivateLocationIcon = 'alert' | 'arrow-down' | 'arrow-left' | 'arrow-right' | 'arrow-small-down'
| 'arrow-small-left' | 'arrow-small-right' | 'arrow-small-up' | 'arrow-up' | 'beaker' | 'bell' | 'bold'
| 'book' | 'bookmark' | 'briefcase' | 'broadcast' | 'browser' | 'bug' | 'calendar' | 'check' | 'checklist'
| 'chevron-down' | 'chevron-left' | 'chevron-right' | 'chevron-up' | 'circle-slash' | 'circuit-board' | 'clippy'
| 'clock' | 'cloud-download' | 'cloud-upload' | 'code' | 'comment' | 'comment-discussion' | 'credit-card'
| 'dash' | 'dashboard' | 'database' | 'desktop-download' | 'device-camera' | 'device-camera-video'
| 'device-desktop' | 'device-mobile' | 'diff' | 'diff-added' | 'diff-ignored' | 'diff-modified' | 'diff-removed'
| 'diff-renamed' | 'ellipses' | 'ellipsis' | 'eye' | 'file' | 'file-binary' | 'file-code' | 'file-directory'
| 'file-media' | 'file-pdf' | 'file-submodule' | 'file-symlink-directory' | 'file-symlink-file' | 'file-text'
| 'file-zip' | 'flame' | 'fold' | 'gear' | 'gift' | 'gist' | 'gist-secret' | 'git-branch' | 'git-commit'
| 'git-compare' | 'git-merge' | 'git-pull-request' | 'globe' | 'grabber' | 'graph' | 'heart' | 'history' | 'home'
| 'horizontal-rule' | 'hubot' | 'inbox' | 'info' | 'issue-closed' | 'issue-opened' | 'issue-reopened' | 'italic'
| 'jersey' | 'key' | 'keyboard' | 'law' | 'light-bulb' | 'link' | 'link-external' | 'list-ordered' | 'list-unordered'
| 'location' | 'lock' | 'mail' | 'mail-read' | 'mail-reply' | 'markdown' | 'mark-github' | 'megaphone' | 'mention'
| 'milestone' | 'mirror' | 'mortar-board' | 'mute' | 'no-newline' | 'octoface' | 'organization' | 'package'
| 'paintcan' | 'pencil' | 'person' | 'pin' | 'plug' | 'plus' | 'plus-small' | 'primitive-dot' | 'primitive-square'
| 'pulse' | 'question' | 'quote' | 'radio-tower' | 'reply' | 'repo' | 'repo-clone' | 'repo-force-push' | 'repo-forked'
| 'repo-pull' | 'repo-push' | 'rocket' | 'rss' | 'ruby' | 'search' | 'server' | 'settings' | 'shield' | 'sign-in'
| 'sign-out' | 'smiley' | 'squirrel' | 'star' | 'stop' | 'sync' | 'tag' | 'tasklist' | 'telescope' | 'terminal'
| 'text-size' | 'three-bars' | 'thumbsdown' | 'thumbsup' | 'tools' | 'trashcan' | 'triangle-down' | 'triangle-left'
| 'triangle-right' | 'triangle-up' | 'unfold' | 'unmute' | 'unverified' | 'verified' | 'versions' | 'watch'
| 'x' | 'zap'
// Allow any string value, but keep auto complete for known values.
| (string & Record<never, never>)
export interface PrivateLocationProps {
/**
* The name assigned to the private location.
*/
name: string
/**
* A valid slug name.
*/
slugName: string
/**
* An icon
*/
icon?: PrivateLocationIcon
/**
* Define a proxy for outgoing API check HTTP calls from your private location.
*/
proxyUrl?: string
}
/**
* Creates a reference to an existing Private Location.
*
* References link existing resources to a project without managing them.
*/
export class PrivateLocationRef extends Construct {
constructor (logicalId: string, physicalId: string | number) {
super(PrivateLocation.__checklyType, logicalId, physicalId, false)
Session.registerConstruct(this)
}
describe (): string {
return `PrivateLocationRef:${this.logicalId}`
}
synthesize () {
return null
}
}
const RE_SLUG = /^((?!((us(-gov)?|ap|ca|cn|eu|sa|af|me)-(central|(north|south)?(east|west)?)-\d+))[a-zA-Z0-9-]{1,30})$/
/**
* Creates a Private Location
*
* @remarks
*
* This class make use of the Private Location endpoints.
*
* {@link https://www.checklyhq.com/docs/constructs/private-location/ Read more in the docs}
*/
export class PrivateLocation extends Construct {
name: string
slugName: string
icon?: string
proxyUrl?: string
static readonly __checklyType = 'private-location'
/**
* Constructs the Private Location instance
*
* @param logicalId unique project-scoped resource name identification
* @param props private location configuration properties
*/
constructor (logicalId: string, props: PrivateLocationProps) {
super(PrivateLocation.__checklyType, logicalId)
this.name = props.name
this.slugName = props.slugName
this.icon = props.icon
this.proxyUrl = props.proxyUrl
Session.registerConstruct(this)
}
describe (): string {
return `PrivateLocation:${this.logicalId}`
}
async validate (diagnostics: Diagnostics): Promise<void> {
await super.validate(diagnostics)
if (!RE_SLUG.test(this.slugName)) {
diagnostics.add(new InvalidPropertyValueDiagnostic(
'slugName',
new Error(`Value must not equal any AWS location.`),
))
}
}
static fromId (id: string) {
return new PrivateLocationRef(`private-location-${id}`, id)
}
allowInChecklyConfig () {
return true
}
synthesize (): any | null {
return {
name: this.name,
slugName: this.slugName,
icon: this.icon,
proxyUrl: this.proxyUrl,
}
}
}