/
monitoredProject.go
319 lines (270 loc) · 13 KB
/
monitoredProject.go
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
// Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package monitoring
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// A [project being monitored](https://cloud.google.com/monitoring/settings/multiple-projects#create-multi) by a Metrics Scope.
//
// To get more information about MonitoredProject, see:
//
// * [API documentation](https://cloud.google.com/monitoring/api/ref_v3/rest/v1/locations.global.metricsScopes.projects)
// * How-to Guides
// - [Official Documentation](https://cloud.google.com/monitoring/settings/manage-api)
//
// ## Example Usage
//
// ### Monitoring Monitored Project Basic
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/monitoring"
// "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// basic, err := organizations.NewProject(ctx, "basic", &organizations.ProjectArgs{
// ProjectId: pulumi.String("m-id"),
// Name: pulumi.String("m-id-display"),
// OrgId: pulumi.String("123456789"),
// })
// if err != nil {
// return err
// }
// _, err = monitoring.NewMonitoredProject(ctx, "primary", &monitoring.MonitoredProjectArgs{
// MetricsScope: pulumi.String("my-project-name"),
// Name: basic.ProjectId,
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// MonitoredProject can be imported using any of these accepted formats:
//
// * `v1/locations/global/metricsScopes/{{name}}`
//
// * `{{name}}`
//
// When using the `pulumi import` command, MonitoredProject can be imported using one of the formats above. For example:
//
// ```sh
// $ pulumi import gcp:monitoring/monitoredProject:MonitoredProject default v1/locations/global/metricsScopes/{{name}}
// ```
//
// ```sh
// $ pulumi import gcp:monitoring/monitoredProject:MonitoredProject default {{name}}
// ```
type MonitoredProject struct {
pulumi.CustomResourceState
// Output only. The time when this `MonitoredProject` was created.
CreateTime pulumi.StringOutput `pulumi:"createTime"`
// Required. The resource name of the existing Metrics Scope that will monitor this project. Example: locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}
//
// ***
MetricsScope pulumi.StringOutput `pulumi:"metricsScope"`
// Immutable. The resource name of the `MonitoredProject`. On input, the resource name includes the scoping project ID and monitored project ID. On output, it contains the equivalent project numbers. Example: `locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}/projects/{MONITORED_PROJECT_ID_OR_NUMBER}`
Name pulumi.StringOutput `pulumi:"name"`
}
// NewMonitoredProject registers a new resource with the given unique name, arguments, and options.
func NewMonitoredProject(ctx *pulumi.Context,
name string, args *MonitoredProjectArgs, opts ...pulumi.ResourceOption) (*MonitoredProject, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.MetricsScope == nil {
return nil, errors.New("invalid value for required argument 'MetricsScope'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource MonitoredProject
err := ctx.RegisterResource("gcp:monitoring/monitoredProject:MonitoredProject", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetMonitoredProject gets an existing MonitoredProject resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetMonitoredProject(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *MonitoredProjectState, opts ...pulumi.ResourceOption) (*MonitoredProject, error) {
var resource MonitoredProject
err := ctx.ReadResource("gcp:monitoring/monitoredProject:MonitoredProject", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering MonitoredProject resources.
type monitoredProjectState struct {
// Output only. The time when this `MonitoredProject` was created.
CreateTime *string `pulumi:"createTime"`
// Required. The resource name of the existing Metrics Scope that will monitor this project. Example: locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}
//
// ***
MetricsScope *string `pulumi:"metricsScope"`
// Immutable. The resource name of the `MonitoredProject`. On input, the resource name includes the scoping project ID and monitored project ID. On output, it contains the equivalent project numbers. Example: `locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}/projects/{MONITORED_PROJECT_ID_OR_NUMBER}`
Name *string `pulumi:"name"`
}
type MonitoredProjectState struct {
// Output only. The time when this `MonitoredProject` was created.
CreateTime pulumi.StringPtrInput
// Required. The resource name of the existing Metrics Scope that will monitor this project. Example: locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}
//
// ***
MetricsScope pulumi.StringPtrInput
// Immutable. The resource name of the `MonitoredProject`. On input, the resource name includes the scoping project ID and monitored project ID. On output, it contains the equivalent project numbers. Example: `locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}/projects/{MONITORED_PROJECT_ID_OR_NUMBER}`
Name pulumi.StringPtrInput
}
func (MonitoredProjectState) ElementType() reflect.Type {
return reflect.TypeOf((*monitoredProjectState)(nil)).Elem()
}
type monitoredProjectArgs struct {
// Required. The resource name of the existing Metrics Scope that will monitor this project. Example: locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}
//
// ***
MetricsScope string `pulumi:"metricsScope"`
// Immutable. The resource name of the `MonitoredProject`. On input, the resource name includes the scoping project ID and monitored project ID. On output, it contains the equivalent project numbers. Example: `locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}/projects/{MONITORED_PROJECT_ID_OR_NUMBER}`
Name *string `pulumi:"name"`
}
// The set of arguments for constructing a MonitoredProject resource.
type MonitoredProjectArgs struct {
// Required. The resource name of the existing Metrics Scope that will monitor this project. Example: locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}
//
// ***
MetricsScope pulumi.StringInput
// Immutable. The resource name of the `MonitoredProject`. On input, the resource name includes the scoping project ID and monitored project ID. On output, it contains the equivalent project numbers. Example: `locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}/projects/{MONITORED_PROJECT_ID_OR_NUMBER}`
Name pulumi.StringPtrInput
}
func (MonitoredProjectArgs) ElementType() reflect.Type {
return reflect.TypeOf((*monitoredProjectArgs)(nil)).Elem()
}
type MonitoredProjectInput interface {
pulumi.Input
ToMonitoredProjectOutput() MonitoredProjectOutput
ToMonitoredProjectOutputWithContext(ctx context.Context) MonitoredProjectOutput
}
func (*MonitoredProject) ElementType() reflect.Type {
return reflect.TypeOf((**MonitoredProject)(nil)).Elem()
}
func (i *MonitoredProject) ToMonitoredProjectOutput() MonitoredProjectOutput {
return i.ToMonitoredProjectOutputWithContext(context.Background())
}
func (i *MonitoredProject) ToMonitoredProjectOutputWithContext(ctx context.Context) MonitoredProjectOutput {
return pulumi.ToOutputWithContext(ctx, i).(MonitoredProjectOutput)
}
// MonitoredProjectArrayInput is an input type that accepts MonitoredProjectArray and MonitoredProjectArrayOutput values.
// You can construct a concrete instance of `MonitoredProjectArrayInput` via:
//
// MonitoredProjectArray{ MonitoredProjectArgs{...} }
type MonitoredProjectArrayInput interface {
pulumi.Input
ToMonitoredProjectArrayOutput() MonitoredProjectArrayOutput
ToMonitoredProjectArrayOutputWithContext(context.Context) MonitoredProjectArrayOutput
}
type MonitoredProjectArray []MonitoredProjectInput
func (MonitoredProjectArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*MonitoredProject)(nil)).Elem()
}
func (i MonitoredProjectArray) ToMonitoredProjectArrayOutput() MonitoredProjectArrayOutput {
return i.ToMonitoredProjectArrayOutputWithContext(context.Background())
}
func (i MonitoredProjectArray) ToMonitoredProjectArrayOutputWithContext(ctx context.Context) MonitoredProjectArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(MonitoredProjectArrayOutput)
}
// MonitoredProjectMapInput is an input type that accepts MonitoredProjectMap and MonitoredProjectMapOutput values.
// You can construct a concrete instance of `MonitoredProjectMapInput` via:
//
// MonitoredProjectMap{ "key": MonitoredProjectArgs{...} }
type MonitoredProjectMapInput interface {
pulumi.Input
ToMonitoredProjectMapOutput() MonitoredProjectMapOutput
ToMonitoredProjectMapOutputWithContext(context.Context) MonitoredProjectMapOutput
}
type MonitoredProjectMap map[string]MonitoredProjectInput
func (MonitoredProjectMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*MonitoredProject)(nil)).Elem()
}
func (i MonitoredProjectMap) ToMonitoredProjectMapOutput() MonitoredProjectMapOutput {
return i.ToMonitoredProjectMapOutputWithContext(context.Background())
}
func (i MonitoredProjectMap) ToMonitoredProjectMapOutputWithContext(ctx context.Context) MonitoredProjectMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(MonitoredProjectMapOutput)
}
type MonitoredProjectOutput struct{ *pulumi.OutputState }
func (MonitoredProjectOutput) ElementType() reflect.Type {
return reflect.TypeOf((**MonitoredProject)(nil)).Elem()
}
func (o MonitoredProjectOutput) ToMonitoredProjectOutput() MonitoredProjectOutput {
return o
}
func (o MonitoredProjectOutput) ToMonitoredProjectOutputWithContext(ctx context.Context) MonitoredProjectOutput {
return o
}
// Output only. The time when this `MonitoredProject` was created.
func (o MonitoredProjectOutput) CreateTime() pulumi.StringOutput {
return o.ApplyT(func(v *MonitoredProject) pulumi.StringOutput { return v.CreateTime }).(pulumi.StringOutput)
}
// Required. The resource name of the existing Metrics Scope that will monitor this project. Example: locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}
//
// ***
func (o MonitoredProjectOutput) MetricsScope() pulumi.StringOutput {
return o.ApplyT(func(v *MonitoredProject) pulumi.StringOutput { return v.MetricsScope }).(pulumi.StringOutput)
}
// Immutable. The resource name of the `MonitoredProject`. On input, the resource name includes the scoping project ID and monitored project ID. On output, it contains the equivalent project numbers. Example: `locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}/projects/{MONITORED_PROJECT_ID_OR_NUMBER}`
func (o MonitoredProjectOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *MonitoredProject) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
type MonitoredProjectArrayOutput struct{ *pulumi.OutputState }
func (MonitoredProjectArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*MonitoredProject)(nil)).Elem()
}
func (o MonitoredProjectArrayOutput) ToMonitoredProjectArrayOutput() MonitoredProjectArrayOutput {
return o
}
func (o MonitoredProjectArrayOutput) ToMonitoredProjectArrayOutputWithContext(ctx context.Context) MonitoredProjectArrayOutput {
return o
}
func (o MonitoredProjectArrayOutput) Index(i pulumi.IntInput) MonitoredProjectOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *MonitoredProject {
return vs[0].([]*MonitoredProject)[vs[1].(int)]
}).(MonitoredProjectOutput)
}
type MonitoredProjectMapOutput struct{ *pulumi.OutputState }
func (MonitoredProjectMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*MonitoredProject)(nil)).Elem()
}
func (o MonitoredProjectMapOutput) ToMonitoredProjectMapOutput() MonitoredProjectMapOutput {
return o
}
func (o MonitoredProjectMapOutput) ToMonitoredProjectMapOutputWithContext(ctx context.Context) MonitoredProjectMapOutput {
return o
}
func (o MonitoredProjectMapOutput) MapIndex(k pulumi.StringInput) MonitoredProjectOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *MonitoredProject {
return vs[0].(map[string]*MonitoredProject)[vs[1].(string)]
}).(MonitoredProjectOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*MonitoredProjectInput)(nil)).Elem(), &MonitoredProject{})
pulumi.RegisterInputType(reflect.TypeOf((*MonitoredProjectArrayInput)(nil)).Elem(), MonitoredProjectArray{})
pulumi.RegisterInputType(reflect.TypeOf((*MonitoredProjectMapInput)(nil)).Elem(), MonitoredProjectMap{})
pulumi.RegisterOutputType(MonitoredProjectOutput{})
pulumi.RegisterOutputType(MonitoredProjectArrayOutput{})
pulumi.RegisterOutputType(MonitoredProjectMapOutput{})
}