Skip to content

Commit 8a454f7

Browse files
Adds CreatedBy to AgentToken (#1158)
* Adds CreatedBy to AgentToken * updated changelog --------- Co-authored-by: jpadrianoGo <[email protected]>
1 parent b5a8a2d commit 8a454f7

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Enhancements
44

5+
* Adds `CreatedBy` relation to `AgentToken` by @jpadrianoGo [#1149](https://github.com/hashicorp/go-tfe/pull/1149)
56
* Adds `Logs` method to `QueryRuns`, which is EXPERIMENTAL, SUBJECT TO CHANGE, and may not be available to all users by @brandonc [#1186](https://github.com/hashicorp/go-tfe/pull/1186)
67

78
# v1.90.0

agent_token.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ type AgentToken struct {
4444
Description string `jsonapi:"attr,description"`
4545
LastUsedAt time.Time `jsonapi:"attr,last-used-at,iso8601"`
4646
Token string `jsonapi:"attr,token"`
47+
48+
// Relations
49+
CreatedBy *User `jsonapi:"relation,created-by"`
4750
}
4851

4952
// AgentTokenList represents a list of agent tokens.

agent_token_integration_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,23 @@ func TestAgentTokensRead(t *testing.T) {
108108
})
109109
}
110110

111+
func TestAgentTokensReadCreatedBy(t *testing.T) {
112+
skipIfEnterprise(t)
113+
114+
client := testClient(t)
115+
ctx := context.Background()
116+
117+
apTest, apTestCleanup := createAgentPool(t, client, nil)
118+
defer apTestCleanup()
119+
120+
token, tokenTestCleanup := createAgentToken(t, client, apTest)
121+
defer tokenTestCleanup()
122+
123+
at, err := client.AgentTokens.Read(ctx, token.ID)
124+
require.NoError(t, err)
125+
require.NotNil(t, at.CreatedBy)
126+
}
127+
111128
func TestAgentTokensDelete(t *testing.T) {
112129
skipIfEnterprise(t)
113130

0 commit comments

Comments
 (0)