44 "context"
55 "fmt"
66 "net/url"
7- "time"
87)
98
109// Compile-time proof of interface implementation.
@@ -13,48 +12,23 @@ var _ AgentPoolTokens = (*agentPoolTokens)(nil)
1312// AgentPoolTokens describes all the access token related methods that the
1413// Scalr IACP API supports.
1514type AgentPoolTokens interface {
16- List (ctx context.Context , agentPoolID string , options AgentPoolTokenListOptions ) (* AgentPoolTokenList , error )
17- Create (ctx context.Context , agentPoolID string , options AgentPoolTokenCreateOptions ) (* AgentPoolToken , error )
15+ List (ctx context.Context , agentPoolID string , options AccessTokenListOptions ) (* AccessTokenList , error )
16+ Create (ctx context.Context , agentPoolID string , options AccessTokenCreateOptions ) (* AccessToken , error )
1817}
1918
2019// agentPoolTokens implements AgentPoolTokens.
2120type agentPoolTokens struct {
2221 client * Client
2322}
2423
25- // AgentPoolTokenList represents a list of agent pools.
26- type AgentPoolTokenList struct {
27- * Pagination
28- Items []* AgentPoolToken
29- }
30-
31- // AgentPoolToken represents a Scalr agent pool.
32- type AgentPoolToken struct {
33- ID string `jsonapi:"primary,access-tokens"`
34- CreatedAt time.Time `jsonapi:"attr,created-at,iso8601"`
35- Description string `jsonapi:"attr,description"`
36- Token string `jsonapi:"attr,token"`
37- }
38-
39- // AgentPoolTokenCreateOptions represents the options for creating a new AgentPoolToken.
40- type AgentPoolTokenListOptions struct {
41- ListOptions
42- }
43-
44- // AgentPoolTokenCreateOptions represents the options for creating a new AgentPoolToken.
45- type AgentPoolTokenCreateOptions struct {
46- ID string `jsonapi:"primary,access-tokens"`
47- Description * string `jsonapi:"attr,description,omitempty"`
48- }
49-
50- // List all the agent pools.
51- func (s * agentPoolTokens ) List (ctx context.Context , agentPoolID string , options AgentPoolTokenListOptions ) (* AgentPoolTokenList , error ) {
24+ // List all the agent pool's tokens.
25+ func (s * agentPoolTokens ) List (ctx context.Context , agentPoolID string , options AccessTokenListOptions ) (* AccessTokenList , error ) {
5226 req , err := s .client .newRequest ("GET" , fmt .Sprintf ("agent-pools/%s/access-tokens" , url .QueryEscape (agentPoolID )), & options )
5327 if err != nil {
5428 return nil , err
5529 }
5630
57- tl := & AgentPoolTokenList {}
31+ tl := & AccessTokenList {}
5832 err = s .client .do (ctx , req , tl )
5933 if err != nil {
6034 return nil , err
@@ -63,8 +37,8 @@ func (s *agentPoolTokens) List(ctx context.Context, agentPoolID string, options
6337 return tl , nil
6438}
6539
66- // Create is used to create a new AgentPoolToken .
67- func (s * agentPoolTokens ) Create (ctx context.Context , agentPoolID string , options AgentPoolTokenCreateOptions ) (* AgentPoolToken , error ) {
40+ // Create is used to create a new AccessToken for AgentPool .
41+ func (s * agentPoolTokens ) Create (ctx context.Context , agentPoolID string , options AccessTokenCreateOptions ) (* AccessToken , error ) {
6842
6943 // Make sure we don't send a user provided ID.
7044 options .ID = ""
@@ -78,7 +52,7 @@ func (s *agentPoolTokens) Create(ctx context.Context, agentPoolID string, option
7852 return nil , err
7953 }
8054
81- agentPoolToken := & AgentPoolToken {}
55+ agentPoolToken := & AccessToken {}
8256 err = s .client .do (ctx , req , agentPoolToken )
8357 if err != nil {
8458 return nil , err
0 commit comments