You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
decort-golang-sdk/pkg/cloudapi/computeci/list.go

54 lines
1.2 KiB

package computeci
import (
"context"
"encoding/json"
"net/http"
)
3 years ago
// Request struct for get list of computeci
type ListRequest struct {
2 years ago
// Find by name
// Required: false
Name string `url:"name,omitempty" json:"name,omitempty"`
// Find by computeci ID
// Required: false
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
// Find by drivers
// Find by computeci ID
Drivers []string `url:"drivers,omitempty" json:"drivers,omitempty"`
3 years ago
// If true list deleted instances as well
// Required: false
3 years ago
IncludeDeleted bool `url:"includeDeleted,omitempty" json:"includeDeleted,omitempty"`
3 years ago
// Page number
// Required: false
3 years ago
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
3 years ago
// Page size
// Required: false
3 years ago
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
}
3 years ago
// List gets list of computeci instances
2 years ago
func (c ComputeCI) List(ctx context.Context, req ListRequest) (*ListComputeCI, error) {
url := "/cloudapi/computeci/list"
3 years ago
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
3 years ago
list := ListComputeCI{}
err = json.Unmarshal(res, &list)
if err != nil {
return nil, err
}
2 years ago
return &list, nil
}