Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ type Instance struct {

MaintenancePolicy string `json:"maintenance_policy"`

// NOTE: Locks can only be used with v4beta.
Locks []LockType `json:"locks"`
}

Expand Down
8 changes: 0 additions & 8 deletions locks.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
)

// LockType represents the type of lock that can be applied to a resource
// NOTE: Locks can only be used with v4beta.
type LockType string

// LockType enums
Expand All @@ -15,7 +14,6 @@ const (
)

// LockedEntity represents the entity that is locked
// NOTE: Locks can only be used with v4beta.
type LockedEntity struct {
ID int `json:"id"`
Type EntityType `json:"type"`
Expand All @@ -24,42 +22,36 @@ type LockedEntity struct {
}

// Lock represents a resource lock
// NOTE: Locks can only be used with v4beta.
type Lock struct {
ID int `json:"id"`
LockType LockType `json:"lock_type"`
Entity LockedEntity `json:"entity"`
}

// LockCreateOptions fields are those accepted by CreateLock
// NOTE: Locks can only be used with v4beta.
type LockCreateOptions struct {
EntityType EntityType `json:"entity_type"`
EntityID int `json:"entity_id"`
LockType LockType `json:"lock_type"`
}

// ListLocks returns a paginated list of Locks
// NOTE: Locks can only be used with v4beta.
func (c *Client) ListLocks(ctx context.Context, opts *ListOptions) ([]Lock, error) {
return getPaginatedResults[Lock](ctx, c, "locks", opts)
}

// GetLock gets a single Lock with the provided ID
// NOTE: Locks can only be used with v4beta.
func (c *Client) GetLock(ctx context.Context, lockID int) (*Lock, error) {
e := formatAPIPath("locks/%d", lockID)
return doGETRequest[Lock](ctx, c, e)
}

// CreateLock creates a lock for a resource
// NOTE: Locks can only be used with v4beta.
func (c *Client) CreateLock(ctx context.Context, opts LockCreateOptions) (*Lock, error) {
return doPOSTRequest[Lock](ctx, c, "locks", opts)
}

// DeleteLock deletes a single Lock with the provided ID
// NOTE: Locks can only be used with v4beta.
func (c *Client) DeleteLock(ctx context.Context, lockID int) error {
e := formatAPIPath("locks/%d", lockID)
return doDELETERequest(ctx, c, e)
Expand Down
1 change: 0 additions & 1 deletion nodebalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ type NodeBalancer struct {

// An array of locks applied to this NodeBalancer for deletion protection.
// Locks prevent the NodeBalancer or its subresources from being deleted.
// NOTE: Locks can only be used with v4beta.
Locks []LockType `json:"locks"`

Created *time.Time `json:"-"`
Expand Down
Loading