feat(api): Add RDP target attributes

This commit is contained in:
Andrew Gaffney authored and irenarindos committed 2025-09-02 15:13:15 -04:00
1 parent 0d15330ac4
commit f5cdf2a354
7 files changed
+288 -73

No files matched your search

+48
View File
@@ -173,6 +173,30 @@ func DefaultBrokeredCredentialSourceIds() Option {
}
}
func WithRdpTargetDefaultClientPort(inDefaultClientPort uint32) Option {
return func(o *options) {
raw, ok := o.postMap["attributes"]
if !ok {
raw = any(map[string]any{})
}
val := raw.(map[string]any)
val["default_client_port"] = inDefaultClientPort
o.postMap["attributes"] = val
}
}
func DefaultRdpTargetDefaultClientPort() Option {
return func(o *options) {
raw, ok := o.postMap["attributes"]
if !ok {
raw = any(map[string]any{})
}
val := raw.(map[string]any)
val["default_client_port"] = nil
o.postMap["attributes"] = val
}
}
func WithSshTargetDefaultClientPort(inDefaultClientPort uint32) Option {
return func(o *options) {
raw, ok := o.postMap["attributes"]
@@ -221,6 +245,30 @@ func DefaultTcpTargetDefaultClientPort() Option {
}
}
func WithRdpTargetDefaultPort(inDefaultPort uint32) Option {
return func(o *options) {
raw, ok := o.postMap["attributes"]
if !ok {
raw = any(map[string]any{})
}
val := raw.(map[string]any)
val["default_port"] = inDefaultPort
o.postMap["attributes"] = val
}
}
func DefaultRdpTargetDefaultPort() Option {
return func(o *options) {
raw, ok := o.postMap["attributes"]
if !ok {
raw = any(map[string]any{})
}
val := raw.(map[string]any)
val["default_port"] = nil
o.postMap["attributes"] = val
}
}
func WithSshTargetDefaultPort(inDefaultPort uint32) Option {
return func(o *options) {
raw, ok := o.postMap["attributes"]
+41
View File
@@ -0,0 +1,41 @@
// Code generated by "make api"; DO NOT EDIT.
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package targets
import (
"fmt"
"github.com/mitchellh/mapstructure"
)
type RdpTargetAttributes struct {
DefaultPort uint32 `json:"default_port,omitempty"`
DefaultClientPort uint32 `json:"default_client_port,omitempty"`
}
func AttributesMapToRdpTargetAttributes(in map[string]any) (*RdpTargetAttributes, error) {
if in == nil {
return nil, fmt.Errorf("nil input map")
}
var out RdpTargetAttributes
dec, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
Result: &out,
TagName: "json",
})
if err != nil {
return nil, fmt.Errorf("error creating mapstructure decoder: %w", err)
}
if err := dec.Decode(in); err != nil {
return nil, fmt.Errorf("error decoding: %w", err)
}
return &out, nil
}
func (pt *Target) GetRdpTargetAttributes() (*RdpTargetAttributes, error) {
if pt.Type != "rdp" {
return nil, fmt.Errorf("asked to fetch %s-type attributes but target is of type %s", "rdp", pt.Type)
}
return AttributesMapToRdpTargetAttributes(pt.Attributes)
}