github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/grafana/workspaceApiKey.go (about) 1 // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT. 2 // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 4 package grafana 5 6 import ( 7 "context" 8 "reflect" 9 10 "errors" 11 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 12 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 13 ) 14 15 // Provides an Amazon Managed Grafana workspace API Key resource. 16 // 17 // ## Example Usage 18 // 19 // ### Basic configuration 20 // 21 // <!--Start PulumiCodeChooser --> 22 // ```go 23 // package main 24 // 25 // import ( 26 // 27 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/grafana" 28 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 29 // 30 // ) 31 // 32 // func main() { 33 // pulumi.Run(func(ctx *pulumi.Context) error { 34 // _, err := grafana.NewWorkspaceApiKey(ctx, "key", &grafana.WorkspaceApiKeyArgs{ 35 // KeyName: pulumi.String("test-key"), 36 // KeyRole: pulumi.String("VIEWER"), 37 // SecondsToLive: pulumi.Int(3600), 38 // WorkspaceId: pulumi.Any(test.Id), 39 // }) 40 // if err != nil { 41 // return err 42 // } 43 // return nil 44 // }) 45 // } 46 // 47 // ``` 48 // <!--End PulumiCodeChooser --> 49 type WorkspaceApiKey struct { 50 pulumi.CustomResourceState 51 52 // The key token in JSON format. Use this value as a bearer token to authenticate HTTP requests to the workspace. 53 Key pulumi.StringOutput `pulumi:"key"` 54 // Specifies the name of the API key. Key names must be unique to the workspace. 55 KeyName pulumi.StringOutput `pulumi:"keyName"` 56 // Specifies the permission level of the API key. Valid values are `VIEWER`, `EDITOR`, or `ADMIN`. 57 KeyRole pulumi.StringOutput `pulumi:"keyRole"` 58 // Specifies the time in seconds until the API key expires. Keys can be valid for up to 30 days. 59 SecondsToLive pulumi.IntOutput `pulumi:"secondsToLive"` 60 // The ID of the workspace that the API key is valid for. 61 WorkspaceId pulumi.StringOutput `pulumi:"workspaceId"` 62 } 63 64 // NewWorkspaceApiKey registers a new resource with the given unique name, arguments, and options. 65 func NewWorkspaceApiKey(ctx *pulumi.Context, 66 name string, args *WorkspaceApiKeyArgs, opts ...pulumi.ResourceOption) (*WorkspaceApiKey, error) { 67 if args == nil { 68 return nil, errors.New("missing one or more required arguments") 69 } 70 71 if args.KeyName == nil { 72 return nil, errors.New("invalid value for required argument 'KeyName'") 73 } 74 if args.KeyRole == nil { 75 return nil, errors.New("invalid value for required argument 'KeyRole'") 76 } 77 if args.SecondsToLive == nil { 78 return nil, errors.New("invalid value for required argument 'SecondsToLive'") 79 } 80 if args.WorkspaceId == nil { 81 return nil, errors.New("invalid value for required argument 'WorkspaceId'") 82 } 83 secrets := pulumi.AdditionalSecretOutputs([]string{ 84 "key", 85 }) 86 opts = append(opts, secrets) 87 opts = internal.PkgResourceDefaultOpts(opts) 88 var resource WorkspaceApiKey 89 err := ctx.RegisterResource("aws:grafana/workspaceApiKey:WorkspaceApiKey", name, args, &resource, opts...) 90 if err != nil { 91 return nil, err 92 } 93 return &resource, nil 94 } 95 96 // GetWorkspaceApiKey gets an existing WorkspaceApiKey resource's state with the given name, ID, and optional 97 // state properties that are used to uniquely qualify the lookup (nil if not required). 98 func GetWorkspaceApiKey(ctx *pulumi.Context, 99 name string, id pulumi.IDInput, state *WorkspaceApiKeyState, opts ...pulumi.ResourceOption) (*WorkspaceApiKey, error) { 100 var resource WorkspaceApiKey 101 err := ctx.ReadResource("aws:grafana/workspaceApiKey:WorkspaceApiKey", name, id, state, &resource, opts...) 102 if err != nil { 103 return nil, err 104 } 105 return &resource, nil 106 } 107 108 // Input properties used for looking up and filtering WorkspaceApiKey resources. 109 type workspaceApiKeyState struct { 110 // The key token in JSON format. Use this value as a bearer token to authenticate HTTP requests to the workspace. 111 Key *string `pulumi:"key"` 112 // Specifies the name of the API key. Key names must be unique to the workspace. 113 KeyName *string `pulumi:"keyName"` 114 // Specifies the permission level of the API key. Valid values are `VIEWER`, `EDITOR`, or `ADMIN`. 115 KeyRole *string `pulumi:"keyRole"` 116 // Specifies the time in seconds until the API key expires. Keys can be valid for up to 30 days. 117 SecondsToLive *int `pulumi:"secondsToLive"` 118 // The ID of the workspace that the API key is valid for. 119 WorkspaceId *string `pulumi:"workspaceId"` 120 } 121 122 type WorkspaceApiKeyState struct { 123 // The key token in JSON format. Use this value as a bearer token to authenticate HTTP requests to the workspace. 124 Key pulumi.StringPtrInput 125 // Specifies the name of the API key. Key names must be unique to the workspace. 126 KeyName pulumi.StringPtrInput 127 // Specifies the permission level of the API key. Valid values are `VIEWER`, `EDITOR`, or `ADMIN`. 128 KeyRole pulumi.StringPtrInput 129 // Specifies the time in seconds until the API key expires. Keys can be valid for up to 30 days. 130 SecondsToLive pulumi.IntPtrInput 131 // The ID of the workspace that the API key is valid for. 132 WorkspaceId pulumi.StringPtrInput 133 } 134 135 func (WorkspaceApiKeyState) ElementType() reflect.Type { 136 return reflect.TypeOf((*workspaceApiKeyState)(nil)).Elem() 137 } 138 139 type workspaceApiKeyArgs struct { 140 // Specifies the name of the API key. Key names must be unique to the workspace. 141 KeyName string `pulumi:"keyName"` 142 // Specifies the permission level of the API key. Valid values are `VIEWER`, `EDITOR`, or `ADMIN`. 143 KeyRole string `pulumi:"keyRole"` 144 // Specifies the time in seconds until the API key expires. Keys can be valid for up to 30 days. 145 SecondsToLive int `pulumi:"secondsToLive"` 146 // The ID of the workspace that the API key is valid for. 147 WorkspaceId string `pulumi:"workspaceId"` 148 } 149 150 // The set of arguments for constructing a WorkspaceApiKey resource. 151 type WorkspaceApiKeyArgs struct { 152 // Specifies the name of the API key. Key names must be unique to the workspace. 153 KeyName pulumi.StringInput 154 // Specifies the permission level of the API key. Valid values are `VIEWER`, `EDITOR`, or `ADMIN`. 155 KeyRole pulumi.StringInput 156 // Specifies the time in seconds until the API key expires. Keys can be valid for up to 30 days. 157 SecondsToLive pulumi.IntInput 158 // The ID of the workspace that the API key is valid for. 159 WorkspaceId pulumi.StringInput 160 } 161 162 func (WorkspaceApiKeyArgs) ElementType() reflect.Type { 163 return reflect.TypeOf((*workspaceApiKeyArgs)(nil)).Elem() 164 } 165 166 type WorkspaceApiKeyInput interface { 167 pulumi.Input 168 169 ToWorkspaceApiKeyOutput() WorkspaceApiKeyOutput 170 ToWorkspaceApiKeyOutputWithContext(ctx context.Context) WorkspaceApiKeyOutput 171 } 172 173 func (*WorkspaceApiKey) ElementType() reflect.Type { 174 return reflect.TypeOf((**WorkspaceApiKey)(nil)).Elem() 175 } 176 177 func (i *WorkspaceApiKey) ToWorkspaceApiKeyOutput() WorkspaceApiKeyOutput { 178 return i.ToWorkspaceApiKeyOutputWithContext(context.Background()) 179 } 180 181 func (i *WorkspaceApiKey) ToWorkspaceApiKeyOutputWithContext(ctx context.Context) WorkspaceApiKeyOutput { 182 return pulumi.ToOutputWithContext(ctx, i).(WorkspaceApiKeyOutput) 183 } 184 185 // WorkspaceApiKeyArrayInput is an input type that accepts WorkspaceApiKeyArray and WorkspaceApiKeyArrayOutput values. 186 // You can construct a concrete instance of `WorkspaceApiKeyArrayInput` via: 187 // 188 // WorkspaceApiKeyArray{ WorkspaceApiKeyArgs{...} } 189 type WorkspaceApiKeyArrayInput interface { 190 pulumi.Input 191 192 ToWorkspaceApiKeyArrayOutput() WorkspaceApiKeyArrayOutput 193 ToWorkspaceApiKeyArrayOutputWithContext(context.Context) WorkspaceApiKeyArrayOutput 194 } 195 196 type WorkspaceApiKeyArray []WorkspaceApiKeyInput 197 198 func (WorkspaceApiKeyArray) ElementType() reflect.Type { 199 return reflect.TypeOf((*[]*WorkspaceApiKey)(nil)).Elem() 200 } 201 202 func (i WorkspaceApiKeyArray) ToWorkspaceApiKeyArrayOutput() WorkspaceApiKeyArrayOutput { 203 return i.ToWorkspaceApiKeyArrayOutputWithContext(context.Background()) 204 } 205 206 func (i WorkspaceApiKeyArray) ToWorkspaceApiKeyArrayOutputWithContext(ctx context.Context) WorkspaceApiKeyArrayOutput { 207 return pulumi.ToOutputWithContext(ctx, i).(WorkspaceApiKeyArrayOutput) 208 } 209 210 // WorkspaceApiKeyMapInput is an input type that accepts WorkspaceApiKeyMap and WorkspaceApiKeyMapOutput values. 211 // You can construct a concrete instance of `WorkspaceApiKeyMapInput` via: 212 // 213 // WorkspaceApiKeyMap{ "key": WorkspaceApiKeyArgs{...} } 214 type WorkspaceApiKeyMapInput interface { 215 pulumi.Input 216 217 ToWorkspaceApiKeyMapOutput() WorkspaceApiKeyMapOutput 218 ToWorkspaceApiKeyMapOutputWithContext(context.Context) WorkspaceApiKeyMapOutput 219 } 220 221 type WorkspaceApiKeyMap map[string]WorkspaceApiKeyInput 222 223 func (WorkspaceApiKeyMap) ElementType() reflect.Type { 224 return reflect.TypeOf((*map[string]*WorkspaceApiKey)(nil)).Elem() 225 } 226 227 func (i WorkspaceApiKeyMap) ToWorkspaceApiKeyMapOutput() WorkspaceApiKeyMapOutput { 228 return i.ToWorkspaceApiKeyMapOutputWithContext(context.Background()) 229 } 230 231 func (i WorkspaceApiKeyMap) ToWorkspaceApiKeyMapOutputWithContext(ctx context.Context) WorkspaceApiKeyMapOutput { 232 return pulumi.ToOutputWithContext(ctx, i).(WorkspaceApiKeyMapOutput) 233 } 234 235 type WorkspaceApiKeyOutput struct{ *pulumi.OutputState } 236 237 func (WorkspaceApiKeyOutput) ElementType() reflect.Type { 238 return reflect.TypeOf((**WorkspaceApiKey)(nil)).Elem() 239 } 240 241 func (o WorkspaceApiKeyOutput) ToWorkspaceApiKeyOutput() WorkspaceApiKeyOutput { 242 return o 243 } 244 245 func (o WorkspaceApiKeyOutput) ToWorkspaceApiKeyOutputWithContext(ctx context.Context) WorkspaceApiKeyOutput { 246 return o 247 } 248 249 // The key token in JSON format. Use this value as a bearer token to authenticate HTTP requests to the workspace. 250 func (o WorkspaceApiKeyOutput) Key() pulumi.StringOutput { 251 return o.ApplyT(func(v *WorkspaceApiKey) pulumi.StringOutput { return v.Key }).(pulumi.StringOutput) 252 } 253 254 // Specifies the name of the API key. Key names must be unique to the workspace. 255 func (o WorkspaceApiKeyOutput) KeyName() pulumi.StringOutput { 256 return o.ApplyT(func(v *WorkspaceApiKey) pulumi.StringOutput { return v.KeyName }).(pulumi.StringOutput) 257 } 258 259 // Specifies the permission level of the API key. Valid values are `VIEWER`, `EDITOR`, or `ADMIN`. 260 func (o WorkspaceApiKeyOutput) KeyRole() pulumi.StringOutput { 261 return o.ApplyT(func(v *WorkspaceApiKey) pulumi.StringOutput { return v.KeyRole }).(pulumi.StringOutput) 262 } 263 264 // Specifies the time in seconds until the API key expires. Keys can be valid for up to 30 days. 265 func (o WorkspaceApiKeyOutput) SecondsToLive() pulumi.IntOutput { 266 return o.ApplyT(func(v *WorkspaceApiKey) pulumi.IntOutput { return v.SecondsToLive }).(pulumi.IntOutput) 267 } 268 269 // The ID of the workspace that the API key is valid for. 270 func (o WorkspaceApiKeyOutput) WorkspaceId() pulumi.StringOutput { 271 return o.ApplyT(func(v *WorkspaceApiKey) pulumi.StringOutput { return v.WorkspaceId }).(pulumi.StringOutput) 272 } 273 274 type WorkspaceApiKeyArrayOutput struct{ *pulumi.OutputState } 275 276 func (WorkspaceApiKeyArrayOutput) ElementType() reflect.Type { 277 return reflect.TypeOf((*[]*WorkspaceApiKey)(nil)).Elem() 278 } 279 280 func (o WorkspaceApiKeyArrayOutput) ToWorkspaceApiKeyArrayOutput() WorkspaceApiKeyArrayOutput { 281 return o 282 } 283 284 func (o WorkspaceApiKeyArrayOutput) ToWorkspaceApiKeyArrayOutputWithContext(ctx context.Context) WorkspaceApiKeyArrayOutput { 285 return o 286 } 287 288 func (o WorkspaceApiKeyArrayOutput) Index(i pulumi.IntInput) WorkspaceApiKeyOutput { 289 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *WorkspaceApiKey { 290 return vs[0].([]*WorkspaceApiKey)[vs[1].(int)] 291 }).(WorkspaceApiKeyOutput) 292 } 293 294 type WorkspaceApiKeyMapOutput struct{ *pulumi.OutputState } 295 296 func (WorkspaceApiKeyMapOutput) ElementType() reflect.Type { 297 return reflect.TypeOf((*map[string]*WorkspaceApiKey)(nil)).Elem() 298 } 299 300 func (o WorkspaceApiKeyMapOutput) ToWorkspaceApiKeyMapOutput() WorkspaceApiKeyMapOutput { 301 return o 302 } 303 304 func (o WorkspaceApiKeyMapOutput) ToWorkspaceApiKeyMapOutputWithContext(ctx context.Context) WorkspaceApiKeyMapOutput { 305 return o 306 } 307 308 func (o WorkspaceApiKeyMapOutput) MapIndex(k pulumi.StringInput) WorkspaceApiKeyOutput { 309 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *WorkspaceApiKey { 310 return vs[0].(map[string]*WorkspaceApiKey)[vs[1].(string)] 311 }).(WorkspaceApiKeyOutput) 312 } 313 314 func init() { 315 pulumi.RegisterInputType(reflect.TypeOf((*WorkspaceApiKeyInput)(nil)).Elem(), &WorkspaceApiKey{}) 316 pulumi.RegisterInputType(reflect.TypeOf((*WorkspaceApiKeyArrayInput)(nil)).Elem(), WorkspaceApiKeyArray{}) 317 pulumi.RegisterInputType(reflect.TypeOf((*WorkspaceApiKeyMapInput)(nil)).Elem(), WorkspaceApiKeyMap{}) 318 pulumi.RegisterOutputType(WorkspaceApiKeyOutput{}) 319 pulumi.RegisterOutputType(WorkspaceApiKeyArrayOutput{}) 320 pulumi.RegisterOutputType(WorkspaceApiKeyMapOutput{}) 321 }