Skip to content

Commit

Permalink
Introduced attribute tenant_token to resource dynatrace_ag_token
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinhard-Pilz-Dynatrace committed Aug 8, 2023
1 parent aa5ccf6 commit 1cf86e4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions dynatrace/api/v2/activegatetokens/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ type TokenCreateResponse struct {
Token *string `json:"token,omitempty"`
}

type TenantTokenResponse struct {
TenantToken string `json:"tenantToken"`
}

type service struct {
credentials *settings.Credentials
}
Expand All @@ -50,6 +54,11 @@ func (me *service) Get(id string, v *activegatetokens.Settings) error {
if err = req.Finish(v); err != nil {
return err
}
var ttr TenantTokenResponse
req = client.Get("/api/v1/deployment/installer/agent/connectioninfo").Expect(200)
if err = req.Finish(&ttr); err == nil {
v.TenantToken = &ttr.TenantToken
}

return nil
}
Expand All @@ -76,6 +85,13 @@ func (me *service) Create(v *activegatetokens.Settings) (*api.Stub, error) {
}
v.ExpirationDate = response.ExpirationDate
v.Token = response.Token

var ttr TenantTokenResponse
req := client.Get("/api/v1/deployment/installer/agent/connectioninfo").Expect(200)
if err = req.Finish(&ttr); err == nil {
v.TenantToken = &ttr.TenantToken
}

return &api.Stub{ID: response.ID, Name: v.Name, Value: v}, nil
}

Expand Down
8 changes: 8 additions & 0 deletions dynatrace/api/v2/activegatetokens/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Settings struct {
ExpirationDate *string `json:"expirationDate,omitempty"`
SeedToken bool `json:"seedToken,omitempty"`
Token *string `json:"token,omitempty"`
TenantToken *string `json:"-"`
}

func (me *Settings) Schema() map[string]*schema.Schema {
Expand Down Expand Up @@ -39,6 +40,12 @@ func (me *Settings) Schema() map[string]*schema.Schema {
Sensitive: true,
Computed: true,
},
"tenant_token": {
Type: schema.TypeString,
Description: "The tenant token. This information isn't directly related to the Active Gate Token. It's included for convenience. You require the permission `InstallerDownload` for that attribute to get populated",
Sensitive: true,
Computed: true,
},
"seed": {
Type: schema.TypeBool,
Description: "The token is a seed token (true) or an individual token (false). We recommend the individual token option (false)",
Expand All @@ -53,6 +60,7 @@ func (me *Settings) MarshalHCL(properties hcl.Properties) error {
"type": me.Type,
"expiration_date": me.ExpirationDate,
"seed": me.SeedToken,
"tenant_token": me.TenantToken,
}); err != nil {
return err
}
Expand Down

0 comments on commit 1cf86e4

Please sign in to comment.