-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into proj/multicluster-obj
- Loading branch information
Showing
130 changed files
with
23,100 additions
and
16,050 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +0,0 @@ | ||
cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= | ||
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= | ||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= | ||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= | ||
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= | ||
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | ||
golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA= | ||
golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
package linodego | ||
|
||
import "context" | ||
|
||
// PlacementGroupAffinityType is an enum that determines the affinity policy | ||
// for Linodes in a placement group. | ||
type PlacementGroupAffinityType string | ||
|
||
const ( | ||
AffinityTypeAntiAffinityLocal PlacementGroupAffinityType = "anti_affinity:local" | ||
) | ||
|
||
// PlacementGroupMember represents a single Linode assigned to a | ||
// placement group. | ||
type PlacementGroupMember struct { | ||
LinodeID int `json:"linode_id"` | ||
IsCompliant bool `json:"is_compliant"` | ||
} | ||
|
||
// PlacementGroup represents a Linode placement group. | ||
// NOTE: Placement Groups may not currently be available to all users. | ||
type PlacementGroup struct { | ||
ID int `json:"id"` | ||
Label string `json:"label"` | ||
Region string `json:"region"` | ||
AffinityType PlacementGroupAffinityType `json:"affinity_type"` | ||
IsCompliant bool `json:"is_compliant"` | ||
IsStrict bool `json:"is_strict"` | ||
Members []PlacementGroupMember `json:"members"` | ||
} | ||
|
||
// PlacementGroupCreateOptions represents the options to use | ||
// when creating a placement group. | ||
type PlacementGroupCreateOptions struct { | ||
Label string `json:"label"` | ||
Region string `json:"region"` | ||
AffinityType PlacementGroupAffinityType `json:"affinity_type"` | ||
IsStrict bool `json:"is_strict"` | ||
} | ||
|
||
// PlacementGroupUpdateOptions represents the options to use | ||
// when updating a placement group. | ||
type PlacementGroupUpdateOptions struct { | ||
Label string `json:"label,omitempty"` | ||
} | ||
|
||
// PlacementGroupAssignOptions represents options used when | ||
// assigning Linodes to a placement group. | ||
type PlacementGroupAssignOptions struct { | ||
Linodes []int `json:"linodes"` | ||
CompliantOnly *bool `json:"compliant_only,omitempty"` | ||
} | ||
|
||
// PlacementGroupUnAssignOptions represents options used when | ||
// unassigning Linodes from a placement group. | ||
type PlacementGroupUnAssignOptions struct { | ||
Linodes []int `json:"linodes"` | ||
} | ||
|
||
// ListPlacementGroups lists placement groups under the current account | ||
// matching the given list options. | ||
// NOTE: Placement Groups may not currently be available to all users. | ||
func (c *Client) ListPlacementGroups( | ||
ctx context.Context, | ||
options *ListOptions, | ||
) ([]PlacementGroup, error) { | ||
return getPaginatedResults[PlacementGroup]( | ||
ctx, | ||
c, | ||
"placement/groups", | ||
options, | ||
) | ||
} | ||
|
||
// GetPlacementGroup gets a placement group with the specified ID. | ||
// NOTE: Placement Groups may not currently be available to all users. | ||
func (c *Client) GetPlacementGroup( | ||
ctx context.Context, | ||
id int, | ||
) (*PlacementGroup, error) { | ||
return doGETRequest[PlacementGroup]( | ||
ctx, | ||
c, | ||
formatAPIPath("placement/groups/%d", id), | ||
) | ||
} | ||
|
||
// CreatePlacementGroup creates a placement group with the specified options. | ||
// NOTE: Placement Groups may not currently be available to all users. | ||
func (c *Client) CreatePlacementGroup( | ||
ctx context.Context, | ||
options PlacementGroupCreateOptions, | ||
) (*PlacementGroup, error) { | ||
return doPOSTRequest[PlacementGroup]( | ||
ctx, | ||
c, | ||
"placement/groups", | ||
options, | ||
) | ||
} | ||
|
||
// UpdatePlacementGroup updates a placement group with the specified ID using the provided options. | ||
// NOTE: Placement Groups may not currently be available to all users. | ||
func (c *Client) UpdatePlacementGroup( | ||
ctx context.Context, | ||
id int, | ||
options PlacementGroupUpdateOptions, | ||
) (*PlacementGroup, error) { | ||
return doPUTRequest[PlacementGroup]( | ||
ctx, | ||
c, | ||
formatAPIPath("placement/groups/%d", id), | ||
options, | ||
) | ||
} | ||
|
||
// AssignPlacementGroupLinodes assigns the specified Linodes to the given | ||
// placement group. | ||
// NOTE: Placement Groups may not currently be available to all users. | ||
func (c *Client) AssignPlacementGroupLinodes( | ||
ctx context.Context, | ||
id int, | ||
options PlacementGroupAssignOptions, | ||
) (*PlacementGroup, error) { | ||
return doPOSTRequest[PlacementGroup]( | ||
ctx, | ||
c, | ||
formatAPIPath("placement/groups/%d/assign", id), | ||
options, | ||
) | ||
} | ||
|
||
// UnassignPlacementGroupLinodes un-assigns the specified Linodes from the given | ||
// placement group. | ||
// NOTE: Placement Groups may not currently be available to all users. | ||
func (c *Client) UnassignPlacementGroupLinodes( | ||
ctx context.Context, | ||
id int, | ||
options PlacementGroupUnAssignOptions, | ||
) (*PlacementGroup, error) { | ||
return doPOSTRequest[PlacementGroup]( | ||
ctx, | ||
c, | ||
formatAPIPath("placement/groups/%d/unassign", id), | ||
options, | ||
) | ||
} | ||
|
||
// DeletePlacementGroup deletes a placement group with the specified ID. | ||
// NOTE: Placement Groups may not currently be available to all users. | ||
func (c *Client) DeletePlacementGroup( | ||
ctx context.Context, | ||
id int, | ||
) error { | ||
return doDELETERequest( | ||
ctx, | ||
c, | ||
formatAPIPath("placement/groups/%d", id), | ||
) | ||
} |
Oops, something went wrong.