@@ -23,24 +23,24 @@ func (s *SetupKey) Annotate(a infer.Annotator) {
2323
2424// SetupKeyArgs represents the input arguments for creating a setup key.
2525type SetupKeyArgs struct {
26- Name string `pulumi:"name"`
27- Type string `pulumi:"type"` // "one-off" | "reusable"
28- ExpiresIn int `pulumi:"expiresIn"` // seconds
29- AutoGroups []string `pulumi:"autoGroups"`
30- UsageLimit int `pulumi:"usageLimit"` // 0 = unlimited
31- Ephemeral * bool `pulumi:"ephemeral,optional"`
32- AllowExtraDNSLabels * bool `pulumi:"allowExtraDnsLabels,optional"`
26+ Name string `pulumi:"name"`
27+ Type SetupKeyType `pulumi:"type"` // "one-off" | "reusable"
28+ ExpiresIn int `pulumi:"expiresIn"` // seconds
29+ AutoGroups []string `pulumi:"autoGroups"`
30+ UsageLimit int `pulumi:"usageLimit"` // 0 = unlimited
31+ Ephemeral * bool `pulumi:"ephemeral,optional"`
32+ AllowExtraDNSLabels * bool `pulumi:"allowExtraDnsLabels,optional"`
3333}
3434
3535// Annotate provides documentation for SetupKeyArgs fields.
3636func (a * SetupKeyArgs ) Annotate (annotator infer.Annotator ) {
37- annotator .Describe (& a .Name , "Setup key name." )
38- annotator .Describe (& a .Type , "Setup key type: 'one-off' or 'reusable'." )
39- annotator .Describe (& a .ExpiresIn , "Expiration time in seconds." )
40- annotator .Describe (& a .AutoGroups , "List of group IDs to auto-assign to peers." )
41- annotator .Describe (& a .UsageLimit , "Usage limit ( 0 = unlimited) ." )
42- annotator .Describe (& a .Ephemeral , "Whether peers registered with this key are ephemeral." )
43- annotator .Describe (& a .AllowExtraDNSLabels , "Allow extra DNS labels to be added to peers ." )
37+ annotator .Describe (& a .Name , "Setup key display name." )
38+ annotator .Describe (& a .Type , "Setup key type: 'one-off' (single use) or 'reusable'." )
39+ annotator .Describe (& a .ExpiresIn , "Time-to-live in seconds from creation; use 0 for no expiration if supported by the API ." )
40+ annotator .Describe (& a .AutoGroups , "Group IDs to auto-assign to peers created with this key ." )
41+ annotator .Describe (& a .UsageLimit , "Maximum uses for reusable keys; 0 = unlimited." )
42+ annotator .Describe (& a .Ephemeral , "Whether peers registered with this key are ephemeral (auto-expire) ." )
43+ annotator .Describe (& a .AllowExtraDNSLabels , "Allow peers to add extra DNS labels beyond the base peer name ." )
4444}
4545
4646// SetupKeyState represents the state/output of a setup key resource.
@@ -57,6 +57,24 @@ type SetupKeyState struct {
5757 UpdatedAt * string `pulumi:"updatedAt,optional"`
5858}
5959
60+ // SetupKeyType defines the kind of setup key accepted by NetBird.
61+ type SetupKeyType string
62+
63+ const (
64+ // SetupKeyTypeReusable creates a key that can be used multiple times.
65+ SetupKeyTypeReusable SetupKeyType = SetupKeyType ("reusable" )
66+ // SetupKeyTypeOneOff creates a key that can only be used once.
67+ SetupKeyTypeOneOff SetupKeyType = SetupKeyType ("one-off" )
68+ )
69+
70+ // Values describes the setup key type enum for schema generation.
71+ func (SetupKeyType ) Values () []infer.EnumValue [Type ] {
72+ return []infer.EnumValue [Type ]{
73+ {Name : "reusable" , Value : Type (SetupKeyTypeReusable ), Description : "Reusable setup key that supports multiple peers." },
74+ {Name : "one-off" , Value : Type (SetupKeyTypeOneOff ), Description : "One-off setup key that can be used only once." },
75+ }
76+ }
77+
6078// Create creates a new NetBird setup key.
6179func (* SetupKey ) Create (ctx context.Context , req infer.CreateRequest [SetupKeyArgs ]) (infer.CreateResponse [SetupKeyState ], error ) {
6280 p .GetLogger (ctx ).Debugf ("Create:SetupKey name=%s, type=%s" , req .Inputs .Name , req .Inputs .Type )
@@ -86,7 +104,7 @@ func (*SetupKey) Create(ctx context.Context, req infer.CreateRequest[SetupKeyArg
86104 // Use CreateSetupKeyRequest for creation
87105 createReq := nbapi.CreateSetupKeyRequest {
88106 Name : req .Inputs .Name ,
89- Type : req .Inputs .Type ,
107+ Type : string ( req .Inputs .Type ) ,
90108 ExpiresIn : req .Inputs .ExpiresIn ,
91109 AutoGroups : req .Inputs .AutoGroups ,
92110 UsageLimit : req .Inputs .UsageLimit ,
@@ -148,7 +166,7 @@ func (*SetupKey) Read(ctx context.Context, setupKeyID string, state SetupKeyStat
148166 p .GetLogger (ctx ).Debugf ("Read:SetupKeyAPI name=%s, id=%s" , setupKey .Name , setupKey .Id )
149167
150168 state .Name = setupKey .Name
151- state .Type = setupKey .Type
169+ state .Type = SetupKeyType ( setupKey .Type )
152170 state .AutoGroups = setupKey .AutoGroups
153171 state .UsageLimit = setupKey .UsageLimit
154172 ephemeral := setupKey .Ephemeral
0 commit comments