Skip to content

Commit

Permalink
add a new API endpoint, get host tags
Browse files Browse the repository at this point in the history
  • Loading branch information
iljassh committed Mar 19, 2021
1 parent bc8a8ea commit af4243c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions api/hoststore/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,35 @@ type hostResult struct {
Items []Host `json:"items"`
}

type tagsResult struct {
Count int `json:"count"`
Items []string `json:"items"`
}

// New creates a new host-store client instance
// See http://apispecs.ssh.com/#swagger-ui-4 for details about api
func New(api restapi.Connector) *HostStore {
return &HostStore{api: api}
}

// HostTags returns hosts tags
func (store *HostStore) HostTags(offset, limit, sortdir, query string) ([]string, error) {
result := tagsResult{}
filters := Params{
Offset: offset,
Limit: limit,
Sortdir: sortdir,
Query: query,
}

_, err := store.api.
URL("/host-store/api/v1/hosts/tags").
Query(&filters).
Get(&result)

return result.Items, err
}

// UpdateDeployStatus update host to be deployable or undeployable
func (store *HostStore) UpdateDeployStatus(id string, status bool) error {
deployStatus := Host{
Expand Down
1 change: 1 addition & 0 deletions api/hoststore/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type Params struct {
Sortdir string `json:"sortdir,omitempty"`
Sortkey string `json:"sortkey,omitempty"`
Filter string `json:"filter,omitempty"`
Query string `json:"query,omitempty"`
}

// Service specify the service available on target host
Expand Down

0 comments on commit af4243c

Please sign in to comment.