mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-23 23:22:57 -06:00
6fe2703665
* Remove `make updatedeps` from Travis build. We'll follow up with more specific plans around dependency updating in subsequent PRs. * Update all `make` targets to set `GO15VENDOREXPERIMENT=1` and to filter out `/vendor/` from `./...` where appropriate. * Temporarily remove `vet` from the `make test` target until we can figure out how to get it to not vet `vendor/`. (Initial experimentation failed to yield the proper incantation.) Everything is pinned to current master, with the exception of: * Azure/azure-sdk-for-go which is pinned before the breaking change today * aws/aws-sdk-go which is pinned to the most recent tag The documentation still needs to be updated, which we can do in a follow up PR. The goal here is to unblock release.
101 lines
2.3 KiB
Go
101 lines
2.3 KiB
Go
package godo
|
|
|
|
import "fmt"
|
|
|
|
const (
|
|
actionsBasePath = "v2/actions"
|
|
|
|
// ActionInProgress is an in progress action status
|
|
ActionInProgress = "in-progress"
|
|
|
|
//ActionCompleted is a completed action status
|
|
ActionCompleted = "completed"
|
|
)
|
|
|
|
// ActionsService handles communction with action related methods of the
|
|
// DigitalOcean API: https://developers.digitalocean.com/documentation/v2#actions
|
|
type ActionsService interface {
|
|
List(*ListOptions) ([]Action, *Response, error)
|
|
Get(int) (*Action, *Response, error)
|
|
}
|
|
|
|
// ActionsServiceOp handles communition with the image action related methods of the
|
|
// DigitalOcean API.
|
|
type ActionsServiceOp struct {
|
|
client *Client
|
|
}
|
|
|
|
var _ ActionsService = &ActionsServiceOp{}
|
|
|
|
type actionsRoot struct {
|
|
Actions []Action `json:"actions"`
|
|
Links *Links `json:"links"`
|
|
}
|
|
|
|
type actionRoot struct {
|
|
Event Action `json:"action"`
|
|
}
|
|
|
|
// Action represents a DigitalOcean Action
|
|
type Action struct {
|
|
ID int `json:"id"`
|
|
Status string `json:"status"`
|
|
Type string `json:"type"`
|
|
StartedAt *Timestamp `json:"started_at"`
|
|
CompletedAt *Timestamp `json:"completed_at"`
|
|
ResourceID int `json:"resource_id"`
|
|
ResourceType string `json:"resource_type"`
|
|
Region *Region `json:"region,omitempty"`
|
|
RegionSlug string `json:"region_slug,omitempty"`
|
|
}
|
|
|
|
// List all actions
|
|
func (s *ActionsServiceOp) List(opt *ListOptions) ([]Action, *Response, error) {
|
|
path := actionsBasePath
|
|
path, err := addOptions(path, opt)
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
|
|
req, err := s.client.NewRequest("GET", path, nil)
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
|
|
root := new(actionsRoot)
|
|
resp, err := s.client.Do(req, root)
|
|
if err != nil {
|
|
return nil, resp, err
|
|
}
|
|
if l := root.Links; l != nil {
|
|
resp.Links = l
|
|
}
|
|
|
|
return root.Actions, resp, err
|
|
}
|
|
|
|
// Get an action by ID.
|
|
func (s *ActionsServiceOp) Get(id int) (*Action, *Response, error) {
|
|
if id < 1 {
|
|
return nil, nil, NewArgError("id", "cannot be less than 1")
|
|
}
|
|
|
|
path := fmt.Sprintf("%s/%d", actionsBasePath, id)
|
|
req, err := s.client.NewRequest("GET", path, nil)
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
|
|
root := new(actionRoot)
|
|
resp, err := s.client.Do(req, root)
|
|
if err != nil {
|
|
return nil, resp, err
|
|
}
|
|
|
|
return &root.Event, resp, err
|
|
}
|
|
|
|
func (a Action) String() string {
|
|
return Stringify(a)
|
|
}
|