/
getDecode.go
223 lines (199 loc) · 8.41 KB
/
getDecode.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
// 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 transform
import (
"context"
"reflect"
"github.com/pulumi/pulumi-vault/sdk/v6/go/vault/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// This data source supports the "/transform/decode/{role_name}" Vault endpoint.
//
// It decodes the provided value using a named role.
//
// ## Example Usage
//
// <!--Start PulumiCodeChooser -->
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-vault/sdk/v6/go/vault"
// "github.com/pulumi/pulumi-vault/sdk/v6/go/vault/transform"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// transform, err := vault.NewMount(ctx, "transform", &vault.MountArgs{
// Path: pulumi.String("transform"),
// Type: pulumi.String("transform"),
// })
// if err != nil {
// return err
// }
// _, err = transform.NewTransformation(ctx, "ccn-fpe", &transform.TransformationArgs{
// Path: transform.Path,
// Type: pulumi.String("fpe"),
// Template: pulumi.String("builtin/creditcardnumber"),
// TweakSource: pulumi.String("internal"),
// AllowedRoles: pulumi.StringArray{
// pulumi.String("payments"),
// },
// })
// if err != nil {
// return err
// }
// payments, err := transform.NewRole(ctx, "payments", &transform.RoleArgs{
// Path: ccn_fpe.Path,
// Transformations: pulumi.StringArray{
// pulumi.String("ccn-fpe"),
// },
// })
// if err != nil {
// return err
// }
// _ = transform.GetDecodeOutput(ctx, transform.GetDecodeOutputArgs{
// Path: payments.Path,
// RoleName: pulumi.String("payments"),
// Value: pulumi.String("9300-3376-4943-8903"),
// }, nil)
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
func GetDecode(ctx *pulumi.Context, args *GetDecodeArgs, opts ...pulumi.InvokeOption) (*GetDecodeResult, error) {
opts = internal.PkgInvokeDefaultOpts(opts)
var rv GetDecodeResult
err := ctx.Invoke("vault:transform/getDecode:getDecode", args, &rv, opts...)
if err != nil {
return nil, err
}
return &rv, nil
}
// A collection of arguments for invoking getDecode.
type GetDecodeArgs struct {
// Specifies a list of items to be decoded in a single batch. If this parameter is set, the top-level parameters 'value', 'transformation' and 'tweak' will be ignored. Each batch item within the list can specify these parameters instead.
BatchInputs []map[string]interface{} `pulumi:"batchInputs"`
// The result of decoding a batch.
BatchResults []map[string]interface{} `pulumi:"batchResults"`
// The result of decoding a value.
DecodedValue *string `pulumi:"decodedValue"`
// The namespace of the target resource.
// The value should not contain leading or trailing forward slashes.
// The `namespace` is always relative to the provider's configured [namespace](https://www.terraform.io/docs/providers/vault/index.html#namespace).
// *Available only for Vault Enterprise*.
Namespace *string `pulumi:"namespace"`
// Path to where the back-end is mounted within Vault.
Path string `pulumi:"path"`
// The name of the role.
RoleName string `pulumi:"roleName"`
// The transformation to perform. If no value is provided and the role contains a single transformation, this value will be inferred from the role.
Transformation *string `pulumi:"transformation"`
// The tweak value to use. Only applicable for FPE transformations
Tweak *string `pulumi:"tweak"`
// The value in which to decode.
Value *string `pulumi:"value"`
}
// A collection of values returned by getDecode.
type GetDecodeResult struct {
BatchInputs []map[string]interface{} `pulumi:"batchInputs"`
BatchResults []map[string]interface{} `pulumi:"batchResults"`
DecodedValue string `pulumi:"decodedValue"`
// The provider-assigned unique ID for this managed resource.
Id string `pulumi:"id"`
Namespace *string `pulumi:"namespace"`
Path string `pulumi:"path"`
RoleName string `pulumi:"roleName"`
Transformation *string `pulumi:"transformation"`
Tweak *string `pulumi:"tweak"`
Value *string `pulumi:"value"`
}
func GetDecodeOutput(ctx *pulumi.Context, args GetDecodeOutputArgs, opts ...pulumi.InvokeOption) GetDecodeResultOutput {
return pulumi.ToOutputWithContext(context.Background(), args).
ApplyT(func(v interface{}) (GetDecodeResult, error) {
args := v.(GetDecodeArgs)
r, err := GetDecode(ctx, &args, opts...)
var s GetDecodeResult
if r != nil {
s = *r
}
return s, err
}).(GetDecodeResultOutput)
}
// A collection of arguments for invoking getDecode.
type GetDecodeOutputArgs struct {
// Specifies a list of items to be decoded in a single batch. If this parameter is set, the top-level parameters 'value', 'transformation' and 'tweak' will be ignored. Each batch item within the list can specify these parameters instead.
BatchInputs pulumi.MapArrayInput `pulumi:"batchInputs"`
// The result of decoding a batch.
BatchResults pulumi.MapArrayInput `pulumi:"batchResults"`
// The result of decoding a value.
DecodedValue pulumi.StringPtrInput `pulumi:"decodedValue"`
// The namespace of the target resource.
// The value should not contain leading or trailing forward slashes.
// The `namespace` is always relative to the provider's configured [namespace](https://www.terraform.io/docs/providers/vault/index.html#namespace).
// *Available only for Vault Enterprise*.
Namespace pulumi.StringPtrInput `pulumi:"namespace"`
// Path to where the back-end is mounted within Vault.
Path pulumi.StringInput `pulumi:"path"`
// The name of the role.
RoleName pulumi.StringInput `pulumi:"roleName"`
// The transformation to perform. If no value is provided and the role contains a single transformation, this value will be inferred from the role.
Transformation pulumi.StringPtrInput `pulumi:"transformation"`
// The tweak value to use. Only applicable for FPE transformations
Tweak pulumi.StringPtrInput `pulumi:"tweak"`
// The value in which to decode.
Value pulumi.StringPtrInput `pulumi:"value"`
}
func (GetDecodeOutputArgs) ElementType() reflect.Type {
return reflect.TypeOf((*GetDecodeArgs)(nil)).Elem()
}
// A collection of values returned by getDecode.
type GetDecodeResultOutput struct{ *pulumi.OutputState }
func (GetDecodeResultOutput) ElementType() reflect.Type {
return reflect.TypeOf((*GetDecodeResult)(nil)).Elem()
}
func (o GetDecodeResultOutput) ToGetDecodeResultOutput() GetDecodeResultOutput {
return o
}
func (o GetDecodeResultOutput) ToGetDecodeResultOutputWithContext(ctx context.Context) GetDecodeResultOutput {
return o
}
func (o GetDecodeResultOutput) BatchInputs() pulumi.MapArrayOutput {
return o.ApplyT(func(v GetDecodeResult) []map[string]interface{} { return v.BatchInputs }).(pulumi.MapArrayOutput)
}
func (o GetDecodeResultOutput) BatchResults() pulumi.MapArrayOutput {
return o.ApplyT(func(v GetDecodeResult) []map[string]interface{} { return v.BatchResults }).(pulumi.MapArrayOutput)
}
func (o GetDecodeResultOutput) DecodedValue() pulumi.StringOutput {
return o.ApplyT(func(v GetDecodeResult) string { return v.DecodedValue }).(pulumi.StringOutput)
}
// The provider-assigned unique ID for this managed resource.
func (o GetDecodeResultOutput) Id() pulumi.StringOutput {
return o.ApplyT(func(v GetDecodeResult) string { return v.Id }).(pulumi.StringOutput)
}
func (o GetDecodeResultOutput) Namespace() pulumi.StringPtrOutput {
return o.ApplyT(func(v GetDecodeResult) *string { return v.Namespace }).(pulumi.StringPtrOutput)
}
func (o GetDecodeResultOutput) Path() pulumi.StringOutput {
return o.ApplyT(func(v GetDecodeResult) string { return v.Path }).(pulumi.StringOutput)
}
func (o GetDecodeResultOutput) RoleName() pulumi.StringOutput {
return o.ApplyT(func(v GetDecodeResult) string { return v.RoleName }).(pulumi.StringOutput)
}
func (o GetDecodeResultOutput) Transformation() pulumi.StringPtrOutput {
return o.ApplyT(func(v GetDecodeResult) *string { return v.Transformation }).(pulumi.StringPtrOutput)
}
func (o GetDecodeResultOutput) Tweak() pulumi.StringPtrOutput {
return o.ApplyT(func(v GetDecodeResult) *string { return v.Tweak }).(pulumi.StringPtrOutput)
}
func (o GetDecodeResultOutput) Value() pulumi.StringPtrOutput {
return o.ApplyT(func(v GetDecodeResult) *string { return v.Value }).(pulumi.StringPtrOutput)
}
func init() {
pulumi.RegisterOutputType(GetDecodeResultOutput{})
}