Skip to content

Commit

Permalink
feat(API): add a new API endpoint to role-store, get principal keys
Browse files Browse the repository at this point in the history
  • Loading branch information
iljassh committed Apr 6, 2021
1 parent cd9ed56 commit 3408c4c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions api/rolestore/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,28 @@ type awsrolesResult struct {
Items []AWSRole `json:"items"`
}

type principalkeysResult struct {
Count int `json:"count"`
Items []PrincipalKey `json:"items"`
}

// New creates a new role-store client instance, using the
// argument SDK API client.
func New(api restapi.Connector) *RoleStore {
return &RoleStore{api: api}
}

// PrincipalKeys returns all principal keys
func (store *RoleStore) PrincipalKeys(id string) ([]PrincipalKey, error) {
result := principalkeysResult{}

_, err := store.api.
URL("/role-store/api/v1/roles/%s/principalkeys", url.PathEscape(id)).
Get(&result)

return result.Items, err
}

// UpdateRole update existing role
func (store *RoleStore) UpdateRole(id string, role *Role) error {
_, err := store.api.
Expand Down
6 changes: 6 additions & 0 deletions api/rolestore/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ type Params struct {
Refresh string `json:"refresh,omitempty"`
}

// PrincipalKey principal key definition
type PrincipalKey struct {
ID string `json:"id,omitempty"`
PublicKey string `json:"public_key,omitempty"`
}

// AWSRole aws role definition.
type AWSRole struct {
ID string `json:"id,omitempty"`
Expand Down

0 comments on commit 3408c4c

Please sign in to comment.