/
getSas.go
174 lines (156 loc) · 5.86 KB
/
getSas.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
// 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 eventhub
import (
"context"
"reflect"
"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Use this data source to obtain a Shared Access Signature (SAS Token) for an existing Event Hub.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
// "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/eventhub"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// exampleResourceGroup, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
// Name: pulumi.String("example-resources"),
// Location: pulumi.String("West Europe"),
// })
// if err != nil {
// return err
// }
// exampleEventHubNamespace, err := eventhub.NewEventHubNamespace(ctx, "example", &eventhub.EventHubNamespaceArgs{
// Name: pulumi.String("example-ehn"),
// Location: exampleResourceGroup.Location,
// ResourceGroupName: exampleResourceGroup.Name,
// Sku: pulumi.String("Basic"),
// })
// if err != nil {
// return err
// }
// exampleEventHub, err := eventhub.NewEventHub(ctx, "example", &eventhub.EventHubArgs{
// Name: pulumi.String("example-eh"),
// NamespaceName: exampleEventHubNamespace.Name,
// ResourceGroupName: exampleResourceGroup.Name,
// PartitionCount: pulumi.Int(1),
// MessageRetention: pulumi.Int(1),
// })
// if err != nil {
// return err
// }
// exampleAuthorizationRule, err := eventhub.NewAuthorizationRule(ctx, "example", &eventhub.AuthorizationRuleArgs{
// Name: pulumi.String("example-ehar"),
// NamespaceName: exampleEventHubNamespace.Name,
// EventhubName: exampleEventHub.Name,
// ResourceGroupName: exampleResourceGroup.Name,
// Listen: pulumi.Bool(true),
// Send: pulumi.Bool(true),
// Manage: pulumi.Bool(true),
// })
// if err != nil {
// return err
// }
// example := eventhub.LookupAuthorizationRuleOutput(ctx, eventhub.GetAuthorizationRuleOutputArgs{
// Name: exampleAuthorizationRule.Name,
// NamespaceName: exampleEventHubNamespace.Name,
// EventhubName: exampleEventHub.Name,
// ResourceGroupName: exampleResourceGroup.Name,
// }, nil)
// _ = example.ApplyT(func(example eventhub.GetAuthorizationRuleResult) (eventhub.GetSasResult, error) {
// return eventhub.GetSasOutput(ctx, eventhub.GetSasOutputArgs{
// ConnectionString: example.PrimaryConnectionString,
// Expiry: "2023-06-23T00:00:00Z",
// }, nil), nil
// }).(eventhub.GetSasResultOutput)
// return nil
// })
// }
//
// ```
func GetSas(ctx *pulumi.Context, args *GetSasArgs, opts ...pulumi.InvokeOption) (*GetSasResult, error) {
opts = internal.PkgInvokeDefaultOpts(opts)
var rv GetSasResult
err := ctx.Invoke("azure:eventhub/getSas:getSas", args, &rv, opts...)
if err != nil {
return nil, err
}
return &rv, nil
}
// A collection of arguments for invoking getSas.
type GetSasArgs struct {
// The connection string for the Event Hub to which this SAS applies.
ConnectionString string `pulumi:"connectionString"`
// The expiration time and date of this SAS. Must be a valid ISO-8601 format time/date string.
Expiry string `pulumi:"expiry"`
}
// A collection of values returned by getSas.
type GetSasResult struct {
ConnectionString string `pulumi:"connectionString"`
Expiry string `pulumi:"expiry"`
// The provider-assigned unique ID for this managed resource.
Id string `pulumi:"id"`
// The computed Event Hub Shared Access Signature (SAS).
Sas string `pulumi:"sas"`
}
func GetSasOutput(ctx *pulumi.Context, args GetSasOutputArgs, opts ...pulumi.InvokeOption) GetSasResultOutput {
return pulumi.ToOutputWithContext(context.Background(), args).
ApplyT(func(v interface{}) (GetSasResult, error) {
args := v.(GetSasArgs)
r, err := GetSas(ctx, &args, opts...)
var s GetSasResult
if r != nil {
s = *r
}
return s, err
}).(GetSasResultOutput)
}
// A collection of arguments for invoking getSas.
type GetSasOutputArgs struct {
// The connection string for the Event Hub to which this SAS applies.
ConnectionString pulumi.StringInput `pulumi:"connectionString"`
// The expiration time and date of this SAS. Must be a valid ISO-8601 format time/date string.
Expiry pulumi.StringInput `pulumi:"expiry"`
}
func (GetSasOutputArgs) ElementType() reflect.Type {
return reflect.TypeOf((*GetSasArgs)(nil)).Elem()
}
// A collection of values returned by getSas.
type GetSasResultOutput struct{ *pulumi.OutputState }
func (GetSasResultOutput) ElementType() reflect.Type {
return reflect.TypeOf((*GetSasResult)(nil)).Elem()
}
func (o GetSasResultOutput) ToGetSasResultOutput() GetSasResultOutput {
return o
}
func (o GetSasResultOutput) ToGetSasResultOutputWithContext(ctx context.Context) GetSasResultOutput {
return o
}
func (o GetSasResultOutput) ConnectionString() pulumi.StringOutput {
return o.ApplyT(func(v GetSasResult) string { return v.ConnectionString }).(pulumi.StringOutput)
}
func (o GetSasResultOutput) Expiry() pulumi.StringOutput {
return o.ApplyT(func(v GetSasResult) string { return v.Expiry }).(pulumi.StringOutput)
}
// The provider-assigned unique ID for this managed resource.
func (o GetSasResultOutput) Id() pulumi.StringOutput {
return o.ApplyT(func(v GetSasResult) string { return v.Id }).(pulumi.StringOutput)
}
// The computed Event Hub Shared Access Signature (SAS).
func (o GetSasResultOutput) Sas() pulumi.StringOutput {
return o.ApplyT(func(v GetSasResult) string { return v.Sas }).(pulumi.StringOutput)
}
func init() {
pulumi.RegisterOutputType(GetSasResultOutput{})
}