diff --git a/VERSION_OMICRON b/VERSION_OMICRON index 2dd5a0a..82d340d 100644 --- a/VERSION_OMICRON +++ b/VERSION_OMICRON @@ -1 +1 @@ -a4e9c7a +9163f85 diff --git a/oxide/paths.go b/oxide/paths.go index 90e4cd5..4bba920 100644 --- a/oxide/paths.go +++ b/oxide/paths.go @@ -1437,7 +1437,7 @@ func (c *Client) DiskListAllPages(ctx context.Context, params DiskListParams) ([ return allPages, nil } -// DiskCreate: Create a disk +// DiskCreate: Create disk func (c *Client) DiskCreate(ctx context.Context, params DiskCreateParams) (*Disk, error) { if err := params.Validate(); err != nil { return nil, err @@ -1736,10 +1736,10 @@ func (c *Client) DiskFinalizeImport(ctx context.Context, params DiskFinalizeImpo return nil } -// FloatingIpList: List floating IPs +// ExternalSubnetList: List external subnets in a project // -// To iterate over all pages, use the `FloatingIpListAllPages` method, instead. -func (c *Client) FloatingIpList(ctx context.Context, params FloatingIpListParams) (*FloatingIpResultsPage, error) { +// To iterate over all pages, use the `ExternalSubnetListAllPages` method, instead. +func (c *Client) ExternalSubnetList(ctx context.Context, params ExternalSubnetListParams) (*ExternalSubnetResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -1748,7 +1748,7 @@ func (c *Client) FloatingIpList(ctx context.Context, params FloatingIpListParams ctx, nil, "GET", - resolveRelative(c.host, "/v1/floating-ips"), + resolveRelative(c.host, "/v1/external-subnets"), map[string]string{}, map[string]string{ "limit": PointerIntToStr(params.Limit), @@ -1778,7 +1778,7 @@ func (c *Client) FloatingIpList(ctx context.Context, params FloatingIpListParams return nil, errors.New("request returned an empty body in the response") } - var body FloatingIpResultsPage + var body ExternalSubnetResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -1787,19 +1787,19 @@ func (c *Client) FloatingIpList(ctx context.Context, params FloatingIpListParams return &body, nil } -// FloatingIpListAllPages: List floating IPs +// ExternalSubnetListAllPages: List external subnets in a project // -// This method is a wrapper around the `FloatingIpList` method. +// This method is a wrapper around the `ExternalSubnetList` method. // This method returns all the pages at once. -func (c *Client) FloatingIpListAllPages(ctx context.Context, params FloatingIpListParams) ([]FloatingIp, error) { +func (c *Client) ExternalSubnetListAllPages(ctx context.Context, params ExternalSubnetListParams) ([]ExternalSubnet, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []FloatingIp + var allPages []ExternalSubnet params.PageToken = "" params.Limit = NewPointer(100) for { - page, err := c.FloatingIpList(ctx, params) + page, err := c.ExternalSubnetList(ctx, params) if err != nil { return nil, err } @@ -1813,8 +1813,8 @@ func (c *Client) FloatingIpListAllPages(ctx context.Context, params FloatingIpLi return allPages, nil } -// FloatingIpCreate: Create floating IP -func (c *Client) FloatingIpCreate(ctx context.Context, params FloatingIpCreateParams) (*FloatingIp, error) { +// ExternalSubnetCreate: Create an external subnet +func (c *Client) ExternalSubnetCreate(ctx context.Context, params ExternalSubnetCreateParams) (*ExternalSubnet, error) { if err := params.Validate(); err != nil { return nil, err } @@ -1829,7 +1829,7 @@ func (c *Client) FloatingIpCreate(ctx context.Context, params FloatingIpCreatePa ctx, b, "POST", - resolveRelative(c.host, "/v1/floating-ips"), + resolveRelative(c.host, "/v1/external-subnets"), map[string]string{}, map[string]string{ "project": string(params.Project), @@ -1856,7 +1856,7 @@ func (c *Client) FloatingIpCreate(ctx context.Context, params FloatingIpCreatePa return nil, errors.New("request returned an empty body in the response") } - var body FloatingIp + var body ExternalSubnet if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -1865,8 +1865,8 @@ func (c *Client) FloatingIpCreate(ctx context.Context, params FloatingIpCreatePa return &body, nil } -// FloatingIpView: Fetch floating IP -func (c *Client) FloatingIpView(ctx context.Context, params FloatingIpViewParams) (*FloatingIp, error) { +// ExternalSubnetView: Fetch an external subnet +func (c *Client) ExternalSubnetView(ctx context.Context, params ExternalSubnetViewParams) (*ExternalSubnet, error) { if err := params.Validate(); err != nil { return nil, err } @@ -1875,9 +1875,9 @@ func (c *Client) FloatingIpView(ctx context.Context, params FloatingIpViewParams ctx, nil, "GET", - resolveRelative(c.host, "/v1/floating-ips/{{.floating_ip}}"), + resolveRelative(c.host, "/v1/external-subnets/{{.external_subnet}}"), map[string]string{ - "floating_ip": string(params.FloatingIp), + "external_subnet": string(params.ExternalSubnet), }, map[string]string{ "project": string(params.Project), @@ -1904,7 +1904,7 @@ func (c *Client) FloatingIpView(ctx context.Context, params FloatingIpViewParams return nil, errors.New("request returned an empty body in the response") } - var body FloatingIp + var body ExternalSubnet if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -1913,8 +1913,8 @@ func (c *Client) FloatingIpView(ctx context.Context, params FloatingIpViewParams return &body, nil } -// FloatingIpUpdate: Update floating IP -func (c *Client) FloatingIpUpdate(ctx context.Context, params FloatingIpUpdateParams) (*FloatingIp, error) { +// ExternalSubnetUpdate: Update an external subnet +func (c *Client) ExternalSubnetUpdate(ctx context.Context, params ExternalSubnetUpdateParams) (*ExternalSubnet, error) { if err := params.Validate(); err != nil { return nil, err } @@ -1929,9 +1929,9 @@ func (c *Client) FloatingIpUpdate(ctx context.Context, params FloatingIpUpdatePa ctx, b, "PUT", - resolveRelative(c.host, "/v1/floating-ips/{{.floating_ip}}"), + resolveRelative(c.host, "/v1/external-subnets/{{.external_subnet}}"), map[string]string{ - "floating_ip": string(params.FloatingIp), + "external_subnet": string(params.ExternalSubnet), }, map[string]string{ "project": string(params.Project), @@ -1958,7 +1958,7 @@ func (c *Client) FloatingIpUpdate(ctx context.Context, params FloatingIpUpdatePa return nil, errors.New("request returned an empty body in the response") } - var body FloatingIp + var body ExternalSubnet if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -1967,8 +1967,8 @@ func (c *Client) FloatingIpUpdate(ctx context.Context, params FloatingIpUpdatePa return &body, nil } -// FloatingIpDelete: Delete floating IP -func (c *Client) FloatingIpDelete(ctx context.Context, params FloatingIpDeleteParams) error { +// ExternalSubnetDelete: Delete an external subnet +func (c *Client) ExternalSubnetDelete(ctx context.Context, params ExternalSubnetDeleteParams) error { if err := params.Validate(); err != nil { return err } @@ -1977,9 +1977,9 @@ func (c *Client) FloatingIpDelete(ctx context.Context, params FloatingIpDeletePa ctx, nil, "DELETE", - resolveRelative(c.host, "/v1/floating-ips/{{.floating_ip}}"), + resolveRelative(c.host, "/v1/external-subnets/{{.external_subnet}}"), map[string]string{ - "floating_ip": string(params.FloatingIp), + "external_subnet": string(params.ExternalSubnet), }, map[string]string{ "project": string(params.Project), @@ -2004,9 +2004,10 @@ func (c *Client) FloatingIpDelete(ctx context.Context, params FloatingIpDeletePa return nil } -// FloatingIpAttach: Attach floating IP -// Attach floating IP to an instance or other resource. -func (c *Client) FloatingIpAttach(ctx context.Context, params FloatingIpAttachParams) (*FloatingIp, error) { +// ExternalSubnetAttach: Attach an external subnet to an instance +// Begins an asynchronous attach operation. Returns the subnet with `instance_id` set to the target instance. The +// attach completes asynchronously; poll the subnet to check completion. +func (c *Client) ExternalSubnetAttach(ctx context.Context, params ExternalSubnetAttachParams) (*ExternalSubnet, error) { if err := params.Validate(); err != nil { return nil, err } @@ -2021,9 +2022,9 @@ func (c *Client) FloatingIpAttach(ctx context.Context, params FloatingIpAttachPa ctx, b, "POST", - resolveRelative(c.host, "/v1/floating-ips/{{.floating_ip}}/attach"), + resolveRelative(c.host, "/v1/external-subnets/{{.external_subnet}}/attach"), map[string]string{ - "floating_ip": string(params.FloatingIp), + "external_subnet": string(params.ExternalSubnet), }, map[string]string{ "project": string(params.Project), @@ -2050,7 +2051,7 @@ func (c *Client) FloatingIpAttach(ctx context.Context, params FloatingIpAttachPa return nil, errors.New("request returned an empty body in the response") } - var body FloatingIp + var body ExternalSubnet if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -2059,8 +2060,9 @@ func (c *Client) FloatingIpAttach(ctx context.Context, params FloatingIpAttachPa return &body, nil } -// FloatingIpDetach: Detach floating IP -func (c *Client) FloatingIpDetach(ctx context.Context, params FloatingIpDetachParams) (*FloatingIp, error) { +// ExternalSubnetDetach: Detach an external subnet from an instance +// Begins an asynchronous detach operation. Returns the subnet with `instance_id` cleared. The detach completes asynchronously. +func (c *Client) ExternalSubnetDetach(ctx context.Context, params ExternalSubnetDetachParams) (*ExternalSubnet, error) { if err := params.Validate(); err != nil { return nil, err } @@ -2069,9 +2071,9 @@ func (c *Client) FloatingIpDetach(ctx context.Context, params FloatingIpDetachPa ctx, nil, "POST", - resolveRelative(c.host, "/v1/floating-ips/{{.floating_ip}}/detach"), + resolveRelative(c.host, "/v1/external-subnets/{{.external_subnet}}/detach"), map[string]string{ - "floating_ip": string(params.FloatingIp), + "external_subnet": string(params.ExternalSubnet), }, map[string]string{ "project": string(params.Project), @@ -2098,7 +2100,7 @@ func (c *Client) FloatingIpDetach(ctx context.Context, params FloatingIpDetachPa return nil, errors.New("request returned an empty body in the response") } - var body FloatingIp + var body ExternalSubnet if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -2107,10 +2109,10 @@ func (c *Client) FloatingIpDetach(ctx context.Context, params FloatingIpDetachPa return &body, nil } -// GroupList: List groups +// FloatingIpList: List floating IPs // -// To iterate over all pages, use the `GroupListAllPages` method, instead. -func (c *Client) GroupList(ctx context.Context, params GroupListParams) (*GroupResultsPage, error) { +// To iterate over all pages, use the `FloatingIpListAllPages` method, instead. +func (c *Client) FloatingIpList(ctx context.Context, params FloatingIpListParams) (*FloatingIpResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -2119,11 +2121,12 @@ func (c *Client) GroupList(ctx context.Context, params GroupListParams) (*GroupR ctx, nil, "GET", - resolveRelative(c.host, "/v1/groups"), + resolveRelative(c.host, "/v1/floating-ips"), map[string]string{}, map[string]string{ "limit": PointerIntToStr(params.Limit), "page_token": params.PageToken, + "project": string(params.Project), "sort_by": string(params.SortBy), }, ) @@ -2148,7 +2151,7 @@ func (c *Client) GroupList(ctx context.Context, params GroupListParams) (*GroupR return nil, errors.New("request returned an empty body in the response") } - var body GroupResultsPage + var body FloatingIpResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -2157,19 +2160,19 @@ func (c *Client) GroupList(ctx context.Context, params GroupListParams) (*GroupR return &body, nil } -// GroupListAllPages: List groups +// FloatingIpListAllPages: List floating IPs // -// This method is a wrapper around the `GroupList` method. +// This method is a wrapper around the `FloatingIpList` method. // This method returns all the pages at once. -func (c *Client) GroupListAllPages(ctx context.Context, params GroupListParams) ([]Group, error) { +func (c *Client) FloatingIpListAllPages(ctx context.Context, params FloatingIpListParams) ([]FloatingIp, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []Group + var allPages []FloatingIp params.PageToken = "" params.Limit = NewPointer(100) for { - page, err := c.GroupList(ctx, params) + page, err := c.FloatingIpList(ctx, params) if err != nil { return nil, err } @@ -2183,21 +2186,29 @@ func (c *Client) GroupListAllPages(ctx context.Context, params GroupListParams) return allPages, nil } -// GroupView: Fetch group -func (c *Client) GroupView(ctx context.Context, params GroupViewParams) (*Group, error) { +// FloatingIpCreate: Create a floating IP +// A specific IP address can be reserved, or an IP can be auto-allocated from a specific pool or the silo's default +// pool. +func (c *Client) FloatingIpCreate(ctx context.Context, params FloatingIpCreateParams) (*FloatingIp, error) { if err := params.Validate(); err != nil { return nil, err } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + // Create the request req, err := c.buildRequest( ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/groups/{{.group_id}}"), + b, + "POST", + resolveRelative(c.host, "/v1/floating-ips"), + map[string]string{}, map[string]string{ - "group_id": params.GroupId, + "project": string(params.Project), }, - map[string]string{}, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -2220,7 +2231,7 @@ func (c *Client) GroupView(ctx context.Context, params GroupViewParams) (*Group, return nil, errors.New("request returned an empty body in the response") } - var body Group + var body FloatingIp if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -2229,12 +2240,8 @@ func (c *Client) GroupView(ctx context.Context, params GroupViewParams) (*Group, return &body, nil } -// ImageList: List images -// List images which are global or scoped to the specified project. The images are returned sorted by creation date, -// with the most recent images appearing first. -// -// To iterate over all pages, use the `ImageListAllPages` method, instead. -func (c *Client) ImageList(ctx context.Context, params ImageListParams) (*ImageResultsPage, error) { +// FloatingIpView: Fetch floating IP +func (c *Client) FloatingIpView(ctx context.Context, params FloatingIpViewParams) (*FloatingIp, error) { if err := params.Validate(); err != nil { return nil, err } @@ -2243,13 +2250,12 @@ func (c *Client) ImageList(ctx context.Context, params ImageListParams) (*ImageR ctx, nil, "GET", - resolveRelative(c.host, "/v1/images"), - map[string]string{}, + resolveRelative(c.host, "/v1/floating-ips/{{.floating_ip}}"), map[string]string{ - "limit": PointerIntToStr(params.Limit), - "page_token": params.PageToken, - "project": string(params.Project), - "sort_by": string(params.SortBy), + "floating_ip": string(params.FloatingIp), + }, + map[string]string{ + "project": string(params.Project), }, ) if err != nil { @@ -2273,7 +2279,7 @@ func (c *Client) ImageList(ctx context.Context, params ImageListParams) (*ImageR return nil, errors.New("request returned an empty body in the response") } - var body ImageResultsPage + var body FloatingIp if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -2282,37 +2288,8 @@ func (c *Client) ImageList(ctx context.Context, params ImageListParams) (*ImageR return &body, nil } -// ImageListAllPages: List images -// List images which are global or scoped to the specified project. The images are returned sorted by creation date, -// with the most recent images appearing first. -// -// This method is a wrapper around the `ImageList` method. -// This method returns all the pages at once. -func (c *Client) ImageListAllPages(ctx context.Context, params ImageListParams) ([]Image, error) { - if err := params.Validate(); err != nil { - return nil, err - } - var allPages []Image - params.PageToken = "" - params.Limit = NewPointer(100) - for { - page, err := c.ImageList(ctx, params) - if err != nil { - return nil, err - } - allPages = append(allPages, page.Items...) - if page.NextPage == "" || page.NextPage == params.PageToken { - break - } - params.PageToken = page.NextPage - } - - return allPages, nil -} - -// ImageCreate: Create image -// Create a new image in a project. -func (c *Client) ImageCreate(ctx context.Context, params ImageCreateParams) (*Image, error) { +// FloatingIpUpdate: Update floating IP +func (c *Client) FloatingIpUpdate(ctx context.Context, params FloatingIpUpdateParams) (*FloatingIp, error) { if err := params.Validate(); err != nil { return nil, err } @@ -2326,57 +2303,10 @@ func (c *Client) ImageCreate(ctx context.Context, params ImageCreateParams) (*Im req, err := c.buildRequest( ctx, b, - "POST", - resolveRelative(c.host, "/v1/images"), - map[string]string{}, - map[string]string{ - "project": string(params.Project), - }, - ) - if err != nil { - return nil, fmt.Errorf("error building request: %v", err) - } - - // Send the request. - resp, err := c.client.Do(req) - if err != nil { - return nil, fmt.Errorf("error sending request: %v", err) - } - defer resp.Body.Close() - - // Create and return an HTTPError when an error response code is received. - if err := NewHTTPError(resp); err != nil { - return nil, err - } - - // Decode the body from the response. - if resp.Body == nil { - return nil, errors.New("request returned an empty body in the response") - } - - var body Image - if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { - return nil, fmt.Errorf("error decoding response body: %v", err) - } - - // Return the response. - return &body, nil -} - -// ImageView: Fetch image -// Fetch the details for a specific image in a project. -func (c *Client) ImageView(ctx context.Context, params ImageViewParams) (*Image, error) { - if err := params.Validate(); err != nil { - return nil, err - } - // Create the request - req, err := c.buildRequest( - ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/images/{{.image}}"), + "PUT", + resolveRelative(c.host, "/v1/floating-ips/{{.floating_ip}}"), map[string]string{ - "image": string(params.Image), + "floating_ip": string(params.FloatingIp), }, map[string]string{ "project": string(params.Project), @@ -2403,7 +2333,7 @@ func (c *Client) ImageView(ctx context.Context, params ImageViewParams) (*Image, return nil, errors.New("request returned an empty body in the response") } - var body Image + var body FloatingIp if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -2412,10 +2342,8 @@ func (c *Client) ImageView(ctx context.Context, params ImageViewParams) (*Image, return &body, nil } -// ImageDelete: Delete image -// Permanently delete an image from a project. This operation cannot be undone. Any instances in the project using -// the image will continue to run, however new instances can not be created with this image. -func (c *Client) ImageDelete(ctx context.Context, params ImageDeleteParams) error { +// FloatingIpDelete: Delete floating IP +func (c *Client) FloatingIpDelete(ctx context.Context, params FloatingIpDeleteParams) error { if err := params.Validate(); err != nil { return err } @@ -2424,9 +2352,9 @@ func (c *Client) ImageDelete(ctx context.Context, params ImageDeleteParams) erro ctx, nil, "DELETE", - resolveRelative(c.host, "/v1/images/{{.image}}"), + resolveRelative(c.host, "/v1/floating-ips/{{.floating_ip}}"), map[string]string{ - "image": string(params.Image), + "floating_ip": string(params.FloatingIp), }, map[string]string{ "project": string(params.Project), @@ -2451,20 +2379,26 @@ func (c *Client) ImageDelete(ctx context.Context, params ImageDeleteParams) erro return nil } -// ImageDemote: Demote silo image -// Demote silo image to be visible only to a specified project -func (c *Client) ImageDemote(ctx context.Context, params ImageDemoteParams) (*Image, error) { +// FloatingIpAttach: Attach floating IP +// Attach floating IP to an instance or other resource. +func (c *Client) FloatingIpAttach(ctx context.Context, params FloatingIpAttachParams) (*FloatingIp, error) { if err := params.Validate(); err != nil { return nil, err } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + // Create the request req, err := c.buildRequest( ctx, - nil, + b, "POST", - resolveRelative(c.host, "/v1/images/{{.image}}/demote"), + resolveRelative(c.host, "/v1/floating-ips/{{.floating_ip}}/attach"), map[string]string{ - "image": string(params.Image), + "floating_ip": string(params.FloatingIp), }, map[string]string{ "project": string(params.Project), @@ -2491,7 +2425,7 @@ func (c *Client) ImageDemote(ctx context.Context, params ImageDemoteParams) (*Im return nil, errors.New("request returned an empty body in the response") } - var body Image + var body FloatingIp if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -2500,9 +2434,8 @@ func (c *Client) ImageDemote(ctx context.Context, params ImageDemoteParams) (*Im return &body, nil } -// ImagePromote: Promote project image -// Promote project image to be visible to all projects in the silo -func (c *Client) ImagePromote(ctx context.Context, params ImagePromoteParams) (*Image, error) { +// FloatingIpDetach: Detach floating IP +func (c *Client) FloatingIpDetach(ctx context.Context, params FloatingIpDetachParams) (*FloatingIp, error) { if err := params.Validate(); err != nil { return nil, err } @@ -2511,9 +2444,9 @@ func (c *Client) ImagePromote(ctx context.Context, params ImagePromoteParams) (* ctx, nil, "POST", - resolveRelative(c.host, "/v1/images/{{.image}}/promote"), + resolveRelative(c.host, "/v1/floating-ips/{{.floating_ip}}/detach"), map[string]string{ - "image": string(params.Image), + "floating_ip": string(params.FloatingIp), }, map[string]string{ "project": string(params.Project), @@ -2540,7 +2473,7 @@ func (c *Client) ImagePromote(ctx context.Context, params ImagePromoteParams) (* return nil, errors.New("request returned an empty body in the response") } - var body Image + var body FloatingIp if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -2549,10 +2482,10 @@ func (c *Client) ImagePromote(ctx context.Context, params ImagePromoteParams) (* return &body, nil } -// InstanceList: List instances +// GroupList: List groups // -// To iterate over all pages, use the `InstanceListAllPages` method, instead. -func (c *Client) InstanceList(ctx context.Context, params InstanceListParams) (*InstanceResultsPage, error) { +// To iterate over all pages, use the `GroupListAllPages` method, instead. +func (c *Client) GroupList(ctx context.Context, params GroupListParams) (*GroupResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -2561,12 +2494,11 @@ func (c *Client) InstanceList(ctx context.Context, params InstanceListParams) (* ctx, nil, "GET", - resolveRelative(c.host, "/v1/instances"), + resolveRelative(c.host, "/v1/groups"), map[string]string{}, map[string]string{ "limit": PointerIntToStr(params.Limit), "page_token": params.PageToken, - "project": string(params.Project), "sort_by": string(params.SortBy), }, ) @@ -2591,7 +2523,7 @@ func (c *Client) InstanceList(ctx context.Context, params InstanceListParams) (* return nil, errors.New("request returned an empty body in the response") } - var body InstanceResultsPage + var body GroupResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -2600,19 +2532,19 @@ func (c *Client) InstanceList(ctx context.Context, params InstanceListParams) (* return &body, nil } -// InstanceListAllPages: List instances +// GroupListAllPages: List groups // -// This method is a wrapper around the `InstanceList` method. +// This method is a wrapper around the `GroupList` method. // This method returns all the pages at once. -func (c *Client) InstanceListAllPages(ctx context.Context, params InstanceListParams) ([]Instance, error) { +func (c *Client) GroupListAllPages(ctx context.Context, params GroupListParams) ([]Group, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []Instance + var allPages []Group params.PageToken = "" params.Limit = NewPointer(100) for { - page, err := c.InstanceList(ctx, params) + page, err := c.GroupList(ctx, params) if err != nil { return nil, err } @@ -2626,27 +2558,21 @@ func (c *Client) InstanceListAllPages(ctx context.Context, params InstanceListPa return allPages, nil } -// InstanceCreate: Create instance -func (c *Client) InstanceCreate(ctx context.Context, params InstanceCreateParams) (*Instance, error) { +// GroupView: Fetch group +func (c *Client) GroupView(ctx context.Context, params GroupViewParams) (*Group, error) { if err := params.Validate(); err != nil { return nil, err } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return nil, fmt.Errorf("encoding json body request failed: %v", err) - } - // Create the request req, err := c.buildRequest( ctx, - b, - "POST", - resolveRelative(c.host, "/v1/instances"), - map[string]string{}, + nil, + "GET", + resolveRelative(c.host, "/v1/groups/{{.group_id}}"), map[string]string{ - "project": string(params.Project), + "group_id": params.GroupId, }, + map[string]string{}, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -2669,7 +2595,7 @@ func (c *Client) InstanceCreate(ctx context.Context, params InstanceCreateParams return nil, errors.New("request returned an empty body in the response") } - var body Instance + var body Group if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -2678,8 +2604,12 @@ func (c *Client) InstanceCreate(ctx context.Context, params InstanceCreateParams return &body, nil } -// InstanceView: Fetch instance -func (c *Client) InstanceView(ctx context.Context, params InstanceViewParams) (*Instance, error) { +// ImageList: List images +// List images which are global or scoped to the specified project. The images are returned sorted by creation date, +// with the most recent images appearing first. +// +// To iterate over all pages, use the `ImageListAllPages` method, instead. +func (c *Client) ImageList(ctx context.Context, params ImageListParams) (*ImageResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -2688,12 +2618,13 @@ func (c *Client) InstanceView(ctx context.Context, params InstanceViewParams) (* ctx, nil, "GET", - resolveRelative(c.host, "/v1/instances/{{.instance}}"), - map[string]string{ - "instance": string(params.Instance), - }, + resolveRelative(c.host, "/v1/images"), + map[string]string{}, map[string]string{ - "project": string(params.Project), + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + "project": string(params.Project), + "sort_by": string(params.SortBy), }, ) if err != nil { @@ -2717,7 +2648,7 @@ func (c *Client) InstanceView(ctx context.Context, params InstanceViewParams) (* return nil, errors.New("request returned an empty body in the response") } - var body Instance + var body ImageResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -2726,8 +2657,37 @@ func (c *Client) InstanceView(ctx context.Context, params InstanceViewParams) (* return &body, nil } -// InstanceUpdate: Update instance -func (c *Client) InstanceUpdate(ctx context.Context, params InstanceUpdateParams) (*Instance, error) { +// ImageListAllPages: List images +// List images which are global or scoped to the specified project. The images are returned sorted by creation date, +// with the most recent images appearing first. +// +// This method is a wrapper around the `ImageList` method. +// This method returns all the pages at once. +func (c *Client) ImageListAllPages(ctx context.Context, params ImageListParams) ([]Image, error) { + if err := params.Validate(); err != nil { + return nil, err + } + var allPages []Image + params.PageToken = "" + params.Limit = NewPointer(100) + for { + page, err := c.ImageList(ctx, params) + if err != nil { + return nil, err + } + allPages = append(allPages, page.Items...) + if page.NextPage == "" || page.NextPage == params.PageToken { + break + } + params.PageToken = page.NextPage + } + + return allPages, nil +} + +// ImageCreate: Create image +// Create a new image in a project. +func (c *Client) ImageCreate(ctx context.Context, params ImageCreateParams) (*Image, error) { if err := params.Validate(); err != nil { return nil, err } @@ -2741,10 +2701,57 @@ func (c *Client) InstanceUpdate(ctx context.Context, params InstanceUpdateParams req, err := c.buildRequest( ctx, b, - "PUT", - resolveRelative(c.host, "/v1/instances/{{.instance}}"), + "POST", + resolveRelative(c.host, "/v1/images"), + map[string]string{}, map[string]string{ - "instance": string(params.Instance), + "project": string(params.Project), + }, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body Image + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// ImageView: Fetch image +// Fetch the details for a specific image in a project. +func (c *Client) ImageView(ctx context.Context, params ImageViewParams) (*Image, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "GET", + resolveRelative(c.host, "/v1/images/{{.image}}"), + map[string]string{ + "image": string(params.Image), }, map[string]string{ "project": string(params.Project), @@ -2771,7 +2778,7 @@ func (c *Client) InstanceUpdate(ctx context.Context, params InstanceUpdateParams return nil, errors.New("request returned an empty body in the response") } - var body Instance + var body Image if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -2780,8 +2787,10 @@ func (c *Client) InstanceUpdate(ctx context.Context, params InstanceUpdateParams return &body, nil } -// InstanceDelete: Delete instance -func (c *Client) InstanceDelete(ctx context.Context, params InstanceDeleteParams) error { +// ImageDelete: Delete image +// Permanently delete an image from a project. This operation cannot be undone. Any instances in the project using +// the image will continue to run, however new instances can not be created with this image. +func (c *Client) ImageDelete(ctx context.Context, params ImageDeleteParams) error { if err := params.Validate(); err != nil { return err } @@ -2790,9 +2799,9 @@ func (c *Client) InstanceDelete(ctx context.Context, params InstanceDeleteParams ctx, nil, "DELETE", - resolveRelative(c.host, "/v1/instances/{{.instance}}"), + resolveRelative(c.host, "/v1/images/{{.image}}"), map[string]string{ - "instance": string(params.Instance), + "image": string(params.Image), }, map[string]string{ "project": string(params.Project), @@ -2817,10 +2826,9 @@ func (c *Client) InstanceDelete(ctx context.Context, params InstanceDeleteParams return nil } -// InstanceAntiAffinityGroupList: List anti-affinity groups containing instance -// -// To iterate over all pages, use the `InstanceAntiAffinityGroupListAllPages` method, instead. -func (c *Client) InstanceAntiAffinityGroupList(ctx context.Context, params InstanceAntiAffinityGroupListParams) (*AntiAffinityGroupResultsPage, error) { +// ImageDemote: Demote silo image +// Demote silo image to be visible only to a specified project +func (c *Client) ImageDemote(ctx context.Context, params ImageDemoteParams) (*Image, error) { if err := params.Validate(); err != nil { return nil, err } @@ -2828,16 +2836,13 @@ func (c *Client) InstanceAntiAffinityGroupList(ctx context.Context, params Insta req, err := c.buildRequest( ctx, nil, - "GET", - resolveRelative(c.host, "/v1/instances/{{.instance}}/anti-affinity-groups"), + "POST", + resolveRelative(c.host, "/v1/images/{{.image}}/demote"), map[string]string{ - "instance": string(params.Instance), + "image": string(params.Image), }, map[string]string{ - "limit": PointerIntToStr(params.Limit), - "page_token": params.PageToken, - "project": string(params.Project), - "sort_by": string(params.SortBy), + "project": string(params.Project), }, ) if err != nil { @@ -2861,7 +2866,7 @@ func (c *Client) InstanceAntiAffinityGroupList(ctx context.Context, params Insta return nil, errors.New("request returned an empty body in the response") } - var body AntiAffinityGroupResultsPage + var body Image if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -2870,36 +2875,59 @@ func (c *Client) InstanceAntiAffinityGroupList(ctx context.Context, params Insta return &body, nil } -// InstanceAntiAffinityGroupListAllPages: List anti-affinity groups containing instance -// -// This method is a wrapper around the `InstanceAntiAffinityGroupList` method. -// This method returns all the pages at once. -func (c *Client) InstanceAntiAffinityGroupListAllPages(ctx context.Context, params InstanceAntiAffinityGroupListParams) ([]AntiAffinityGroup, error) { +// ImagePromote: Promote project image +// Promote project image to be visible to all projects in the silo +func (c *Client) ImagePromote(ctx context.Context, params ImagePromoteParams) (*Image, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []AntiAffinityGroup - params.PageToken = "" - params.Limit = NewPointer(100) - for { - page, err := c.InstanceAntiAffinityGroupList(ctx, params) - if err != nil { - return nil, err - } - allPages = append(allPages, page.Items...) - if page.NextPage == "" || page.NextPage == params.PageToken { - break - } - params.PageToken = page.NextPage + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "POST", + resolveRelative(c.host, "/v1/images/{{.image}}/promote"), + map[string]string{ + "image": string(params.Image), + }, + map[string]string{ + "project": string(params.Project), + }, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) } - return allPages, nil + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body Image + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil } -// InstanceDiskList: List disks for instance +// InstanceList: List instances // -// To iterate over all pages, use the `InstanceDiskListAllPages` method, instead. -func (c *Client) InstanceDiskList(ctx context.Context, params InstanceDiskListParams) (*DiskResultsPage, error) { +// To iterate over all pages, use the `InstanceListAllPages` method, instead. +func (c *Client) InstanceList(ctx context.Context, params InstanceListParams) (*InstanceResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -2908,10 +2936,8 @@ func (c *Client) InstanceDiskList(ctx context.Context, params InstanceDiskListPa ctx, nil, "GET", - resolveRelative(c.host, "/v1/instances/{{.instance}}/disks"), - map[string]string{ - "instance": string(params.Instance), - }, + resolveRelative(c.host, "/v1/instances"), + map[string]string{}, map[string]string{ "limit": PointerIntToStr(params.Limit), "page_token": params.PageToken, @@ -2940,7 +2966,7 @@ func (c *Client) InstanceDiskList(ctx context.Context, params InstanceDiskListPa return nil, errors.New("request returned an empty body in the response") } - var body DiskResultsPage + var body InstanceResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -2949,19 +2975,19 @@ func (c *Client) InstanceDiskList(ctx context.Context, params InstanceDiskListPa return &body, nil } -// InstanceDiskListAllPages: List disks for instance +// InstanceListAllPages: List instances // -// This method is a wrapper around the `InstanceDiskList` method. +// This method is a wrapper around the `InstanceList` method. // This method returns all the pages at once. -func (c *Client) InstanceDiskListAllPages(ctx context.Context, params InstanceDiskListParams) ([]Disk, error) { +func (c *Client) InstanceListAllPages(ctx context.Context, params InstanceListParams) ([]Instance, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []Disk + var allPages []Instance params.PageToken = "" params.Limit = NewPointer(100) for { - page, err := c.InstanceDiskList(ctx, params) + page, err := c.InstanceList(ctx, params) if err != nil { return nil, err } @@ -2975,8 +3001,8 @@ func (c *Client) InstanceDiskListAllPages(ctx context.Context, params InstanceDi return allPages, nil } -// InstanceDiskAttach: Attach disk to instance -func (c *Client) InstanceDiskAttach(ctx context.Context, params InstanceDiskAttachParams) (*Disk, error) { +// InstanceCreate: Create instance +func (c *Client) InstanceCreate(ctx context.Context, params InstanceCreateParams) (*Instance, error) { if err := params.Validate(); err != nil { return nil, err } @@ -2991,10 +3017,8 @@ func (c *Client) InstanceDiskAttach(ctx context.Context, params InstanceDiskAtta ctx, b, "POST", - resolveRelative(c.host, "/v1/instances/{{.instance}}/disks/attach"), - map[string]string{ - "instance": string(params.Instance), - }, + resolveRelative(c.host, "/v1/instances"), + map[string]string{}, map[string]string{ "project": string(params.Project), }, @@ -3020,7 +3044,7 @@ func (c *Client) InstanceDiskAttach(ctx context.Context, params InstanceDiskAtta return nil, errors.New("request returned an empty body in the response") } - var body Disk + var body Instance if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -3029,62 +3053,8 @@ func (c *Client) InstanceDiskAttach(ctx context.Context, params InstanceDiskAtta return &body, nil } -// InstanceDiskDetach: Detach disk from instance -func (c *Client) InstanceDiskDetach(ctx context.Context, params InstanceDiskDetachParams) (*Disk, error) { - if err := params.Validate(); err != nil { - return nil, err - } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return nil, fmt.Errorf("encoding json body request failed: %v", err) - } - - // Create the request - req, err := c.buildRequest( - ctx, - b, - "POST", - resolveRelative(c.host, "/v1/instances/{{.instance}}/disks/detach"), - map[string]string{ - "instance": string(params.Instance), - }, - map[string]string{ - "project": string(params.Project), - }, - ) - if err != nil { - return nil, fmt.Errorf("error building request: %v", err) - } - - // Send the request. - resp, err := c.client.Do(req) - if err != nil { - return nil, fmt.Errorf("error sending request: %v", err) - } - defer resp.Body.Close() - - // Create and return an HTTPError when an error response code is received. - if err := NewHTTPError(resp); err != nil { - return nil, err - } - - // Decode the body from the response. - if resp.Body == nil { - return nil, errors.New("request returned an empty body in the response") - } - - var body Disk - if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { - return nil, fmt.Errorf("error decoding response body: %v", err) - } - - // Return the response. - return &body, nil -} - -// InstanceExternalIpList: List external IP addresses -func (c *Client) InstanceExternalIpList(ctx context.Context, params InstanceExternalIpListParams) (*ExternalIpResultsPage, error) { +// InstanceView: Fetch instance +func (c *Client) InstanceView(ctx context.Context, params InstanceViewParams) (*Instance, error) { if err := params.Validate(); err != nil { return nil, err } @@ -3093,7 +3063,7 @@ func (c *Client) InstanceExternalIpList(ctx context.Context, params InstanceExte ctx, nil, "GET", - resolveRelative(c.host, "/v1/instances/{{.instance}}/external-ips"), + resolveRelative(c.host, "/v1/instances/{{.instance}}"), map[string]string{ "instance": string(params.Instance), }, @@ -3122,7 +3092,7 @@ func (c *Client) InstanceExternalIpList(ctx context.Context, params InstanceExte return nil, errors.New("request returned an empty body in the response") } - var body ExternalIpResultsPage + var body Instance if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -3131,8 +3101,8 @@ func (c *Client) InstanceExternalIpList(ctx context.Context, params InstanceExte return &body, nil } -// InstanceEphemeralIpAttach: Allocate and attach ephemeral IP to instance -func (c *Client) InstanceEphemeralIpAttach(ctx context.Context, params InstanceEphemeralIpAttachParams) (*ExternalIp, error) { +// InstanceUpdate: Update instance +func (c *Client) InstanceUpdate(ctx context.Context, params InstanceUpdateParams) (*Instance, error) { if err := params.Validate(); err != nil { return nil, err } @@ -3146,8 +3116,8 @@ func (c *Client) InstanceEphemeralIpAttach(ctx context.Context, params InstanceE req, err := c.buildRequest( ctx, b, - "POST", - resolveRelative(c.host, "/v1/instances/{{.instance}}/external-ips/ephemeral"), + "PUT", + resolveRelative(c.host, "/v1/instances/{{.instance}}"), map[string]string{ "instance": string(params.Instance), }, @@ -3176,7 +3146,7 @@ func (c *Client) InstanceEphemeralIpAttach(ctx context.Context, params InstanceE return nil, errors.New("request returned an empty body in the response") } - var body ExternalIp + var body Instance if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -3185,8 +3155,8 @@ func (c *Client) InstanceEphemeralIpAttach(ctx context.Context, params InstanceE return &body, nil } -// InstanceEphemeralIpDetach: Detach and deallocate ephemeral IP from instance -func (c *Client) InstanceEphemeralIpDetach(ctx context.Context, params InstanceEphemeralIpDetachParams) error { +// InstanceDelete: Delete instance +func (c *Client) InstanceDelete(ctx context.Context, params InstanceDeleteParams) error { if err := params.Validate(); err != nil { return err } @@ -3195,7 +3165,7 @@ func (c *Client) InstanceEphemeralIpDetach(ctx context.Context, params InstanceE ctx, nil, "DELETE", - resolveRelative(c.host, "/v1/instances/{{.instance}}/external-ips/ephemeral"), + resolveRelative(c.host, "/v1/instances/{{.instance}}"), map[string]string{ "instance": string(params.Instance), }, @@ -3222,56 +3192,10 @@ func (c *Client) InstanceEphemeralIpDetach(ctx context.Context, params InstanceE return nil } -// InstanceReboot: Reboot an instance -func (c *Client) InstanceReboot(ctx context.Context, params InstanceRebootParams) (*Instance, error) { - if err := params.Validate(); err != nil { - return nil, err - } - // Create the request - req, err := c.buildRequest( - ctx, - nil, - "POST", - resolveRelative(c.host, "/v1/instances/{{.instance}}/reboot"), - map[string]string{ - "instance": string(params.Instance), - }, - map[string]string{ - "project": string(params.Project), - }, - ) - if err != nil { - return nil, fmt.Errorf("error building request: %v", err) - } - - // Send the request. - resp, err := c.client.Do(req) - if err != nil { - return nil, fmt.Errorf("error sending request: %v", err) - } - defer resp.Body.Close() - - // Create and return an HTTPError when an error response code is received. - if err := NewHTTPError(resp); err != nil { - return nil, err - } - - // Decode the body from the response. - if resp.Body == nil { - return nil, errors.New("request returned an empty body in the response") - } - - var body Instance - if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { - return nil, fmt.Errorf("error decoding response body: %v", err) - } - - // Return the response. - return &body, nil -} - -// InstanceSerialConsole: Fetch instance serial console -func (c *Client) InstanceSerialConsole(ctx context.Context, params InstanceSerialConsoleParams) (*InstanceSerialConsoleData, error) { +// InstanceAntiAffinityGroupList: List anti-affinity groups containing instance +// +// To iterate over all pages, use the `InstanceAntiAffinityGroupListAllPages` method, instead. +func (c *Client) InstanceAntiAffinityGroupList(ctx context.Context, params InstanceAntiAffinityGroupListParams) (*AntiAffinityGroupResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -3280,15 +3204,15 @@ func (c *Client) InstanceSerialConsole(ctx context.Context, params InstanceSeria ctx, nil, "GET", - resolveRelative(c.host, "/v1/instances/{{.instance}}/serial-console"), + resolveRelative(c.host, "/v1/instances/{{.instance}}/anti-affinity-groups"), map[string]string{ "instance": string(params.Instance), }, map[string]string{ - "from_start": PointerIntToStr(params.FromStart), - "max_bytes": PointerIntToStr(params.MaxBytes), - "most_recent": PointerIntToStr(params.MostRecent), - "project": string(params.Project), + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + "project": string(params.Project), + "sort_by": string(params.SortBy), }, ) if err != nil { @@ -3312,7 +3236,7 @@ func (c *Client) InstanceSerialConsole(ctx context.Context, params InstanceSeria return nil, errors.New("request returned an empty body in the response") } - var body InstanceSerialConsoleData + var body AntiAffinityGroupResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -3321,50 +3245,36 @@ func (c *Client) InstanceSerialConsole(ctx context.Context, params InstanceSeria return &body, nil } -// InstanceSerialConsoleStream: Stream instance serial console -func (c *Client) InstanceSerialConsoleStream(ctx context.Context, params InstanceSerialConsoleStreamParams) error { +// InstanceAntiAffinityGroupListAllPages: List anti-affinity groups containing instance +// +// This method is a wrapper around the `InstanceAntiAffinityGroupList` method. +// This method returns all the pages at once. +func (c *Client) InstanceAntiAffinityGroupListAllPages(ctx context.Context, params InstanceAntiAffinityGroupListParams) ([]AntiAffinityGroup, error) { if err := params.Validate(); err != nil { - return err - } - // Create the request - req, err := c.buildRequest( - ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/instances/{{.instance}}/serial-console/stream"), - map[string]string{ - "instance": string(params.Instance), - }, - map[string]string{ - "most_recent": PointerIntToStr(params.MostRecent), - "project": string(params.Project), - }, - ) - if err != nil { - return fmt.Errorf("error building request: %v", err) - } - - // Send the request. - resp, err := c.client.Do(req) - if err != nil { - return fmt.Errorf("error sending request: %v", err) + return nil, err } - defer resp.Body.Close() - - // Create and return an HTTPError when an error response code is received. - if err := NewHTTPError(resp); err != nil { - return err + var allPages []AntiAffinityGroup + params.PageToken = "" + params.Limit = NewPointer(100) + for { + page, err := c.InstanceAntiAffinityGroupList(ctx, params) + if err != nil { + return nil, err + } + allPages = append(allPages, page.Items...) + if page.NextPage == "" || page.NextPage == params.PageToken { + break + } + params.PageToken = page.NextPage } - return nil + return allPages, nil } -// InstanceSshPublicKeyList: List SSH public keys for instance -// List SSH public keys injected via cloud-init during instance creation. Note that this list is a snapshot in -// time and will not reflect updates made after the instance is created. +// InstanceDiskList: List disks for instance // -// To iterate over all pages, use the `InstanceSshPublicKeyListAllPages` method, instead. -func (c *Client) InstanceSshPublicKeyList(ctx context.Context, params InstanceSshPublicKeyListParams) (*SshKeyResultsPage, error) { +// To iterate over all pages, use the `InstanceDiskListAllPages` method, instead. +func (c *Client) InstanceDiskList(ctx context.Context, params InstanceDiskListParams) (*DiskResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -3373,7 +3283,7 @@ func (c *Client) InstanceSshPublicKeyList(ctx context.Context, params InstanceSs ctx, nil, "GET", - resolveRelative(c.host, "/v1/instances/{{.instance}}/ssh-public-keys"), + resolveRelative(c.host, "/v1/instances/{{.instance}}/disks"), map[string]string{ "instance": string(params.Instance), }, @@ -3405,7 +3315,7 @@ func (c *Client) InstanceSshPublicKeyList(ctx context.Context, params InstanceSs return nil, errors.New("request returned an empty body in the response") } - var body SshKeyResultsPage + var body DiskResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -3414,21 +3324,19 @@ func (c *Client) InstanceSshPublicKeyList(ctx context.Context, params InstanceSs return &body, nil } -// InstanceSshPublicKeyListAllPages: List SSH public keys for instance -// List SSH public keys injected via cloud-init during instance creation. Note that this list is a snapshot in -// time and will not reflect updates made after the instance is created. +// InstanceDiskListAllPages: List disks for instance // -// This method is a wrapper around the `InstanceSshPublicKeyList` method. +// This method is a wrapper around the `InstanceDiskList` method. // This method returns all the pages at once. -func (c *Client) InstanceSshPublicKeyListAllPages(ctx context.Context, params InstanceSshPublicKeyListParams) ([]SshKey, error) { +func (c *Client) InstanceDiskListAllPages(ctx context.Context, params InstanceDiskListParams) ([]Disk, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []SshKey + var allPages []Disk params.PageToken = "" params.Limit = NewPointer(100) for { - page, err := c.InstanceSshPublicKeyList(ctx, params) + page, err := c.InstanceDiskList(ctx, params) if err != nil { return nil, err } @@ -3442,17 +3350,23 @@ func (c *Client) InstanceSshPublicKeyListAllPages(ctx context.Context, params In return allPages, nil } -// InstanceStart: Boot instance -func (c *Client) InstanceStart(ctx context.Context, params InstanceStartParams) (*Instance, error) { +// InstanceDiskAttach: Attach disk to instance +func (c *Client) InstanceDiskAttach(ctx context.Context, params InstanceDiskAttachParams) (*Disk, error) { if err := params.Validate(); err != nil { return nil, err } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + // Create the request req, err := c.buildRequest( ctx, - nil, + b, "POST", - resolveRelative(c.host, "/v1/instances/{{.instance}}/start"), + resolveRelative(c.host, "/v1/instances/{{.instance}}/disks/attach"), map[string]string{ "instance": string(params.Instance), }, @@ -3481,7 +3395,7 @@ func (c *Client) InstanceStart(ctx context.Context, params InstanceStartParams) return nil, errors.New("request returned an empty body in the response") } - var body Instance + var body Disk if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -3490,17 +3404,23 @@ func (c *Client) InstanceStart(ctx context.Context, params InstanceStartParams) return &body, nil } -// InstanceStop: Stop instance -func (c *Client) InstanceStop(ctx context.Context, params InstanceStopParams) (*Instance, error) { +// InstanceDiskDetach: Detach disk from instance +func (c *Client) InstanceDiskDetach(ctx context.Context, params InstanceDiskDetachParams) (*Disk, error) { if err := params.Validate(); err != nil { return nil, err } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + // Create the request req, err := c.buildRequest( ctx, - nil, + b, "POST", - resolveRelative(c.host, "/v1/instances/{{.instance}}/stop"), + resolveRelative(c.host, "/v1/instances/{{.instance}}/disks/detach"), map[string]string{ "instance": string(params.Instance), }, @@ -3529,7 +3449,7 @@ func (c *Client) InstanceStop(ctx context.Context, params InstanceStopParams) (* return nil, errors.New("request returned an empty body in the response") } - var body Instance + var body Disk if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -3538,10 +3458,8 @@ func (c *Client) InstanceStop(ctx context.Context, params InstanceStopParams) (* return &body, nil } -// InternetGatewayIpAddressList: List IP addresses attached to internet gateway -// -// To iterate over all pages, use the `InternetGatewayIpAddressListAllPages` method, instead. -func (c *Client) InternetGatewayIpAddressList(ctx context.Context, params InternetGatewayIpAddressListParams) (*InternetGatewayIpAddressResultsPage, error) { +// InstanceExternalIpList: List external IP addresses +func (c *Client) InstanceExternalIpList(ctx context.Context, params InstanceExternalIpListParams) (*ExternalIpResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -3550,15 +3468,12 @@ func (c *Client) InternetGatewayIpAddressList(ctx context.Context, params Intern ctx, nil, "GET", - resolveRelative(c.host, "/v1/internet-gateway-ip-addresses"), - map[string]string{}, + resolveRelative(c.host, "/v1/instances/{{.instance}}/external-ips"), map[string]string{ - "gateway": string(params.Gateway), - "limit": PointerIntToStr(params.Limit), - "page_token": params.PageToken, - "project": string(params.Project), - "sort_by": string(params.SortBy), - "vpc": string(params.Vpc), + "instance": string(params.Instance), + }, + map[string]string{ + "project": string(params.Project), }, ) if err != nil { @@ -3582,7 +3497,7 @@ func (c *Client) InternetGatewayIpAddressList(ctx context.Context, params Intern return nil, errors.New("request returned an empty body in the response") } - var body InternetGatewayIpAddressResultsPage + var body ExternalIpResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -3591,34 +3506,8 @@ func (c *Client) InternetGatewayIpAddressList(ctx context.Context, params Intern return &body, nil } -// InternetGatewayIpAddressListAllPages: List IP addresses attached to internet gateway -// -// This method is a wrapper around the `InternetGatewayIpAddressList` method. -// This method returns all the pages at once. -func (c *Client) InternetGatewayIpAddressListAllPages(ctx context.Context, params InternetGatewayIpAddressListParams) ([]InternetGatewayIpAddress, error) { - if err := params.Validate(); err != nil { - return nil, err - } - var allPages []InternetGatewayIpAddress - params.PageToken = "" - params.Limit = NewPointer(100) - for { - page, err := c.InternetGatewayIpAddressList(ctx, params) - if err != nil { - return nil, err - } - allPages = append(allPages, page.Items...) - if page.NextPage == "" || page.NextPage == params.PageToken { - break - } - params.PageToken = page.NextPage - } - - return allPages, nil -} - -// InternetGatewayIpAddressCreate: Attach IP address to internet gateway -func (c *Client) InternetGatewayIpAddressCreate(ctx context.Context, params InternetGatewayIpAddressCreateParams) (*InternetGatewayIpAddress, error) { +// InstanceEphemeralIpAttach: Allocate and attach ephemeral IP to instance +func (c *Client) InstanceEphemeralIpAttach(ctx context.Context, params InstanceEphemeralIpAttachParams) (*ExternalIp, error) { if err := params.Validate(); err != nil { return nil, err } @@ -3633,12 +3522,12 @@ func (c *Client) InternetGatewayIpAddressCreate(ctx context.Context, params Inte ctx, b, "POST", - resolveRelative(c.host, "/v1/internet-gateway-ip-addresses"), - map[string]string{}, + resolveRelative(c.host, "/v1/instances/{{.instance}}/external-ips/ephemeral"), + map[string]string{ + "instance": string(params.Instance), + }, map[string]string{ - "gateway": string(params.Gateway), "project": string(params.Project), - "vpc": string(params.Vpc), }, ) if err != nil { @@ -3662,7 +3551,7 @@ func (c *Client) InternetGatewayIpAddressCreate(ctx context.Context, params Inte return nil, errors.New("request returned an empty body in the response") } - var body InternetGatewayIpAddress + var body ExternalIp if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -3671,8 +3560,10 @@ func (c *Client) InternetGatewayIpAddressCreate(ctx context.Context, params Inte return &body, nil } -// InternetGatewayIpAddressDelete: Detach IP address from internet gateway -func (c *Client) InternetGatewayIpAddressDelete(ctx context.Context, params InternetGatewayIpAddressDeleteParams) error { +// InstanceEphemeralIpDetach: Detach and deallocate ephemeral IP from instance +// When an instance has both IPv4 and IPv6 ephemeral IPs, the `ip_version` query parameter must be specified to +// identify which IP to detach. +func (c *Client) InstanceEphemeralIpDetach(ctx context.Context, params InstanceEphemeralIpDetachParams) error { if err := params.Validate(); err != nil { return err } @@ -3681,15 +3572,13 @@ func (c *Client) InternetGatewayIpAddressDelete(ctx context.Context, params Inte ctx, nil, "DELETE", - resolveRelative(c.host, "/v1/internet-gateway-ip-addresses/{{.address}}"), + resolveRelative(c.host, "/v1/instances/{{.instance}}/external-ips/ephemeral"), map[string]string{ - "address": string(params.Address), + "instance": string(params.Instance), }, map[string]string{ - "cascade": strconv.FormatBool(*params.Cascade), - "gateway": string(params.Gateway), - "project": string(params.Project), - "vpc": string(params.Vpc), + "ip_version": string(params.IpVersion), + "project": string(params.Project), }, ) if err != nil { @@ -3711,10 +3600,8 @@ func (c *Client) InternetGatewayIpAddressDelete(ctx context.Context, params Inte return nil } -// InternetGatewayIpPoolList: List IP pools attached to internet gateway -// -// To iterate over all pages, use the `InternetGatewayIpPoolListAllPages` method, instead. -func (c *Client) InternetGatewayIpPoolList(ctx context.Context, params InternetGatewayIpPoolListParams) (*InternetGatewayIpPoolResultsPage, error) { +// InstanceReboot: Reboot instance +func (c *Client) InstanceReboot(ctx context.Context, params InstanceRebootParams) (*Instance, error) { if err := params.Validate(); err != nil { return nil, err } @@ -3722,16 +3609,13 @@ func (c *Client) InternetGatewayIpPoolList(ctx context.Context, params InternetG req, err := c.buildRequest( ctx, nil, - "GET", - resolveRelative(c.host, "/v1/internet-gateway-ip-pools"), - map[string]string{}, + "POST", + resolveRelative(c.host, "/v1/instances/{{.instance}}/reboot"), map[string]string{ - "gateway": string(params.Gateway), - "limit": PointerIntToStr(params.Limit), - "page_token": params.PageToken, - "project": string(params.Project), - "sort_by": string(params.SortBy), - "vpc": string(params.Vpc), + "instance": string(params.Instance), + }, + map[string]string{ + "project": string(params.Project), }, ) if err != nil { @@ -3755,7 +3639,7 @@ func (c *Client) InternetGatewayIpPoolList(ctx context.Context, params InternetG return nil, errors.New("request returned an empty body in the response") } - var body InternetGatewayIpPoolResultsPage + var body Instance if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -3764,54 +3648,25 @@ func (c *Client) InternetGatewayIpPoolList(ctx context.Context, params InternetG return &body, nil } -// InternetGatewayIpPoolListAllPages: List IP pools attached to internet gateway -// -// This method is a wrapper around the `InternetGatewayIpPoolList` method. -// This method returns all the pages at once. -func (c *Client) InternetGatewayIpPoolListAllPages(ctx context.Context, params InternetGatewayIpPoolListParams) ([]InternetGatewayIpPool, error) { - if err := params.Validate(); err != nil { - return nil, err - } - var allPages []InternetGatewayIpPool - params.PageToken = "" - params.Limit = NewPointer(100) - for { - page, err := c.InternetGatewayIpPoolList(ctx, params) - if err != nil { - return nil, err - } - allPages = append(allPages, page.Items...) - if page.NextPage == "" || page.NextPage == params.PageToken { - break - } - params.PageToken = page.NextPage - } - - return allPages, nil -} - -// InternetGatewayIpPoolCreate: Attach IP pool to internet gateway -func (c *Client) InternetGatewayIpPoolCreate(ctx context.Context, params InternetGatewayIpPoolCreateParams) (*InternetGatewayIpPool, error) { +// InstanceSerialConsole: Fetch instance serial console +func (c *Client) InstanceSerialConsole(ctx context.Context, params InstanceSerialConsoleParams) (*InstanceSerialConsoleData, error) { if err := params.Validate(); err != nil { return nil, err } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return nil, fmt.Errorf("encoding json body request failed: %v", err) - } - // Create the request req, err := c.buildRequest( ctx, - b, - "POST", - resolveRelative(c.host, "/v1/internet-gateway-ip-pools"), - map[string]string{}, + nil, + "GET", + resolveRelative(c.host, "/v1/instances/{{.instance}}/serial-console"), map[string]string{ - "gateway": string(params.Gateway), - "project": string(params.Project), - "vpc": string(params.Vpc), + "instance": string(params.Instance), + }, + map[string]string{ + "from_start": PointerIntToStr(params.FromStart), + "max_bytes": PointerIntToStr(params.MaxBytes), + "most_recent": PointerIntToStr(params.MostRecent), + "project": string(params.Project), }, ) if err != nil { @@ -3835,7 +3690,7 @@ func (c *Client) InternetGatewayIpPoolCreate(ctx context.Context, params Interne return nil, errors.New("request returned an empty body in the response") } - var body InternetGatewayIpPool + var body InstanceSerialConsoleData if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -3844,8 +3699,8 @@ func (c *Client) InternetGatewayIpPoolCreate(ctx context.Context, params Interne return &body, nil } -// InternetGatewayIpPoolDelete: Detach IP pool from internet gateway -func (c *Client) InternetGatewayIpPoolDelete(ctx context.Context, params InternetGatewayIpPoolDeleteParams) error { +// InstanceSerialConsoleStream: Stream instance serial console +func (c *Client) InstanceSerialConsoleStream(ctx context.Context, params InstanceSerialConsoleStreamParams) error { if err := params.Validate(); err != nil { return err } @@ -3853,16 +3708,14 @@ func (c *Client) InternetGatewayIpPoolDelete(ctx context.Context, params Interne req, err := c.buildRequest( ctx, nil, - "DELETE", - resolveRelative(c.host, "/v1/internet-gateway-ip-pools/{{.pool}}"), + "GET", + resolveRelative(c.host, "/v1/instances/{{.instance}}/serial-console/stream"), map[string]string{ - "pool": string(params.Pool), + "instance": string(params.Instance), }, map[string]string{ - "cascade": strconv.FormatBool(*params.Cascade), - "gateway": string(params.Gateway), - "project": string(params.Project), - "vpc": string(params.Vpc), + "most_recent": PointerIntToStr(params.MostRecent), + "project": string(params.Project), }, ) if err != nil { @@ -3884,10 +3737,12 @@ func (c *Client) InternetGatewayIpPoolDelete(ctx context.Context, params Interne return nil } -// InternetGatewayList: List internet gateways +// InstanceSshPublicKeyList: List SSH public keys for instance +// List SSH public keys injected via cloud-init during instance creation. Note that this list is a snapshot in +// time and will not reflect updates made after the instance is created. // -// To iterate over all pages, use the `InternetGatewayListAllPages` method, instead. -func (c *Client) InternetGatewayList(ctx context.Context, params InternetGatewayListParams) (*InternetGatewayResultsPage, error) { +// To iterate over all pages, use the `InstanceSshPublicKeyListAllPages` method, instead. +func (c *Client) InstanceSshPublicKeyList(ctx context.Context, params InstanceSshPublicKeyListParams) (*SshKeyResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -3896,14 +3751,15 @@ func (c *Client) InternetGatewayList(ctx context.Context, params InternetGateway ctx, nil, "GET", - resolveRelative(c.host, "/v1/internet-gateways"), - map[string]string{}, + resolveRelative(c.host, "/v1/instances/{{.instance}}/ssh-public-keys"), + map[string]string{ + "instance": string(params.Instance), + }, map[string]string{ "limit": PointerIntToStr(params.Limit), "page_token": params.PageToken, "project": string(params.Project), "sort_by": string(params.SortBy), - "vpc": string(params.Vpc), }, ) if err != nil { @@ -3927,7 +3783,7 @@ func (c *Client) InternetGatewayList(ctx context.Context, params InternetGateway return nil, errors.New("request returned an empty body in the response") } - var body InternetGatewayResultsPage + var body SshKeyResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -3936,19 +3792,21 @@ func (c *Client) InternetGatewayList(ctx context.Context, params InternetGateway return &body, nil } -// InternetGatewayListAllPages: List internet gateways +// InstanceSshPublicKeyListAllPages: List SSH public keys for instance +// List SSH public keys injected via cloud-init during instance creation. Note that this list is a snapshot in +// time and will not reflect updates made after the instance is created. // -// This method is a wrapper around the `InternetGatewayList` method. +// This method is a wrapper around the `InstanceSshPublicKeyList` method. // This method returns all the pages at once. -func (c *Client) InternetGatewayListAllPages(ctx context.Context, params InternetGatewayListParams) ([]InternetGateway, error) { +func (c *Client) InstanceSshPublicKeyListAllPages(ctx context.Context, params InstanceSshPublicKeyListParams) ([]SshKey, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []InternetGateway + var allPages []SshKey params.PageToken = "" params.Limit = NewPointer(100) for { - page, err := c.InternetGatewayList(ctx, params) + page, err := c.InstanceSshPublicKeyList(ctx, params) if err != nil { return nil, err } @@ -3962,27 +3820,22 @@ func (c *Client) InternetGatewayListAllPages(ctx context.Context, params Interne return allPages, nil } -// InternetGatewayCreate: Create VPC internet gateway -func (c *Client) InternetGatewayCreate(ctx context.Context, params InternetGatewayCreateParams) (*InternetGateway, error) { +// InstanceStart: Boot instance +func (c *Client) InstanceStart(ctx context.Context, params InstanceStartParams) (*Instance, error) { if err := params.Validate(); err != nil { return nil, err } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return nil, fmt.Errorf("encoding json body request failed: %v", err) - } - // Create the request req, err := c.buildRequest( ctx, - b, + nil, "POST", - resolveRelative(c.host, "/v1/internet-gateways"), - map[string]string{}, + resolveRelative(c.host, "/v1/instances/{{.instance}}/start"), + map[string]string{ + "instance": string(params.Instance), + }, map[string]string{ "project": string(params.Project), - "vpc": string(params.Vpc), }, ) if err != nil { @@ -4006,7 +3859,7 @@ func (c *Client) InternetGatewayCreate(ctx context.Context, params InternetGatew return nil, errors.New("request returned an empty body in the response") } - var body InternetGateway + var body Instance if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -4015,8 +3868,8 @@ func (c *Client) InternetGatewayCreate(ctx context.Context, params InternetGatew return &body, nil } -// InternetGatewayView: Fetch internet gateway -func (c *Client) InternetGatewayView(ctx context.Context, params InternetGatewayViewParams) (*InternetGateway, error) { +// InstanceStop: Stop instance +func (c *Client) InstanceStop(ctx context.Context, params InstanceStopParams) (*Instance, error) { if err := params.Validate(); err != nil { return nil, err } @@ -4024,14 +3877,13 @@ func (c *Client) InternetGatewayView(ctx context.Context, params InternetGateway req, err := c.buildRequest( ctx, nil, - "GET", - resolveRelative(c.host, "/v1/internet-gateways/{{.gateway}}"), + "POST", + resolveRelative(c.host, "/v1/instances/{{.instance}}/stop"), map[string]string{ - "gateway": string(params.Gateway), + "instance": string(params.Instance), }, map[string]string{ "project": string(params.Project), - "vpc": string(params.Vpc), }, ) if err != nil { @@ -4055,7 +3907,7 @@ func (c *Client) InternetGatewayView(ctx context.Context, params InternetGateway return nil, errors.New("request returned an empty body in the response") } - var body InternetGateway + var body Instance if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -4064,79 +3916,43 @@ func (c *Client) InternetGatewayView(ctx context.Context, params InternetGateway return &body, nil } -// InternetGatewayDelete: Delete internet gateway -func (c *Client) InternetGatewayDelete(ctx context.Context, params InternetGatewayDeleteParams) error { +// InternetGatewayIpAddressList: List IP addresses attached to internet gateway +// +// To iterate over all pages, use the `InternetGatewayIpAddressListAllPages` method, instead. +func (c *Client) InternetGatewayIpAddressList(ctx context.Context, params InternetGatewayIpAddressListParams) (*InternetGatewayIpAddressResultsPage, error) { if err := params.Validate(); err != nil { - return err + return nil, err } // Create the request req, err := c.buildRequest( ctx, nil, - "DELETE", - resolveRelative(c.host, "/v1/internet-gateways/{{.gateway}}"), - map[string]string{ - "gateway": string(params.Gateway), - }, + "GET", + resolveRelative(c.host, "/v1/internet-gateway-ip-addresses"), + map[string]string{}, map[string]string{ - "cascade": strconv.FormatBool(*params.Cascade), - "project": string(params.Project), - "vpc": string(params.Vpc), + "gateway": string(params.Gateway), + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + "project": string(params.Project), + "sort_by": string(params.SortBy), + "vpc": string(params.Vpc), }, ) if err != nil { - return fmt.Errorf("error building request: %v", err) + return nil, fmt.Errorf("error building request: %v", err) } // Send the request. resp, err := c.client.Do(req) if err != nil { - return fmt.Errorf("error sending request: %v", err) + return nil, fmt.Errorf("error sending request: %v", err) } defer resp.Body.Close() // Create and return an HTTPError when an error response code is received. if err := NewHTTPError(resp); err != nil { - return err - } - - return nil -} - -// ProjectIpPoolList: List IP pools -// -// To iterate over all pages, use the `ProjectIpPoolListAllPages` method, instead. -func (c *Client) ProjectIpPoolList(ctx context.Context, params ProjectIpPoolListParams) (*SiloIpPoolResultsPage, error) { - if err := params.Validate(); err != nil { - return nil, err - } - // Create the request - req, err := c.buildRequest( - ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/ip-pools"), - map[string]string{}, - map[string]string{ - "limit": PointerIntToStr(params.Limit), - "page_token": params.PageToken, - "sort_by": string(params.SortBy), - }, - ) - if err != nil { - return nil, fmt.Errorf("error building request: %v", err) - } - - // Send the request. - resp, err := c.client.Do(req) - if err != nil { - return nil, fmt.Errorf("error sending request: %v", err) - } - defer resp.Body.Close() - - // Create and return an HTTPError when an error response code is received. - if err := NewHTTPError(resp); err != nil { - return nil, err + return nil, err } // Decode the body from the response. @@ -4144,7 +3960,7 @@ func (c *Client) ProjectIpPoolList(ctx context.Context, params ProjectIpPoolList return nil, errors.New("request returned an empty body in the response") } - var body SiloIpPoolResultsPage + var body InternetGatewayIpAddressResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -4153,19 +3969,19 @@ func (c *Client) ProjectIpPoolList(ctx context.Context, params ProjectIpPoolList return &body, nil } -// ProjectIpPoolListAllPages: List IP pools +// InternetGatewayIpAddressListAllPages: List IP addresses attached to internet gateway // -// This method is a wrapper around the `ProjectIpPoolList` method. +// This method is a wrapper around the `InternetGatewayIpAddressList` method. // This method returns all the pages at once. -func (c *Client) ProjectIpPoolListAllPages(ctx context.Context, params ProjectIpPoolListParams) ([]SiloIpPool, error) { +func (c *Client) InternetGatewayIpAddressListAllPages(ctx context.Context, params InternetGatewayIpAddressListParams) ([]InternetGatewayIpAddress, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []SiloIpPool + var allPages []InternetGatewayIpAddress params.PageToken = "" params.Limit = NewPointer(100) for { - page, err := c.ProjectIpPoolList(ctx, params) + page, err := c.InternetGatewayIpAddressList(ctx, params) if err != nil { return nil, err } @@ -4179,21 +3995,29 @@ func (c *Client) ProjectIpPoolListAllPages(ctx context.Context, params ProjectIp return allPages, nil } -// ProjectIpPoolView: Fetch IP pool -func (c *Client) ProjectIpPoolView(ctx context.Context, params ProjectIpPoolViewParams) (*SiloIpPool, error) { +// InternetGatewayIpAddressCreate: Attach IP address to internet gateway +func (c *Client) InternetGatewayIpAddressCreate(ctx context.Context, params InternetGatewayIpAddressCreateParams) (*InternetGatewayIpAddress, error) { if err := params.Validate(); err != nil { return nil, err } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + // Create the request req, err := c.buildRequest( ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/ip-pools/{{.pool}}"), + b, + "POST", + resolveRelative(c.host, "/v1/internet-gateway-ip-addresses"), + map[string]string{}, map[string]string{ - "pool": string(params.Pool), + "gateway": string(params.Gateway), + "project": string(params.Project), + "vpc": string(params.Vpc), }, - map[string]string{}, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -4216,7 +4040,7 @@ func (c *Client) ProjectIpPoolView(ctx context.Context, params ProjectIpPoolView return nil, errors.New("request returned an empty body in the response") } - var body SiloIpPool + var body InternetGatewayIpAddress if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -4225,27 +4049,26 @@ func (c *Client) ProjectIpPoolView(ctx context.Context, params ProjectIpPoolView return &body, nil } -// LoginLocal: Authenticate a user via username and password -func (c *Client) LoginLocal(ctx context.Context, params LoginLocalParams) error { +// InternetGatewayIpAddressDelete: Detach IP address from internet gateway +func (c *Client) InternetGatewayIpAddressDelete(ctx context.Context, params InternetGatewayIpAddressDeleteParams) error { if err := params.Validate(); err != nil { return err } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return fmt.Errorf("encoding json body request failed: %v", err) - } - // Create the request req, err := c.buildRequest( ctx, - b, - "POST", - resolveRelative(c.host, "/v1/login/{{.silo_name}}/local"), + nil, + "DELETE", + resolveRelative(c.host, "/v1/internet-gateway-ip-addresses/{{.address}}"), map[string]string{ - "silo_name": string(params.SiloName), + "address": string(params.Address), + }, + map[string]string{ + "cascade": strconv.FormatBool(*params.Cascade), + "gateway": string(params.Gateway), + "project": string(params.Project), + "vpc": string(params.Vpc), }, - map[string]string{}, ) if err != nil { return fmt.Errorf("error building request: %v", err) @@ -4266,16 +4089,28 @@ func (c *Client) LoginLocal(ctx context.Context, params LoginLocalParams) error return nil } -// CurrentUserView: Fetch user for current session -func (c *Client) CurrentUserView(ctx context.Context) (*CurrentUser, error) { +// InternetGatewayIpPoolList: List IP pools attached to internet gateway +// +// To iterate over all pages, use the `InternetGatewayIpPoolListAllPages` method, instead. +func (c *Client) InternetGatewayIpPoolList(ctx context.Context, params InternetGatewayIpPoolListParams) (*InternetGatewayIpPoolResultsPage, error) { + if err := params.Validate(); err != nil { + return nil, err + } // Create the request req, err := c.buildRequest( ctx, nil, "GET", - resolveRelative(c.host, "/v1/me"), - map[string]string{}, + resolveRelative(c.host, "/v1/internet-gateway-ip-pools"), map[string]string{}, + map[string]string{ + "gateway": string(params.Gateway), + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + "project": string(params.Project), + "sort_by": string(params.SortBy), + "vpc": string(params.Vpc), + }, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -4298,7 +4133,7 @@ func (c *Client) CurrentUserView(ctx context.Context) (*CurrentUser, error) { return nil, errors.New("request returned an empty body in the response") } - var body CurrentUser + var body InternetGatewayIpPoolResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -4307,25 +4142,54 @@ func (c *Client) CurrentUserView(ctx context.Context) (*CurrentUser, error) { return &body, nil } -// CurrentUserAccessTokenList: List access tokens -// List device access tokens for the currently authenticated user. +// InternetGatewayIpPoolListAllPages: List IP pools attached to internet gateway // -// To iterate over all pages, use the `CurrentUserAccessTokenListAllPages` method, instead. -func (c *Client) CurrentUserAccessTokenList(ctx context.Context, params CurrentUserAccessTokenListParams) (*DeviceAccessTokenResultsPage, error) { +// This method is a wrapper around the `InternetGatewayIpPoolList` method. +// This method returns all the pages at once. +func (c *Client) InternetGatewayIpPoolListAllPages(ctx context.Context, params InternetGatewayIpPoolListParams) ([]InternetGatewayIpPool, error) { + if err := params.Validate(); err != nil { + return nil, err + } + var allPages []InternetGatewayIpPool + params.PageToken = "" + params.Limit = NewPointer(100) + for { + page, err := c.InternetGatewayIpPoolList(ctx, params) + if err != nil { + return nil, err + } + allPages = append(allPages, page.Items...) + if page.NextPage == "" || page.NextPage == params.PageToken { + break + } + params.PageToken = page.NextPage + } + + return allPages, nil +} + +// InternetGatewayIpPoolCreate: Attach IP pool to internet gateway +func (c *Client) InternetGatewayIpPoolCreate(ctx context.Context, params InternetGatewayIpPoolCreateParams) (*InternetGatewayIpPool, error) { if err := params.Validate(); err != nil { return nil, err } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + // Create the request req, err := c.buildRequest( ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/me/access-tokens"), + b, + "POST", + resolveRelative(c.host, "/v1/internet-gateway-ip-pools"), map[string]string{}, map[string]string{ - "limit": PointerIntToStr(params.Limit), - "page_token": params.PageToken, - "sort_by": string(params.SortBy), + "gateway": string(params.Gateway), + "project": string(params.Project), + "vpc": string(params.Vpc), }, ) if err != nil { @@ -4349,7 +4213,7 @@ func (c *Client) CurrentUserAccessTokenList(ctx context.Context, params CurrentU return nil, errors.New("request returned an empty body in the response") } - var body DeviceAccessTokenResultsPage + var body InternetGatewayIpPool if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -4358,36 +4222,8 @@ func (c *Client) CurrentUserAccessTokenList(ctx context.Context, params CurrentU return &body, nil } -// CurrentUserAccessTokenListAllPages: List access tokens -// List device access tokens for the currently authenticated user. -// -// This method is a wrapper around the `CurrentUserAccessTokenList` method. -// This method returns all the pages at once. -func (c *Client) CurrentUserAccessTokenListAllPages(ctx context.Context, params CurrentUserAccessTokenListParams) ([]DeviceAccessToken, error) { - if err := params.Validate(); err != nil { - return nil, err - } - var allPages []DeviceAccessToken - params.PageToken = "" - params.Limit = NewPointer(100) - for { - page, err := c.CurrentUserAccessTokenList(ctx, params) - if err != nil { - return nil, err - } - allPages = append(allPages, page.Items...) - if page.NextPage == "" || page.NextPage == params.PageToken { - break - } - params.PageToken = page.NextPage - } - - return allPages, nil -} - -// CurrentUserAccessTokenDelete: Delete access token -// Delete a device access token for the currently authenticated user. -func (c *Client) CurrentUserAccessTokenDelete(ctx context.Context, params CurrentUserAccessTokenDeleteParams) error { +// InternetGatewayIpPoolDelete: Detach IP pool from internet gateway +func (c *Client) InternetGatewayIpPoolDelete(ctx context.Context, params InternetGatewayIpPoolDeleteParams) error { if err := params.Validate(); err != nil { return err } @@ -4396,11 +4232,16 @@ func (c *Client) CurrentUserAccessTokenDelete(ctx context.Context, params Curren ctx, nil, "DELETE", - resolveRelative(c.host, "/v1/me/access-tokens/{{.token_id}}"), + resolveRelative(c.host, "/v1/internet-gateway-ip-pools/{{.pool}}"), map[string]string{ - "token_id": params.TokenId, + "pool": string(params.Pool), + }, + map[string]string{ + "cascade": strconv.FormatBool(*params.Cascade), + "gateway": string(params.Gateway), + "project": string(params.Project), + "vpc": string(params.Vpc), }, - map[string]string{}, ) if err != nil { return fmt.Errorf("error building request: %v", err) @@ -4421,10 +4262,10 @@ func (c *Client) CurrentUserAccessTokenDelete(ctx context.Context, params Curren return nil } -// CurrentUserGroups: Fetch current user's groups +// InternetGatewayList: List internet gateways // -// To iterate over all pages, use the `CurrentUserGroupsAllPages` method, instead. -func (c *Client) CurrentUserGroups(ctx context.Context, params CurrentUserGroupsParams) (*GroupResultsPage, error) { +// To iterate over all pages, use the `InternetGatewayListAllPages` method, instead. +func (c *Client) InternetGatewayList(ctx context.Context, params InternetGatewayListParams) (*InternetGatewayResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -4433,12 +4274,14 @@ func (c *Client) CurrentUserGroups(ctx context.Context, params CurrentUserGroups ctx, nil, "GET", - resolveRelative(c.host, "/v1/me/groups"), + resolveRelative(c.host, "/v1/internet-gateways"), map[string]string{}, map[string]string{ "limit": PointerIntToStr(params.Limit), "page_token": params.PageToken, + "project": string(params.Project), "sort_by": string(params.SortBy), + "vpc": string(params.Vpc), }, ) if err != nil { @@ -4462,7 +4305,7 @@ func (c *Client) CurrentUserGroups(ctx context.Context, params CurrentUserGroups return nil, errors.New("request returned an empty body in the response") } - var body GroupResultsPage + var body InternetGatewayResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -4471,19 +4314,19 @@ func (c *Client) CurrentUserGroups(ctx context.Context, params CurrentUserGroups return &body, nil } -// CurrentUserGroupsAllPages: Fetch current user's groups +// InternetGatewayListAllPages: List internet gateways // -// This method is a wrapper around the `CurrentUserGroups` method. +// This method is a wrapper around the `InternetGatewayList` method. // This method returns all the pages at once. -func (c *Client) CurrentUserGroupsAllPages(ctx context.Context, params CurrentUserGroupsParams) ([]Group, error) { +func (c *Client) InternetGatewayListAllPages(ctx context.Context, params InternetGatewayListParams) ([]InternetGateway, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []Group + var allPages []InternetGateway params.PageToken = "" params.Limit = NewPointer(100) for { - page, err := c.CurrentUserGroups(ctx, params) + page, err := c.InternetGatewayList(ctx, params) if err != nil { return nil, err } @@ -4497,25 +4340,27 @@ func (c *Client) CurrentUserGroupsAllPages(ctx context.Context, params CurrentUs return allPages, nil } -// CurrentUserSshKeyList: List SSH public keys -// Lists SSH public keys for the currently authenticated user. -// -// To iterate over all pages, use the `CurrentUserSshKeyListAllPages` method, instead. -func (c *Client) CurrentUserSshKeyList(ctx context.Context, params CurrentUserSshKeyListParams) (*SshKeyResultsPage, error) { +// InternetGatewayCreate: Create VPC internet gateway +func (c *Client) InternetGatewayCreate(ctx context.Context, params InternetGatewayCreateParams) (*InternetGateway, error) { if err := params.Validate(); err != nil { return nil, err } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + // Create the request req, err := c.buildRequest( ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/me/ssh-keys"), + b, + "POST", + resolveRelative(c.host, "/v1/internet-gateways"), map[string]string{}, map[string]string{ - "limit": PointerIntToStr(params.Limit), - "page_token": params.PageToken, - "sort_by": string(params.SortBy), + "project": string(params.Project), + "vpc": string(params.Vpc), }, ) if err != nil { @@ -4539,85 +4384,7 @@ func (c *Client) CurrentUserSshKeyList(ctx context.Context, params CurrentUserSs return nil, errors.New("request returned an empty body in the response") } - var body SshKeyResultsPage - if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { - return nil, fmt.Errorf("error decoding response body: %v", err) - } - - // Return the response. - return &body, nil -} - -// CurrentUserSshKeyListAllPages: List SSH public keys -// Lists SSH public keys for the currently authenticated user. -// -// This method is a wrapper around the `CurrentUserSshKeyList` method. -// This method returns all the pages at once. -func (c *Client) CurrentUserSshKeyListAllPages(ctx context.Context, params CurrentUserSshKeyListParams) ([]SshKey, error) { - if err := params.Validate(); err != nil { - return nil, err - } - var allPages []SshKey - params.PageToken = "" - params.Limit = NewPointer(100) - for { - page, err := c.CurrentUserSshKeyList(ctx, params) - if err != nil { - return nil, err - } - allPages = append(allPages, page.Items...) - if page.NextPage == "" || page.NextPage == params.PageToken { - break - } - params.PageToken = page.NextPage - } - - return allPages, nil -} - -// CurrentUserSshKeyCreate: Create SSH public key -// Create an SSH public key for the currently authenticated user. -func (c *Client) CurrentUserSshKeyCreate(ctx context.Context, params CurrentUserSshKeyCreateParams) (*SshKey, error) { - if err := params.Validate(); err != nil { - return nil, err - } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return nil, fmt.Errorf("encoding json body request failed: %v", err) - } - - // Create the request - req, err := c.buildRequest( - ctx, - b, - "POST", - resolveRelative(c.host, "/v1/me/ssh-keys"), - map[string]string{}, - map[string]string{}, - ) - if err != nil { - return nil, fmt.Errorf("error building request: %v", err) - } - - // Send the request. - resp, err := c.client.Do(req) - if err != nil { - return nil, fmt.Errorf("error sending request: %v", err) - } - defer resp.Body.Close() - - // Create and return an HTTPError when an error response code is received. - if err := NewHTTPError(resp); err != nil { - return nil, err - } - - // Decode the body from the response. - if resp.Body == nil { - return nil, errors.New("request returned an empty body in the response") - } - - var body SshKey + var body InternetGateway if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -4626,9 +4393,8 @@ func (c *Client) CurrentUserSshKeyCreate(ctx context.Context, params CurrentUser return &body, nil } -// CurrentUserSshKeyView: Fetch SSH public key -// Fetch SSH public key associated with the currently authenticated user. -func (c *Client) CurrentUserSshKeyView(ctx context.Context, params CurrentUserSshKeyViewParams) (*SshKey, error) { +// InternetGatewayView: Fetch internet gateway +func (c *Client) InternetGatewayView(ctx context.Context, params InternetGatewayViewParams) (*InternetGateway, error) { if err := params.Validate(); err != nil { return nil, err } @@ -4637,11 +4403,14 @@ func (c *Client) CurrentUserSshKeyView(ctx context.Context, params CurrentUserSs ctx, nil, "GET", - resolveRelative(c.host, "/v1/me/ssh-keys/{{.ssh_key}}"), + resolveRelative(c.host, "/v1/internet-gateways/{{.gateway}}"), map[string]string{ - "ssh_key": string(params.SshKey), + "gateway": string(params.Gateway), + }, + map[string]string{ + "project": string(params.Project), + "vpc": string(params.Vpc), }, - map[string]string{}, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -4664,7 +4433,7 @@ func (c *Client) CurrentUserSshKeyView(ctx context.Context, params CurrentUserSs return nil, errors.New("request returned an empty body in the response") } - var body SshKey + var body InternetGateway if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -4673,9 +4442,8 @@ func (c *Client) CurrentUserSshKeyView(ctx context.Context, params CurrentUserSs return &body, nil } -// CurrentUserSshKeyDelete: Delete SSH public key -// Delete an SSH public key associated with the currently authenticated user. -func (c *Client) CurrentUserSshKeyDelete(ctx context.Context, params CurrentUserSshKeyDeleteParams) error { +// InternetGatewayDelete: Delete internet gateway +func (c *Client) InternetGatewayDelete(ctx context.Context, params InternetGatewayDeleteParams) error { if err := params.Validate(); err != nil { return err } @@ -4684,11 +4452,15 @@ func (c *Client) CurrentUserSshKeyDelete(ctx context.Context, params CurrentUser ctx, nil, "DELETE", - resolveRelative(c.host, "/v1/me/ssh-keys/{{.ssh_key}}"), + resolveRelative(c.host, "/v1/internet-gateways/{{.gateway}}"), map[string]string{ - "ssh_key": string(params.SshKey), + "gateway": string(params.Gateway), + }, + map[string]string{ + "cascade": strconv.FormatBool(*params.Cascade), + "project": string(params.Project), + "vpc": string(params.Vpc), }, - map[string]string{}, ) if err != nil { return fmt.Errorf("error building request: %v", err) @@ -4709,11 +4481,10 @@ func (c *Client) CurrentUserSshKeyDelete(ctx context.Context, params CurrentUser return nil } -// SiloMetric: View metrics -// View CPU, memory, or storage utilization metrics at the silo or project level. +// ProjectIpPoolList: List IP pools // -// To iterate over all pages, use the `SiloMetricAllPages` method, instead. -func (c *Client) SiloMetric(ctx context.Context, params SiloMetricParams) (*MeasurementResultsPage, error) { +// To iterate over all pages, use the `ProjectIpPoolListAllPages` method, instead. +func (c *Client) ProjectIpPoolList(ctx context.Context, params ProjectIpPoolListParams) (*SiloIpPoolResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -4722,17 +4493,12 @@ func (c *Client) SiloMetric(ctx context.Context, params SiloMetricParams) (*Meas ctx, nil, "GET", - resolveRelative(c.host, "/v1/metrics/{{.metric_name}}"), - map[string]string{ - "metric_name": string(params.MetricName), - }, + resolveRelative(c.host, "/v1/ip-pools"), + map[string]string{}, map[string]string{ - "end_time": params.EndTime.Format(time.RFC3339), "limit": PointerIntToStr(params.Limit), - "order": string(params.Order), "page_token": params.PageToken, - "project": string(params.Project), - "start_time": params.StartTime.Format(time.RFC3339), + "sort_by": string(params.SortBy), }, ) if err != nil { @@ -4756,7 +4522,7 @@ func (c *Client) SiloMetric(ctx context.Context, params SiloMetricParams) (*Meas return nil, errors.New("request returned an empty body in the response") } - var body MeasurementResultsPage + var body SiloIpPoolResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -4765,20 +4531,19 @@ func (c *Client) SiloMetric(ctx context.Context, params SiloMetricParams) (*Meas return &body, nil } -// SiloMetricAllPages: View metrics -// View CPU, memory, or storage utilization metrics at the silo or project level. +// ProjectIpPoolListAllPages: List IP pools // -// This method is a wrapper around the `SiloMetric` method. +// This method is a wrapper around the `ProjectIpPoolList` method. // This method returns all the pages at once. -func (c *Client) SiloMetricAllPages(ctx context.Context, params SiloMetricParams) ([]Measurement, error) { +func (c *Client) ProjectIpPoolListAllPages(ctx context.Context, params ProjectIpPoolListParams) ([]SiloIpPool, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []Measurement + var allPages []SiloIpPool params.PageToken = "" params.Limit = NewPointer(100) for { - page, err := c.SiloMetric(ctx, params) + page, err := c.ProjectIpPoolList(ctx, params) if err != nil { return nil, err } @@ -4792,10 +4557,8 @@ func (c *Client) SiloMetricAllPages(ctx context.Context, params SiloMetricParams return allPages, nil } -// InstanceNetworkInterfaceList: List network interfaces -// -// To iterate over all pages, use the `InstanceNetworkInterfaceListAllPages` method, instead. -func (c *Client) InstanceNetworkInterfaceList(ctx context.Context, params InstanceNetworkInterfaceListParams) (*InstanceNetworkInterfaceResultsPage, error) { +// ProjectIpPoolView: Fetch IP pool +func (c *Client) ProjectIpPoolView(ctx context.Context, params ProjectIpPoolViewParams) (*SiloIpPool, error) { if err := params.Validate(); err != nil { return nil, err } @@ -4804,15 +4567,11 @@ func (c *Client) InstanceNetworkInterfaceList(ctx context.Context, params Instan ctx, nil, "GET", - resolveRelative(c.host, "/v1/network-interfaces"), - map[string]string{}, + resolveRelative(c.host, "/v1/ip-pools/{{.pool}}"), map[string]string{ - "instance": string(params.Instance), - "limit": PointerIntToStr(params.Limit), - "page_token": params.PageToken, - "project": string(params.Project), - "sort_by": string(params.SortBy), + "pool": string(params.Pool), }, + map[string]string{}, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -4835,7 +4594,7 @@ func (c *Client) InstanceNetworkInterfaceList(ctx context.Context, params Instan return nil, errors.New("request returned an empty body in the response") } - var body InstanceNetworkInterfaceResultsPage + var body SiloIpPool if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -4844,41 +4603,15 @@ func (c *Client) InstanceNetworkInterfaceList(ctx context.Context, params Instan return &body, nil } -// InstanceNetworkInterfaceListAllPages: List network interfaces -// -// This method is a wrapper around the `InstanceNetworkInterfaceList` method. -// This method returns all the pages at once. -func (c *Client) InstanceNetworkInterfaceListAllPages(ctx context.Context, params InstanceNetworkInterfaceListParams) ([]InstanceNetworkInterface, error) { - if err := params.Validate(); err != nil { - return nil, err - } - var allPages []InstanceNetworkInterface - params.PageToken = "" - params.Limit = NewPointer(100) - for { - page, err := c.InstanceNetworkInterfaceList(ctx, params) - if err != nil { - return nil, err - } - allPages = append(allPages, page.Items...) - if page.NextPage == "" || page.NextPage == params.PageToken { - break - } - params.PageToken = page.NextPage - } - - return allPages, nil -} - -// InstanceNetworkInterfaceCreate: Create network interface -func (c *Client) InstanceNetworkInterfaceCreate(ctx context.Context, params InstanceNetworkInterfaceCreateParams) (*InstanceNetworkInterface, error) { +// LoginLocal: Authenticate a user via username and password +func (c *Client) LoginLocal(ctx context.Context, params LoginLocalParams) error { if err := params.Validate(); err != nil { - return nil, err + return err } // Encode the request body as json. b := new(bytes.Buffer) if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return nil, fmt.Errorf("encoding json body request failed: %v", err) + return fmt.Errorf("encoding json body request failed: %v", err) } // Create the request @@ -4886,12 +4619,41 @@ func (c *Client) InstanceNetworkInterfaceCreate(ctx context.Context, params Inst ctx, b, "POST", - resolveRelative(c.host, "/v1/network-interfaces"), - map[string]string{}, + resolveRelative(c.host, "/v1/login/{{.silo_name}}/local"), map[string]string{ - "instance": string(params.Instance), - "project": string(params.Project), + "silo_name": string(params.SiloName), }, + map[string]string{}, + ) + if err != nil { + return fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return err + } + + return nil +} + +// CurrentUserView: Fetch user for current session +func (c *Client) CurrentUserView(ctx context.Context) (*CurrentUser, error) { + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "GET", + resolveRelative(c.host, "/v1/me"), + map[string]string{}, + map[string]string{}, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -4914,7 +4676,7 @@ func (c *Client) InstanceNetworkInterfaceCreate(ctx context.Context, params Inst return nil, errors.New("request returned an empty body in the response") } - var body InstanceNetworkInterface + var body CurrentUser if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -4923,8 +4685,11 @@ func (c *Client) InstanceNetworkInterfaceCreate(ctx context.Context, params Inst return &body, nil } -// InstanceNetworkInterfaceView: Fetch network interface -func (c *Client) InstanceNetworkInterfaceView(ctx context.Context, params InstanceNetworkInterfaceViewParams) (*InstanceNetworkInterface, error) { +// CurrentUserAccessTokenList: List access tokens +// List device access tokens for the currently authenticated user. +// +// To iterate over all pages, use the `CurrentUserAccessTokenListAllPages` method, instead. +func (c *Client) CurrentUserAccessTokenList(ctx context.Context, params CurrentUserAccessTokenListParams) (*DeviceAccessTokenResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -4933,13 +4698,12 @@ func (c *Client) InstanceNetworkInterfaceView(ctx context.Context, params Instan ctx, nil, "GET", - resolveRelative(c.host, "/v1/network-interfaces/{{.interface}}"), - map[string]string{ - "interface": string(params.Interface), - }, + resolveRelative(c.host, "/v1/me/access-tokens"), + map[string]string{}, map[string]string{ - "instance": string(params.Instance), - "project": string(params.Project), + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + "sort_by": string(params.SortBy), }, ) if err != nil { @@ -4963,7 +4727,7 @@ func (c *Client) InstanceNetworkInterfaceView(ctx context.Context, params Instan return nil, errors.New("request returned an empty body in the response") } - var body InstanceNetworkInterface + var body DeviceAccessTokenResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -4972,66 +4736,36 @@ func (c *Client) InstanceNetworkInterfaceView(ctx context.Context, params Instan return &body, nil } -// InstanceNetworkInterfaceUpdate: Update network interface -func (c *Client) InstanceNetworkInterfaceUpdate(ctx context.Context, params InstanceNetworkInterfaceUpdateParams) (*InstanceNetworkInterface, error) { +// CurrentUserAccessTokenListAllPages: List access tokens +// List device access tokens for the currently authenticated user. +// +// This method is a wrapper around the `CurrentUserAccessTokenList` method. +// This method returns all the pages at once. +func (c *Client) CurrentUserAccessTokenListAllPages(ctx context.Context, params CurrentUserAccessTokenListParams) ([]DeviceAccessToken, error) { if err := params.Validate(); err != nil { return nil, err } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return nil, fmt.Errorf("encoding json body request failed: %v", err) - } - - // Create the request - req, err := c.buildRequest( - ctx, - b, - "PUT", - resolveRelative(c.host, "/v1/network-interfaces/{{.interface}}"), - map[string]string{ - "interface": string(params.Interface), - }, - map[string]string{ - "instance": string(params.Instance), - "project": string(params.Project), - }, - ) - if err != nil { - return nil, fmt.Errorf("error building request: %v", err) - } - - // Send the request. - resp, err := c.client.Do(req) - if err != nil { - return nil, fmt.Errorf("error sending request: %v", err) - } - defer resp.Body.Close() - - // Create and return an HTTPError when an error response code is received. - if err := NewHTTPError(resp); err != nil { - return nil, err - } - - // Decode the body from the response. - if resp.Body == nil { - return nil, errors.New("request returned an empty body in the response") - } - - var body InstanceNetworkInterface - if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { - return nil, fmt.Errorf("error decoding response body: %v", err) + var allPages []DeviceAccessToken + params.PageToken = "" + params.Limit = NewPointer(100) + for { + page, err := c.CurrentUserAccessTokenList(ctx, params) + if err != nil { + return nil, err + } + allPages = append(allPages, page.Items...) + if page.NextPage == "" || page.NextPage == params.PageToken { + break + } + params.PageToken = page.NextPage } - // Return the response. - return &body, nil + return allPages, nil } -// InstanceNetworkInterfaceDelete: Delete network interface -// Note that the primary interface for an instance cannot be deleted if there are any secondary interfaces. A -// new primary interface must be designated first. The primary interface can be deleted if there are no secondary -// interfaces. -func (c *Client) InstanceNetworkInterfaceDelete(ctx context.Context, params InstanceNetworkInterfaceDeleteParams) error { +// CurrentUserAccessTokenDelete: Delete access token +// Delete a device access token for the currently authenticated user. +func (c *Client) CurrentUserAccessTokenDelete(ctx context.Context, params CurrentUserAccessTokenDeleteParams) error { if err := params.Validate(); err != nil { return err } @@ -5040,14 +4774,11 @@ func (c *Client) InstanceNetworkInterfaceDelete(ctx context.Context, params Inst ctx, nil, "DELETE", - resolveRelative(c.host, "/v1/network-interfaces/{{.interface}}"), - map[string]string{ - "interface": string(params.Interface), - }, + resolveRelative(c.host, "/v1/me/access-tokens/{{.token_id}}"), map[string]string{ - "instance": string(params.Instance), - "project": string(params.Project), + "token_id": params.TokenId, }, + map[string]string{}, ) if err != nil { return fmt.Errorf("error building request: %v", err) @@ -5068,58 +4799,25 @@ func (c *Client) InstanceNetworkInterfaceDelete(ctx context.Context, params Inst return nil } -// Ping: Ping API -// Always responds with Ok if it responds at all. -func (c *Client) Ping(ctx context.Context) (*Ping, error) { - // Create the request - req, err := c.buildRequest( - ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/ping"), - map[string]string{}, - map[string]string{}, - ) - if err != nil { - return nil, fmt.Errorf("error building request: %v", err) - } - - // Send the request. - resp, err := c.client.Do(req) - if err != nil { - return nil, fmt.Errorf("error sending request: %v", err) - } - defer resp.Body.Close() - - // Create and return an HTTPError when an error response code is received. - if err := NewHTTPError(resp); err != nil { +// CurrentUserGroups: Fetch current user's groups +// +// To iterate over all pages, use the `CurrentUserGroupsAllPages` method, instead. +func (c *Client) CurrentUserGroups(ctx context.Context, params CurrentUserGroupsParams) (*GroupResultsPage, error) { + if err := params.Validate(); err != nil { return nil, err } - - // Decode the body from the response. - if resp.Body == nil { - return nil, errors.New("request returned an empty body in the response") - } - - var body Ping - if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { - return nil, fmt.Errorf("error decoding response body: %v", err) - } - - // Return the response. - return &body, nil -} - -// PolicyView: Fetch current silo's IAM policy -func (c *Client) PolicyView(ctx context.Context) (*SiloRolePolicy, error) { // Create the request req, err := c.buildRequest( ctx, nil, "GET", - resolveRelative(c.host, "/v1/policy"), - map[string]string{}, + resolveRelative(c.host, "/v1/me/groups"), map[string]string{}, + map[string]string{ + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + "sort_by": string(params.SortBy), + }, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -5142,7 +4840,7 @@ func (c *Client) PolicyView(ctx context.Context) (*SiloRolePolicy, error) { return nil, errors.New("request returned an empty body in the response") } - var body SiloRolePolicy + var body GroupResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -5151,60 +4849,37 @@ func (c *Client) PolicyView(ctx context.Context) (*SiloRolePolicy, error) { return &body, nil } -// PolicyUpdate: Update current silo's IAM policy -func (c *Client) PolicyUpdate(ctx context.Context, params PolicyUpdateParams) (*SiloRolePolicy, error) { +// CurrentUserGroupsAllPages: Fetch current user's groups +// +// This method is a wrapper around the `CurrentUserGroups` method. +// This method returns all the pages at once. +func (c *Client) CurrentUserGroupsAllPages(ctx context.Context, params CurrentUserGroupsParams) ([]Group, error) { if err := params.Validate(); err != nil { return nil, err } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return nil, fmt.Errorf("encoding json body request failed: %v", err) - } - - // Create the request - req, err := c.buildRequest( - ctx, - b, - "PUT", - resolveRelative(c.host, "/v1/policy"), - map[string]string{}, - map[string]string{}, - ) - if err != nil { - return nil, fmt.Errorf("error building request: %v", err) - } - - // Send the request. - resp, err := c.client.Do(req) - if err != nil { - return nil, fmt.Errorf("error sending request: %v", err) - } - defer resp.Body.Close() - - // Create and return an HTTPError when an error response code is received. - if err := NewHTTPError(resp); err != nil { - return nil, err - } - - // Decode the body from the response. - if resp.Body == nil { - return nil, errors.New("request returned an empty body in the response") - } - - var body SiloRolePolicy - if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { - return nil, fmt.Errorf("error decoding response body: %v", err) + var allPages []Group + params.PageToken = "" + params.Limit = NewPointer(100) + for { + page, err := c.CurrentUserGroups(ctx, params) + if err != nil { + return nil, err + } + allPages = append(allPages, page.Items...) + if page.NextPage == "" || page.NextPage == params.PageToken { + break + } + params.PageToken = page.NextPage } - // Return the response. - return &body, nil + return allPages, nil } -// ProjectList: List projects +// CurrentUserSshKeyList: List SSH public keys +// Lists SSH public keys for the currently authenticated user. // -// To iterate over all pages, use the `ProjectListAllPages` method, instead. -func (c *Client) ProjectList(ctx context.Context, params ProjectListParams) (*ProjectResultsPage, error) { +// To iterate over all pages, use the `CurrentUserSshKeyListAllPages` method, instead. +func (c *Client) CurrentUserSshKeyList(ctx context.Context, params CurrentUserSshKeyListParams) (*SshKeyResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -5213,7 +4888,7 @@ func (c *Client) ProjectList(ctx context.Context, params ProjectListParams) (*Pr ctx, nil, "GET", - resolveRelative(c.host, "/v1/projects"), + resolveRelative(c.host, "/v1/me/ssh-keys"), map[string]string{}, map[string]string{ "limit": PointerIntToStr(params.Limit), @@ -5242,7 +4917,7 @@ func (c *Client) ProjectList(ctx context.Context, params ProjectListParams) (*Pr return nil, errors.New("request returned an empty body in the response") } - var body ProjectResultsPage + var body SshKeyResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -5251,19 +4926,20 @@ func (c *Client) ProjectList(ctx context.Context, params ProjectListParams) (*Pr return &body, nil } -// ProjectListAllPages: List projects +// CurrentUserSshKeyListAllPages: List SSH public keys +// Lists SSH public keys for the currently authenticated user. // -// This method is a wrapper around the `ProjectList` method. +// This method is a wrapper around the `CurrentUserSshKeyList` method. // This method returns all the pages at once. -func (c *Client) ProjectListAllPages(ctx context.Context, params ProjectListParams) ([]Project, error) { +func (c *Client) CurrentUserSshKeyListAllPages(ctx context.Context, params CurrentUserSshKeyListParams) ([]SshKey, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []Project + var allPages []SshKey params.PageToken = "" params.Limit = NewPointer(100) for { - page, err := c.ProjectList(ctx, params) + page, err := c.CurrentUserSshKeyList(ctx, params) if err != nil { return nil, err } @@ -5277,8 +4953,9 @@ func (c *Client) ProjectListAllPages(ctx context.Context, params ProjectListPara return allPages, nil } -// ProjectCreate: Create project -func (c *Client) ProjectCreate(ctx context.Context, params ProjectCreateParams) (*Project, error) { +// CurrentUserSshKeyCreate: Create SSH public key +// Create an SSH public key for the currently authenticated user. +func (c *Client) CurrentUserSshKeyCreate(ctx context.Context, params CurrentUserSshKeyCreateParams) (*SshKey, error) { if err := params.Validate(); err != nil { return nil, err } @@ -5293,7 +4970,7 @@ func (c *Client) ProjectCreate(ctx context.Context, params ProjectCreateParams) ctx, b, "POST", - resolveRelative(c.host, "/v1/projects"), + resolveRelative(c.host, "/v1/me/ssh-keys"), map[string]string{}, map[string]string{}, ) @@ -5318,7 +4995,7 @@ func (c *Client) ProjectCreate(ctx context.Context, params ProjectCreateParams) return nil, errors.New("request returned an empty body in the response") } - var body Project + var body SshKey if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -5327,8 +5004,9 @@ func (c *Client) ProjectCreate(ctx context.Context, params ProjectCreateParams) return &body, nil } -// ProjectView: Fetch project -func (c *Client) ProjectView(ctx context.Context, params ProjectViewParams) (*Project, error) { +// CurrentUserSshKeyView: Fetch SSH public key +// Fetch SSH public key associated with the currently authenticated user. +func (c *Client) CurrentUserSshKeyView(ctx context.Context, params CurrentUserSshKeyViewParams) (*SshKey, error) { if err := params.Validate(); err != nil { return nil, err } @@ -5337,9 +5015,9 @@ func (c *Client) ProjectView(ctx context.Context, params ProjectViewParams) (*Pr ctx, nil, "GET", - resolveRelative(c.host, "/v1/projects/{{.project}}"), + resolveRelative(c.host, "/v1/me/ssh-keys/{{.ssh_key}}"), map[string]string{ - "project": string(params.Project), + "ssh_key": string(params.SshKey), }, map[string]string{}, ) @@ -5364,7 +5042,7 @@ func (c *Client) ProjectView(ctx context.Context, params ProjectViewParams) (*Pr return nil, errors.New("request returned an empty body in the response") } - var body Project + var body SshKey if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -5373,71 +5051,20 @@ func (c *Client) ProjectView(ctx context.Context, params ProjectViewParams) (*Pr return &body, nil } -// ProjectUpdate: Update a project -func (c *Client) ProjectUpdate(ctx context.Context, params ProjectUpdateParams) (*Project, error) { +// CurrentUserSshKeyDelete: Delete SSH public key +// Delete an SSH public key associated with the currently authenticated user. +func (c *Client) CurrentUserSshKeyDelete(ctx context.Context, params CurrentUserSshKeyDeleteParams) error { if err := params.Validate(); err != nil { - return nil, err - } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return nil, fmt.Errorf("encoding json body request failed: %v", err) - } - - // Create the request - req, err := c.buildRequest( - ctx, - b, - "PUT", - resolveRelative(c.host, "/v1/projects/{{.project}}"), - map[string]string{ - "project": string(params.Project), - }, - map[string]string{}, - ) - if err != nil { - return nil, fmt.Errorf("error building request: %v", err) - } - - // Send the request. - resp, err := c.client.Do(req) - if err != nil { - return nil, fmt.Errorf("error sending request: %v", err) - } - defer resp.Body.Close() - - // Create and return an HTTPError when an error response code is received. - if err := NewHTTPError(resp); err != nil { - return nil, err - } - - // Decode the body from the response. - if resp.Body == nil { - return nil, errors.New("request returned an empty body in the response") - } - - var body Project - if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { - return nil, fmt.Errorf("error decoding response body: %v", err) - } - - // Return the response. - return &body, nil -} - -// ProjectDelete: Delete project -func (c *Client) ProjectDelete(ctx context.Context, params ProjectDeleteParams) error { - if err := params.Validate(); err != nil { - return err + return err } // Create the request req, err := c.buildRequest( ctx, nil, "DELETE", - resolveRelative(c.host, "/v1/projects/{{.project}}"), + resolveRelative(c.host, "/v1/me/ssh-keys/{{.ssh_key}}"), map[string]string{ - "project": string(params.Project), + "ssh_key": string(params.SshKey), }, map[string]string{}, ) @@ -5460,8 +5087,11 @@ func (c *Client) ProjectDelete(ctx context.Context, params ProjectDeleteParams) return nil } -// ProjectPolicyView: Fetch project's IAM policy -func (c *Client) ProjectPolicyView(ctx context.Context, params ProjectPolicyViewParams) (*ProjectRolePolicy, error) { +// SiloMetric: View metrics +// View CPU, memory, or storage utilization metrics at the silo or project level. +// +// To iterate over all pages, use the `SiloMetricAllPages` method, instead. +func (c *Client) SiloMetric(ctx context.Context, params SiloMetricParams) (*MeasurementResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -5470,11 +5100,18 @@ func (c *Client) ProjectPolicyView(ctx context.Context, params ProjectPolicyView ctx, nil, "GET", - resolveRelative(c.host, "/v1/projects/{{.project}}/policy"), + resolveRelative(c.host, "/v1/metrics/{{.metric_name}}"), map[string]string{ - "project": string(params.Project), + "metric_name": string(params.MetricName), + }, + map[string]string{ + "end_time": params.EndTime.Format(time.RFC3339), + "limit": PointerIntToStr(params.Limit), + "order": string(params.Order), + "page_token": params.PageToken, + "project": string(params.Project), + "start_time": params.StartTime.Format(time.RFC3339), }, - map[string]string{}, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -5497,7 +5134,7 @@ func (c *Client) ProjectPolicyView(ctx context.Context, params ProjectPolicyView return nil, errors.New("request returned an empty body in the response") } - var body ProjectRolePolicy + var body MeasurementResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -5506,62 +5143,37 @@ func (c *Client) ProjectPolicyView(ctx context.Context, params ProjectPolicyView return &body, nil } -// ProjectPolicyUpdate: Update project's IAM policy -func (c *Client) ProjectPolicyUpdate(ctx context.Context, params ProjectPolicyUpdateParams) (*ProjectRolePolicy, error) { +// SiloMetricAllPages: View metrics +// View CPU, memory, or storage utilization metrics at the silo or project level. +// +// This method is a wrapper around the `SiloMetric` method. +// This method returns all the pages at once. +func (c *Client) SiloMetricAllPages(ctx context.Context, params SiloMetricParams) ([]Measurement, error) { if err := params.Validate(); err != nil { return nil, err } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return nil, fmt.Errorf("encoding json body request failed: %v", err) - } - - // Create the request - req, err := c.buildRequest( - ctx, - b, - "PUT", - resolveRelative(c.host, "/v1/projects/{{.project}}/policy"), - map[string]string{ - "project": string(params.Project), - }, - map[string]string{}, - ) - if err != nil { - return nil, fmt.Errorf("error building request: %v", err) - } - - // Send the request. - resp, err := c.client.Do(req) - if err != nil { - return nil, fmt.Errorf("error sending request: %v", err) - } - defer resp.Body.Close() - - // Create and return an HTTPError when an error response code is received. - if err := NewHTTPError(resp); err != nil { - return nil, err - } - - // Decode the body from the response. - if resp.Body == nil { - return nil, errors.New("request returned an empty body in the response") - } - - var body ProjectRolePolicy - if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { - return nil, fmt.Errorf("error decoding response body: %v", err) + var allPages []Measurement + params.PageToken = "" + params.Limit = NewPointer(100) + for { + page, err := c.SiloMetric(ctx, params) + if err != nil { + return nil, err + } + allPages = append(allPages, page.Items...) + if page.NextPage == "" || page.NextPage == params.PageToken { + break + } + params.PageToken = page.NextPage } - // Return the response. - return &body, nil + return allPages, nil } -// SnapshotList: List snapshots +// InstanceNetworkInterfaceList: List network interfaces // -// To iterate over all pages, use the `SnapshotListAllPages` method, instead. -func (c *Client) SnapshotList(ctx context.Context, params SnapshotListParams) (*SnapshotResultsPage, error) { +// To iterate over all pages, use the `InstanceNetworkInterfaceListAllPages` method, instead. +func (c *Client) InstanceNetworkInterfaceList(ctx context.Context, params InstanceNetworkInterfaceListParams) (*InstanceNetworkInterfaceResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -5570,9 +5182,10 @@ func (c *Client) SnapshotList(ctx context.Context, params SnapshotListParams) (* ctx, nil, "GET", - resolveRelative(c.host, "/v1/snapshots"), + resolveRelative(c.host, "/v1/network-interfaces"), map[string]string{}, map[string]string{ + "instance": string(params.Instance), "limit": PointerIntToStr(params.Limit), "page_token": params.PageToken, "project": string(params.Project), @@ -5600,7 +5213,7 @@ func (c *Client) SnapshotList(ctx context.Context, params SnapshotListParams) (* return nil, errors.New("request returned an empty body in the response") } - var body SnapshotResultsPage + var body InstanceNetworkInterfaceResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -5609,19 +5222,19 @@ func (c *Client) SnapshotList(ctx context.Context, params SnapshotListParams) (* return &body, nil } -// SnapshotListAllPages: List snapshots +// InstanceNetworkInterfaceListAllPages: List network interfaces // -// This method is a wrapper around the `SnapshotList` method. +// This method is a wrapper around the `InstanceNetworkInterfaceList` method. // This method returns all the pages at once. -func (c *Client) SnapshotListAllPages(ctx context.Context, params SnapshotListParams) ([]Snapshot, error) { +func (c *Client) InstanceNetworkInterfaceListAllPages(ctx context.Context, params InstanceNetworkInterfaceListParams) ([]InstanceNetworkInterface, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []Snapshot + var allPages []InstanceNetworkInterface params.PageToken = "" params.Limit = NewPointer(100) for { - page, err := c.SnapshotList(ctx, params) + page, err := c.InstanceNetworkInterfaceList(ctx, params) if err != nil { return nil, err } @@ -5635,9 +5248,8 @@ func (c *Client) SnapshotListAllPages(ctx context.Context, params SnapshotListPa return allPages, nil } -// SnapshotCreate: Create snapshot -// Creates a point-in-time snapshot from a disk. -func (c *Client) SnapshotCreate(ctx context.Context, params SnapshotCreateParams) (*Snapshot, error) { +// InstanceNetworkInterfaceCreate: Create network interface +func (c *Client) InstanceNetworkInterfaceCreate(ctx context.Context, params InstanceNetworkInterfaceCreateParams) (*InstanceNetworkInterface, error) { if err := params.Validate(); err != nil { return nil, err } @@ -5652,10 +5264,11 @@ func (c *Client) SnapshotCreate(ctx context.Context, params SnapshotCreateParams ctx, b, "POST", - resolveRelative(c.host, "/v1/snapshots"), + resolveRelative(c.host, "/v1/network-interfaces"), map[string]string{}, map[string]string{ - "project": string(params.Project), + "instance": string(params.Instance), + "project": string(params.Project), }, ) if err != nil { @@ -5679,7 +5292,7 @@ func (c *Client) SnapshotCreate(ctx context.Context, params SnapshotCreateParams return nil, errors.New("request returned an empty body in the response") } - var body Snapshot + var body InstanceNetworkInterface if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -5688,8 +5301,8 @@ func (c *Client) SnapshotCreate(ctx context.Context, params SnapshotCreateParams return &body, nil } -// SnapshotView: Fetch snapshot -func (c *Client) SnapshotView(ctx context.Context, params SnapshotViewParams) (*Snapshot, error) { +// InstanceNetworkInterfaceView: Fetch network interface +func (c *Client) InstanceNetworkInterfaceView(ctx context.Context, params InstanceNetworkInterfaceViewParams) (*InstanceNetworkInterface, error) { if err := params.Validate(); err != nil { return nil, err } @@ -5698,12 +5311,13 @@ func (c *Client) SnapshotView(ctx context.Context, params SnapshotViewParams) (* ctx, nil, "GET", - resolveRelative(c.host, "/v1/snapshots/{{.snapshot}}"), + resolveRelative(c.host, "/v1/network-interfaces/{{.interface}}"), map[string]string{ - "snapshot": string(params.Snapshot), + "interface": string(params.Interface), }, map[string]string{ - "project": string(params.Project), + "instance": string(params.Instance), + "project": string(params.Project), }, ) if err != nil { @@ -5727,7 +5341,7 @@ func (c *Client) SnapshotView(ctx context.Context, params SnapshotViewParams) (* return nil, errors.New("request returned an empty body in the response") } - var body Snapshot + var body InstanceNetworkInterface if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -5736,74 +5350,114 @@ func (c *Client) SnapshotView(ctx context.Context, params SnapshotViewParams) (* return &body, nil } -// SnapshotDelete: Delete snapshot -func (c *Client) SnapshotDelete(ctx context.Context, params SnapshotDeleteParams) error { +// InstanceNetworkInterfaceUpdate: Update network interface +func (c *Client) InstanceNetworkInterfaceUpdate(ctx context.Context, params InstanceNetworkInterfaceUpdateParams) (*InstanceNetworkInterface, error) { if err := params.Validate(); err != nil { - return err + return nil, err + } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) } + // Create the request req, err := c.buildRequest( ctx, - nil, - "DELETE", - resolveRelative(c.host, "/v1/snapshots/{{.snapshot}}"), + b, + "PUT", + resolveRelative(c.host, "/v1/network-interfaces/{{.interface}}"), map[string]string{ - "snapshot": string(params.Snapshot), + "interface": string(params.Interface), }, map[string]string{ - "project": string(params.Project), + "instance": string(params.Instance), + "project": string(params.Project), }, ) if err != nil { - return fmt.Errorf("error building request: %v", err) + return nil, fmt.Errorf("error building request: %v", err) } // Send the request. resp, err := c.client.Do(req) if err != nil { - return fmt.Errorf("error sending request: %v", err) + return nil, fmt.Errorf("error sending request: %v", err) } defer resp.Body.Close() // Create and return an HTTPError when an error response code is received. if err := NewHTTPError(resp); err != nil { - return err + return nil, err } - return nil + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body InstanceNetworkInterface + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil } -// AuditLogList: View audit log -// A single item in the audit log represents both the beginning and end of the logged operation (represented by -// `time_started` and `time_completed`) so that clients do not have to find multiple entries and match them up -// by request ID to get the full picture of an operation. Because timestamps may not be unique, entries have -// also have a unique `id` that can be used to deduplicate items fetched from overlapping time intervals. -// -// Audit log entries are designed to be immutable: once you see an entry, fetching it again will never get you -// a different result. The list is ordered by `time_completed`, not `time_started`. If you fetch the audit log -// for a time range that is fully in the past, the resulting list is guaranteed to be complete, i.e., fetching the -// same timespan again later will always produce the same set of entries. -// -// To iterate over all pages, use the `AuditLogListAllPages` method, instead. -func (c *Client) AuditLogList(ctx context.Context, params AuditLogListParams) (*AuditLogEntryResultsPage, error) { +// InstanceNetworkInterfaceDelete: Delete network interface +// Note that the primary interface for an instance cannot be deleted if there are any secondary interfaces. A +// new primary interface must be designated first. The primary interface can be deleted if there are no secondary +// interfaces. +func (c *Client) InstanceNetworkInterfaceDelete(ctx context.Context, params InstanceNetworkInterfaceDeleteParams) error { if err := params.Validate(); err != nil { - return nil, err + return err } // Create the request req, err := c.buildRequest( ctx, nil, - "GET", - resolveRelative(c.host, "/v1/system/audit-log"), - map[string]string{}, + "DELETE", + resolveRelative(c.host, "/v1/network-interfaces/{{.interface}}"), map[string]string{ - "end_time": params.EndTime.Format(time.RFC3339), - "limit": PointerIntToStr(params.Limit), - "page_token": params.PageToken, - "sort_by": string(params.SortBy), - "start_time": params.StartTime.Format(time.RFC3339), + "interface": string(params.Interface), + }, + map[string]string{ + "instance": string(params.Instance), + "project": string(params.Project), }, ) + if err != nil { + return fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return err + } + + return nil +} + +// Ping: Ping API +// Always responds with Ok if it responds at all. +func (c *Client) Ping(ctx context.Context) (*Ping, error) { + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "GET", + resolveRelative(c.host, "/v1/ping"), + map[string]string{}, + map[string]string{}, + ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) } @@ -5825,7 +5479,7 @@ func (c *Client) AuditLogList(ctx context.Context, params AuditLogListParams) (* return nil, errors.New("request returned an empty body in the response") } - var body AuditLogEntryResultsPage + var body Ping if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -5834,60 +5488,16 @@ func (c *Client) AuditLogList(ctx context.Context, params AuditLogListParams) (* return &body, nil } -// AuditLogListAllPages: View audit log -// A single item in the audit log represents both the beginning and end of the logged operation (represented by -// `time_started` and `time_completed`) so that clients do not have to find multiple entries and match them up -// by request ID to get the full picture of an operation. Because timestamps may not be unique, entries have -// also have a unique `id` that can be used to deduplicate items fetched from overlapping time intervals. -// -// Audit log entries are designed to be immutable: once you see an entry, fetching it again will never get you -// a different result. The list is ordered by `time_completed`, not `time_started`. If you fetch the audit log -// for a time range that is fully in the past, the resulting list is guaranteed to be complete, i.e., fetching the -// same timespan again later will always produce the same set of entries. -// -// This method is a wrapper around the `AuditLogList` method. -// This method returns all the pages at once. -func (c *Client) AuditLogListAllPages(ctx context.Context, params AuditLogListParams) ([]AuditLogEntry, error) { - if err := params.Validate(); err != nil { - return nil, err - } - var allPages []AuditLogEntry - params.PageToken = "" - params.Limit = NewPointer(100) - for { - page, err := c.AuditLogList(ctx, params) - if err != nil { - return nil, err - } - allPages = append(allPages, page.Items...) - if page.NextPage == "" || page.NextPage == params.PageToken { - break - } - params.PageToken = page.NextPage - } - - return allPages, nil -} - -// PhysicalDiskList: List physical disks -// -// To iterate over all pages, use the `PhysicalDiskListAllPages` method, instead. -func (c *Client) PhysicalDiskList(ctx context.Context, params PhysicalDiskListParams) (*PhysicalDiskResultsPage, error) { - if err := params.Validate(); err != nil { - return nil, err - } +// PolicyView: Fetch current silo's IAM policy +func (c *Client) PolicyView(ctx context.Context) (*SiloRolePolicy, error) { // Create the request req, err := c.buildRequest( ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/hardware/disks"), + resolveRelative(c.host, "/v1/policy"), + map[string]string{}, map[string]string{}, - map[string]string{ - "limit": PointerIntToStr(params.Limit), - "page_token": params.PageToken, - "sort_by": string(params.SortBy), - }, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -5910,7 +5520,7 @@ func (c *Client) PhysicalDiskList(ctx context.Context, params PhysicalDiskListPa return nil, errors.New("request returned an empty body in the response") } - var body PhysicalDiskResultsPage + var body SiloRolePolicy if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -5919,46 +5529,24 @@ func (c *Client) PhysicalDiskList(ctx context.Context, params PhysicalDiskListPa return &body, nil } -// PhysicalDiskListAllPages: List physical disks -// -// This method is a wrapper around the `PhysicalDiskList` method. -// This method returns all the pages at once. -func (c *Client) PhysicalDiskListAllPages(ctx context.Context, params PhysicalDiskListParams) ([]PhysicalDisk, error) { +// PolicyUpdate: Update current silo's IAM policy +func (c *Client) PolicyUpdate(ctx context.Context, params PolicyUpdateParams) (*SiloRolePolicy, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []PhysicalDisk - params.PageToken = "" - params.Limit = NewPointer(100) - for { - page, err := c.PhysicalDiskList(ctx, params) - if err != nil { - return nil, err - } - allPages = append(allPages, page.Items...) - if page.NextPage == "" || page.NextPage == params.PageToken { - break - } - params.PageToken = page.NextPage + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) } - return allPages, nil -} - -// PhysicalDiskView: Get a physical disk -func (c *Client) PhysicalDiskView(ctx context.Context, params PhysicalDiskViewParams) (*PhysicalDisk, error) { - if err := params.Validate(); err != nil { - return nil, err - } // Create the request req, err := c.buildRequest( ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/system/hardware/disks/{{.disk_id}}"), - map[string]string{ - "disk_id": params.DiskId, - }, + b, + "PUT", + resolveRelative(c.host, "/v1/policy"), + map[string]string{}, map[string]string{}, ) if err != nil { @@ -5982,7 +5570,7 @@ func (c *Client) PhysicalDiskView(ctx context.Context, params PhysicalDiskViewPa return nil, errors.New("request returned an empty body in the response") } - var body PhysicalDisk + var body SiloRolePolicy if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -5991,10 +5579,10 @@ func (c *Client) PhysicalDiskView(ctx context.Context, params PhysicalDiskViewPa return &body, nil } -// NetworkingSwitchPortLldpNeighbors: Fetch the LLDP neighbors seen on a switch port +// ProjectList: List projects // -// To iterate over all pages, use the `NetworkingSwitchPortLldpNeighborsAllPages` method, instead. -func (c *Client) NetworkingSwitchPortLldpNeighbors(ctx context.Context, params NetworkingSwitchPortLldpNeighborsParams) (*LldpNeighborResultsPage, error) { +// To iterate over all pages, use the `ProjectListAllPages` method, instead. +func (c *Client) ProjectList(ctx context.Context, params ProjectListParams) (*ProjectResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -6003,12 +5591,8 @@ func (c *Client) NetworkingSwitchPortLldpNeighbors(ctx context.Context, params N ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/hardware/rack-switch-port/{{.rack_id}}/{{.switch_location}}/{{.port}}/lldp/neighbors"), - map[string]string{ - "port": string(params.Port), - "rack_id": params.RackId, - "switch_location": string(params.SwitchLocation), - }, + resolveRelative(c.host, "/v1/projects"), + map[string]string{}, map[string]string{ "limit": PointerIntToStr(params.Limit), "page_token": params.PageToken, @@ -6036,7 +5620,7 @@ func (c *Client) NetworkingSwitchPortLldpNeighbors(ctx context.Context, params N return nil, errors.New("request returned an empty body in the response") } - var body LldpNeighborResultsPage + var body ProjectResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -6045,19 +5629,19 @@ func (c *Client) NetworkingSwitchPortLldpNeighbors(ctx context.Context, params N return &body, nil } -// NetworkingSwitchPortLldpNeighborsAllPages: Fetch the LLDP neighbors seen on a switch port +// ProjectListAllPages: List projects // -// This method is a wrapper around the `NetworkingSwitchPortLldpNeighbors` method. +// This method is a wrapper around the `ProjectList` method. // This method returns all the pages at once. -func (c *Client) NetworkingSwitchPortLldpNeighborsAllPages(ctx context.Context, params NetworkingSwitchPortLldpNeighborsParams) ([]LldpNeighbor, error) { +func (c *Client) ProjectListAllPages(ctx context.Context, params ProjectListParams) ([]Project, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []LldpNeighbor + var allPages []Project params.PageToken = "" params.Limit = NewPointer(100) for { - page, err := c.NetworkingSwitchPortLldpNeighbors(ctx, params) + page, err := c.ProjectList(ctx, params) if err != nil { return nil, err } @@ -6071,25 +5655,25 @@ func (c *Client) NetworkingSwitchPortLldpNeighborsAllPages(ctx context.Context, return allPages, nil } -// RackList: List racks -// -// To iterate over all pages, use the `RackListAllPages` method, instead. -func (c *Client) RackList(ctx context.Context, params RackListParams) (*RackResultsPage, error) { +// ProjectCreate: Create project +func (c *Client) ProjectCreate(ctx context.Context, params ProjectCreateParams) (*Project, error) { if err := params.Validate(); err != nil { return nil, err } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + // Create the request req, err := c.buildRequest( ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/system/hardware/racks"), + b, + "POST", + resolveRelative(c.host, "/v1/projects"), + map[string]string{}, map[string]string{}, - map[string]string{ - "limit": PointerIntToStr(params.Limit), - "page_token": params.PageToken, - "sort_by": string(params.SortBy), - }, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -6112,7 +5696,7 @@ func (c *Client) RackList(ctx context.Context, params RackListParams) (*RackResu return nil, errors.New("request returned an empty body in the response") } - var body RackResultsPage + var body Project if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -6121,34 +5705,8 @@ func (c *Client) RackList(ctx context.Context, params RackListParams) (*RackResu return &body, nil } -// RackListAllPages: List racks -// -// This method is a wrapper around the `RackList` method. -// This method returns all the pages at once. -func (c *Client) RackListAllPages(ctx context.Context, params RackListParams) ([]Rack, error) { - if err := params.Validate(); err != nil { - return nil, err - } - var allPages []Rack - params.PageToken = "" - params.Limit = NewPointer(100) - for { - page, err := c.RackList(ctx, params) - if err != nil { - return nil, err - } - allPages = append(allPages, page.Items...) - if page.NextPage == "" || page.NextPage == params.PageToken { - break - } - params.PageToken = page.NextPage - } - - return allPages, nil -} - -// RackView: Fetch rack -func (c *Client) RackView(ctx context.Context, params RackViewParams) (*Rack, error) { +// ProjectView: Fetch project +func (c *Client) ProjectView(ctx context.Context, params ProjectViewParams) (*Project, error) { if err := params.Validate(); err != nil { return nil, err } @@ -6157,9 +5715,9 @@ func (c *Client) RackView(ctx context.Context, params RackViewParams) (*Rack, er ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/hardware/racks/{{.rack_id}}"), + resolveRelative(c.host, "/v1/projects/{{.project}}"), map[string]string{ - "rack_id": params.RackId, + "project": string(params.Project), }, map[string]string{}, ) @@ -6184,7 +5742,7 @@ func (c *Client) RackView(ctx context.Context, params RackViewParams) (*Rack, er return nil, errors.New("request returned an empty body in the response") } - var body Rack + var body Project if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -6193,25 +5751,27 @@ func (c *Client) RackView(ctx context.Context, params RackViewParams) (*Rack, er return &body, nil } -// SledList: List sleds -// -// To iterate over all pages, use the `SledListAllPages` method, instead. -func (c *Client) SledList(ctx context.Context, params SledListParams) (*SledResultsPage, error) { +// ProjectUpdate: Update project +func (c *Client) ProjectUpdate(ctx context.Context, params ProjectUpdateParams) (*Project, error) { if err := params.Validate(); err != nil { return nil, err } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + // Create the request req, err := c.buildRequest( ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/system/hardware/sleds"), - map[string]string{}, + b, + "PUT", + resolveRelative(c.host, "/v1/projects/{{.project}}"), map[string]string{ - "limit": PointerIntToStr(params.Limit), - "page_token": params.PageToken, - "sort_by": string(params.SortBy), + "project": string(params.Project), }, + map[string]string{}, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -6234,7 +5794,7 @@ func (c *Client) SledList(ctx context.Context, params SledListParams) (*SledResu return nil, errors.New("request returned an empty body in the response") } - var body SledResultsPage + var body Project if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -6243,86 +5803,43 @@ func (c *Client) SledList(ctx context.Context, params SledListParams) (*SledResu return &body, nil } -// SledListAllPages: List sleds -// -// This method is a wrapper around the `SledList` method. -// This method returns all the pages at once. -func (c *Client) SledListAllPages(ctx context.Context, params SledListParams) ([]Sled, error) { +// ProjectDelete: Delete project +func (c *Client) ProjectDelete(ctx context.Context, params ProjectDeleteParams) error { if err := params.Validate(); err != nil { - return nil, err - } - var allPages []Sled - params.PageToken = "" - params.Limit = NewPointer(100) - for { - page, err := c.SledList(ctx, params) - if err != nil { - return nil, err - } - allPages = append(allPages, page.Items...) - if page.NextPage == "" || page.NextPage == params.PageToken { - break - } - params.PageToken = page.NextPage - } - - return allPages, nil -} - -// SledAdd: Add sled to initialized rack -func (c *Client) SledAdd(ctx context.Context, params SledAddParams) (*SledId, error) { - if err := params.Validate(); err != nil { - return nil, err - } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return nil, fmt.Errorf("encoding json body request failed: %v", err) + return err } - // Create the request req, err := c.buildRequest( ctx, - b, - "POST", - resolveRelative(c.host, "/v1/system/hardware/sleds"), - map[string]string{}, + nil, + "DELETE", + resolveRelative(c.host, "/v1/projects/{{.project}}"), + map[string]string{ + "project": string(params.Project), + }, map[string]string{}, ) if err != nil { - return nil, fmt.Errorf("error building request: %v", err) + return fmt.Errorf("error building request: %v", err) } // Send the request. resp, err := c.client.Do(req) if err != nil { - return nil, fmt.Errorf("error sending request: %v", err) + return fmt.Errorf("error sending request: %v", err) } defer resp.Body.Close() // Create and return an HTTPError when an error response code is received. if err := NewHTTPError(resp); err != nil { - return nil, err - } - - // Decode the body from the response. - if resp.Body == nil { - return nil, errors.New("request returned an empty body in the response") - } - - var body SledId - if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { - return nil, fmt.Errorf("error decoding response body: %v", err) + return err } - // Return the response. - return &body, nil + return nil } -// SledListUninitialized: List uninitialized sleds -// -// To iterate over all pages, use the `SledListUninitializedAllPages` method, instead. -func (c *Client) SledListUninitialized(ctx context.Context, params SledListUninitializedParams) (*UninitializedSledResultsPage, error) { +// ProjectPolicyView: Fetch project's IAM policy +func (c *Client) ProjectPolicyView(ctx context.Context, params ProjectPolicyViewParams) (*ProjectRolePolicy, error) { if err := params.Validate(); err != nil { return nil, err } @@ -6331,12 +5848,11 @@ func (c *Client) SledListUninitialized(ctx context.Context, params SledListUnini ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/hardware/sleds-uninitialized"), - map[string]string{}, + resolveRelative(c.host, "/v1/projects/{{.project}}/policy"), map[string]string{ - "limit": PointerIntToStr(params.Limit), - "page_token": params.PageToken, + "project": string(params.Project), }, + map[string]string{}, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -6359,7 +5875,7 @@ func (c *Client) SledListUninitialized(ctx context.Context, params SledListUnini return nil, errors.New("request returned an empty body in the response") } - var body UninitializedSledResultsPage + var body ProjectRolePolicy if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -6368,45 +5884,25 @@ func (c *Client) SledListUninitialized(ctx context.Context, params SledListUnini return &body, nil } -// SledListUninitializedAllPages: List uninitialized sleds -// -// This method is a wrapper around the `SledListUninitialized` method. -// This method returns all the pages at once. -func (c *Client) SledListUninitializedAllPages(ctx context.Context, params SledListUninitializedParams) ([]UninitializedSled, error) { +// ProjectPolicyUpdate: Update project's IAM policy +func (c *Client) ProjectPolicyUpdate(ctx context.Context, params ProjectPolicyUpdateParams) (*ProjectRolePolicy, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []UninitializedSled - params.PageToken = "" - params.Limit = NewPointer(100) - for { - page, err := c.SledListUninitialized(ctx, params) - if err != nil { - return nil, err - } - allPages = append(allPages, page.Items...) - if page.NextPage == "" || page.NextPage == params.PageToken { - break - } - params.PageToken = page.NextPage + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) } - return allPages, nil -} - -// SledView: Fetch sled -func (c *Client) SledView(ctx context.Context, params SledViewParams) (*Sled, error) { - if err := params.Validate(); err != nil { - return nil, err - } // Create the request req, err := c.buildRequest( ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/system/hardware/sleds/{{.sled_id}}"), + b, + "PUT", + resolveRelative(c.host, "/v1/projects/{{.project}}/policy"), map[string]string{ - "sled_id": params.SledId, + "project": string(params.Project), }, map[string]string{}, ) @@ -6431,7 +5927,7 @@ func (c *Client) SledView(ctx context.Context, params SledViewParams) (*Sled, er return nil, errors.New("request returned an empty body in the response") } - var body Sled + var body ProjectRolePolicy if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -6440,10 +5936,10 @@ func (c *Client) SledView(ctx context.Context, params SledViewParams) (*Sled, er return &body, nil } -// SledPhysicalDiskList: List physical disks attached to sleds +// SnapshotList: List snapshots // -// To iterate over all pages, use the `SledPhysicalDiskListAllPages` method, instead. -func (c *Client) SledPhysicalDiskList(ctx context.Context, params SledPhysicalDiskListParams) (*PhysicalDiskResultsPage, error) { +// To iterate over all pages, use the `SnapshotListAllPages` method, instead. +func (c *Client) SnapshotList(ctx context.Context, params SnapshotListParams) (*SnapshotResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -6452,13 +5948,12 @@ func (c *Client) SledPhysicalDiskList(ctx context.Context, params SledPhysicalDi ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/hardware/sleds/{{.sled_id}}/disks"), - map[string]string{ - "sled_id": params.SledId, - }, + resolveRelative(c.host, "/v1/snapshots"), + map[string]string{}, map[string]string{ "limit": PointerIntToStr(params.Limit), "page_token": params.PageToken, + "project": string(params.Project), "sort_by": string(params.SortBy), }, ) @@ -6483,7 +5978,7 @@ func (c *Client) SledPhysicalDiskList(ctx context.Context, params SledPhysicalDi return nil, errors.New("request returned an empty body in the response") } - var body PhysicalDiskResultsPage + var body SnapshotResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -6492,19 +5987,19 @@ func (c *Client) SledPhysicalDiskList(ctx context.Context, params SledPhysicalDi return &body, nil } -// SledPhysicalDiskListAllPages: List physical disks attached to sleds +// SnapshotListAllPages: List snapshots // -// This method is a wrapper around the `SledPhysicalDiskList` method. +// This method is a wrapper around the `SnapshotList` method. // This method returns all the pages at once. -func (c *Client) SledPhysicalDiskListAllPages(ctx context.Context, params SledPhysicalDiskListParams) ([]PhysicalDisk, error) { +func (c *Client) SnapshotListAllPages(ctx context.Context, params SnapshotListParams) ([]Snapshot, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []PhysicalDisk + var allPages []Snapshot params.PageToken = "" params.Limit = NewPointer(100) for { - page, err := c.SledPhysicalDiskList(ctx, params) + page, err := c.SnapshotList(ctx, params) if err != nil { return nil, err } @@ -6518,26 +6013,27 @@ func (c *Client) SledPhysicalDiskListAllPages(ctx context.Context, params SledPh return allPages, nil } -// SledInstanceList: List instances running on given sled -// -// To iterate over all pages, use the `SledInstanceListAllPages` method, instead. -func (c *Client) SledInstanceList(ctx context.Context, params SledInstanceListParams) (*SledInstanceResultsPage, error) { +// SnapshotCreate: Create snapshot +// Creates a point-in-time snapshot from a disk. +func (c *Client) SnapshotCreate(ctx context.Context, params SnapshotCreateParams) (*Snapshot, error) { if err := params.Validate(); err != nil { return nil, err } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + // Create the request req, err := c.buildRequest( ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/system/hardware/sleds/{{.sled_id}}/instances"), - map[string]string{ - "sled_id": params.SledId, - }, + b, + "POST", + resolveRelative(c.host, "/v1/snapshots"), + map[string]string{}, map[string]string{ - "limit": PointerIntToStr(params.Limit), - "page_token": params.PageToken, - "sort_by": string(params.SortBy), + "project": string(params.Project), }, ) if err != nil { @@ -6561,7 +6057,7 @@ func (c *Client) SledInstanceList(ctx context.Context, params SledInstanceListPa return nil, errors.New("request returned an empty body in the response") } - var body SledInstanceResultsPage + var body Snapshot if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -6570,53 +6066,23 @@ func (c *Client) SledInstanceList(ctx context.Context, params SledInstanceListPa return &body, nil } -// SledInstanceListAllPages: List instances running on given sled -// -// This method is a wrapper around the `SledInstanceList` method. -// This method returns all the pages at once. -func (c *Client) SledInstanceListAllPages(ctx context.Context, params SledInstanceListParams) ([]SledInstance, error) { - if err := params.Validate(); err != nil { - return nil, err - } - var allPages []SledInstance - params.PageToken = "" - params.Limit = NewPointer(100) - for { - page, err := c.SledInstanceList(ctx, params) - if err != nil { - return nil, err - } - allPages = append(allPages, page.Items...) - if page.NextPage == "" || page.NextPage == params.PageToken { - break - } - params.PageToken = page.NextPage - } - - return allPages, nil -} - -// SledSetProvisionPolicy: Set sled provision policy -func (c *Client) SledSetProvisionPolicy(ctx context.Context, params SledSetProvisionPolicyParams) (*SledProvisionPolicyResponse, error) { +// SnapshotView: Fetch snapshot +func (c *Client) SnapshotView(ctx context.Context, params SnapshotViewParams) (*Snapshot, error) { if err := params.Validate(); err != nil { return nil, err } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return nil, fmt.Errorf("encoding json body request failed: %v", err) - } - // Create the request req, err := c.buildRequest( ctx, - b, - "PUT", - resolveRelative(c.host, "/v1/system/hardware/sleds/{{.sled_id}}/provision-policy"), + nil, + "GET", + resolveRelative(c.host, "/v1/snapshots/{{.snapshot}}"), map[string]string{ - "sled_id": params.SledId, + "snapshot": string(params.Snapshot), + }, + map[string]string{ + "project": string(params.Project), }, - map[string]string{}, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -6639,7 +6105,7 @@ func (c *Client) SledSetProvisionPolicy(ctx context.Context, params SledSetProvi return nil, errors.New("request returned an empty body in the response") } - var body SledProvisionPolicyResponse + var body Snapshot if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -6648,50 +6114,97 @@ func (c *Client) SledSetProvisionPolicy(ctx context.Context, params SledSetProvi return &body, nil } -// NetworkingSwitchPortList: List switch ports -// -// To iterate over all pages, use the `NetworkingSwitchPortListAllPages` method, instead. -func (c *Client) NetworkingSwitchPortList(ctx context.Context, params NetworkingSwitchPortListParams) (*SwitchPortResultsPage, error) { +// SnapshotDelete: Delete snapshot +func (c *Client) SnapshotDelete(ctx context.Context, params SnapshotDeleteParams) error { if err := params.Validate(); err != nil { - return nil, err + return err } // Create the request req, err := c.buildRequest( ctx, nil, - "GET", - resolveRelative(c.host, "/v1/system/hardware/switch-port"), - map[string]string{}, + "DELETE", + resolveRelative(c.host, "/v1/snapshots/{{.snapshot}}"), map[string]string{ - "limit": PointerIntToStr(params.Limit), - "page_token": params.PageToken, - "sort_by": string(params.SortBy), - "switch_port_id": params.SwitchPortId, + "snapshot": string(params.Snapshot), + }, + map[string]string{ + "project": string(params.Project), }, ) if err != nil { - return nil, fmt.Errorf("error building request: %v", err) + return fmt.Errorf("error building request: %v", err) } // Send the request. resp, err := c.client.Do(req) if err != nil { - return nil, fmt.Errorf("error sending request: %v", err) + return fmt.Errorf("error sending request: %v", err) } defer resp.Body.Close() // Create and return an HTTPError when an error response code is received. if err := NewHTTPError(resp); err != nil { - return nil, err + return err } - // Decode the body from the response. - if resp.Body == nil { - return nil, errors.New("request returned an empty body in the response") - } + return nil +} - var body SwitchPortResultsPage - if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { +// AuditLogList: View audit log +// A single item in the audit log represents both the beginning and end of the logged operation (represented by +// `time_started` and `time_completed`) so that clients do not have to find multiple entries and match them up +// by request ID to get the full picture of an operation. Because timestamps may not be unique, entries have +// also have a unique `id` that can be used to deduplicate items fetched from overlapping time intervals. +// +// Audit log entries are designed to be immutable: once you see an entry, fetching it again will never get you +// a different result. The list is ordered by `time_completed`, not `time_started`. If you fetch the audit log +// for a time range that is fully in the past, the resulting list is guaranteed to be complete, i.e., fetching the +// same timespan again later will always produce the same set of entries. +// +// To iterate over all pages, use the `AuditLogListAllPages` method, instead. +func (c *Client) AuditLogList(ctx context.Context, params AuditLogListParams) (*AuditLogEntryResultsPage, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "GET", + resolveRelative(c.host, "/v1/system/audit-log"), + map[string]string{}, + map[string]string{ + "end_time": params.EndTime.Format(time.RFC3339), + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + "sort_by": string(params.SortBy), + "start_time": params.StartTime.Format(time.RFC3339), + }, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body AuditLogEntryResultsPage + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -6699,19 +6212,28 @@ func (c *Client) NetworkingSwitchPortList(ctx context.Context, params Networking return &body, nil } -// NetworkingSwitchPortListAllPages: List switch ports +// AuditLogListAllPages: View audit log +// A single item in the audit log represents both the beginning and end of the logged operation (represented by +// `time_started` and `time_completed`) so that clients do not have to find multiple entries and match them up +// by request ID to get the full picture of an operation. Because timestamps may not be unique, entries have +// also have a unique `id` that can be used to deduplicate items fetched from overlapping time intervals. // -// This method is a wrapper around the `NetworkingSwitchPortList` method. +// Audit log entries are designed to be immutable: once you see an entry, fetching it again will never get you +// a different result. The list is ordered by `time_completed`, not `time_started`. If you fetch the audit log +// for a time range that is fully in the past, the resulting list is guaranteed to be complete, i.e., fetching the +// same timespan again later will always produce the same set of entries. +// +// This method is a wrapper around the `AuditLogList` method. // This method returns all the pages at once. -func (c *Client) NetworkingSwitchPortListAllPages(ctx context.Context, params NetworkingSwitchPortListParams) ([]SwitchPort, error) { +func (c *Client) AuditLogListAllPages(ctx context.Context, params AuditLogListParams) ([]AuditLogEntry, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []SwitchPort + var allPages []AuditLogEntry params.PageToken = "" params.Limit = NewPointer(100) for { - page, err := c.NetworkingSwitchPortList(ctx, params) + page, err := c.AuditLogList(ctx, params) if err != nil { return nil, err } @@ -6725,8 +6247,10 @@ func (c *Client) NetworkingSwitchPortListAllPages(ctx context.Context, params Ne return allPages, nil } -// NetworkingSwitchPortLldpConfigView: Fetch the LLDP configuration for a switch port -func (c *Client) NetworkingSwitchPortLldpConfigView(ctx context.Context, params NetworkingSwitchPortLldpConfigViewParams) (*LldpLinkConfig, error) { +// PhysicalDiskList: List physical disks +// +// To iterate over all pages, use the `PhysicalDiskListAllPages` method, instead. +func (c *Client) PhysicalDiskList(ctx context.Context, params PhysicalDiskListParams) (*PhysicalDiskResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -6735,13 +6259,12 @@ func (c *Client) NetworkingSwitchPortLldpConfigView(ctx context.Context, params ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/hardware/switch-port/{{.port}}/lldp/config"), - map[string]string{ - "port": string(params.Port), - }, + resolveRelative(c.host, "/v1/system/hardware/disks"), + map[string]string{}, map[string]string{ - "rack_id": params.RackId, - "switch_location": string(params.SwitchLocation), + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + "sort_by": string(params.SortBy), }, ) if err != nil { @@ -6765,7 +6288,7 @@ func (c *Client) NetworkingSwitchPortLldpConfigView(ctx context.Context, params return nil, errors.New("request returned an empty body in the response") } - var body LldpLinkConfig + var body PhysicalDiskResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -6774,134 +6297,82 @@ func (c *Client) NetworkingSwitchPortLldpConfigView(ctx context.Context, params return &body, nil } -// NetworkingSwitchPortLldpConfigUpdate: Update the LLDP configuration for a switch port -func (c *Client) NetworkingSwitchPortLldpConfigUpdate(ctx context.Context, params NetworkingSwitchPortLldpConfigUpdateParams) error { +// PhysicalDiskListAllPages: List physical disks +// +// This method is a wrapper around the `PhysicalDiskList` method. +// This method returns all the pages at once. +func (c *Client) PhysicalDiskListAllPages(ctx context.Context, params PhysicalDiskListParams) ([]PhysicalDisk, error) { if err := params.Validate(); err != nil { - return err - } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return fmt.Errorf("encoding json body request failed: %v", err) - } - - // Create the request - req, err := c.buildRequest( - ctx, - b, - "POST", - resolveRelative(c.host, "/v1/system/hardware/switch-port/{{.port}}/lldp/config"), - map[string]string{ - "port": string(params.Port), - }, - map[string]string{ - "rack_id": params.RackId, - "switch_location": string(params.SwitchLocation), - }, - ) - if err != nil { - return fmt.Errorf("error building request: %v", err) - } - - // Send the request. - resp, err := c.client.Do(req) - if err != nil { - return fmt.Errorf("error sending request: %v", err) + return nil, err } - defer resp.Body.Close() - - // Create and return an HTTPError when an error response code is received. - if err := NewHTTPError(resp); err != nil { - return err + var allPages []PhysicalDisk + params.PageToken = "" + params.Limit = NewPointer(100) + for { + page, err := c.PhysicalDiskList(ctx, params) + if err != nil { + return nil, err + } + allPages = append(allPages, page.Items...) + if page.NextPage == "" || page.NextPage == params.PageToken { + break + } + params.PageToken = page.NextPage } - return nil + return allPages, nil } -// NetworkingSwitchPortApplySettings: Apply switch port settings -func (c *Client) NetworkingSwitchPortApplySettings(ctx context.Context, params NetworkingSwitchPortApplySettingsParams) error { +// PhysicalDiskView: Get physical disk +func (c *Client) PhysicalDiskView(ctx context.Context, params PhysicalDiskViewParams) (*PhysicalDisk, error) { if err := params.Validate(); err != nil { - return err - } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return fmt.Errorf("encoding json body request failed: %v", err) + return nil, err } - // Create the request req, err := c.buildRequest( ctx, - b, - "POST", - resolveRelative(c.host, "/v1/system/hardware/switch-port/{{.port}}/settings"), - map[string]string{ - "port": string(params.Port), - }, + nil, + "GET", + resolveRelative(c.host, "/v1/system/hardware/disks/{{.disk_id}}"), map[string]string{ - "rack_id": params.RackId, - "switch_location": string(params.SwitchLocation), + "disk_id": params.DiskId, }, + map[string]string{}, ) if err != nil { - return fmt.Errorf("error building request: %v", err) + return nil, fmt.Errorf("error building request: %v", err) } // Send the request. resp, err := c.client.Do(req) if err != nil { - return fmt.Errorf("error sending request: %v", err) + return nil, fmt.Errorf("error sending request: %v", err) } defer resp.Body.Close() // Create and return an HTTPError when an error response code is received. if err := NewHTTPError(resp); err != nil { - return err - } - - return nil -} - -// NetworkingSwitchPortClearSettings: Clear switch port settings -func (c *Client) NetworkingSwitchPortClearSettings(ctx context.Context, params NetworkingSwitchPortClearSettingsParams) error { - if err := params.Validate(); err != nil { - return err - } - // Create the request - req, err := c.buildRequest( - ctx, - nil, - "DELETE", - resolveRelative(c.host, "/v1/system/hardware/switch-port/{{.port}}/settings"), - map[string]string{ - "port": string(params.Port), - }, - map[string]string{ - "rack_id": params.RackId, - "switch_location": string(params.SwitchLocation), - }, - ) - if err != nil { - return fmt.Errorf("error building request: %v", err) + return nil, err } - // Send the request. - resp, err := c.client.Do(req) - if err != nil { - return fmt.Errorf("error sending request: %v", err) + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") } - defer resp.Body.Close() - // Create and return an HTTPError when an error response code is received. - if err := NewHTTPError(resp); err != nil { - return err + var body PhysicalDisk + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) } - return nil + // Return the response. + return &body, nil } -// NetworkingSwitchPortStatus: Get switch port status -func (c *Client) NetworkingSwitchPortStatus(ctx context.Context, params NetworkingSwitchPortStatusParams) (*SwitchLinkState, error) { +// NetworkingSwitchPortLldpNeighbors: Fetch the LLDP neighbors seen on a switch port +// +// To iterate over all pages, use the `NetworkingSwitchPortLldpNeighborsAllPages` method, instead. +func (c *Client) NetworkingSwitchPortLldpNeighbors(ctx context.Context, params NetworkingSwitchPortLldpNeighborsParams) (*LldpNeighborResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -6910,14 +6381,17 @@ func (c *Client) NetworkingSwitchPortStatus(ctx context.Context, params Networki ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/hardware/switch-port/{{.port}}/status"), - map[string]string{ - "port": string(params.Port), - }, + resolveRelative(c.host, "/v1/system/hardware/rack-switch-port/{{.rack_id}}/{{.switch_location}}/{{.port}}/lldp/neighbors"), map[string]string{ + "port": string(params.Port), "rack_id": params.RackId, "switch_location": string(params.SwitchLocation), }, + map[string]string{ + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + "sort_by": string(params.SortBy), + }, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -6940,7 +6414,7 @@ func (c *Client) NetworkingSwitchPortStatus(ctx context.Context, params Networki return nil, errors.New("request returned an empty body in the response") } - var body SwitchLinkState + var body LldpNeighborResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -6949,20 +6423,168 @@ func (c *Client) NetworkingSwitchPortStatus(ctx context.Context, params Networki return &body, nil } -// SwitchList: List switches +// NetworkingSwitchPortLldpNeighborsAllPages: Fetch the LLDP neighbors seen on a switch port // -// To iterate over all pages, use the `SwitchListAllPages` method, instead. -func (c *Client) SwitchList(ctx context.Context, params SwitchListParams) (*SwitchResultsPage, error) { +// This method is a wrapper around the `NetworkingSwitchPortLldpNeighbors` method. +// This method returns all the pages at once. +func (c *Client) NetworkingSwitchPortLldpNeighborsAllPages(ctx context.Context, params NetworkingSwitchPortLldpNeighborsParams) ([]LldpNeighbor, error) { if err := params.Validate(); err != nil { return nil, err } - // Create the request - req, err := c.buildRequest( - ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/system/hardware/switches"), - map[string]string{}, + var allPages []LldpNeighbor + params.PageToken = "" + params.Limit = NewPointer(100) + for { + page, err := c.NetworkingSwitchPortLldpNeighbors(ctx, params) + if err != nil { + return nil, err + } + allPages = append(allPages, page.Items...) + if page.NextPage == "" || page.NextPage == params.PageToken { + break + } + params.PageToken = page.NextPage + } + + return allPages, nil +} + +// RackList: List racks +// +// To iterate over all pages, use the `RackListAllPages` method, instead. +func (c *Client) RackList(ctx context.Context, params RackListParams) (*RackResultsPage, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "GET", + resolveRelative(c.host, "/v1/system/hardware/racks"), + map[string]string{}, + map[string]string{ + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + "sort_by": string(params.SortBy), + }, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body RackResultsPage + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// RackListAllPages: List racks +// +// This method is a wrapper around the `RackList` method. +// This method returns all the pages at once. +func (c *Client) RackListAllPages(ctx context.Context, params RackListParams) ([]Rack, error) { + if err := params.Validate(); err != nil { + return nil, err + } + var allPages []Rack + params.PageToken = "" + params.Limit = NewPointer(100) + for { + page, err := c.RackList(ctx, params) + if err != nil { + return nil, err + } + allPages = append(allPages, page.Items...) + if page.NextPage == "" || page.NextPage == params.PageToken { + break + } + params.PageToken = page.NextPage + } + + return allPages, nil +} + +// RackView: Fetch rack +func (c *Client) RackView(ctx context.Context, params RackViewParams) (*Rack, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "GET", + resolveRelative(c.host, "/v1/system/hardware/racks/{{.rack_id}}"), + map[string]string{ + "rack_id": params.RackId, + }, + map[string]string{}, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body Rack + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// SledList: List sleds +// +// To iterate over all pages, use the `SledListAllPages` method, instead. +func (c *Client) SledList(ctx context.Context, params SledListParams) (*SledResultsPage, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "GET", + resolveRelative(c.host, "/v1/system/hardware/sleds"), + map[string]string{}, map[string]string{ "limit": PointerIntToStr(params.Limit), "page_token": params.PageToken, @@ -6990,7 +6612,1530 @@ func (c *Client) SwitchList(ctx context.Context, params SwitchListParams) (*Swit return nil, errors.New("request returned an empty body in the response") } - var body SwitchResultsPage + var body SledResultsPage + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// SledListAllPages: List sleds +// +// This method is a wrapper around the `SledList` method. +// This method returns all the pages at once. +func (c *Client) SledListAllPages(ctx context.Context, params SledListParams) ([]Sled, error) { + if err := params.Validate(); err != nil { + return nil, err + } + var allPages []Sled + params.PageToken = "" + params.Limit = NewPointer(100) + for { + page, err := c.SledList(ctx, params) + if err != nil { + return nil, err + } + allPages = append(allPages, page.Items...) + if page.NextPage == "" || page.NextPage == params.PageToken { + break + } + params.PageToken = page.NextPage + } + + return allPages, nil +} + +// SledAdd: Add sled to initialized rack +func (c *Client) SledAdd(ctx context.Context, params SledAddParams) (*SledId, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + + // Create the request + req, err := c.buildRequest( + ctx, + b, + "POST", + resolveRelative(c.host, "/v1/system/hardware/sleds"), + map[string]string{}, + map[string]string{}, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body SledId + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// SledListUninitialized: List uninitialized sleds +// +// To iterate over all pages, use the `SledListUninitializedAllPages` method, instead. +func (c *Client) SledListUninitialized(ctx context.Context, params SledListUninitializedParams) (*UninitializedSledResultsPage, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "GET", + resolveRelative(c.host, "/v1/system/hardware/sleds-uninitialized"), + map[string]string{}, + map[string]string{ + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + }, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body UninitializedSledResultsPage + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// SledListUninitializedAllPages: List uninitialized sleds +// +// This method is a wrapper around the `SledListUninitialized` method. +// This method returns all the pages at once. +func (c *Client) SledListUninitializedAllPages(ctx context.Context, params SledListUninitializedParams) ([]UninitializedSled, error) { + if err := params.Validate(); err != nil { + return nil, err + } + var allPages []UninitializedSled + params.PageToken = "" + params.Limit = NewPointer(100) + for { + page, err := c.SledListUninitialized(ctx, params) + if err != nil { + return nil, err + } + allPages = append(allPages, page.Items...) + if page.NextPage == "" || page.NextPage == params.PageToken { + break + } + params.PageToken = page.NextPage + } + + return allPages, nil +} + +// SledView: Fetch sled +func (c *Client) SledView(ctx context.Context, params SledViewParams) (*Sled, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "GET", + resolveRelative(c.host, "/v1/system/hardware/sleds/{{.sled_id}}"), + map[string]string{ + "sled_id": params.SledId, + }, + map[string]string{}, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body Sled + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// SledPhysicalDiskList: List physical disks attached to sleds +// +// To iterate over all pages, use the `SledPhysicalDiskListAllPages` method, instead. +func (c *Client) SledPhysicalDiskList(ctx context.Context, params SledPhysicalDiskListParams) (*PhysicalDiskResultsPage, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "GET", + resolveRelative(c.host, "/v1/system/hardware/sleds/{{.sled_id}}/disks"), + map[string]string{ + "sled_id": params.SledId, + }, + map[string]string{ + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + "sort_by": string(params.SortBy), + }, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body PhysicalDiskResultsPage + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// SledPhysicalDiskListAllPages: List physical disks attached to sleds +// +// This method is a wrapper around the `SledPhysicalDiskList` method. +// This method returns all the pages at once. +func (c *Client) SledPhysicalDiskListAllPages(ctx context.Context, params SledPhysicalDiskListParams) ([]PhysicalDisk, error) { + if err := params.Validate(); err != nil { + return nil, err + } + var allPages []PhysicalDisk + params.PageToken = "" + params.Limit = NewPointer(100) + for { + page, err := c.SledPhysicalDiskList(ctx, params) + if err != nil { + return nil, err + } + allPages = append(allPages, page.Items...) + if page.NextPage == "" || page.NextPage == params.PageToken { + break + } + params.PageToken = page.NextPage + } + + return allPages, nil +} + +// SledInstanceList: List instances running on given sled +// +// To iterate over all pages, use the `SledInstanceListAllPages` method, instead. +func (c *Client) SledInstanceList(ctx context.Context, params SledInstanceListParams) (*SledInstanceResultsPage, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "GET", + resolveRelative(c.host, "/v1/system/hardware/sleds/{{.sled_id}}/instances"), + map[string]string{ + "sled_id": params.SledId, + }, + map[string]string{ + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + "sort_by": string(params.SortBy), + }, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body SledInstanceResultsPage + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// SledInstanceListAllPages: List instances running on given sled +// +// This method is a wrapper around the `SledInstanceList` method. +// This method returns all the pages at once. +func (c *Client) SledInstanceListAllPages(ctx context.Context, params SledInstanceListParams) ([]SledInstance, error) { + if err := params.Validate(); err != nil { + return nil, err + } + var allPages []SledInstance + params.PageToken = "" + params.Limit = NewPointer(100) + for { + page, err := c.SledInstanceList(ctx, params) + if err != nil { + return nil, err + } + allPages = append(allPages, page.Items...) + if page.NextPage == "" || page.NextPage == params.PageToken { + break + } + params.PageToken = page.NextPage + } + + return allPages, nil +} + +// SledSetProvisionPolicy: Set sled provision policy +func (c *Client) SledSetProvisionPolicy(ctx context.Context, params SledSetProvisionPolicyParams) (*SledProvisionPolicyResponse, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + + // Create the request + req, err := c.buildRequest( + ctx, + b, + "PUT", + resolveRelative(c.host, "/v1/system/hardware/sleds/{{.sled_id}}/provision-policy"), + map[string]string{ + "sled_id": params.SledId, + }, + map[string]string{}, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body SledProvisionPolicyResponse + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// NetworkingSwitchPortList: List switch ports +// +// To iterate over all pages, use the `NetworkingSwitchPortListAllPages` method, instead. +func (c *Client) NetworkingSwitchPortList(ctx context.Context, params NetworkingSwitchPortListParams) (*SwitchPortResultsPage, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "GET", + resolveRelative(c.host, "/v1/system/hardware/switch-port"), + map[string]string{}, + map[string]string{ + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + "sort_by": string(params.SortBy), + "switch_port_id": params.SwitchPortId, + }, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body SwitchPortResultsPage + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// NetworkingSwitchPortListAllPages: List switch ports +// +// This method is a wrapper around the `NetworkingSwitchPortList` method. +// This method returns all the pages at once. +func (c *Client) NetworkingSwitchPortListAllPages(ctx context.Context, params NetworkingSwitchPortListParams) ([]SwitchPort, error) { + if err := params.Validate(); err != nil { + return nil, err + } + var allPages []SwitchPort + params.PageToken = "" + params.Limit = NewPointer(100) + for { + page, err := c.NetworkingSwitchPortList(ctx, params) + if err != nil { + return nil, err + } + allPages = append(allPages, page.Items...) + if page.NextPage == "" || page.NextPage == params.PageToken { + break + } + params.PageToken = page.NextPage + } + + return allPages, nil +} + +// NetworkingSwitchPortLldpConfigView: Fetch the LLDP configuration for a switch port +func (c *Client) NetworkingSwitchPortLldpConfigView(ctx context.Context, params NetworkingSwitchPortLldpConfigViewParams) (*LldpLinkConfig, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "GET", + resolveRelative(c.host, "/v1/system/hardware/switch-port/{{.port}}/lldp/config"), + map[string]string{ + "port": string(params.Port), + }, + map[string]string{ + "rack_id": params.RackId, + "switch_location": string(params.SwitchLocation), + }, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body LldpLinkConfig + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// NetworkingSwitchPortLldpConfigUpdate: Update the LLDP configuration for a switch port +func (c *Client) NetworkingSwitchPortLldpConfigUpdate(ctx context.Context, params NetworkingSwitchPortLldpConfigUpdateParams) error { + if err := params.Validate(); err != nil { + return err + } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return fmt.Errorf("encoding json body request failed: %v", err) + } + + // Create the request + req, err := c.buildRequest( + ctx, + b, + "POST", + resolveRelative(c.host, "/v1/system/hardware/switch-port/{{.port}}/lldp/config"), + map[string]string{ + "port": string(params.Port), + }, + map[string]string{ + "rack_id": params.RackId, + "switch_location": string(params.SwitchLocation), + }, + ) + if err != nil { + return fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return err + } + + return nil +} + +// NetworkingSwitchPortApplySettings: Apply switch port settings +func (c *Client) NetworkingSwitchPortApplySettings(ctx context.Context, params NetworkingSwitchPortApplySettingsParams) error { + if err := params.Validate(); err != nil { + return err + } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return fmt.Errorf("encoding json body request failed: %v", err) + } + + // Create the request + req, err := c.buildRequest( + ctx, + b, + "POST", + resolveRelative(c.host, "/v1/system/hardware/switch-port/{{.port}}/settings"), + map[string]string{ + "port": string(params.Port), + }, + map[string]string{ + "rack_id": params.RackId, + "switch_location": string(params.SwitchLocation), + }, + ) + if err != nil { + return fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return err + } + + return nil +} + +// NetworkingSwitchPortClearSettings: Clear switch port settings +func (c *Client) NetworkingSwitchPortClearSettings(ctx context.Context, params NetworkingSwitchPortClearSettingsParams) error { + if err := params.Validate(); err != nil { + return err + } + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "DELETE", + resolveRelative(c.host, "/v1/system/hardware/switch-port/{{.port}}/settings"), + map[string]string{ + "port": string(params.Port), + }, + map[string]string{ + "rack_id": params.RackId, + "switch_location": string(params.SwitchLocation), + }, + ) + if err != nil { + return fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return err + } + + return nil +} + +// NetworkingSwitchPortStatus: Get switch port status +func (c *Client) NetworkingSwitchPortStatus(ctx context.Context, params NetworkingSwitchPortStatusParams) (*SwitchLinkState, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "GET", + resolveRelative(c.host, "/v1/system/hardware/switch-port/{{.port}}/status"), + map[string]string{ + "port": string(params.Port), + }, + map[string]string{ + "rack_id": params.RackId, + "switch_location": string(params.SwitchLocation), + }, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body SwitchLinkState + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// SwitchList: List switches +// +// To iterate over all pages, use the `SwitchListAllPages` method, instead. +func (c *Client) SwitchList(ctx context.Context, params SwitchListParams) (*SwitchResultsPage, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "GET", + resolveRelative(c.host, "/v1/system/hardware/switches"), + map[string]string{}, + map[string]string{ + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + "sort_by": string(params.SortBy), + }, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body SwitchResultsPage + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// SwitchListAllPages: List switches +// +// This method is a wrapper around the `SwitchList` method. +// This method returns all the pages at once. +func (c *Client) SwitchListAllPages(ctx context.Context, params SwitchListParams) ([]Switch, error) { + if err := params.Validate(); err != nil { + return nil, err + } + var allPages []Switch + params.PageToken = "" + params.Limit = NewPointer(100) + for { + page, err := c.SwitchList(ctx, params) + if err != nil { + return nil, err + } + allPages = append(allPages, page.Items...) + if page.NextPage == "" || page.NextPage == params.PageToken { + break + } + params.PageToken = page.NextPage + } + + return allPages, nil +} + +// SwitchView: Fetch switch +func (c *Client) SwitchView(ctx context.Context, params SwitchViewParams) (*Switch, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "GET", + resolveRelative(c.host, "/v1/system/hardware/switches/{{.switch_id}}"), + map[string]string{ + "switch_id": params.SwitchId, + }, + map[string]string{}, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body Switch + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// SiloIdentityProviderList: List identity providers for silo +// List identity providers for silo by silo name or ID. +// +// To iterate over all pages, use the `SiloIdentityProviderListAllPages` method, instead. +func (c *Client) SiloIdentityProviderList(ctx context.Context, params SiloIdentityProviderListParams) (*IdentityProviderResultsPage, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "GET", + resolveRelative(c.host, "/v1/system/identity-providers"), + map[string]string{}, + map[string]string{ + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + "silo": string(params.Silo), + "sort_by": string(params.SortBy), + }, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body IdentityProviderResultsPage + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// SiloIdentityProviderListAllPages: List identity providers for silo +// List identity providers for silo by silo name or ID. +// +// This method is a wrapper around the `SiloIdentityProviderList` method. +// This method returns all the pages at once. +func (c *Client) SiloIdentityProviderListAllPages(ctx context.Context, params SiloIdentityProviderListParams) ([]IdentityProvider, error) { + if err := params.Validate(); err != nil { + return nil, err + } + var allPages []IdentityProvider + params.PageToken = "" + params.Limit = NewPointer(100) + for { + page, err := c.SiloIdentityProviderList(ctx, params) + if err != nil { + return nil, err + } + allPages = append(allPages, page.Items...) + if page.NextPage == "" || page.NextPage == params.PageToken { + break + } + params.PageToken = page.NextPage + } + + return allPages, nil +} + +// LocalIdpUserCreate: Create user +// Users can only be created in Silos with `provision_type` == `Fixed`. Otherwise, Silo users are just-in-time (JIT) +// provisioned when a user first logs in using an external Identity Provider. +func (c *Client) LocalIdpUserCreate(ctx context.Context, params LocalIdpUserCreateParams) (*User, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + + // Create the request + req, err := c.buildRequest( + ctx, + b, + "POST", + resolveRelative(c.host, "/v1/system/identity-providers/local/users"), + map[string]string{}, + map[string]string{ + "silo": string(params.Silo), + }, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body User + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// LocalIdpUserDelete: Delete user +func (c *Client) LocalIdpUserDelete(ctx context.Context, params LocalIdpUserDeleteParams) error { + if err := params.Validate(); err != nil { + return err + } + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "DELETE", + resolveRelative(c.host, "/v1/system/identity-providers/local/users/{{.user_id}}"), + map[string]string{ + "user_id": params.UserId, + }, + map[string]string{ + "silo": string(params.Silo), + }, + ) + if err != nil { + return fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return err + } + + return nil +} + +// LocalIdpUserSetPassword: Set or invalidate user's password +// Passwords can only be updated for users in Silos with identity mode `LocalOnly`. +func (c *Client) LocalIdpUserSetPassword(ctx context.Context, params LocalIdpUserSetPasswordParams) error { + if err := params.Validate(); err != nil { + return err + } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return fmt.Errorf("encoding json body request failed: %v", err) + } + + // Create the request + req, err := c.buildRequest( + ctx, + b, + "POST", + resolveRelative(c.host, "/v1/system/identity-providers/local/users/{{.user_id}}/set-password"), + map[string]string{ + "user_id": params.UserId, + }, + map[string]string{ + "silo": string(params.Silo), + }, + ) + if err != nil { + return fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return err + } + + return nil +} + +// SamlIdentityProviderCreate: Create SAML identity provider +func (c *Client) SamlIdentityProviderCreate(ctx context.Context, params SamlIdentityProviderCreateParams) (*SamlIdentityProvider, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + + // Create the request + req, err := c.buildRequest( + ctx, + b, + "POST", + resolveRelative(c.host, "/v1/system/identity-providers/saml"), + map[string]string{}, + map[string]string{ + "silo": string(params.Silo), + }, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body SamlIdentityProvider + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// SamlIdentityProviderView: Fetch SAML identity provider +func (c *Client) SamlIdentityProviderView(ctx context.Context, params SamlIdentityProviderViewParams) (*SamlIdentityProvider, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "GET", + resolveRelative(c.host, "/v1/system/identity-providers/saml/{{.provider}}"), + map[string]string{ + "provider": string(params.Provider), + }, + map[string]string{ + "silo": string(params.Silo), + }, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body SamlIdentityProvider + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// IpPoolList: List IP pools +// +// To iterate over all pages, use the `IpPoolListAllPages` method, instead. +func (c *Client) IpPoolList(ctx context.Context, params IpPoolListParams) (*IpPoolResultsPage, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "GET", + resolveRelative(c.host, "/v1/system/ip-pools"), + map[string]string{}, + map[string]string{ + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + "sort_by": string(params.SortBy), + }, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body IpPoolResultsPage + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// IpPoolListAllPages: List IP pools +// +// This method is a wrapper around the `IpPoolList` method. +// This method returns all the pages at once. +func (c *Client) IpPoolListAllPages(ctx context.Context, params IpPoolListParams) ([]IpPool, error) { + if err := params.Validate(); err != nil { + return nil, err + } + var allPages []IpPool + params.PageToken = "" + params.Limit = NewPointer(100) + for { + page, err := c.IpPoolList(ctx, params) + if err != nil { + return nil, err + } + allPages = append(allPages, page.Items...) + if page.NextPage == "" || page.NextPage == params.PageToken { + break + } + params.PageToken = page.NextPage + } + + return allPages, nil +} + +// IpPoolCreate: Create IP pool +// IPv6 is not yet supported for unicast pools. +func (c *Client) IpPoolCreate(ctx context.Context, params IpPoolCreateParams) (*IpPool, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + + // Create the request + req, err := c.buildRequest( + ctx, + b, + "POST", + resolveRelative(c.host, "/v1/system/ip-pools"), + map[string]string{}, + map[string]string{}, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body IpPool + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// IpPoolServiceView: Fetch Oxide service IP pool +func (c *Client) IpPoolServiceView(ctx context.Context) (*IpPool, error) { + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "GET", + resolveRelative(c.host, "/v1/system/ip-pools-service"), + map[string]string{}, + map[string]string{}, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body IpPool + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// IpPoolServiceRangeList: List IP ranges for the Oxide service pool +// Ranges are ordered by their first address. +// +// To iterate over all pages, use the `IpPoolServiceRangeListAllPages` method, instead. +func (c *Client) IpPoolServiceRangeList(ctx context.Context, params IpPoolServiceRangeListParams) (*IpPoolRangeResultsPage, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "GET", + resolveRelative(c.host, "/v1/system/ip-pools-service/ranges"), + map[string]string{}, + map[string]string{ + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + }, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body IpPoolRangeResultsPage + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// IpPoolServiceRangeListAllPages: List IP ranges for the Oxide service pool +// Ranges are ordered by their first address. +// +// This method is a wrapper around the `IpPoolServiceRangeList` method. +// This method returns all the pages at once. +func (c *Client) IpPoolServiceRangeListAllPages(ctx context.Context, params IpPoolServiceRangeListParams) ([]IpPoolRange, error) { + if err := params.Validate(); err != nil { + return nil, err + } + var allPages []IpPoolRange + params.PageToken = "" + params.Limit = NewPointer(100) + for { + page, err := c.IpPoolServiceRangeList(ctx, params) + if err != nil { + return nil, err + } + allPages = append(allPages, page.Items...) + if page.NextPage == "" || page.NextPage == params.PageToken { + break + } + params.PageToken = page.NextPage + } + + return allPages, nil +} + +// IpPoolServiceRangeAdd: Add IP range to Oxide service pool +// IPv6 ranges are not allowed yet. +func (c *Client) IpPoolServiceRangeAdd(ctx context.Context, params IpPoolServiceRangeAddParams) (*IpPoolRange, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + + // Create the request + req, err := c.buildRequest( + ctx, + b, + "POST", + resolveRelative(c.host, "/v1/system/ip-pools-service/ranges/add"), + map[string]string{}, + map[string]string{}, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body IpPoolRange + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// IpPoolServiceRangeRemove: Remove IP range from Oxide service pool +func (c *Client) IpPoolServiceRangeRemove(ctx context.Context, params IpPoolServiceRangeRemoveParams) error { + if err := params.Validate(); err != nil { + return err + } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return fmt.Errorf("encoding json body request failed: %v", err) + } + + // Create the request + req, err := c.buildRequest( + ctx, + b, + "POST", + resolveRelative(c.host, "/v1/system/ip-pools-service/ranges/remove"), + map[string]string{}, + map[string]string{}, + ) + if err != nil { + return fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return err + } + + return nil +} + +// IpPoolView: Fetch IP pool +func (c *Client) IpPoolView(ctx context.Context, params IpPoolViewParams) (*IpPool, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "GET", + resolveRelative(c.host, "/v1/system/ip-pools/{{.pool}}"), + map[string]string{ + "pool": string(params.Pool), + }, + map[string]string{}, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body IpPool if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -6999,45 +8144,25 @@ func (c *Client) SwitchList(ctx context.Context, params SwitchListParams) (*Swit return &body, nil } -// SwitchListAllPages: List switches -// -// This method is a wrapper around the `SwitchList` method. -// This method returns all the pages at once. -func (c *Client) SwitchListAllPages(ctx context.Context, params SwitchListParams) ([]Switch, error) { +// IpPoolUpdate: Update IP pool +func (c *Client) IpPoolUpdate(ctx context.Context, params IpPoolUpdateParams) (*IpPool, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []Switch - params.PageToken = "" - params.Limit = NewPointer(100) - for { - page, err := c.SwitchList(ctx, params) - if err != nil { - return nil, err - } - allPages = append(allPages, page.Items...) - if page.NextPage == "" || page.NextPage == params.PageToken { - break - } - params.PageToken = page.NextPage + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) } - return allPages, nil -} - -// SwitchView: Fetch switch -func (c *Client) SwitchView(ctx context.Context, params SwitchViewParams) (*Switch, error) { - if err := params.Validate(); err != nil { - return nil, err - } // Create the request req, err := c.buildRequest( ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/system/hardware/switches/{{.switch_id}}"), + b, + "PUT", + resolveRelative(c.host, "/v1/system/ip-pools/{{.pool}}"), map[string]string{ - "switch_id": params.SwitchId, + "pool": string(params.Pool), }, map[string]string{}, ) @@ -7062,7 +8187,7 @@ func (c *Client) SwitchView(ctx context.Context, params SwitchViewParams) (*Swit return nil, errors.New("request returned an empty body in the response") } - var body Switch + var body IpPool if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -7071,11 +8196,46 @@ func (c *Client) SwitchView(ctx context.Context, params SwitchViewParams) (*Swit return &body, nil } -// SiloIdentityProviderList: List identity providers for silo -// List identity providers for silo by silo name or ID. +// IpPoolDelete: Delete IP pool +func (c *Client) IpPoolDelete(ctx context.Context, params IpPoolDeleteParams) error { + if err := params.Validate(); err != nil { + return err + } + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "DELETE", + resolveRelative(c.host, "/v1/system/ip-pools/{{.pool}}"), + map[string]string{ + "pool": string(params.Pool), + }, + map[string]string{}, + ) + if err != nil { + return fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return err + } + + return nil +} + +// IpPoolRangeList: List ranges for IP pool +// Ranges are ordered by their first address. // -// To iterate over all pages, use the `SiloIdentityProviderListAllPages` method, instead. -func (c *Client) SiloIdentityProviderList(ctx context.Context, params SiloIdentityProviderListParams) (*IdentityProviderResultsPage, error) { +// To iterate over all pages, use the `IpPoolRangeListAllPages` method, instead. +func (c *Client) IpPoolRangeList(ctx context.Context, params IpPoolRangeListParams) (*IpPoolRangeResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -7084,13 +8244,13 @@ func (c *Client) SiloIdentityProviderList(ctx context.Context, params SiloIdenti ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/identity-providers"), - map[string]string{}, + resolveRelative(c.host, "/v1/system/ip-pools/{{.pool}}/ranges"), + map[string]string{ + "pool": string(params.Pool), + }, map[string]string{ "limit": PointerIntToStr(params.Limit), "page_token": params.PageToken, - "silo": string(params.Silo), - "sort_by": string(params.SortBy), }, ) if err != nil { @@ -7114,7 +8274,7 @@ func (c *Client) SiloIdentityProviderList(ctx context.Context, params SiloIdenti return nil, errors.New("request returned an empty body in the response") } - var body IdentityProviderResultsPage + var body IpPoolRangeResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -7123,20 +8283,20 @@ func (c *Client) SiloIdentityProviderList(ctx context.Context, params SiloIdenti return &body, nil } -// SiloIdentityProviderListAllPages: List identity providers for silo -// List identity providers for silo by silo name or ID. +// IpPoolRangeListAllPages: List ranges for IP pool +// Ranges are ordered by their first address. // -// This method is a wrapper around the `SiloIdentityProviderList` method. +// This method is a wrapper around the `IpPoolRangeList` method. // This method returns all the pages at once. -func (c *Client) SiloIdentityProviderListAllPages(ctx context.Context, params SiloIdentityProviderListParams) ([]IdentityProvider, error) { +func (c *Client) IpPoolRangeListAllPages(ctx context.Context, params IpPoolRangeListParams) ([]IpPoolRange, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []IdentityProvider + var allPages []IpPoolRange params.PageToken = "" params.Limit = NewPointer(100) for { - page, err := c.SiloIdentityProviderList(ctx, params) + page, err := c.IpPoolRangeList(ctx, params) if err != nil { return nil, err } @@ -7150,10 +8310,15 @@ func (c *Client) SiloIdentityProviderListAllPages(ctx context.Context, params Si return allPages, nil } -// LocalIdpUserCreate: Create user -// Users can only be created in Silos with `provision_type` == `Fixed`. Otherwise, Silo users are just-in-time (JIT) -// provisioned when a user first logs in using an external Identity Provider. -func (c *Client) LocalIdpUserCreate(ctx context.Context, params LocalIdpUserCreateParams) (*User, error) { +// IpPoolRangeAdd: Add range to an IP pool +// IPv6 ranges are not allowed yet for unicast pools. +// +// For multicast pools, all ranges must be either Any-Source Multicast (ASM) or Source-Specific Multicast (SSM), +// but not both. Mixing ASM and SSM ranges in the same pool is not allowed. +// +// ASM: IPv4 addresses outside 232.0.0.0/8, IPv6 addresses with flag field != 3 SSM: IPv4 addresses in 232.0.0.0/8, IPv6 +// addresses with flag field = 3 +func (c *Client) IpPoolRangeAdd(ctx context.Context, params IpPoolRangeAddParams) (*IpPoolRange, error) { if err := params.Validate(); err != nil { return nil, err } @@ -7168,11 +8333,11 @@ func (c *Client) LocalIdpUserCreate(ctx context.Context, params LocalIdpUserCrea ctx, b, "POST", - resolveRelative(c.host, "/v1/system/identity-providers/local/users"), - map[string]string{}, + resolveRelative(c.host, "/v1/system/ip-pools/{{.pool}}/ranges/add"), map[string]string{ - "silo": string(params.Silo), + "pool": string(params.Pool), }, + map[string]string{}, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -7195,7 +8360,7 @@ func (c *Client) LocalIdpUserCreate(ctx context.Context, params LocalIdpUserCrea return nil, errors.New("request returned an empty body in the response") } - var body User + var body IpPoolRange if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -7204,46 +8369,8 @@ func (c *Client) LocalIdpUserCreate(ctx context.Context, params LocalIdpUserCrea return &body, nil } -// LocalIdpUserDelete: Delete user -func (c *Client) LocalIdpUserDelete(ctx context.Context, params LocalIdpUserDeleteParams) error { - if err := params.Validate(); err != nil { - return err - } - // Create the request - req, err := c.buildRequest( - ctx, - nil, - "DELETE", - resolveRelative(c.host, "/v1/system/identity-providers/local/users/{{.user_id}}"), - map[string]string{ - "user_id": params.UserId, - }, - map[string]string{ - "silo": string(params.Silo), - }, - ) - if err != nil { - return fmt.Errorf("error building request: %v", err) - } - - // Send the request. - resp, err := c.client.Do(req) - if err != nil { - return fmt.Errorf("error sending request: %v", err) - } - defer resp.Body.Close() - - // Create and return an HTTPError when an error response code is received. - if err := NewHTTPError(resp); err != nil { - return err - } - - return nil -} - -// LocalIdpUserSetPassword: Set or invalidate user's password -// Passwords can only be updated for users in Silos with identity mode `LocalOnly`. -func (c *Client) LocalIdpUserSetPassword(ctx context.Context, params LocalIdpUserSetPasswordParams) error { +// IpPoolRangeRemove: Remove range from IP pool +func (c *Client) IpPoolRangeRemove(ctx context.Context, params IpPoolRangeRemoveParams) error { if err := params.Validate(); err != nil { return err } @@ -7258,13 +8385,11 @@ func (c *Client) LocalIdpUserSetPassword(ctx context.Context, params LocalIdpUse ctx, b, "POST", - resolveRelative(c.host, "/v1/system/identity-providers/local/users/{{.user_id}}/set-password"), - map[string]string{ - "user_id": params.UserId, - }, + resolveRelative(c.host, "/v1/system/ip-pools/{{.pool}}/ranges/remove"), map[string]string{ - "silo": string(params.Silo), + "pool": string(params.Pool), }, + map[string]string{}, ) if err != nil { return fmt.Errorf("error building request: %v", err) @@ -7285,26 +8410,26 @@ func (c *Client) LocalIdpUserSetPassword(ctx context.Context, params LocalIdpUse return nil } -// SamlIdentityProviderCreate: Create SAML identity provider -func (c *Client) SamlIdentityProviderCreate(ctx context.Context, params SamlIdentityProviderCreateParams) (*SamlIdentityProvider, error) { +// IpPoolSiloList: List IP pool's linked silos +// +// To iterate over all pages, use the `IpPoolSiloListAllPages` method, instead. +func (c *Client) IpPoolSiloList(ctx context.Context, params IpPoolSiloListParams) (*IpPoolSiloLinkResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return nil, fmt.Errorf("encoding json body request failed: %v", err) - } - // Create the request req, err := c.buildRequest( ctx, - b, - "POST", - resolveRelative(c.host, "/v1/system/identity-providers/saml"), - map[string]string{}, + nil, + "GET", + resolveRelative(c.host, "/v1/system/ip-pools/{{.pool}}/silos"), map[string]string{ - "silo": string(params.Silo), + "pool": string(params.Pool), + }, + map[string]string{ + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + "sort_by": string(params.SortBy), }, ) if err != nil { @@ -7328,7 +8453,7 @@ func (c *Client) SamlIdentityProviderCreate(ctx context.Context, params SamlIden return nil, errors.New("request returned an empty body in the response") } - var body SamlIdentityProvider + var body IpPoolSiloLinkResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -7337,23 +8462,55 @@ func (c *Client) SamlIdentityProviderCreate(ctx context.Context, params SamlIden return &body, nil } -// SamlIdentityProviderView: Fetch SAML identity provider -func (c *Client) SamlIdentityProviderView(ctx context.Context, params SamlIdentityProviderViewParams) (*SamlIdentityProvider, error) { +// IpPoolSiloListAllPages: List IP pool's linked silos +// +// This method is a wrapper around the `IpPoolSiloList` method. +// This method returns all the pages at once. +func (c *Client) IpPoolSiloListAllPages(ctx context.Context, params IpPoolSiloListParams) ([]IpPoolSiloLink, error) { + if err := params.Validate(); err != nil { + return nil, err + } + var allPages []IpPoolSiloLink + params.PageToken = "" + params.Limit = NewPointer(100) + for { + page, err := c.IpPoolSiloList(ctx, params) + if err != nil { + return nil, err + } + allPages = append(allPages, page.Items...) + if page.NextPage == "" || page.NextPage == params.PageToken { + break + } + params.PageToken = page.NextPage + } + + return allPages, nil +} + +// IpPoolSiloLink: Link IP pool to silo +// Users in linked silos can allocate external IPs from this pool for their instances. A silo can have at most +// one default pool. IPs are allocated from the default pool when users ask for one without specifying a pool. +func (c *Client) IpPoolSiloLink(ctx context.Context, params IpPoolSiloLinkParams) (*IpPoolSiloLink, error) { if err := params.Validate(); err != nil { return nil, err } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + // Create the request req, err := c.buildRequest( ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/system/identity-providers/saml/{{.provider}}"), - map[string]string{ - "provider": string(params.Provider), - }, + b, + "POST", + resolveRelative(c.host, "/v1/system/ip-pools/{{.pool}}/silos"), map[string]string{ - "silo": string(params.Silo), + "pool": string(params.Pool), }, + map[string]string{}, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -7376,7 +8533,7 @@ func (c *Client) SamlIdentityProviderView(ctx context.Context, params SamlIdenti return nil, errors.New("request returned an empty body in the response") } - var body SamlIdentityProvider + var body IpPoolSiloLink if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -7385,25 +8542,31 @@ func (c *Client) SamlIdentityProviderView(ctx context.Context, params SamlIdenti return &body, nil } -// IpPoolList: List IP pools -// -// To iterate over all pages, use the `IpPoolListAllPages` method, instead. -func (c *Client) IpPoolList(ctx context.Context, params IpPoolListParams) (*IpPoolResultsPage, error) { +// IpPoolSiloUpdate: Make IP pool default for silo +// When a user asks for an IP (e.g., at instance create time) without specifying a pool, the IP comes from the +// default pool if a default is configured. When a pool is made the default for a silo, any existing default will +// remain linked to the silo, but will no longer be the default. +func (c *Client) IpPoolSiloUpdate(ctx context.Context, params IpPoolSiloUpdateParams) (*IpPoolSiloLink, error) { if err := params.Validate(); err != nil { return nil, err } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + // Create the request req, err := c.buildRequest( ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/system/ip-pools"), - map[string]string{}, + b, + "PUT", + resolveRelative(c.host, "/v1/system/ip-pools/{{.pool}}/silos/{{.silo}}"), map[string]string{ - "limit": PointerIntToStr(params.Limit), - "page_token": params.PageToken, - "sort_by": string(params.SortBy), + "pool": string(params.Pool), + "silo": string(params.Silo), }, + map[string]string{}, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -7426,7 +8589,7 @@ func (c *Client) IpPoolList(ctx context.Context, params IpPoolListParams) (*IpPo return nil, errors.New("request returned an empty body in the response") } - var body IpPoolResultsPage + var body IpPoolSiloLink if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -7435,92 +8598,57 @@ func (c *Client) IpPoolList(ctx context.Context, params IpPoolListParams) (*IpPo return &body, nil } -// IpPoolListAllPages: List IP pools -// -// This method is a wrapper around the `IpPoolList` method. -// This method returns all the pages at once. -func (c *Client) IpPoolListAllPages(ctx context.Context, params IpPoolListParams) ([]IpPool, error) { - if err := params.Validate(); err != nil { - return nil, err - } - var allPages []IpPool - params.PageToken = "" - params.Limit = NewPointer(100) - for { - page, err := c.IpPoolList(ctx, params) - if err != nil { - return nil, err - } - allPages = append(allPages, page.Items...) - if page.NextPage == "" || page.NextPage == params.PageToken { - break - } - params.PageToken = page.NextPage - } - - return allPages, nil -} - -// IpPoolCreate: Create IP pool -// IPv6 is not yet supported for unicast pools. -func (c *Client) IpPoolCreate(ctx context.Context, params IpPoolCreateParams) (*IpPool, error) { +// IpPoolSiloUnlink: Unlink IP pool from silo +// Will fail if there are any outstanding IPs allocated in the silo. +func (c *Client) IpPoolSiloUnlink(ctx context.Context, params IpPoolSiloUnlinkParams) error { if err := params.Validate(); err != nil { - return nil, err - } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return nil, fmt.Errorf("encoding json body request failed: %v", err) + return err } - // Create the request req, err := c.buildRequest( ctx, - b, - "POST", - resolveRelative(c.host, "/v1/system/ip-pools"), - map[string]string{}, + nil, + "DELETE", + resolveRelative(c.host, "/v1/system/ip-pools/{{.pool}}/silos/{{.silo}}"), + map[string]string{ + "pool": string(params.Pool), + "silo": string(params.Silo), + }, map[string]string{}, ) if err != nil { - return nil, fmt.Errorf("error building request: %v", err) + return fmt.Errorf("error building request: %v", err) } // Send the request. resp, err := c.client.Do(req) if err != nil { - return nil, fmt.Errorf("error sending request: %v", err) + return fmt.Errorf("error sending request: %v", err) } defer resp.Body.Close() // Create and return an HTTPError when an error response code is received. if err := NewHTTPError(resp); err != nil { - return nil, err - } - - // Decode the body from the response. - if resp.Body == nil { - return nil, errors.New("request returned an empty body in the response") - } - - var body IpPool - if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { - return nil, fmt.Errorf("error decoding response body: %v", err) + return err } - // Return the response. - return &body, nil + return nil } -// IpPoolServiceView: Fetch Oxide service IP pool -func (c *Client) IpPoolServiceView(ctx context.Context) (*IpPool, error) { +// IpPoolUtilizationView: Fetch IP pool utilization +func (c *Client) IpPoolUtilizationView(ctx context.Context, params IpPoolUtilizationViewParams) (*IpPoolUtilization, error) { + if err := params.Validate(); err != nil { + return nil, err + } // Create the request req, err := c.buildRequest( ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/ip-pools-service"), - map[string]string{}, + resolveRelative(c.host, "/v1/system/ip-pools/{{.pool}}/utilization"), + map[string]string{ + "pool": string(params.Pool), + }, map[string]string{}, ) if err != nil { @@ -7544,7 +8672,7 @@ func (c *Client) IpPoolServiceView(ctx context.Context) (*IpPool, error) { return nil, errors.New("request returned an empty body in the response") } - var body IpPool + var body IpPoolUtilization if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -7553,11 +8681,11 @@ func (c *Client) IpPoolServiceView(ctx context.Context) (*IpPool, error) { return &body, nil } -// IpPoolServiceRangeList: List IP ranges for the Oxide service pool -// Ranges are ordered by their first address. +// SystemMetric: View metrics +// View CPU, memory, or storage utilization metrics at the fleet or silo level. // -// To iterate over all pages, use the `IpPoolServiceRangeListAllPages` method, instead. -func (c *Client) IpPoolServiceRangeList(ctx context.Context, params IpPoolServiceRangeListParams) (*IpPoolRangeResultsPage, error) { +// To iterate over all pages, use the `SystemMetricAllPages` method, instead. +func (c *Client) SystemMetric(ctx context.Context, params SystemMetricParams) (*MeasurementResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -7566,11 +8694,17 @@ func (c *Client) IpPoolServiceRangeList(ctx context.Context, params IpPoolServic ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/ip-pools-service/ranges"), - map[string]string{}, + resolveRelative(c.host, "/v1/system/metrics/{{.metric_name}}"), map[string]string{ + "metric_name": string(params.MetricName), + }, + map[string]string{ + "end_time": params.EndTime.Format(time.RFC3339), "limit": PointerIntToStr(params.Limit), + "order": string(params.Order), "page_token": params.PageToken, + "silo": string(params.Silo), + "start_time": params.StartTime.Format(time.RFC3339), }, ) if err != nil { @@ -7594,7 +8728,7 @@ func (c *Client) IpPoolServiceRangeList(ctx context.Context, params IpPoolServic return nil, errors.New("request returned an empty body in the response") } - var body IpPoolRangeResultsPage + var body MeasurementResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -7603,20 +8737,20 @@ func (c *Client) IpPoolServiceRangeList(ctx context.Context, params IpPoolServic return &body, nil } -// IpPoolServiceRangeListAllPages: List IP ranges for the Oxide service pool -// Ranges are ordered by their first address. +// SystemMetricAllPages: View metrics +// View CPU, memory, or storage utilization metrics at the fleet or silo level. // -// This method is a wrapper around the `IpPoolServiceRangeList` method. +// This method is a wrapper around the `SystemMetric` method. // This method returns all the pages at once. -func (c *Client) IpPoolServiceRangeListAllPages(ctx context.Context, params IpPoolServiceRangeListParams) ([]IpPoolRange, error) { +func (c *Client) SystemMetricAllPages(ctx context.Context, params SystemMetricParams) ([]Measurement, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []IpPoolRange + var allPages []Measurement params.PageToken = "" params.Limit = NewPointer(100) for { - page, err := c.IpPoolServiceRangeList(ctx, params) + page, err := c.SystemMetric(ctx, params) if err != nil { return nil, err } @@ -7630,26 +8764,25 @@ func (c *Client) IpPoolServiceRangeListAllPages(ctx context.Context, params IpPo return allPages, nil } -// IpPoolServiceRangeAdd: Add IP range to Oxide service pool -// IPv6 ranges are not allowed yet. -func (c *Client) IpPoolServiceRangeAdd(ctx context.Context, params IpPoolServiceRangeAddParams) (*IpPoolRange, error) { +// NetworkingAddressLotList: List address lots +// +// To iterate over all pages, use the `NetworkingAddressLotListAllPages` method, instead. +func (c *Client) NetworkingAddressLotList(ctx context.Context, params NetworkingAddressLotListParams) (*AddressLotResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return nil, fmt.Errorf("encoding json body request failed: %v", err) - } - // Create the request req, err := c.buildRequest( ctx, - b, - "POST", - resolveRelative(c.host, "/v1/system/ip-pools-service/ranges/add"), - map[string]string{}, + nil, + "GET", + resolveRelative(c.host, "/v1/system/networking/address-lot"), map[string]string{}, + map[string]string{ + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + "sort_by": string(params.SortBy), + }, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -7672,7 +8805,7 @@ func (c *Client) IpPoolServiceRangeAdd(ctx context.Context, params IpPoolService return nil, errors.New("request returned an empty body in the response") } - var body IpPoolRange + var body AddressLotResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -7681,15 +8814,41 @@ func (c *Client) IpPoolServiceRangeAdd(ctx context.Context, params IpPoolService return &body, nil } -// IpPoolServiceRangeRemove: Remove IP range from Oxide service pool -func (c *Client) IpPoolServiceRangeRemove(ctx context.Context, params IpPoolServiceRangeRemoveParams) error { +// NetworkingAddressLotListAllPages: List address lots +// +// This method is a wrapper around the `NetworkingAddressLotList` method. +// This method returns all the pages at once. +func (c *Client) NetworkingAddressLotListAllPages(ctx context.Context, params NetworkingAddressLotListParams) ([]AddressLot, error) { if err := params.Validate(); err != nil { - return err + return nil, err + } + var allPages []AddressLot + params.PageToken = "" + params.Limit = NewPointer(100) + for { + page, err := c.NetworkingAddressLotList(ctx, params) + if err != nil { + return nil, err + } + allPages = append(allPages, page.Items...) + if page.NextPage == "" || page.NextPage == params.PageToken { + break + } + params.PageToken = page.NextPage + } + + return allPages, nil +} + +// NetworkingAddressLotCreate: Create address lot +func (c *Client) NetworkingAddressLotCreate(ctx context.Context, params NetworkingAddressLotCreateParams) (*AddressLotCreateResponse, error) { + if err := params.Validate(); err != nil { + return nil, err } // Encode the request body as json. b := new(bytes.Buffer) if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return fmt.Errorf("encoding json body request failed: %v", err) + return nil, fmt.Errorf("encoding json body request failed: %v", err) } // Create the request @@ -7697,43 +8856,8 @@ func (c *Client) IpPoolServiceRangeRemove(ctx context.Context, params IpPoolServ ctx, b, "POST", - resolveRelative(c.host, "/v1/system/ip-pools-service/ranges/remove"), - map[string]string{}, + resolveRelative(c.host, "/v1/system/networking/address-lot"), map[string]string{}, - ) - if err != nil { - return fmt.Errorf("error building request: %v", err) - } - - // Send the request. - resp, err := c.client.Do(req) - if err != nil { - return fmt.Errorf("error sending request: %v", err) - } - defer resp.Body.Close() - - // Create and return an HTTPError when an error response code is received. - if err := NewHTTPError(resp); err != nil { - return err - } - - return nil -} - -// IpPoolView: Fetch IP pool -func (c *Client) IpPoolView(ctx context.Context, params IpPoolViewParams) (*IpPool, error) { - if err := params.Validate(); err != nil { - return nil, err - } - // Create the request - req, err := c.buildRequest( - ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/system/ip-pools/{{.pool}}"), - map[string]string{ - "pool": string(params.Pool), - }, map[string]string{}, ) if err != nil { @@ -7757,7 +8881,7 @@ func (c *Client) IpPoolView(ctx context.Context, params IpPoolViewParams) (*IpPo return nil, errors.New("request returned an empty body in the response") } - var body IpPool + var body AddressLotCreateResponse if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -7766,25 +8890,19 @@ func (c *Client) IpPoolView(ctx context.Context, params IpPoolViewParams) (*IpPo return &body, nil } -// IpPoolUpdate: Update IP pool -func (c *Client) IpPoolUpdate(ctx context.Context, params IpPoolUpdateParams) (*IpPool, error) { +// NetworkingAddressLotView: Fetch address lot +func (c *Client) NetworkingAddressLotView(ctx context.Context, params NetworkingAddressLotViewParams) (*AddressLotViewResponse, error) { if err := params.Validate(); err != nil { return nil, err } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return nil, fmt.Errorf("encoding json body request failed: %v", err) - } - // Create the request req, err := c.buildRequest( ctx, - b, - "PUT", - resolveRelative(c.host, "/v1/system/ip-pools/{{.pool}}"), + nil, + "GET", + resolveRelative(c.host, "/v1/system/networking/address-lot/{{.address_lot}}"), map[string]string{ - "pool": string(params.Pool), + "address_lot": string(params.AddressLot), }, map[string]string{}, ) @@ -7809,7 +8927,7 @@ func (c *Client) IpPoolUpdate(ctx context.Context, params IpPoolUpdateParams) (* return nil, errors.New("request returned an empty body in the response") } - var body IpPool + var body AddressLotViewResponse if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -7818,8 +8936,8 @@ func (c *Client) IpPoolUpdate(ctx context.Context, params IpPoolUpdateParams) (* return &body, nil } -// IpPoolDelete: Delete IP pool -func (c *Client) IpPoolDelete(ctx context.Context, params IpPoolDeleteParams) error { +// NetworkingAddressLotDelete: Delete address lot +func (c *Client) NetworkingAddressLotDelete(ctx context.Context, params NetworkingAddressLotDeleteParams) error { if err := params.Validate(); err != nil { return err } @@ -7828,9 +8946,9 @@ func (c *Client) IpPoolDelete(ctx context.Context, params IpPoolDeleteParams) er ctx, nil, "DELETE", - resolveRelative(c.host, "/v1/system/ip-pools/{{.pool}}"), + resolveRelative(c.host, "/v1/system/networking/address-lot/{{.address_lot}}"), map[string]string{ - "pool": string(params.Pool), + "address_lot": string(params.AddressLot), }, map[string]string{}, ) @@ -7853,11 +8971,10 @@ func (c *Client) IpPoolDelete(ctx context.Context, params IpPoolDeleteParams) er return nil } -// IpPoolRangeList: List ranges for IP pool -// Ranges are ordered by their first address. +// NetworkingAddressLotBlockList: List blocks in address lot // -// To iterate over all pages, use the `IpPoolRangeListAllPages` method, instead. -func (c *Client) IpPoolRangeList(ctx context.Context, params IpPoolRangeListParams) (*IpPoolRangeResultsPage, error) { +// To iterate over all pages, use the `NetworkingAddressLotBlockListAllPages` method, instead. +func (c *Client) NetworkingAddressLotBlockList(ctx context.Context, params NetworkingAddressLotBlockListParams) (*AddressLotBlockResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -7866,13 +8983,14 @@ func (c *Client) IpPoolRangeList(ctx context.Context, params IpPoolRangeListPara ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/ip-pools/{{.pool}}/ranges"), + resolveRelative(c.host, "/v1/system/networking/address-lot/{{.address_lot}}/blocks"), map[string]string{ - "pool": string(params.Pool), + "address_lot": string(params.AddressLot), }, map[string]string{ "limit": PointerIntToStr(params.Limit), "page_token": params.PageToken, + "sort_by": string(params.SortBy), }, ) if err != nil { @@ -7896,7 +9014,7 @@ func (c *Client) IpPoolRangeList(ctx context.Context, params IpPoolRangeListPara return nil, errors.New("request returned an empty body in the response") } - var body IpPoolRangeResultsPage + var body AddressLotBlockResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -7905,20 +9023,19 @@ func (c *Client) IpPoolRangeList(ctx context.Context, params IpPoolRangeListPara return &body, nil } -// IpPoolRangeListAllPages: List ranges for IP pool -// Ranges are ordered by their first address. +// NetworkingAddressLotBlockListAllPages: List blocks in address lot // -// This method is a wrapper around the `IpPoolRangeList` method. +// This method is a wrapper around the `NetworkingAddressLotBlockList` method. // This method returns all the pages at once. -func (c *Client) IpPoolRangeListAllPages(ctx context.Context, params IpPoolRangeListParams) ([]IpPoolRange, error) { +func (c *Client) NetworkingAddressLotBlockListAllPages(ctx context.Context, params NetworkingAddressLotBlockListParams) ([]AddressLotBlock, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []IpPoolRange + var allPages []AddressLotBlock params.PageToken = "" params.Limit = NewPointer(100) for { - page, err := c.IpPoolRangeList(ctx, params) + page, err := c.NetworkingAddressLotBlockList(ctx, params) if err != nil { return nil, err } @@ -7932,15 +9049,49 @@ func (c *Client) IpPoolRangeListAllPages(ctx context.Context, params IpPoolRange return allPages, nil } -// IpPoolRangeAdd: Add range to IP pool. -// IPv6 ranges are not allowed yet for unicast pools. -// -// For multicast pools, all ranges must be either Any-Source Multicast (ASM) or Source-Specific Multicast (SSM), -// but not both. Mixing ASM and SSM ranges in the same pool is not allowed. -// -// ASM: IPv4 addresses outside 232.0.0.0/8, IPv6 addresses with flag field != 3 SSM: IPv4 addresses in 232.0.0.0/8, IPv6 -// addresses with flag field = 3 -func (c *Client) IpPoolRangeAdd(ctx context.Context, params IpPoolRangeAddParams) (*IpPoolRange, error) { +// NetworkingAllowListView: Get user-facing services IP allowlist +func (c *Client) NetworkingAllowListView(ctx context.Context) (*AllowList, error) { + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "GET", + resolveRelative(c.host, "/v1/system/networking/allow-list"), + map[string]string{}, + map[string]string{}, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body AllowList + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// NetworkingAllowListUpdate: Update user-facing services IP allowlist +func (c *Client) NetworkingAllowListUpdate(ctx context.Context, params NetworkingAllowListUpdateParams) (*AllowList, error) { if err := params.Validate(); err != nil { return nil, err } @@ -7954,11 +9105,9 @@ func (c *Client) IpPoolRangeAdd(ctx context.Context, params IpPoolRangeAddParams req, err := c.buildRequest( ctx, b, - "POST", - resolveRelative(c.host, "/v1/system/ip-pools/{{.pool}}/ranges/add"), - map[string]string{ - "pool": string(params.Pool), - }, + "PUT", + resolveRelative(c.host, "/v1/system/networking/allow-list"), + map[string]string{}, map[string]string{}, ) if err != nil { @@ -7982,7 +9131,7 @@ func (c *Client) IpPoolRangeAdd(ctx context.Context, params IpPoolRangeAddParams return nil, errors.New("request returned an empty body in the response") } - var body IpPoolRange + var body AllowList if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -7991,8 +9140,8 @@ func (c *Client) IpPoolRangeAdd(ctx context.Context, params IpPoolRangeAddParams return &body, nil } -// IpPoolRangeRemove: Remove range from IP pool -func (c *Client) IpPoolRangeRemove(ctx context.Context, params IpPoolRangeRemoveParams) error { +// NetworkingBfdDisable: Disable BFD session +func (c *Client) NetworkingBfdDisable(ctx context.Context, params NetworkingBfdDisableParams) error { if err := params.Validate(); err != nil { return err } @@ -8007,10 +9156,8 @@ func (c *Client) IpPoolRangeRemove(ctx context.Context, params IpPoolRangeRemove ctx, b, "POST", - resolveRelative(c.host, "/v1/system/ip-pools/{{.pool}}/ranges/remove"), - map[string]string{ - "pool": string(params.Pool), - }, + resolveRelative(c.host, "/v1/system/networking/bfd-disable"), + map[string]string{}, map[string]string{}, ) if err != nil { @@ -8032,27 +9179,55 @@ func (c *Client) IpPoolRangeRemove(ctx context.Context, params IpPoolRangeRemove return nil } -// IpPoolSiloList: List IP pool's linked silos -// -// To iterate over all pages, use the `IpPoolSiloListAllPages` method, instead. -func (c *Client) IpPoolSiloList(ctx context.Context, params IpPoolSiloListParams) (*IpPoolSiloLinkResultsPage, error) { +// NetworkingBfdEnable: Enable BFD session +func (c *Client) NetworkingBfdEnable(ctx context.Context, params NetworkingBfdEnableParams) error { if err := params.Validate(); err != nil { - return nil, err + return err + } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return fmt.Errorf("encoding json body request failed: %v", err) + } + + // Create the request + req, err := c.buildRequest( + ctx, + b, + "POST", + resolveRelative(c.host, "/v1/system/networking/bfd-enable"), + map[string]string{}, + map[string]string{}, + ) + if err != nil { + return fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return err } + + return nil +} + +// NetworkingBfdStatus: Get BFD status +func (c *Client) NetworkingBfdStatus(ctx context.Context) (*[]BfdStatus, error) { // Create the request req, err := c.buildRequest( ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/ip-pools/{{.pool}}/silos"), - map[string]string{ - "pool": string(params.Pool), - }, - map[string]string{ - "limit": PointerIntToStr(params.Limit), - "page_token": params.PageToken, - "sort_by": string(params.SortBy), - }, + resolveRelative(c.host, "/v1/system/networking/bfd-status"), + map[string]string{}, + map[string]string{}, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -8075,7 +9250,7 @@ func (c *Client) IpPoolSiloList(ctx context.Context, params IpPoolSiloListParams return nil, errors.New("request returned an empty body in the response") } - var body IpPoolSiloLinkResultsPage + var body []BfdStatus if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -8084,55 +9259,25 @@ func (c *Client) IpPoolSiloList(ctx context.Context, params IpPoolSiloListParams return &body, nil } -// IpPoolSiloListAllPages: List IP pool's linked silos +// NetworkingBgpConfigList: List BGP configurations // -// This method is a wrapper around the `IpPoolSiloList` method. -// This method returns all the pages at once. -func (c *Client) IpPoolSiloListAllPages(ctx context.Context, params IpPoolSiloListParams) ([]IpPoolSiloLink, error) { - if err := params.Validate(); err != nil { - return nil, err - } - var allPages []IpPoolSiloLink - params.PageToken = "" - params.Limit = NewPointer(100) - for { - page, err := c.IpPoolSiloList(ctx, params) - if err != nil { - return nil, err - } - allPages = append(allPages, page.Items...) - if page.NextPage == "" || page.NextPage == params.PageToken { - break - } - params.PageToken = page.NextPage - } - - return allPages, nil -} - -// IpPoolSiloLink: Link IP pool to silo -// Users in linked silos can allocate external IPs from this pool for their instances. A silo can have at most -// one default pool. IPs are allocated from the default pool when users ask for one without specifying a pool. -func (c *Client) IpPoolSiloLink(ctx context.Context, params IpPoolSiloLinkParams) (*IpPoolSiloLink, error) { +// To iterate over all pages, use the `NetworkingBgpConfigListAllPages` method, instead. +func (c *Client) NetworkingBgpConfigList(ctx context.Context, params NetworkingBgpConfigListParams) (*BgpConfigResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return nil, fmt.Errorf("encoding json body request failed: %v", err) - } - // Create the request req, err := c.buildRequest( ctx, - b, - "POST", - resolveRelative(c.host, "/v1/system/ip-pools/{{.pool}}/silos"), + nil, + "GET", + resolveRelative(c.host, "/v1/system/networking/bgp"), + map[string]string{}, map[string]string{ - "pool": string(params.Pool), + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + "sort_by": string(params.SortBy), }, - map[string]string{}, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -8155,20 +9300,43 @@ func (c *Client) IpPoolSiloLink(ctx context.Context, params IpPoolSiloLinkParams return nil, errors.New("request returned an empty body in the response") } - var body IpPoolSiloLink + var body BgpConfigResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } - // Return the response. - return &body, nil + // Return the response. + return &body, nil +} + +// NetworkingBgpConfigListAllPages: List BGP configurations +// +// This method is a wrapper around the `NetworkingBgpConfigList` method. +// This method returns all the pages at once. +func (c *Client) NetworkingBgpConfigListAllPages(ctx context.Context, params NetworkingBgpConfigListParams) ([]BgpConfig, error) { + if err := params.Validate(); err != nil { + return nil, err + } + var allPages []BgpConfig + params.PageToken = "" + params.Limit = NewPointer(100) + for { + page, err := c.NetworkingBgpConfigList(ctx, params) + if err != nil { + return nil, err + } + allPages = append(allPages, page.Items...) + if page.NextPage == "" || page.NextPage == params.PageToken { + break + } + params.PageToken = page.NextPage + } + + return allPages, nil } -// IpPoolSiloUpdate: Make IP pool default for silo -// When a user asks for an IP (e.g., at instance create time) without specifying a pool, the IP comes from the -// default pool if a default is configured. When a pool is made the default for a silo, any existing default will -// remain linked to the silo, but will no longer be the default. -func (c *Client) IpPoolSiloUpdate(ctx context.Context, params IpPoolSiloUpdateParams) (*IpPoolSiloLink, error) { +// NetworkingBgpConfigCreate: Create new BGP configuration +func (c *Client) NetworkingBgpConfigCreate(ctx context.Context, params NetworkingBgpConfigCreateParams) (*BgpConfig, error) { if err := params.Validate(); err != nil { return nil, err } @@ -8182,12 +9350,9 @@ func (c *Client) IpPoolSiloUpdate(ctx context.Context, params IpPoolSiloUpdatePa req, err := c.buildRequest( ctx, b, - "PUT", - resolveRelative(c.host, "/v1/system/ip-pools/{{.pool}}/silos/{{.silo}}"), - map[string]string{ - "pool": string(params.Pool), - "silo": string(params.Silo), - }, + "POST", + resolveRelative(c.host, "/v1/system/networking/bgp"), + map[string]string{}, map[string]string{}, ) if err != nil { @@ -8211,7 +9376,7 @@ func (c *Client) IpPoolSiloUpdate(ctx context.Context, params IpPoolSiloUpdatePa return nil, errors.New("request returned an empty body in the response") } - var body IpPoolSiloLink + var body BgpConfig if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -8220,9 +9385,8 @@ func (c *Client) IpPoolSiloUpdate(ctx context.Context, params IpPoolSiloUpdatePa return &body, nil } -// IpPoolSiloUnlink: Unlink IP pool from silo -// Will fail if there are any outstanding IPs allocated in the silo. -func (c *Client) IpPoolSiloUnlink(ctx context.Context, params IpPoolSiloUnlinkParams) error { +// NetworkingBgpConfigDelete: Delete BGP configuration +func (c *Client) NetworkingBgpConfigDelete(ctx context.Context, params NetworkingBgpConfigDeleteParams) error { if err := params.Validate(); err != nil { return err } @@ -8231,12 +9395,11 @@ func (c *Client) IpPoolSiloUnlink(ctx context.Context, params IpPoolSiloUnlinkPa ctx, nil, "DELETE", - resolveRelative(c.host, "/v1/system/ip-pools/{{.pool}}/silos/{{.silo}}"), + resolveRelative(c.host, "/v1/system/networking/bgp"), + map[string]string{}, map[string]string{ - "pool": string(params.Pool), - "silo": string(params.Silo), + "name_or_id": string(params.NameOrId), }, - map[string]string{}, ) if err != nil { return fmt.Errorf("error building request: %v", err) @@ -8257,8 +9420,10 @@ func (c *Client) IpPoolSiloUnlink(ctx context.Context, params IpPoolSiloUnlinkPa return nil } -// IpPoolUtilizationView: Fetch IP pool utilization -func (c *Client) IpPoolUtilizationView(ctx context.Context, params IpPoolUtilizationViewParams) (*IpPoolUtilization, error) { +// NetworkingBgpAnnounceSetList: List BGP announce sets +// +// To iterate over all pages, use the `NetworkingBgpAnnounceSetListAllPages` method, instead. +func (c *Client) NetworkingBgpAnnounceSetList(ctx context.Context, params NetworkingBgpAnnounceSetListParams) (*[]BgpAnnounceSet, error) { if err := params.Validate(); err != nil { return nil, err } @@ -8267,11 +9432,13 @@ func (c *Client) IpPoolUtilizationView(ctx context.Context, params IpPoolUtiliza ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/ip-pools/{{.pool}}/utilization"), + resolveRelative(c.host, "/v1/system/networking/bgp-announce-set"), + map[string]string{}, map[string]string{ - "pool": string(params.Pool), + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + "sort_by": string(params.SortBy), }, - map[string]string{}, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -8294,7 +9461,7 @@ func (c *Client) IpPoolUtilizationView(ctx context.Context, params IpPoolUtiliza return nil, errors.New("request returned an empty body in the response") } - var body IpPoolUtilization + var body []BgpAnnounceSet if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -8303,31 +9470,26 @@ func (c *Client) IpPoolUtilizationView(ctx context.Context, params IpPoolUtiliza return &body, nil } -// SystemMetric: View metrics -// View CPU, memory, or storage utilization metrics at the fleet or silo level. -// -// To iterate over all pages, use the `SystemMetricAllPages` method, instead. -func (c *Client) SystemMetric(ctx context.Context, params SystemMetricParams) (*MeasurementResultsPage, error) { +// NetworkingBgpAnnounceSetUpdate: Update BGP announce set +// If the announce set exists, this endpoint replaces the existing announce set with the one specified. +func (c *Client) NetworkingBgpAnnounceSetUpdate(ctx context.Context, params NetworkingBgpAnnounceSetUpdateParams) (*BgpAnnounceSet, error) { if err := params.Validate(); err != nil { return nil, err } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + // Create the request req, err := c.buildRequest( ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/system/metrics/{{.metric_name}}"), - map[string]string{ - "metric_name": string(params.MetricName), - }, - map[string]string{ - "end_time": params.EndTime.Format(time.RFC3339), - "limit": PointerIntToStr(params.Limit), - "order": string(params.Order), - "page_token": params.PageToken, - "silo": string(params.Silo), - "start_time": params.StartTime.Format(time.RFC3339), - }, + b, + "PUT", + resolveRelative(c.host, "/v1/system/networking/bgp-announce-set"), + map[string]string{}, + map[string]string{}, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -8350,7 +9512,7 @@ func (c *Client) SystemMetric(ctx context.Context, params SystemMetricParams) (* return nil, errors.New("request returned an empty body in the response") } - var body MeasurementResultsPage + var body BgpAnnounceSet if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -8359,127 +9521,55 @@ func (c *Client) SystemMetric(ctx context.Context, params SystemMetricParams) (* return &body, nil } -// SystemMetricAllPages: View metrics -// View CPU, memory, or storage utilization metrics at the fleet or silo level. -// -// This method is a wrapper around the `SystemMetric` method. -// This method returns all the pages at once. -func (c *Client) SystemMetricAllPages(ctx context.Context, params SystemMetricParams) ([]Measurement, error) { - if err := params.Validate(); err != nil { - return nil, err - } - var allPages []Measurement - params.PageToken = "" - params.Limit = NewPointer(100) - for { - page, err := c.SystemMetric(ctx, params) - if err != nil { - return nil, err - } - allPages = append(allPages, page.Items...) - if page.NextPage == "" || page.NextPage == params.PageToken { - break - } - params.PageToken = page.NextPage - } - - return allPages, nil -} - -// NetworkingAddressLotList: List address lots -// -// To iterate over all pages, use the `NetworkingAddressLotListAllPages` method, instead. -func (c *Client) NetworkingAddressLotList(ctx context.Context, params NetworkingAddressLotListParams) (*AddressLotResultsPage, error) { +// NetworkingBgpAnnounceSetDelete: Delete BGP announce set +func (c *Client) NetworkingBgpAnnounceSetDelete(ctx context.Context, params NetworkingBgpAnnounceSetDeleteParams) error { if err := params.Validate(); err != nil { - return nil, err + return err } // Create the request req, err := c.buildRequest( ctx, nil, - "GET", - resolveRelative(c.host, "/v1/system/networking/address-lot"), - map[string]string{}, + "DELETE", + resolveRelative(c.host, "/v1/system/networking/bgp-announce-set/{{.announce_set}}"), map[string]string{ - "limit": PointerIntToStr(params.Limit), - "page_token": params.PageToken, - "sort_by": string(params.SortBy), + "announce_set": string(params.AnnounceSet), }, + map[string]string{}, ) if err != nil { - return nil, fmt.Errorf("error building request: %v", err) + return fmt.Errorf("error building request: %v", err) } // Send the request. resp, err := c.client.Do(req) if err != nil { - return nil, fmt.Errorf("error sending request: %v", err) + return fmt.Errorf("error sending request: %v", err) } defer resp.Body.Close() // Create and return an HTTPError when an error response code is received. if err := NewHTTPError(resp); err != nil { - return nil, err - } - - // Decode the body from the response. - if resp.Body == nil { - return nil, errors.New("request returned an empty body in the response") - } - - var body AddressLotResultsPage - if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { - return nil, fmt.Errorf("error decoding response body: %v", err) - } - - // Return the response. - return &body, nil -} - -// NetworkingAddressLotListAllPages: List address lots -// -// This method is a wrapper around the `NetworkingAddressLotList` method. -// This method returns all the pages at once. -func (c *Client) NetworkingAddressLotListAllPages(ctx context.Context, params NetworkingAddressLotListParams) ([]AddressLot, error) { - if err := params.Validate(); err != nil { - return nil, err - } - var allPages []AddressLot - params.PageToken = "" - params.Limit = NewPointer(100) - for { - page, err := c.NetworkingAddressLotList(ctx, params) - if err != nil { - return nil, err - } - allPages = append(allPages, page.Items...) - if page.NextPage == "" || page.NextPage == params.PageToken { - break - } - params.PageToken = page.NextPage + return err } - return allPages, nil + return nil } -// NetworkingAddressLotCreate: Create address lot -func (c *Client) NetworkingAddressLotCreate(ctx context.Context, params NetworkingAddressLotCreateParams) (*AddressLotCreateResponse, error) { +// NetworkingBgpAnnouncementList: Get originated routes for a specified BGP announce set +func (c *Client) NetworkingBgpAnnouncementList(ctx context.Context, params NetworkingBgpAnnouncementListParams) (*[]BgpAnnouncement, error) { if err := params.Validate(); err != nil { return nil, err } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return nil, fmt.Errorf("encoding json body request failed: %v", err) - } - // Create the request req, err := c.buildRequest( ctx, - b, - "POST", - resolveRelative(c.host, "/v1/system/networking/address-lot"), - map[string]string{}, + nil, + "GET", + resolveRelative(c.host, "/v1/system/networking/bgp-announce-set/{{.announce_set}}/announcement"), + map[string]string{ + "announce_set": string(params.AnnounceSet), + }, map[string]string{}, ) if err != nil { @@ -8503,7 +9593,7 @@ func (c *Client) NetworkingAddressLotCreate(ctx context.Context, params Networki return nil, errors.New("request returned an empty body in the response") } - var body AddressLotCreateResponse + var body []BgpAnnouncement if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -8512,20 +9602,15 @@ func (c *Client) NetworkingAddressLotCreate(ctx context.Context, params Networki return &body, nil } -// NetworkingAddressLotView: Fetch address lot -func (c *Client) NetworkingAddressLotView(ctx context.Context, params NetworkingAddressLotViewParams) (*AddressLotViewResponse, error) { - if err := params.Validate(); err != nil { - return nil, err - } +// NetworkingBgpExported: Get BGP exported routes +func (c *Client) NetworkingBgpExported(ctx context.Context) (*BgpExported, error) { // Create the request req, err := c.buildRequest( ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/networking/address-lot/{{.address_lot}}"), - map[string]string{ - "address_lot": string(params.AddressLot), - }, + resolveRelative(c.host, "/v1/system/networking/bgp-exported"), + map[string]string{}, map[string]string{}, ) if err != nil { @@ -8549,7 +9634,7 @@ func (c *Client) NetworkingAddressLotView(ctx context.Context, params Networking return nil, errors.New("request returned an empty body in the response") } - var body AddressLotViewResponse + var body BgpExported if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -8558,45 +9643,8 @@ func (c *Client) NetworkingAddressLotView(ctx context.Context, params Networking return &body, nil } -// NetworkingAddressLotDelete: Delete address lot -func (c *Client) NetworkingAddressLotDelete(ctx context.Context, params NetworkingAddressLotDeleteParams) error { - if err := params.Validate(); err != nil { - return err - } - // Create the request - req, err := c.buildRequest( - ctx, - nil, - "DELETE", - resolveRelative(c.host, "/v1/system/networking/address-lot/{{.address_lot}}"), - map[string]string{ - "address_lot": string(params.AddressLot), - }, - map[string]string{}, - ) - if err != nil { - return fmt.Errorf("error building request: %v", err) - } - - // Send the request. - resp, err := c.client.Do(req) - if err != nil { - return fmt.Errorf("error sending request: %v", err) - } - defer resp.Body.Close() - - // Create and return an HTTPError when an error response code is received. - if err := NewHTTPError(resp); err != nil { - return err - } - - return nil -} - -// NetworkingAddressLotBlockList: List blocks in address lot -// -// To iterate over all pages, use the `NetworkingAddressLotBlockListAllPages` method, instead. -func (c *Client) NetworkingAddressLotBlockList(ctx context.Context, params NetworkingAddressLotBlockListParams) (*AddressLotBlockResultsPage, error) { +// NetworkingBgpMessageHistory: Get BGP router message history +func (c *Client) NetworkingBgpMessageHistory(ctx context.Context, params NetworkingBgpMessageHistoryParams) (*AggregateBgpMessageHistory, error) { if err := params.Validate(); err != nil { return nil, err } @@ -8605,14 +9653,10 @@ func (c *Client) NetworkingAddressLotBlockList(ctx context.Context, params Netwo ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/networking/address-lot/{{.address_lot}}/blocks"), - map[string]string{ - "address_lot": string(params.AddressLot), - }, + resolveRelative(c.host, "/v1/system/networking/bgp-message-history"), + map[string]string{}, map[string]string{ - "limit": PointerIntToStr(params.Limit), - "page_token": params.PageToken, - "sort_by": string(params.SortBy), + "asn": PointerIntToStr(params.Asn), }, ) if err != nil { @@ -8636,7 +9680,7 @@ func (c *Client) NetworkingAddressLotBlockList(ctx context.Context, params Netwo return nil, errors.New("request returned an empty body in the response") } - var body AddressLotBlockResultsPage + var body AggregateBgpMessageHistory if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -8645,42 +9689,21 @@ func (c *Client) NetworkingAddressLotBlockList(ctx context.Context, params Netwo return &body, nil } -// NetworkingAddressLotBlockListAllPages: List blocks in address lot -// -// This method is a wrapper around the `NetworkingAddressLotBlockList` method. -// This method returns all the pages at once. -func (c *Client) NetworkingAddressLotBlockListAllPages(ctx context.Context, params NetworkingAddressLotBlockListParams) ([]AddressLotBlock, error) { +// NetworkingBgpImportedRoutesIpv4: Get imported IPv4 BGP routes +func (c *Client) NetworkingBgpImportedRoutesIpv4(ctx context.Context, params NetworkingBgpImportedRoutesIpv4Params) (*[]BgpImportedRouteIpv4, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []AddressLotBlock - params.PageToken = "" - params.Limit = NewPointer(100) - for { - page, err := c.NetworkingAddressLotBlockList(ctx, params) - if err != nil { - return nil, err - } - allPages = append(allPages, page.Items...) - if page.NextPage == "" || page.NextPage == params.PageToken { - break - } - params.PageToken = page.NextPage - } - - return allPages, nil -} - -// NetworkingAllowListView: Get user-facing services IP allowlist -func (c *Client) NetworkingAllowListView(ctx context.Context) (*AllowList, error) { // Create the request req, err := c.buildRequest( ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/networking/allow-list"), - map[string]string{}, + resolveRelative(c.host, "/v1/system/networking/bgp-routes-ipv4"), map[string]string{}, + map[string]string{ + "asn": PointerIntToStr(params.Asn), + }, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -8703,7 +9726,7 @@ func (c *Client) NetworkingAllowListView(ctx context.Context) (*AllowList, error return nil, errors.New("request returned an empty body in the response") } - var body AllowList + var body []BgpImportedRouteIpv4 if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -8712,23 +9735,14 @@ func (c *Client) NetworkingAllowListView(ctx context.Context) (*AllowList, error return &body, nil } -// NetworkingAllowListUpdate: Update user-facing services IP allowlist -func (c *Client) NetworkingAllowListUpdate(ctx context.Context, params NetworkingAllowListUpdateParams) (*AllowList, error) { - if err := params.Validate(); err != nil { - return nil, err - } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return nil, fmt.Errorf("encoding json body request failed: %v", err) - } - +// NetworkingBgpStatus: Get BGP peer status +func (c *Client) NetworkingBgpStatus(ctx context.Context) (*[]BgpPeerStatus, error) { // Create the request req, err := c.buildRequest( ctx, - b, - "PUT", - resolveRelative(c.host, "/v1/system/networking/allow-list"), + nil, + "GET", + resolveRelative(c.host, "/v1/system/networking/bgp-status"), map[string]string{}, map[string]string{}, ) @@ -8753,7 +9767,7 @@ func (c *Client) NetworkingAllowListUpdate(ctx context.Context, params Networkin return nil, errors.New("request returned an empty body in the response") } - var body AllowList + var body []BgpPeerStatus if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -8762,47 +9776,49 @@ func (c *Client) NetworkingAllowListUpdate(ctx context.Context, params Networkin return &body, nil } -// NetworkingBfdDisable: Disable a BFD session -func (c *Client) NetworkingBfdDisable(ctx context.Context, params NetworkingBfdDisableParams) error { - if err := params.Validate(); err != nil { - return err - } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return fmt.Errorf("encoding json body request failed: %v", err) - } - +// NetworkingInboundIcmpView: Return whether API services can receive limited ICMP traffic +func (c *Client) NetworkingInboundIcmpView(ctx context.Context) (*ServiceIcmpConfig, error) { // Create the request req, err := c.buildRequest( ctx, - b, - "POST", - resolveRelative(c.host, "/v1/system/networking/bfd-disable"), + nil, + "GET", + resolveRelative(c.host, "/v1/system/networking/inbound-icmp"), map[string]string{}, map[string]string{}, ) if err != nil { - return fmt.Errorf("error building request: %v", err) + return nil, fmt.Errorf("error building request: %v", err) } // Send the request. resp, err := c.client.Do(req) if err != nil { - return fmt.Errorf("error sending request: %v", err) + return nil, fmt.Errorf("error sending request: %v", err) } defer resp.Body.Close() // Create and return an HTTPError when an error response code is received. if err := NewHTTPError(resp); err != nil { - return err + return nil, err } - return nil + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body ServiceIcmpConfig + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil } -// NetworkingBfdEnable: Enable a BFD session -func (c *Client) NetworkingBfdEnable(ctx context.Context, params NetworkingBfdEnableParams) error { +// NetworkingInboundIcmpUpdate: Set whether API services can receive limited ICMP traffic +func (c *Client) NetworkingInboundIcmpUpdate(ctx context.Context, params NetworkingInboundIcmpUpdateParams) error { if err := params.Validate(); err != nil { return err } @@ -8816,8 +9832,8 @@ func (c *Client) NetworkingBfdEnable(ctx context.Context, params NetworkingBfdEn req, err := c.buildRequest( ctx, b, - "POST", - resolveRelative(c.host, "/v1/system/networking/bfd-enable"), + "PUT", + resolveRelative(c.host, "/v1/system/networking/inbound-icmp"), map[string]string{}, map[string]string{}, ) @@ -8840,51 +9856,10 @@ func (c *Client) NetworkingBfdEnable(ctx context.Context, params NetworkingBfdEn return nil } -// NetworkingBfdStatus: Get BFD status -func (c *Client) NetworkingBfdStatus(ctx context.Context) (*[]BfdStatus, error) { - // Create the request - req, err := c.buildRequest( - ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/system/networking/bfd-status"), - map[string]string{}, - map[string]string{}, - ) - if err != nil { - return nil, fmt.Errorf("error building request: %v", err) - } - - // Send the request. - resp, err := c.client.Do(req) - if err != nil { - return nil, fmt.Errorf("error sending request: %v", err) - } - defer resp.Body.Close() - - // Create and return an HTTPError when an error response code is received. - if err := NewHTTPError(resp); err != nil { - return nil, err - } - - // Decode the body from the response. - if resp.Body == nil { - return nil, errors.New("request returned an empty body in the response") - } - - var body []BfdStatus - if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { - return nil, fmt.Errorf("error decoding response body: %v", err) - } - - // Return the response. - return &body, nil -} - -// NetworkingBgpConfigList: List BGP configurations +// NetworkingLoopbackAddressList: List loopback addresses // -// To iterate over all pages, use the `NetworkingBgpConfigListAllPages` method, instead. -func (c *Client) NetworkingBgpConfigList(ctx context.Context, params NetworkingBgpConfigListParams) (*BgpConfigResultsPage, error) { +// To iterate over all pages, use the `NetworkingLoopbackAddressListAllPages` method, instead. +func (c *Client) NetworkingLoopbackAddressList(ctx context.Context, params NetworkingLoopbackAddressListParams) (*LoopbackAddressResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -8893,7 +9868,7 @@ func (c *Client) NetworkingBgpConfigList(ctx context.Context, params NetworkingB ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/networking/bgp"), + resolveRelative(c.host, "/v1/system/networking/loopback-address"), map[string]string{}, map[string]string{ "limit": PointerIntToStr(params.Limit), @@ -8922,7 +9897,7 @@ func (c *Client) NetworkingBgpConfigList(ctx context.Context, params NetworkingB return nil, errors.New("request returned an empty body in the response") } - var body BgpConfigResultsPage + var body LoopbackAddressResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -8931,19 +9906,19 @@ func (c *Client) NetworkingBgpConfigList(ctx context.Context, params NetworkingB return &body, nil } -// NetworkingBgpConfigListAllPages: List BGP configurations +// NetworkingLoopbackAddressListAllPages: List loopback addresses // -// This method is a wrapper around the `NetworkingBgpConfigList` method. +// This method is a wrapper around the `NetworkingLoopbackAddressList` method. // This method returns all the pages at once. -func (c *Client) NetworkingBgpConfigListAllPages(ctx context.Context, params NetworkingBgpConfigListParams) ([]BgpConfig, error) { +func (c *Client) NetworkingLoopbackAddressListAllPages(ctx context.Context, params NetworkingLoopbackAddressListParams) ([]LoopbackAddress, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []BgpConfig + var allPages []LoopbackAddress params.PageToken = "" params.Limit = NewPointer(100) for { - page, err := c.NetworkingBgpConfigList(ctx, params) + page, err := c.NetworkingLoopbackAddressList(ctx, params) if err != nil { return nil, err } @@ -8957,8 +9932,8 @@ func (c *Client) NetworkingBgpConfigListAllPages(ctx context.Context, params Net return allPages, nil } -// NetworkingBgpConfigCreate: Create new BGP configuration -func (c *Client) NetworkingBgpConfigCreate(ctx context.Context, params NetworkingBgpConfigCreateParams) (*BgpConfig, error) { +// NetworkingLoopbackAddressCreate: Create loopback address +func (c *Client) NetworkingLoopbackAddressCreate(ctx context.Context, params NetworkingLoopbackAddressCreateParams) (*LoopbackAddress, error) { if err := params.Validate(); err != nil { return nil, err } @@ -8973,7 +9948,7 @@ func (c *Client) NetworkingBgpConfigCreate(ctx context.Context, params Networkin ctx, b, "POST", - resolveRelative(c.host, "/v1/system/networking/bgp"), + resolveRelative(c.host, "/v1/system/networking/loopback-address"), map[string]string{}, map[string]string{}, ) @@ -8998,7 +9973,7 @@ func (c *Client) NetworkingBgpConfigCreate(ctx context.Context, params Networkin return nil, errors.New("request returned an empty body in the response") } - var body BgpConfig + var body LoopbackAddress if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -9007,8 +9982,8 @@ func (c *Client) NetworkingBgpConfigCreate(ctx context.Context, params Networkin return &body, nil } -// NetworkingBgpConfigDelete: Delete BGP configuration -func (c *Client) NetworkingBgpConfigDelete(ctx context.Context, params NetworkingBgpConfigDeleteParams) error { +// NetworkingLoopbackAddressDelete: Delete loopback address +func (c *Client) NetworkingLoopbackAddressDelete(ctx context.Context, params NetworkingLoopbackAddressDeleteParams) error { if err := params.Validate(); err != nil { return err } @@ -9017,11 +9992,14 @@ func (c *Client) NetworkingBgpConfigDelete(ctx context.Context, params Networkin ctx, nil, "DELETE", - resolveRelative(c.host, "/v1/system/networking/bgp"), - map[string]string{}, + resolveRelative(c.host, "/v1/system/networking/loopback-address/{{.rack_id}}/{{.switch_location}}/{{.address}}/{{.subnet_mask}}"), map[string]string{ - "name_or_id": string(params.NameOrId), + "address": params.Address, + "rack_id": params.RackId, + "subnet_mask": PointerIntToStr(params.SubnetMask), + "switch_location": string(params.SwitchLocation), }, + map[string]string{}, ) if err != nil { return fmt.Errorf("error building request: %v", err) @@ -9042,10 +10020,10 @@ func (c *Client) NetworkingBgpConfigDelete(ctx context.Context, params Networkin return nil } -// NetworkingBgpAnnounceSetList: List BGP announce sets +// NetworkingSwitchPortSettingsList: List switch port settings // -// To iterate over all pages, use the `NetworkingBgpAnnounceSetListAllPages` method, instead. -func (c *Client) NetworkingBgpAnnounceSetList(ctx context.Context, params NetworkingBgpAnnounceSetListParams) (*[]BgpAnnounceSet, error) { +// To iterate over all pages, use the `NetworkingSwitchPortSettingsListAllPages` method, instead. +func (c *Client) NetworkingSwitchPortSettingsList(ctx context.Context, params NetworkingSwitchPortSettingsListParams) (*SwitchPortSettingsIdentityResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -9054,12 +10032,13 @@ func (c *Client) NetworkingBgpAnnounceSetList(ctx context.Context, params Networ ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/networking/bgp-announce-set"), + resolveRelative(c.host, "/v1/system/networking/switch-port-settings"), map[string]string{}, map[string]string{ - "limit": PointerIntToStr(params.Limit), - "page_token": params.PageToken, - "sort_by": string(params.SortBy), + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + "port_settings": string(params.PortSettings), + "sort_by": string(params.SortBy), }, ) if err != nil { @@ -9083,7 +10062,7 @@ func (c *Client) NetworkingBgpAnnounceSetList(ctx context.Context, params Networ return nil, errors.New("request returned an empty body in the response") } - var body []BgpAnnounceSet + var body SwitchPortSettingsIdentityResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -9092,9 +10071,34 @@ func (c *Client) NetworkingBgpAnnounceSetList(ctx context.Context, params Networ return &body, nil } -// NetworkingBgpAnnounceSetUpdate: Update BGP announce set -// If the announce set exists, this endpoint replaces the existing announce set with the one specified. -func (c *Client) NetworkingBgpAnnounceSetUpdate(ctx context.Context, params NetworkingBgpAnnounceSetUpdateParams) (*BgpAnnounceSet, error) { +// NetworkingSwitchPortSettingsListAllPages: List switch port settings +// +// This method is a wrapper around the `NetworkingSwitchPortSettingsList` method. +// This method returns all the pages at once. +func (c *Client) NetworkingSwitchPortSettingsListAllPages(ctx context.Context, params NetworkingSwitchPortSettingsListParams) ([]SwitchPortSettingsIdentity, error) { + if err := params.Validate(); err != nil { + return nil, err + } + var allPages []SwitchPortSettingsIdentity + params.PageToken = "" + params.Limit = NewPointer(100) + for { + page, err := c.NetworkingSwitchPortSettingsList(ctx, params) + if err != nil { + return nil, err + } + allPages = append(allPages, page.Items...) + if page.NextPage == "" || page.NextPage == params.PageToken { + break + } + params.PageToken = page.NextPage + } + + return allPages, nil +} + +// NetworkingSwitchPortSettingsCreate: Create switch port settings +func (c *Client) NetworkingSwitchPortSettingsCreate(ctx context.Context, params NetworkingSwitchPortSettingsCreateParams) (*SwitchPortSettings, error) { if err := params.Validate(); err != nil { return nil, err } @@ -9108,8 +10112,8 @@ func (c *Client) NetworkingBgpAnnounceSetUpdate(ctx context.Context, params Netw req, err := c.buildRequest( ctx, b, - "PUT", - resolveRelative(c.host, "/v1/system/networking/bgp-announce-set"), + "POST", + resolveRelative(c.host, "/v1/system/networking/switch-port-settings"), map[string]string{}, map[string]string{}, ) @@ -9134,7 +10138,7 @@ func (c *Client) NetworkingBgpAnnounceSetUpdate(ctx context.Context, params Netw return nil, errors.New("request returned an empty body in the response") } - var body BgpAnnounceSet + var body SwitchPortSettings if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -9143,8 +10147,8 @@ func (c *Client) NetworkingBgpAnnounceSetUpdate(ctx context.Context, params Netw return &body, nil } -// NetworkingBgpAnnounceSetDelete: Delete BGP announce set -func (c *Client) NetworkingBgpAnnounceSetDelete(ctx context.Context, params NetworkingBgpAnnounceSetDeleteParams) error { +// NetworkingSwitchPortSettingsDelete: Delete switch port settings +func (c *Client) NetworkingSwitchPortSettingsDelete(ctx context.Context, params NetworkingSwitchPortSettingsDeleteParams) error { if err := params.Validate(); err != nil { return err } @@ -9153,11 +10157,11 @@ func (c *Client) NetworkingBgpAnnounceSetDelete(ctx context.Context, params Netw ctx, nil, "DELETE", - resolveRelative(c.host, "/v1/system/networking/bgp-announce-set/{{.announce_set}}"), + resolveRelative(c.host, "/v1/system/networking/switch-port-settings"), + map[string]string{}, map[string]string{ - "announce_set": string(params.AnnounceSet), + "port_settings": string(params.PortSettings), }, - map[string]string{}, ) if err != nil { return fmt.Errorf("error building request: %v", err) @@ -9178,8 +10182,8 @@ func (c *Client) NetworkingBgpAnnounceSetDelete(ctx context.Context, params Netw return nil } -// NetworkingBgpAnnouncementList: Get originated routes for a specified BGP announce set -func (c *Client) NetworkingBgpAnnouncementList(ctx context.Context, params NetworkingBgpAnnouncementListParams) (*[]BgpAnnouncement, error) { +// NetworkingSwitchPortSettingsView: Get information about switch port +func (c *Client) NetworkingSwitchPortSettingsView(ctx context.Context, params NetworkingSwitchPortSettingsViewParams) (*SwitchPortSettings, error) { if err := params.Validate(); err != nil { return nil, err } @@ -9188,9 +10192,9 @@ func (c *Client) NetworkingBgpAnnouncementList(ctx context.Context, params Netwo ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/networking/bgp-announce-set/{{.announce_set}}/announcement"), + resolveRelative(c.host, "/v1/system/networking/switch-port-settings/{{.port}}"), map[string]string{ - "announce_set": string(params.AnnounceSet), + "port": string(params.Port), }, map[string]string{}, ) @@ -9215,7 +10219,7 @@ func (c *Client) NetworkingBgpAnnouncementList(ctx context.Context, params Netwo return nil, errors.New("request returned an empty body in the response") } - var body []BgpAnnouncement + var body SwitchPortSettings if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -9224,14 +10228,14 @@ func (c *Client) NetworkingBgpAnnouncementList(ctx context.Context, params Netwo return &body, nil } -// NetworkingBgpExported: Get BGP exported routes -func (c *Client) NetworkingBgpExported(ctx context.Context) (*BgpExported, error) { +// SystemPolicyView: Fetch top-level IAM policy +func (c *Client) SystemPolicyView(ctx context.Context) (*FleetRolePolicy, error) { // Create the request req, err := c.buildRequest( ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/networking/bgp-exported"), + resolveRelative(c.host, "/v1/system/policy"), map[string]string{}, map[string]string{}, ) @@ -9256,7 +10260,7 @@ func (c *Client) NetworkingBgpExported(ctx context.Context) (*BgpExported, error return nil, errors.New("request returned an empty body in the response") } - var body BgpExported + var body FleetRolePolicy if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -9265,21 +10269,25 @@ func (c *Client) NetworkingBgpExported(ctx context.Context) (*BgpExported, error return &body, nil } -// NetworkingBgpMessageHistory: Get BGP router message history -func (c *Client) NetworkingBgpMessageHistory(ctx context.Context, params NetworkingBgpMessageHistoryParams) (*AggregateBgpMessageHistory, error) { +// SystemPolicyUpdate: Update top-level IAM policy +func (c *Client) SystemPolicyUpdate(ctx context.Context, params SystemPolicyUpdateParams) (*FleetRolePolicy, error) { if err := params.Validate(); err != nil { return nil, err } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + // Create the request req, err := c.buildRequest( ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/system/networking/bgp-message-history"), + b, + "PUT", + resolveRelative(c.host, "/v1/system/policy"), + map[string]string{}, map[string]string{}, - map[string]string{ - "asn": PointerIntToStr(params.Asn), - }, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -9302,7 +10310,7 @@ func (c *Client) NetworkingBgpMessageHistory(ctx context.Context, params Network return nil, errors.New("request returned an empty body in the response") } - var body AggregateBgpMessageHistory + var body FleetRolePolicy if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -9311,8 +10319,9 @@ func (c *Client) NetworkingBgpMessageHistory(ctx context.Context, params Network return &body, nil } -// NetworkingBgpImportedRoutesIpv4: Get imported IPv4 BGP routes -func (c *Client) NetworkingBgpImportedRoutesIpv4(ctx context.Context, params NetworkingBgpImportedRoutesIpv4Params) (*[]BgpImportedRouteIpv4, error) { +// ScimTokenList: List SCIM tokens +// Specify the silo by name or ID using the `silo` query parameter. +func (c *Client) ScimTokenList(ctx context.Context, params ScimTokenListParams) (*[]ScimClientBearerToken, error) { if err := params.Validate(); err != nil { return nil, err } @@ -9321,10 +10330,10 @@ func (c *Client) NetworkingBgpImportedRoutesIpv4(ctx context.Context, params Net ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/networking/bgp-routes-ipv4"), + resolveRelative(c.host, "/v1/system/scim/tokens"), map[string]string{}, map[string]string{ - "asn": PointerIntToStr(params.Asn), + "silo": string(params.Silo), }, ) if err != nil { @@ -9348,7 +10357,7 @@ func (c *Client) NetworkingBgpImportedRoutesIpv4(ctx context.Context, params Net return nil, errors.New("request returned an empty body in the response") } - var body []BgpImportedRouteIpv4 + var body []ScimClientBearerToken if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -9357,16 +10366,23 @@ func (c *Client) NetworkingBgpImportedRoutesIpv4(ctx context.Context, params Net return &body, nil } -// NetworkingBgpStatus: Get BGP peer status -func (c *Client) NetworkingBgpStatus(ctx context.Context) (*[]BgpPeerStatus, error) { +// ScimTokenCreate: Create SCIM token +// Specify the silo by name or ID using the `silo` query parameter. Be sure to save the bearer token in the +// response. It will not be retrievable later through the token view and list endpoints. +func (c *Client) ScimTokenCreate(ctx context.Context, params ScimTokenCreateParams) (*ScimClientBearerTokenValue, error) { + if err := params.Validate(); err != nil { + return nil, err + } // Create the request req, err := c.buildRequest( ctx, nil, - "GET", - resolveRelative(c.host, "/v1/system/networking/bgp-status"), - map[string]string{}, + "POST", + resolveRelative(c.host, "/v1/system/scim/tokens"), map[string]string{}, + map[string]string{ + "silo": string(params.Silo), + }, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -9389,7 +10405,7 @@ func (c *Client) NetworkingBgpStatus(ctx context.Context) (*[]BgpPeerStatus, err return nil, errors.New("request returned an empty body in the response") } - var body []BgpPeerStatus + var body ScimClientBearerTokenValue if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -9398,16 +10414,24 @@ func (c *Client) NetworkingBgpStatus(ctx context.Context) (*[]BgpPeerStatus, err return &body, nil } -// NetworkingInboundIcmpView: Return whether API services can receive limited ICMP traffic -func (c *Client) NetworkingInboundIcmpView(ctx context.Context) (*ServiceIcmpConfig, error) { +// ScimTokenView: Fetch SCIM token +// Specify the silo by name or ID using the `silo` query parameter. +func (c *Client) ScimTokenView(ctx context.Context, params ScimTokenViewParams) (*ScimClientBearerToken, error) { + if err := params.Validate(); err != nil { + return nil, err + } // Create the request req, err := c.buildRequest( ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/networking/inbound-icmp"), - map[string]string{}, - map[string]string{}, + resolveRelative(c.host, "/v1/system/scim/tokens/{{.token_id}}"), + map[string]string{ + "token_id": params.TokenId, + }, + map[string]string{ + "silo": string(params.Silo), + }, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -9430,7 +10454,7 @@ func (c *Client) NetworkingInboundIcmpView(ctx context.Context) (*ServiceIcmpCon return nil, errors.New("request returned an empty body in the response") } - var body ServiceIcmpConfig + var body ScimClientBearerToken if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -9439,25 +10463,24 @@ func (c *Client) NetworkingInboundIcmpView(ctx context.Context) (*ServiceIcmpCon return &body, nil } -// NetworkingInboundIcmpUpdate: Set whether API services can receive limited ICMP traffic -func (c *Client) NetworkingInboundIcmpUpdate(ctx context.Context, params NetworkingInboundIcmpUpdateParams) error { +// ScimTokenDelete: Delete SCIM token +// Specify the silo by name or ID using the `silo` query parameter. +func (c *Client) ScimTokenDelete(ctx context.Context, params ScimTokenDeleteParams) error { if err := params.Validate(); err != nil { return err } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return fmt.Errorf("encoding json body request failed: %v", err) - } - // Create the request req, err := c.buildRequest( ctx, - b, - "PUT", - resolveRelative(c.host, "/v1/system/networking/inbound-icmp"), - map[string]string{}, - map[string]string{}, + nil, + "DELETE", + resolveRelative(c.host, "/v1/system/scim/tokens/{{.token_id}}"), + map[string]string{ + "token_id": params.TokenId, + }, + map[string]string{ + "silo": string(params.Silo), + }, ) if err != nil { return fmt.Errorf("error building request: %v", err) @@ -9478,10 +10501,10 @@ func (c *Client) NetworkingInboundIcmpUpdate(ctx context.Context, params Network return nil } -// NetworkingLoopbackAddressList: List loopback addresses +// SystemQuotasList: Lists resource quotas for all silos // -// To iterate over all pages, use the `NetworkingLoopbackAddressListAllPages` method, instead. -func (c *Client) NetworkingLoopbackAddressList(ctx context.Context, params NetworkingLoopbackAddressListParams) (*LoopbackAddressResultsPage, error) { +// To iterate over all pages, use the `SystemQuotasListAllPages` method, instead. +func (c *Client) SystemQuotasList(ctx context.Context, params SystemQuotasListParams) (*SiloQuotasResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -9490,7 +10513,7 @@ func (c *Client) NetworkingLoopbackAddressList(ctx context.Context, params Netwo ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/networking/loopback-address"), + resolveRelative(c.host, "/v1/system/silo-quotas"), map[string]string{}, map[string]string{ "limit": PointerIntToStr(params.Limit), @@ -9519,7 +10542,7 @@ func (c *Client) NetworkingLoopbackAddressList(ctx context.Context, params Netwo return nil, errors.New("request returned an empty body in the response") } - var body LoopbackAddressResultsPage + var body SiloQuotasResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -9528,19 +10551,97 @@ func (c *Client) NetworkingLoopbackAddressList(ctx context.Context, params Netwo return &body, nil } -// NetworkingLoopbackAddressListAllPages: List loopback addresses +// SystemQuotasListAllPages: Lists resource quotas for all silos // -// This method is a wrapper around the `NetworkingLoopbackAddressList` method. +// This method is a wrapper around the `SystemQuotasList` method. // This method returns all the pages at once. -func (c *Client) NetworkingLoopbackAddressListAllPages(ctx context.Context, params NetworkingLoopbackAddressListParams) ([]LoopbackAddress, error) { +func (c *Client) SystemQuotasListAllPages(ctx context.Context, params SystemQuotasListParams) ([]SiloQuotas, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []LoopbackAddress + var allPages []SiloQuotas params.PageToken = "" params.Limit = NewPointer(100) for { - page, err := c.NetworkingLoopbackAddressList(ctx, params) + page, err := c.SystemQuotasList(ctx, params) + if err != nil { + return nil, err + } + allPages = append(allPages, page.Items...) + if page.NextPage == "" || page.NextPage == params.PageToken { + break + } + params.PageToken = page.NextPage + } + + return allPages, nil +} + +// SiloList: List silos +// Lists silos that are discoverable based on the current permissions. +// +// To iterate over all pages, use the `SiloListAllPages` method, instead. +func (c *Client) SiloList(ctx context.Context, params SiloListParams) (*SiloResultsPage, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Create the request + req, err := c.buildRequest( + ctx, + nil, + "GET", + resolveRelative(c.host, "/v1/system/silos"), + map[string]string{}, + map[string]string{ + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + "sort_by": string(params.SortBy), + }, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body SiloResultsPage + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil +} + +// SiloListAllPages: List silos +// Lists silos that are discoverable based on the current permissions. +// +// This method is a wrapper around the `SiloList` method. +// This method returns all the pages at once. +func (c *Client) SiloListAllPages(ctx context.Context, params SiloListParams) ([]Silo, error) { + if err := params.Validate(); err != nil { + return nil, err + } + var allPages []Silo + params.PageToken = "" + params.Limit = NewPointer(100) + for { + page, err := c.SiloList(ctx, params) if err != nil { return nil, err } @@ -9551,27 +10652,74 @@ func (c *Client) NetworkingLoopbackAddressListAllPages(ctx context.Context, para params.PageToken = page.NextPage } - return allPages, nil + return allPages, nil +} + +// SiloCreate: Create silo +func (c *Client) SiloCreate(ctx context.Context, params SiloCreateParams) (*Silo, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + + // Create the request + req, err := c.buildRequest( + ctx, + b, + "POST", + resolveRelative(c.host, "/v1/system/silos"), + map[string]string{}, + map[string]string{}, + ) + if err != nil { + return nil, fmt.Errorf("error building request: %v", err) + } + + // Send the request. + resp, err := c.client.Do(req) + if err != nil { + return nil, fmt.Errorf("error sending request: %v", err) + } + defer resp.Body.Close() + + // Create and return an HTTPError when an error response code is received. + if err := NewHTTPError(resp); err != nil { + return nil, err + } + + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body Silo + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil } -// NetworkingLoopbackAddressCreate: Create loopback address -func (c *Client) NetworkingLoopbackAddressCreate(ctx context.Context, params NetworkingLoopbackAddressCreateParams) (*LoopbackAddress, error) { +// SiloView: Fetch silo +// Fetch silo by name or ID. +func (c *Client) SiloView(ctx context.Context, params SiloViewParams) (*Silo, error) { if err := params.Validate(); err != nil { return nil, err } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return nil, fmt.Errorf("encoding json body request failed: %v", err) - } - // Create the request req, err := c.buildRequest( ctx, - b, - "POST", - resolveRelative(c.host, "/v1/system/networking/loopback-address"), - map[string]string{}, + nil, + "GET", + resolveRelative(c.host, "/v1/system/silos/{{.silo}}"), + map[string]string{ + "silo": string(params.Silo), + }, map[string]string{}, ) if err != nil { @@ -9595,7 +10743,7 @@ func (c *Client) NetworkingLoopbackAddressCreate(ctx context.Context, params Net return nil, errors.New("request returned an empty body in the response") } - var body LoopbackAddress + var body Silo if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -9604,8 +10752,9 @@ func (c *Client) NetworkingLoopbackAddressCreate(ctx context.Context, params Net return &body, nil } -// NetworkingLoopbackAddressDelete: Delete loopback address -func (c *Client) NetworkingLoopbackAddressDelete(ctx context.Context, params NetworkingLoopbackAddressDeleteParams) error { +// SiloDelete: Delete silo +// Delete a silo by name or ID. +func (c *Client) SiloDelete(ctx context.Context, params SiloDeleteParams) error { if err := params.Validate(); err != nil { return err } @@ -9614,12 +10763,9 @@ func (c *Client) NetworkingLoopbackAddressDelete(ctx context.Context, params Net ctx, nil, "DELETE", - resolveRelative(c.host, "/v1/system/networking/loopback-address/{{.rack_id}}/{{.switch_location}}/{{.address}}/{{.subnet_mask}}"), + resolveRelative(c.host, "/v1/system/silos/{{.silo}}"), map[string]string{ - "address": params.Address, - "rack_id": params.RackId, - "subnet_mask": PointerIntToStr(params.SubnetMask), - "switch_location": string(params.SwitchLocation), + "silo": string(params.Silo), }, map[string]string{}, ) @@ -9642,10 +10788,12 @@ func (c *Client) NetworkingLoopbackAddressDelete(ctx context.Context, params Net return nil } -// NetworkingSwitchPortSettingsList: List switch port settings +// SiloIpPoolList: List IP pools linked to silo +// Linked IP pools are available to users in the specified silo. A silo can have at most one default pool. IPs +// are allocated from the default pool when users ask for one without specifying a pool. // -// To iterate over all pages, use the `NetworkingSwitchPortSettingsListAllPages` method, instead. -func (c *Client) NetworkingSwitchPortSettingsList(ctx context.Context, params NetworkingSwitchPortSettingsListParams) (*SwitchPortSettingsIdentityResultsPage, error) { +// To iterate over all pages, use the `SiloIpPoolListAllPages` method, instead. +func (c *Client) SiloIpPoolList(ctx context.Context, params SiloIpPoolListParams) (*SiloIpPoolResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -9654,13 +10802,14 @@ func (c *Client) NetworkingSwitchPortSettingsList(ctx context.Context, params Ne ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/networking/switch-port-settings"), - map[string]string{}, + resolveRelative(c.host, "/v1/system/silos/{{.silo}}/ip-pools"), map[string]string{ - "limit": PointerIntToStr(params.Limit), - "page_token": params.PageToken, - "port_settings": string(params.PortSettings), - "sort_by": string(params.SortBy), + "silo": string(params.Silo), + }, + map[string]string{ + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + "sort_by": string(params.SortBy), }, ) if err != nil { @@ -9684,7 +10833,7 @@ func (c *Client) NetworkingSwitchPortSettingsList(ctx context.Context, params Ne return nil, errors.New("request returned an empty body in the response") } - var body SwitchPortSettingsIdentityResultsPage + var body SiloIpPoolResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -9693,19 +10842,21 @@ func (c *Client) NetworkingSwitchPortSettingsList(ctx context.Context, params Ne return &body, nil } -// NetworkingSwitchPortSettingsListAllPages: List switch port settings +// SiloIpPoolListAllPages: List IP pools linked to silo +// Linked IP pools are available to users in the specified silo. A silo can have at most one default pool. IPs +// are allocated from the default pool when users ask for one without specifying a pool. // -// This method is a wrapper around the `NetworkingSwitchPortSettingsList` method. +// This method is a wrapper around the `SiloIpPoolList` method. // This method returns all the pages at once. -func (c *Client) NetworkingSwitchPortSettingsListAllPages(ctx context.Context, params NetworkingSwitchPortSettingsListParams) ([]SwitchPortSettingsIdentity, error) { +func (c *Client) SiloIpPoolListAllPages(ctx context.Context, params SiloIpPoolListParams) ([]SiloIpPool, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []SwitchPortSettingsIdentity + var allPages []SiloIpPool params.PageToken = "" params.Limit = NewPointer(100) for { - page, err := c.NetworkingSwitchPortSettingsList(ctx, params) + page, err := c.SiloIpPoolList(ctx, params) if err != nil { return nil, err } @@ -9719,24 +10870,20 @@ func (c *Client) NetworkingSwitchPortSettingsListAllPages(ctx context.Context, p return allPages, nil } -// NetworkingSwitchPortSettingsCreate: Create switch port settings -func (c *Client) NetworkingSwitchPortSettingsCreate(ctx context.Context, params NetworkingSwitchPortSettingsCreateParams) (*SwitchPortSettings, error) { +// SiloPolicyView: Fetch silo IAM policy +func (c *Client) SiloPolicyView(ctx context.Context, params SiloPolicyViewParams) (*SiloRolePolicy, error) { if err := params.Validate(); err != nil { return nil, err } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return nil, fmt.Errorf("encoding json body request failed: %v", err) - } - // Create the request req, err := c.buildRequest( ctx, - b, - "POST", - resolveRelative(c.host, "/v1/system/networking/switch-port-settings"), - map[string]string{}, + nil, + "GET", + resolveRelative(c.host, "/v1/system/silos/{{.silo}}/policy"), + map[string]string{ + "silo": string(params.Silo), + }, map[string]string{}, ) if err != nil { @@ -9760,7 +10907,7 @@ func (c *Client) NetworkingSwitchPortSettingsCreate(ctx context.Context, params return nil, errors.New("request returned an empty body in the response") } - var body SwitchPortSettings + var body SiloRolePolicy if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -9769,43 +10916,60 @@ func (c *Client) NetworkingSwitchPortSettingsCreate(ctx context.Context, params return &body, nil } -// NetworkingSwitchPortSettingsDelete: Delete switch port settings -func (c *Client) NetworkingSwitchPortSettingsDelete(ctx context.Context, params NetworkingSwitchPortSettingsDeleteParams) error { +// SiloPolicyUpdate: Update silo IAM policy +func (c *Client) SiloPolicyUpdate(ctx context.Context, params SiloPolicyUpdateParams) (*SiloRolePolicy, error) { if err := params.Validate(); err != nil { - return err + return nil, err + } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) } + // Create the request req, err := c.buildRequest( ctx, - nil, - "DELETE", - resolveRelative(c.host, "/v1/system/networking/switch-port-settings"), - map[string]string{}, + b, + "PUT", + resolveRelative(c.host, "/v1/system/silos/{{.silo}}/policy"), map[string]string{ - "port_settings": string(params.PortSettings), + "silo": string(params.Silo), }, + map[string]string{}, ) if err != nil { - return fmt.Errorf("error building request: %v", err) + return nil, fmt.Errorf("error building request: %v", err) } // Send the request. resp, err := c.client.Do(req) if err != nil { - return fmt.Errorf("error sending request: %v", err) + return nil, fmt.Errorf("error sending request: %v", err) } defer resp.Body.Close() // Create and return an HTTPError when an error response code is received. if err := NewHTTPError(resp); err != nil { - return err + return nil, err } - return nil + // Decode the body from the response. + if resp.Body == nil { + return nil, errors.New("request returned an empty body in the response") + } + + var body SiloRolePolicy + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + return nil, fmt.Errorf("error decoding response body: %v", err) + } + + // Return the response. + return &body, nil } -// NetworkingSwitchPortSettingsView: Get information about switch port -func (c *Client) NetworkingSwitchPortSettingsView(ctx context.Context, params NetworkingSwitchPortSettingsViewParams) (*SwitchPortSettings, error) { +// SiloQuotasView: Fetch resource quotas for silo +func (c *Client) SiloQuotasView(ctx context.Context, params SiloQuotasViewParams) (*SiloQuotas, error) { if err := params.Validate(); err != nil { return nil, err } @@ -9814,9 +10978,9 @@ func (c *Client) NetworkingSwitchPortSettingsView(ctx context.Context, params Ne ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/networking/switch-port-settings/{{.port}}"), + resolveRelative(c.host, "/v1/system/silos/{{.silo}}/quotas"), map[string]string{ - "port": string(params.Port), + "silo": string(params.Silo), }, map[string]string{}, ) @@ -9841,7 +11005,7 @@ func (c *Client) NetworkingSwitchPortSettingsView(ctx context.Context, params Ne return nil, errors.New("request returned an empty body in the response") } - var body SwitchPortSettings + var body SiloQuotas if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -9850,15 +11014,27 @@ func (c *Client) NetworkingSwitchPortSettingsView(ctx context.Context, params Ne return &body, nil } -// SystemPolicyView: Fetch top-level IAM policy -func (c *Client) SystemPolicyView(ctx context.Context) (*FleetRolePolicy, error) { +// SiloQuotasUpdate: Update resource quotas for silo +// If a quota value is not specified, it will remain unchanged. +func (c *Client) SiloQuotasUpdate(ctx context.Context, params SiloQuotasUpdateParams) (*SiloQuotas, error) { + if err := params.Validate(); err != nil { + return nil, err + } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + // Create the request req, err := c.buildRequest( ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/system/policy"), - map[string]string{}, + b, + "PUT", + resolveRelative(c.host, "/v1/system/silos/{{.silo}}/quotas"), + map[string]string{ + "silo": string(params.Silo), + }, map[string]string{}, ) if err != nil { @@ -9882,7 +11058,7 @@ func (c *Client) SystemPolicyView(ctx context.Context) (*FleetRolePolicy, error) return nil, errors.New("request returned an empty body in the response") } - var body FleetRolePolicy + var body SiloQuotas if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -9891,25 +11067,25 @@ func (c *Client) SystemPolicyView(ctx context.Context) (*FleetRolePolicy, error) return &body, nil } -// SystemPolicyUpdate: Update top-level IAM policy -func (c *Client) SystemPolicyUpdate(ctx context.Context, params SystemPolicyUpdateParams) (*FleetRolePolicy, error) { +// SubnetPoolList: List subnet pools +// +// To iterate over all pages, use the `SubnetPoolListAllPages` method, instead. +func (c *Client) SubnetPoolList(ctx context.Context, params SubnetPoolListParams) (*SubnetPoolResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return nil, fmt.Errorf("encoding json body request failed: %v", err) - } - // Create the request req, err := c.buildRequest( ctx, - b, - "PUT", - resolveRelative(c.host, "/v1/system/policy"), - map[string]string{}, + nil, + "GET", + resolveRelative(c.host, "/v1/system/subnet-pools"), map[string]string{}, + map[string]string{ + "limit": PointerIntToStr(params.Limit), + "page_token": params.PageToken, + "sort_by": string(params.SortBy), + }, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -9932,7 +11108,7 @@ func (c *Client) SystemPolicyUpdate(ctx context.Context, params SystemPolicyUpda return nil, errors.New("request returned an empty body in the response") } - var body FleetRolePolicy + var body SubnetPoolResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -9941,22 +11117,51 @@ func (c *Client) SystemPolicyUpdate(ctx context.Context, params SystemPolicyUpda return &body, nil } -// ScimTokenList: List SCIM tokens -// Specify the silo by name or ID using the `silo` query parameter. -func (c *Client) ScimTokenList(ctx context.Context, params ScimTokenListParams) (*[]ScimClientBearerToken, error) { +// SubnetPoolListAllPages: List subnet pools +// +// This method is a wrapper around the `SubnetPoolList` method. +// This method returns all the pages at once. +func (c *Client) SubnetPoolListAllPages(ctx context.Context, params SubnetPoolListParams) ([]SubnetPool, error) { + if err := params.Validate(); err != nil { + return nil, err + } + var allPages []SubnetPool + params.PageToken = "" + params.Limit = NewPointer(100) + for { + page, err := c.SubnetPoolList(ctx, params) + if err != nil { + return nil, err + } + allPages = append(allPages, page.Items...) + if page.NextPage == "" || page.NextPage == params.PageToken { + break + } + params.PageToken = page.NextPage + } + + return allPages, nil +} + +// SubnetPoolCreate: Create a subnet pool +func (c *Client) SubnetPoolCreate(ctx context.Context, params SubnetPoolCreateParams) (*SubnetPool, error) { if err := params.Validate(); err != nil { return nil, err } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + // Create the request req, err := c.buildRequest( ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/system/scim/tokens"), + b, + "POST", + resolveRelative(c.host, "/v1/system/subnet-pools"), + map[string]string{}, map[string]string{}, - map[string]string{ - "silo": string(params.Silo), - }, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -9979,7 +11184,7 @@ func (c *Client) ScimTokenList(ctx context.Context, params ScimTokenListParams) return nil, errors.New("request returned an empty body in the response") } - var body []ScimClientBearerToken + var body SubnetPool if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -9988,10 +11193,8 @@ func (c *Client) ScimTokenList(ctx context.Context, params ScimTokenListParams) return &body, nil } -// ScimTokenCreate: Create SCIM token -// Specify the silo by name or ID using the `silo` query parameter. Be sure to save the bearer token in the -// response. It will not be retrievable later through the token view and list endpoints. -func (c *Client) ScimTokenCreate(ctx context.Context, params ScimTokenCreateParams) (*ScimClientBearerTokenValue, error) { +// SubnetPoolView: Fetch a subnet pool +func (c *Client) SubnetPoolView(ctx context.Context, params SubnetPoolViewParams) (*SubnetPool, error) { if err := params.Validate(); err != nil { return nil, err } @@ -9999,12 +11202,12 @@ func (c *Client) ScimTokenCreate(ctx context.Context, params ScimTokenCreatePara req, err := c.buildRequest( ctx, nil, - "POST", - resolveRelative(c.host, "/v1/system/scim/tokens"), - map[string]string{}, + "GET", + resolveRelative(c.host, "/v1/system/subnet-pools/{{.pool}}"), map[string]string{ - "silo": string(params.Silo), + "pool": string(params.Pool), }, + map[string]string{}, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -10027,7 +11230,7 @@ func (c *Client) ScimTokenCreate(ctx context.Context, params ScimTokenCreatePara return nil, errors.New("request returned an empty body in the response") } - var body ScimClientBearerTokenValue + var body SubnetPool if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -10036,24 +11239,27 @@ func (c *Client) ScimTokenCreate(ctx context.Context, params ScimTokenCreatePara return &body, nil } -// ScimTokenView: Fetch SCIM token -// Specify the silo by name or ID using the `silo` query parameter. -func (c *Client) ScimTokenView(ctx context.Context, params ScimTokenViewParams) (*ScimClientBearerToken, error) { +// SubnetPoolUpdate: Update a subnet pool +func (c *Client) SubnetPoolUpdate(ctx context.Context, params SubnetPoolUpdateParams) (*SubnetPool, error) { if err := params.Validate(); err != nil { return nil, err } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + // Create the request req, err := c.buildRequest( ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/system/scim/tokens/{{.token_id}}"), - map[string]string{ - "token_id": params.TokenId, - }, + b, + "PUT", + resolveRelative(c.host, "/v1/system/subnet-pools/{{.pool}}"), map[string]string{ - "silo": string(params.Silo), + "pool": string(params.Pool), }, + map[string]string{}, ) if err != nil { return nil, fmt.Errorf("error building request: %v", err) @@ -10076,7 +11282,7 @@ func (c *Client) ScimTokenView(ctx context.Context, params ScimTokenViewParams) return nil, errors.New("request returned an empty body in the response") } - var body ScimClientBearerToken + var body SubnetPool if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -10085,9 +11291,8 @@ func (c *Client) ScimTokenView(ctx context.Context, params ScimTokenViewParams) return &body, nil } -// ScimTokenDelete: Delete SCIM token -// Specify the silo by name or ID using the `silo` query parameter. -func (c *Client) ScimTokenDelete(ctx context.Context, params ScimTokenDeleteParams) error { +// SubnetPoolDelete: Delete a subnet pool +func (c *Client) SubnetPoolDelete(ctx context.Context, params SubnetPoolDeleteParams) error { if err := params.Validate(); err != nil { return err } @@ -10096,13 +11301,11 @@ func (c *Client) ScimTokenDelete(ctx context.Context, params ScimTokenDeletePara ctx, nil, "DELETE", - resolveRelative(c.host, "/v1/system/scim/tokens/{{.token_id}}"), + resolveRelative(c.host, "/v1/system/subnet-pools/{{.pool}}"), map[string]string{ - "token_id": params.TokenId, - }, - map[string]string{ - "silo": string(params.Silo), + "pool": string(params.Pool), }, + map[string]string{}, ) if err != nil { return fmt.Errorf("error building request: %v", err) @@ -10123,10 +11326,10 @@ func (c *Client) ScimTokenDelete(ctx context.Context, params ScimTokenDeletePara return nil } -// SystemQuotasList: Lists resource quotas for all silos +// SubnetPoolMemberList: List members in a subnet pool // -// To iterate over all pages, use the `SystemQuotasListAllPages` method, instead. -func (c *Client) SystemQuotasList(ctx context.Context, params SystemQuotasListParams) (*SiloQuotasResultsPage, error) { +// To iterate over all pages, use the `SubnetPoolMemberListAllPages` method, instead. +func (c *Client) SubnetPoolMemberList(ctx context.Context, params SubnetPoolMemberListParams) (*SubnetPoolMemberResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -10135,85 +11338,10 @@ func (c *Client) SystemQuotasList(ctx context.Context, params SystemQuotasListPa ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/silo-quotas"), - map[string]string{}, + resolveRelative(c.host, "/v1/system/subnet-pools/{{.pool}}/members"), map[string]string{ - "limit": PointerIntToStr(params.Limit), - "page_token": params.PageToken, - "sort_by": string(params.SortBy), + "pool": string(params.Pool), }, - ) - if err != nil { - return nil, fmt.Errorf("error building request: %v", err) - } - - // Send the request. - resp, err := c.client.Do(req) - if err != nil { - return nil, fmt.Errorf("error sending request: %v", err) - } - defer resp.Body.Close() - - // Create and return an HTTPError when an error response code is received. - if err := NewHTTPError(resp); err != nil { - return nil, err - } - - // Decode the body from the response. - if resp.Body == nil { - return nil, errors.New("request returned an empty body in the response") - } - - var body SiloQuotasResultsPage - if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { - return nil, fmt.Errorf("error decoding response body: %v", err) - } - - // Return the response. - return &body, nil -} - -// SystemQuotasListAllPages: Lists resource quotas for all silos -// -// This method is a wrapper around the `SystemQuotasList` method. -// This method returns all the pages at once. -func (c *Client) SystemQuotasListAllPages(ctx context.Context, params SystemQuotasListParams) ([]SiloQuotas, error) { - if err := params.Validate(); err != nil { - return nil, err - } - var allPages []SiloQuotas - params.PageToken = "" - params.Limit = NewPointer(100) - for { - page, err := c.SystemQuotasList(ctx, params) - if err != nil { - return nil, err - } - allPages = append(allPages, page.Items...) - if page.NextPage == "" || page.NextPage == params.PageToken { - break - } - params.PageToken = page.NextPage - } - - return allPages, nil -} - -// SiloList: List silos -// Lists silos that are discoverable based on the current permissions. -// -// To iterate over all pages, use the `SiloListAllPages` method, instead. -func (c *Client) SiloList(ctx context.Context, params SiloListParams) (*SiloResultsPage, error) { - if err := params.Validate(); err != nil { - return nil, err - } - // Create the request - req, err := c.buildRequest( - ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/system/silos"), - map[string]string{}, map[string]string{ "limit": PointerIntToStr(params.Limit), "page_token": params.PageToken, @@ -10241,7 +11369,7 @@ func (c *Client) SiloList(ctx context.Context, params SiloListParams) (*SiloResu return nil, errors.New("request returned an empty body in the response") } - var body SiloResultsPage + var body SubnetPoolMemberResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -10250,20 +11378,19 @@ func (c *Client) SiloList(ctx context.Context, params SiloListParams) (*SiloResu return &body, nil } -// SiloListAllPages: List silos -// Lists silos that are discoverable based on the current permissions. +// SubnetPoolMemberListAllPages: List members in a subnet pool // -// This method is a wrapper around the `SiloList` method. +// This method is a wrapper around the `SubnetPoolMemberList` method. // This method returns all the pages at once. -func (c *Client) SiloListAllPages(ctx context.Context, params SiloListParams) ([]Silo, error) { +func (c *Client) SubnetPoolMemberListAllPages(ctx context.Context, params SubnetPoolMemberListParams) ([]SubnetPoolMember, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []Silo + var allPages []SubnetPoolMember params.PageToken = "" params.Limit = NewPointer(100) for { - page, err := c.SiloList(ctx, params) + page, err := c.SubnetPoolMemberList(ctx, params) if err != nil { return nil, err } @@ -10277,8 +11404,8 @@ func (c *Client) SiloListAllPages(ctx context.Context, params SiloListParams) ([ return allPages, nil } -// SiloCreate: Create a silo -func (c *Client) SiloCreate(ctx context.Context, params SiloCreateParams) (*Silo, error) { +// SubnetPoolMemberAdd: Add a member to a subnet pool +func (c *Client) SubnetPoolMemberAdd(ctx context.Context, params SubnetPoolMemberAddParams) (*SubnetPoolMember, error) { if err := params.Validate(); err != nil { return nil, err } @@ -10293,54 +11420,9 @@ func (c *Client) SiloCreate(ctx context.Context, params SiloCreateParams) (*Silo ctx, b, "POST", - resolveRelative(c.host, "/v1/system/silos"), - map[string]string{}, - map[string]string{}, - ) - if err != nil { - return nil, fmt.Errorf("error building request: %v", err) - } - - // Send the request. - resp, err := c.client.Do(req) - if err != nil { - return nil, fmt.Errorf("error sending request: %v", err) - } - defer resp.Body.Close() - - // Create and return an HTTPError when an error response code is received. - if err := NewHTTPError(resp); err != nil { - return nil, err - } - - // Decode the body from the response. - if resp.Body == nil { - return nil, errors.New("request returned an empty body in the response") - } - - var body Silo - if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { - return nil, fmt.Errorf("error decoding response body: %v", err) - } - - // Return the response. - return &body, nil -} - -// SiloView: Fetch silo -// Fetch silo by name or ID. -func (c *Client) SiloView(ctx context.Context, params SiloViewParams) (*Silo, error) { - if err := params.Validate(); err != nil { - return nil, err - } - // Create the request - req, err := c.buildRequest( - ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/system/silos/{{.silo}}"), + resolveRelative(c.host, "/v1/system/subnet-pools/{{.pool}}/members/add"), map[string]string{ - "silo": string(params.Silo), + "pool": string(params.Pool), }, map[string]string{}, ) @@ -10365,7 +11447,7 @@ func (c *Client) SiloView(ctx context.Context, params SiloViewParams) (*Silo, er return nil, errors.New("request returned an empty body in the response") } - var body Silo + var body SubnetPoolMember if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -10374,20 +11456,25 @@ func (c *Client) SiloView(ctx context.Context, params SiloViewParams) (*Silo, er return &body, nil } -// SiloDelete: Delete a silo -// Delete a silo by name or ID. -func (c *Client) SiloDelete(ctx context.Context, params SiloDeleteParams) error { +// SubnetPoolMemberRemove: Remove a member from a subnet pool +func (c *Client) SubnetPoolMemberRemove(ctx context.Context, params SubnetPoolMemberRemoveParams) error { if err := params.Validate(); err != nil { return err } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return fmt.Errorf("encoding json body request failed: %v", err) + } + // Create the request req, err := c.buildRequest( ctx, - nil, - "DELETE", - resolveRelative(c.host, "/v1/system/silos/{{.silo}}"), + b, + "POST", + resolveRelative(c.host, "/v1/system/subnet-pools/{{.pool}}/members/remove"), map[string]string{ - "silo": string(params.Silo), + "pool": string(params.Pool), }, map[string]string{}, ) @@ -10410,12 +11497,10 @@ func (c *Client) SiloDelete(ctx context.Context, params SiloDeleteParams) error return nil } -// SiloIpPoolList: List IP pools linked to silo -// Linked IP pools are available to users in the specified silo. A silo can have at most one default pool. IPs -// are allocated from the default pool when users ask for one without specifying a pool. +// SubnetPoolSiloList: List silos linked to a subnet pool // -// To iterate over all pages, use the `SiloIpPoolListAllPages` method, instead. -func (c *Client) SiloIpPoolList(ctx context.Context, params SiloIpPoolListParams) (*SiloIpPoolResultsPage, error) { +// To iterate over all pages, use the `SubnetPoolSiloListAllPages` method, instead. +func (c *Client) SubnetPoolSiloList(ctx context.Context, params SubnetPoolSiloListParams) (*SubnetPoolSiloLinkResultsPage, error) { if err := params.Validate(); err != nil { return nil, err } @@ -10424,9 +11509,9 @@ func (c *Client) SiloIpPoolList(ctx context.Context, params SiloIpPoolListParams ctx, nil, "GET", - resolveRelative(c.host, "/v1/system/silos/{{.silo}}/ip-pools"), + resolveRelative(c.host, "/v1/system/subnet-pools/{{.pool}}/silos"), map[string]string{ - "silo": string(params.Silo), + "pool": string(params.Pool), }, map[string]string{ "limit": PointerIntToStr(params.Limit), @@ -10455,7 +11540,7 @@ func (c *Client) SiloIpPoolList(ctx context.Context, params SiloIpPoolListParams return nil, errors.New("request returned an empty body in the response") } - var body SiloIpPoolResultsPage + var body SubnetPoolSiloLinkResultsPage if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -10464,21 +11549,19 @@ func (c *Client) SiloIpPoolList(ctx context.Context, params SiloIpPoolListParams return &body, nil } -// SiloIpPoolListAllPages: List IP pools linked to silo -// Linked IP pools are available to users in the specified silo. A silo can have at most one default pool. IPs -// are allocated from the default pool when users ask for one without specifying a pool. +// SubnetPoolSiloListAllPages: List silos linked to a subnet pool // -// This method is a wrapper around the `SiloIpPoolList` method. +// This method is a wrapper around the `SubnetPoolSiloList` method. // This method returns all the pages at once. -func (c *Client) SiloIpPoolListAllPages(ctx context.Context, params SiloIpPoolListParams) ([]SiloIpPool, error) { +func (c *Client) SubnetPoolSiloListAllPages(ctx context.Context, params SubnetPoolSiloListParams) ([]SubnetPoolSiloLink, error) { if err := params.Validate(); err != nil { return nil, err } - var allPages []SiloIpPool + var allPages []SubnetPoolSiloLink params.PageToken = "" params.Limit = NewPointer(100) for { - page, err := c.SiloIpPoolList(ctx, params) + page, err := c.SubnetPoolSiloList(ctx, params) if err != nil { return nil, err } @@ -10492,19 +11575,25 @@ func (c *Client) SiloIpPoolListAllPages(ctx context.Context, params SiloIpPoolLi return allPages, nil } -// SiloPolicyView: Fetch silo IAM policy -func (c *Client) SiloPolicyView(ctx context.Context, params SiloPolicyViewParams) (*SiloRolePolicy, error) { +// SubnetPoolSiloLink: Link a subnet pool to a silo +func (c *Client) SubnetPoolSiloLink(ctx context.Context, params SubnetPoolSiloLinkParams) (*SubnetPoolSiloLink, error) { if err := params.Validate(); err != nil { return nil, err } + // Encode the request body as json. + b := new(bytes.Buffer) + if err := json.NewEncoder(b).Encode(params.Body); err != nil { + return nil, fmt.Errorf("encoding json body request failed: %v", err) + } + // Create the request req, err := c.buildRequest( ctx, - nil, - "GET", - resolveRelative(c.host, "/v1/system/silos/{{.silo}}/policy"), + b, + "POST", + resolveRelative(c.host, "/v1/system/subnet-pools/{{.pool}}/silos"), map[string]string{ - "silo": string(params.Silo), + "pool": string(params.Pool), }, map[string]string{}, ) @@ -10529,7 +11618,7 @@ func (c *Client) SiloPolicyView(ctx context.Context, params SiloPolicyViewParams return nil, errors.New("request returned an empty body in the response") } - var body SiloRolePolicy + var body SubnetPoolSiloLink if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -10538,8 +11627,8 @@ func (c *Client) SiloPolicyView(ctx context.Context, params SiloPolicyViewParams return &body, nil } -// SiloPolicyUpdate: Update silo IAM policy -func (c *Client) SiloPolicyUpdate(ctx context.Context, params SiloPolicyUpdateParams) (*SiloRolePolicy, error) { +// SubnetPoolSiloUpdate: Update a subnet pool's link to a silo +func (c *Client) SubnetPoolSiloUpdate(ctx context.Context, params SubnetPoolSiloUpdateParams) (*SubnetPoolSiloLink, error) { if err := params.Validate(); err != nil { return nil, err } @@ -10554,8 +11643,9 @@ func (c *Client) SiloPolicyUpdate(ctx context.Context, params SiloPolicyUpdatePa ctx, b, "PUT", - resolveRelative(c.host, "/v1/system/silos/{{.silo}}/policy"), + resolveRelative(c.host, "/v1/system/subnet-pools/{{.pool}}/silos/{{.silo}}"), map[string]string{ + "pool": string(params.Pool), "silo": string(params.Silo), }, map[string]string{}, @@ -10581,7 +11671,7 @@ func (c *Client) SiloPolicyUpdate(ctx context.Context, params SiloPolicyUpdatePa return nil, errors.New("request returned an empty body in the response") } - var body SiloRolePolicy + var body SubnetPoolSiloLink if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -10590,72 +11680,55 @@ func (c *Client) SiloPolicyUpdate(ctx context.Context, params SiloPolicyUpdatePa return &body, nil } -// SiloQuotasView: Fetch resource quotas for silo -func (c *Client) SiloQuotasView(ctx context.Context, params SiloQuotasViewParams) (*SiloQuotas, error) { +// SubnetPoolSiloUnlink: Unlink a subnet pool from a silo +func (c *Client) SubnetPoolSiloUnlink(ctx context.Context, params SubnetPoolSiloUnlinkParams) error { if err := params.Validate(); err != nil { - return nil, err + return err } // Create the request req, err := c.buildRequest( ctx, nil, - "GET", - resolveRelative(c.host, "/v1/system/silos/{{.silo}}/quotas"), + "DELETE", + resolveRelative(c.host, "/v1/system/subnet-pools/{{.pool}}/silos/{{.silo}}"), map[string]string{ + "pool": string(params.Pool), "silo": string(params.Silo), }, map[string]string{}, ) if err != nil { - return nil, fmt.Errorf("error building request: %v", err) + return fmt.Errorf("error building request: %v", err) } // Send the request. resp, err := c.client.Do(req) if err != nil { - return nil, fmt.Errorf("error sending request: %v", err) + return fmt.Errorf("error sending request: %v", err) } defer resp.Body.Close() // Create and return an HTTPError when an error response code is received. if err := NewHTTPError(resp); err != nil { - return nil, err - } - - // Decode the body from the response. - if resp.Body == nil { - return nil, errors.New("request returned an empty body in the response") - } - - var body SiloQuotas - if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { - return nil, fmt.Errorf("error decoding response body: %v", err) + return err } - // Return the response. - return &body, nil + return nil } -// SiloQuotasUpdate: Update resource quotas for silo -// If a quota value is not specified, it will remain unchanged. -func (c *Client) SiloQuotasUpdate(ctx context.Context, params SiloQuotasUpdateParams) (*SiloQuotas, error) { +// SubnetPoolUtilizationView: Fetch subnet pool utilization +func (c *Client) SubnetPoolUtilizationView(ctx context.Context, params SubnetPoolUtilizationViewParams) (*SubnetPoolUtilization, error) { if err := params.Validate(); err != nil { return nil, err } - // Encode the request body as json. - b := new(bytes.Buffer) - if err := json.NewEncoder(b).Encode(params.Body); err != nil { - return nil, fmt.Errorf("encoding json body request failed: %v", err) - } - // Create the request req, err := c.buildRequest( ctx, - b, - "PUT", - resolveRelative(c.host, "/v1/system/silos/{{.silo}}/quotas"), + nil, + "GET", + resolveRelative(c.host, "/v1/system/subnet-pools/{{.pool}}/utilization"), map[string]string{ - "silo": string(params.Silo), + "pool": string(params.Pool), }, map[string]string{}, ) @@ -10680,7 +11753,7 @@ func (c *Client) SiloQuotasUpdate(ctx context.Context, params SiloQuotasUpdatePa return nil, errors.New("request returned an empty body in the response") } - var body SiloQuotas + var body SubnetPoolUtilization if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { return nil, fmt.Errorf("error decoding response body: %v", err) } @@ -13206,7 +14279,7 @@ func (c *Client) VpcView(ctx context.Context, params VpcViewParams) (*Vpc, error return &body, nil } -// VpcUpdate: Update a VPC +// VpcUpdate: Update VPC func (c *Client) VpcUpdate(ctx context.Context, params VpcUpdateParams) (*Vpc, error) { if err := params.Validate(); err != nil { return nil, err diff --git a/oxide/types.go b/oxide/types.go index 798d818..b2c0a2e 100644 --- a/oxide/types.go +++ b/oxide/types.go @@ -27,6 +27,47 @@ type Address struct { VlanId *int `json:"vlan_id,omitempty" yaml:"vlan_id,omitempty"` } +// AddressAllocatorType is the type definition for a AddressAllocatorType. +type AddressAllocatorType string + +// AddressAllocatorExplicit is reserve a specific IP address. The pool is inferred from the address since IP +// pools cannot have overlapping ranges. +// +// Required fields: +// - Ip +// - Type +type AddressAllocatorExplicit struct { + // Ip is the IP address to reserve. + Ip string `json:"ip" yaml:"ip"` + Type AddressAllocatorType `json:"type" yaml:"type"` +} + +// AddressAllocatorAuto is automatically allocate an IP address from a pool. +// +// Required fields: +// - Type +type AddressAllocatorAuto struct { + // PoolSelector is pool selection. + // + // If omitted, the silo's default pool is used. If the silo has default pools for both IPv4 and IPv6, the request + // will fail unless `ip_version` is specified. + PoolSelector PoolSelector `json:"pool_selector,omitempty" yaml:"pool_selector,omitempty"` + Type AddressAllocatorType `json:"type" yaml:"type"` +} + +// AddressAllocator is specify how to allocate a floating IP address. +type AddressAllocator struct { + // Ip is the IP address to reserve. + Ip string `json:"ip,omitempty" yaml:"ip,omitempty"` + // Type is the type definition for a Type. + Type AddressAllocatorType `json:"type,omitempty" yaml:"type,omitempty"` + // PoolSelector is pool selection. + // + // If omitted, the silo's default pool is used. If the silo has default pools for both IPv4 and IPv6, the request + // will fail unless `ip_version` is specified. + PoolSelector PoolSelector `json:"pool_selector,omitempty" yaml:"pool_selector,omitempty"` +} + // AddressConfig is a set of addresses associated with a port configuration. // // Required fields: @@ -162,52 +203,6 @@ type AddressLotViewResponse struct { Lot AddressLot `json:"lot" yaml:"lot"` } -// AddressSelectorType is the type definition for a AddressSelectorType. -type AddressSelectorType string - -// AddressSelectorExplicit is reserve a specific IP address. -// -// Required fields: -// - Ip -// - Type -type AddressSelectorExplicit struct { - // Ip is the IP address to reserve. Must be available in the pool. - Ip string `json:"ip" yaml:"ip"` - // Pool is the pool containing this address. If not specified, the default pool for the address's IP version - // is used. - Pool NameOrId `json:"pool,omitempty" yaml:"pool,omitempty"` - Type AddressSelectorType `json:"type" yaml:"type"` -} - -// AddressSelectorAuto is automatically allocate an IP address from a specified pool. -// -// Required fields: -// - Type -type AddressSelectorAuto struct { - // PoolSelector is pool selection. - // - // If omitted, this field uses the silo's default pool. If the silo has default pools for both IPv4 and IPv6, - // the request will fail unless `ip_version` is specified in the pool selector. - PoolSelector PoolSelector `json:"pool_selector,omitempty" yaml:"pool_selector,omitempty"` - Type AddressSelectorType `json:"type" yaml:"type"` -} - -// AddressSelector is specify how to allocate a floating IP address. -type AddressSelector struct { - // Ip is the IP address to reserve. Must be available in the pool. - Ip string `json:"ip,omitempty" yaml:"ip,omitempty"` - // Pool is the pool containing this address. If not specified, the default pool for the address's IP version - // is used. - Pool NameOrId `json:"pool,omitzero" yaml:"pool,omitzero"` - // Type is the type definition for a Type. - Type AddressSelectorType `json:"type,omitempty" yaml:"type,omitempty"` - // PoolSelector is pool selection. - // - // If omitted, this field uses the silo's default pool. If the silo has default pools for both IPv4 and IPv6, - // the request will fail unless `ip_version` is specified in the pool selector. - PoolSelector PoolSelector `json:"pool_selector,omitempty" yaml:"pool_selector,omitempty"` -} - // AffinityGroup is view of an Affinity Group // // Required fields: @@ -743,9 +738,12 @@ type AntiAffinityGroupUpdate struct { // - TimeStarted type AuditLogEntry struct { Actor AuditLogEntryActor `json:"actor" yaml:"actor"` - // AuthMethod is how the user authenticated the request. Possible values are "session_cookie" and "access_token". Optional - // because it will not be defined on unauthenticated requests like login attempts. - AuthMethod string `json:"auth_method,omitempty" yaml:"auth_method,omitempty"` + // AuthMethod is how the user authenticated the request (access token, session, or SCIM token). Null for + // unauthenticated requests like login attempts. + AuthMethod AuthMethod `json:"auth_method,omitempty" yaml:"auth_method,omitempty"` + // CredentialId is iD of the credential used for authentication. Null for unauthenticated requests. The value + // of `auth_method` indicates what kind of credential it is (access token, session, or SCIM token). + CredentialId string `json:"credential_id,omitempty" yaml:"credential_id,omitempty"` // Id is unique identifier for the audit log entry Id string `json:"id" yaml:"id"` // OperationId is aPI endpoint ID, e.g., `project_create` @@ -883,6 +881,9 @@ type AuditLogEntryResultsPage struct { NextPage string `json:"next_page,omitempty" yaml:"next_page,omitempty"` } +// AuthMethod is console session cookie +type AuthMethod string + // AuthzScope is timeseries data is limited to fleet readers. type AuthzScope string @@ -898,6 +899,21 @@ type Baseboard struct { Serial string `json:"serial" yaml:"serial"` } +// BaseboardId is a representation of a Baseboard ID as used in the inventory subsystem. +// +// This type is essentially the same as a `Baseboard` except it doesn't have a revision or HW type (Gimlet, PC, +// Unknown). +// +// Required fields: +// - PartNumber +// - SerialNumber +type BaseboardId struct { + // PartNumber is oxide Part Number + PartNumber string `json:"part_number" yaml:"part_number"` + // SerialNumber is serial number (unique for a given part number) + SerialNumber string `json:"serial_number" yaml:"serial_number"` +} + // BfdMode is bFD connection mode. type BfdMode string @@ -3197,6 +3213,128 @@ type ExternalIpResultsPage struct { NextPage string `json:"next_page,omitempty" yaml:"next_page,omitempty"` } +// ExternalSubnet is an external subnet allocated from a subnet pool +// +// Required fields: +// - Description +// - Id +// - Name +// - ProjectId +// - Subnet +// - SubnetPoolId +// - SubnetPoolMemberId +// - TimeCreated +// - TimeModified +type ExternalSubnet struct { + // Description is human-readable free-form text about a resource + Description string `json:"description" yaml:"description"` + // Id is unique, immutable, system-controlled identifier for each resource + Id string `json:"id" yaml:"id"` + // InstanceId is the instance this subnet is attached to, if any + InstanceId string `json:"instance_id,omitempty" yaml:"instance_id,omitempty"` + // Name is unique, mutable, user-controlled identifier for each resource + Name Name `json:"name" yaml:"name"` + // ProjectId is the project this subnet belongs to + ProjectId string `json:"project_id" yaml:"project_id"` + // Subnet is the allocated subnet CIDR + Subnet IpNet `json:"subnet" yaml:"subnet"` + // SubnetPoolId is the subnet pool this was allocated from + SubnetPoolId string `json:"subnet_pool_id" yaml:"subnet_pool_id"` + // SubnetPoolMemberId is the subnet pool member this subnet corresponds to + SubnetPoolMemberId string `json:"subnet_pool_member_id" yaml:"subnet_pool_member_id"` + // TimeCreated is timestamp when this resource was created + TimeCreated *time.Time `json:"time_created" yaml:"time_created"` + // TimeModified is timestamp when this resource was last modified + TimeModified *time.Time `json:"time_modified" yaml:"time_modified"` +} + +// ExternalSubnetAllocatorType is the type definition for a ExternalSubnetAllocatorType. +type ExternalSubnetAllocatorType string + +// ExternalSubnetAllocatorExplicit is reserve a specific subnet. +// +// Required fields: +// - Subnet +// - Type +type ExternalSubnetAllocatorExplicit struct { + // Subnet is the subnet CIDR to reserve. Must be available in the pool. + Subnet IpNet `json:"subnet" yaml:"subnet"` + Type ExternalSubnetAllocatorType `json:"type" yaml:"type"` +} + +// ExternalSubnetAllocatorAuto is automatically allocate a subnet with the specified prefix length. +// +// Required fields: +// - PrefixLen +// - Type +type ExternalSubnetAllocatorAuto struct { + // PoolSelector is pool selection. + // + // If omitted, this field uses the silo's default pool. If the silo has default pools for both IPv4 and IPv6, + // the request will fail unless `ip_version` is specified in the pool selector. + PoolSelector PoolSelector `json:"pool_selector,omitempty" yaml:"pool_selector,omitempty"` + // PrefixLen is the prefix length for the allocated subnet (e.g., 24 for a /24). + PrefixLen *int `json:"prefix_len" yaml:"prefix_len"` + Type ExternalSubnetAllocatorType `json:"type" yaml:"type"` +} + +// ExternalSubnetAllocator is specify how to allocate an external subnet. +type ExternalSubnetAllocator struct { + // Subnet is the subnet CIDR to reserve. Must be available in the pool. + Subnet IpNet `json:"subnet,omitempty" yaml:"subnet,omitempty"` + // Type is the type definition for a Type. + Type ExternalSubnetAllocatorType `json:"type,omitempty" yaml:"type,omitempty"` + // PoolSelector is pool selection. + // + // If omitted, this field uses the silo's default pool. If the silo has default pools for both IPv4 and IPv6, + // the request will fail unless `ip_version` is specified in the pool selector. + PoolSelector PoolSelector `json:"pool_selector,omitempty" yaml:"pool_selector,omitempty"` + // PrefixLen is the prefix length for the allocated subnet (e.g., 24 for a /24). + PrefixLen *int `json:"prefix_len,omitempty" yaml:"prefix_len,omitempty"` +} + +// ExternalSubnetAttach is attach an external subnet to an instance +// +// Required fields: +// - Instance +type ExternalSubnetAttach struct { + // Instance is name or ID of the instance to attach to + Instance NameOrId `json:"instance" yaml:"instance"` +} + +// ExternalSubnetCreate is create an external subnet +// +// Required fields: +// - Allocator +// - Description +// - Name +type ExternalSubnetCreate struct { + // Allocator is subnet allocation method. + Allocator ExternalSubnetAllocator `json:"allocator" yaml:"allocator"` + Description string `json:"description" yaml:"description"` + // Name is names must begin with a lower case ASCII letter, be composed exclusively of lowercase ASCII, uppercase + // ASCII, numbers, and '-', and may not end with a '-'. Names cannot be a UUID, but they may contain a UUID. They + // can be at most 63 characters long. + Name Name `json:"name" yaml:"name"` +} + +// ExternalSubnetResultsPage is a single page of results +// +// Required fields: +// - Items +type ExternalSubnetResultsPage struct { + // Items is list of items on this page of results + Items []ExternalSubnet `json:"items" yaml:"items"` + // NextPage is token used to fetch the next page of results (if any) + NextPage string `json:"next_page,omitempty" yaml:"next_page,omitempty"` +} + +// ExternalSubnetUpdate is update an external subnet +type ExternalSubnetUpdate struct { + Description string `json:"description,omitempty" yaml:"description,omitempty"` + Name Name `json:"name,omitempty" yaml:"name,omitempty"` +} + // FailureDomain is instances are considered co-located if they are on the same sled type FailureDomain string @@ -3588,9 +3726,9 @@ type FloatingIpAttach struct { // - Description // - Name type FloatingIpCreate struct { - // AddressSelector is iP address allocation method. - AddressSelector AddressSelector `json:"address_selector,omitempty" yaml:"address_selector,omitempty"` - Description string `json:"description" yaml:"description"` + // AddressAllocator is iP address allocation method. + AddressAllocator AddressAllocator `json:"address_allocator,omitempty" yaml:"address_allocator,omitempty"` + Description string `json:"description" yaml:"description"` // Name is names must begin with a lower case ASCII letter, be composed exclusively of lowercase ASCII, uppercase // ASCII, numbers, and '-', and may not end with a '-'. Names cannot be a UUID, but they may contain a UUID. They // can be at most 63 characters long. @@ -5855,7 +5993,7 @@ type PoolSelectorAuto struct { Type PoolSelectorType `json:"type" yaml:"type"` } -// PoolSelector is specify which IP pool to allocate from. +// PoolSelector is specify which IP or external subnet pool to allocate from. type PoolSelector struct { // Pool is the pool to allocate from. Pool NameOrId `json:"pool,omitempty" yaml:"pool,omitempty"` @@ -6538,6 +6676,44 @@ type Rack struct { TimeModified *time.Time `json:"time_modified" yaml:"time_modified"` } +// RackMembershipAddSledsRequest is the type definition for a RackMembershipAddSledsRequest. +// +// Required fields: +// - SledIds +type RackMembershipAddSledsRequest struct { + SledIds []BaseboardId `json:"sled_ids" yaml:"sled_ids"` +} + +// RackMembershipChangeState is the type definition for a RackMembershipChangeState. +type RackMembershipChangeState string + +// RackMembershipStatus is status of the rack membership uniquely identified by the (rack_id, version) pair +// +// Required fields: +// - Members +// - RackId +// - State +// - TimeCreated +// - UnacknowledgedMembers +// - Version +type RackMembershipStatus struct { + // Members is all members of the rack for this version + Members []BaseboardId `json:"members" yaml:"members"` + RackId string `json:"rack_id" yaml:"rack_id"` + State RackMembershipChangeState `json:"state" yaml:"state"` + TimeAborted *time.Time `json:"time_aborted,omitempty" yaml:"time_aborted,omitempty"` + TimeCommitted *time.Time `json:"time_committed,omitempty" yaml:"time_committed,omitempty"` + TimeCreated *time.Time `json:"time_created" yaml:"time_created"` + // UnacknowledgedMembers is all members that have not yet confirmed this membership version + UnacknowledgedMembers []BaseboardId `json:"unacknowledged_members" yaml:"unacknowledged_members"` + // Version is version that uniquely identifies the rack membership at a given point in time + Version RackMembershipVersion `json:"version" yaml:"version"` +} + +// RackMembershipVersion is a unique, monotonically increasing number representing the set of active sleds +// in a rack at a given point in time. +type RackMembershipVersion uint64 + // RackResultsPage is a single page of results // // Required fields: @@ -7667,110 +7843,303 @@ type SshKeyResultsPage struct { NextPage string `json:"next_page,omitempty" yaml:"next_page,omitempty"` } -// SupportBundleCreate is the type definition for a SupportBundleCreate. -type SupportBundleCreate struct { - // UserComment is user comment for the support bundle - UserComment string `json:"user_comment,omitempty" yaml:"user_comment,omitempty"` -} - -// SupportBundleInfo is the type definition for a SupportBundleInfo. +// SubnetPool is a pool of subnets for external subnet allocation // // Required fields: +// - Description // - Id -// - ReasonForCreation -// - State +// - IpVersion +// - Name +// - PoolType // - TimeCreated -type SupportBundleInfo struct { - Id string `json:"id" yaml:"id"` - ReasonForCreation string `json:"reason_for_creation" yaml:"reason_for_creation"` - ReasonForFailure string `json:"reason_for_failure,omitempty" yaml:"reason_for_failure,omitempty"` - State SupportBundleState `json:"state" yaml:"state"` - TimeCreated *time.Time `json:"time_created" yaml:"time_created"` - UserComment string `json:"user_comment,omitempty" yaml:"user_comment,omitempty"` +// - TimeModified +type SubnetPool struct { + // Description is human-readable free-form text about a resource + Description string `json:"description" yaml:"description"` + // Id is unique, immutable, system-controlled identifier for each resource + Id string `json:"id" yaml:"id"` + // IpVersion is the IP version for this pool + IpVersion IpVersion `json:"ip_version" yaml:"ip_version"` + // Name is unique, mutable, user-controlled identifier for each resource + Name Name `json:"name" yaml:"name"` + // PoolType is type of subnet pool (unicast or multicast) + PoolType IpPoolType `json:"pool_type" yaml:"pool_type"` + // TimeCreated is timestamp when this resource was created + TimeCreated *time.Time `json:"time_created" yaml:"time_created"` + // TimeModified is timestamp when this resource was last modified + TimeModified *time.Time `json:"time_modified" yaml:"time_modified"` } -// SupportBundleInfoResultsPage is a single page of results +// SubnetPoolCreate is create a subnet pool // // Required fields: -// - Items -type SupportBundleInfoResultsPage struct { - // Items is list of items on this page of results - Items []SupportBundleInfo `json:"items" yaml:"items"` - // NextPage is token used to fetch the next page of results (if any) - NextPage string `json:"next_page,omitempty" yaml:"next_page,omitempty"` +// - Description +// - IpVersion +// - Name +type SubnetPoolCreate struct { + Description string `json:"description" yaml:"description"` + // IpVersion is the IP version for this pool (IPv4 or IPv6). All subnets in the pool must match this version. + // + IpVersion IpVersion `json:"ip_version" yaml:"ip_version"` + // Name is names must begin with a lower case ASCII letter, be composed exclusively of lowercase ASCII, uppercase + // ASCII, numbers, and '-', and may not end with a '-'. Names cannot be a UUID, but they may contain a UUID. They + // can be at most 63 characters long. + Name Name `json:"name" yaml:"name"` } -// SupportBundleState is support Bundle still actively being collected. -// -// This is the initial state for a Support Bundle, and it will automatically transition to either "Failing" or -// "Active". +// SubnetPoolLinkSilo is link a subnet pool to a silo // -// If a user no longer wants to access a Support Bundle, they can request cancellation, which will transition to -// the "Destroying" state. -type SupportBundleState string - -// SupportBundleUpdate is the type definition for a SupportBundleUpdate. -type SupportBundleUpdate struct { - // UserComment is user comment for the support bundle - UserComment string `json:"user_comment,omitempty" yaml:"user_comment,omitempty"` +// Required fields: +// - IsDefault +// - Silo +type SubnetPoolLinkSilo struct { + // IsDefault is whether this is the default subnet pool for the silo. When true, external subnet allocations that + // don't specify a pool use this one. + IsDefault *bool `json:"is_default" yaml:"is_default"` + // Silo is the silo to link + Silo NameOrId `json:"silo" yaml:"silo"` } -// Switch is an operator's view of a Switch. +// SubnetPoolMember is a member (subnet) within a subnet pool // // Required fields: -// - Baseboard +// - Description // - Id -// - RackId +// - MaxPrefixLength +// - MinPrefixLength +// - Name +// - Subnet +// - SubnetPoolId // - TimeCreated // - TimeModified -type Switch struct { - // Baseboard is properties that uniquely identify an Oxide hardware component - Baseboard Baseboard `json:"baseboard" yaml:"baseboard"` +type SubnetPoolMember struct { + // Description is human-readable free-form text about a resource + Description string `json:"description" yaml:"description"` // Id is unique, immutable, system-controlled identifier for each resource Id string `json:"id" yaml:"id"` - // RackId is the rack to which this Switch is currently attached - RackId string `json:"rack_id" yaml:"rack_id"` + // MaxPrefixLength is maximum prefix length for allocations from this subnet; a larger prefix means smaller allocations + // are allowed (e.g. a /24 prefix yields smaller subnet allocations than a /16 prefix). + MaxPrefixLength *int `json:"max_prefix_length" yaml:"max_prefix_length"` + // MinPrefixLength is minimum prefix length for allocations from this subnet; a smaller prefix means larger + // allocations are allowed (e.g. a /16 prefix yields larger subnet allocations than a /24 prefix). + MinPrefixLength *int `json:"min_prefix_length" yaml:"min_prefix_length"` + // Name is unique, mutable, user-controlled identifier for each resource + Name Name `json:"name" yaml:"name"` + // Subnet is the subnet CIDR + Subnet IpNet `json:"subnet" yaml:"subnet"` + // SubnetPoolId is iD of the parent subnet pool + SubnetPoolId string `json:"subnet_pool_id" yaml:"subnet_pool_id"` // TimeCreated is timestamp when this resource was created TimeCreated *time.Time `json:"time_created" yaml:"time_created"` // TimeModified is timestamp when this resource was last modified TimeModified *time.Time `json:"time_modified" yaml:"time_modified"` } -// SwitchBgpHistory is bGP message history for a particular switch. +// SubnetPoolMemberAdd is add a member (subnet) to a subnet pool // // Required fields: -// - History -// - Switch -type SwitchBgpHistory struct { - // History is message history indexed by peer address. - History map[string]BgpMessageHistory `json:"history" yaml:"history"` - // Switch is switch this message history is associated with. - Switch SwitchLocation `json:"switch" yaml:"switch"` +// - Subnet +type SubnetPoolMemberAdd struct { + // MaxPrefixLength is maximum prefix length for allocations from this subnet; a larger prefix means smaller allocations + // are allowed (e.g. a /24 prefix yields smaller subnet allocations than a /16 prefix). + // + // Valid values: 0-32 for IPv4, 0-128 for IPv6. Default if not specified is 32 for IPv4 and 128 for IPv6. + MaxPrefixLength *int `json:"max_prefix_length,omitempty" yaml:"max_prefix_length,omitempty"` + // MinPrefixLength is minimum prefix length for allocations from this subnet; a smaller prefix means larger + // allocations are allowed (e.g. a /16 prefix yields larger subnet allocations than a /24 prefix). + // + // Valid values: 0-32 for IPv4, 0-128 for IPv6. Default if not specified is equal to the subnet's prefix length. + // + MinPrefixLength *int `json:"min_prefix_length,omitempty" yaml:"min_prefix_length,omitempty"` + // Subnet is the subnet to add to the pool + Subnet IpNet `json:"subnet" yaml:"subnet"` } -// SwitchInterfaceConfig is a switch port interface configuration for a port settings object. +// SubnetPoolMemberRemove is remove a subnet from a pool // // Required fields: -// - Id -// - InterfaceName -// - Kind -// - PortSettingsId -// - V6Enabled -type SwitchInterfaceConfig struct { - // Id is a unique identifier for this switch interface. - Id string `json:"id" yaml:"id"` - // InterfaceName is the name of this switch interface. - InterfaceName Name `json:"interface_name" yaml:"interface_name"` - // Kind is the switch interface kind. - Kind SwitchInterfaceKind2 `json:"kind" yaml:"kind"` - // PortSettingsId is the port settings object this switch interface configuration belongs to. - PortSettingsId string `json:"port_settings_id" yaml:"port_settings_id"` - // V6Enabled is whether or not IPv6 is enabled on this interface. - V6Enabled *bool `json:"v6_enabled" yaml:"v6_enabled"` +// - Subnet +type SubnetPoolMemberRemove struct { + // Subnet is the subnet to remove from the pool. Must match an existing entry exactly. + Subnet IpNet `json:"subnet" yaml:"subnet"` } -// SwitchInterfaceConfigCreate is a layer-3 switch interface configuration. When IPv6 is enabled, a link local -// address will be created for the interface. +// SubnetPoolMemberResultsPage is a single page of results +// +// Required fields: +// - Items +type SubnetPoolMemberResultsPage struct { + // Items is list of items on this page of results + Items []SubnetPoolMember `json:"items" yaml:"items"` + // NextPage is token used to fetch the next page of results (if any) + NextPage string `json:"next_page,omitempty" yaml:"next_page,omitempty"` +} + +// SubnetPoolResultsPage is a single page of results +// +// Required fields: +// - Items +type SubnetPoolResultsPage struct { + // Items is list of items on this page of results + Items []SubnetPool `json:"items" yaml:"items"` + // NextPage is token used to fetch the next page of results (if any) + NextPage string `json:"next_page,omitempty" yaml:"next_page,omitempty"` +} + +// SubnetPoolSiloLink is a link between a subnet pool and a silo +// +// Required fields: +// - IsDefault +// - SiloId +// - SubnetPoolId +type SubnetPoolSiloLink struct { + IsDefault *bool `json:"is_default" yaml:"is_default"` + SiloId string `json:"silo_id" yaml:"silo_id"` + SubnetPoolId string `json:"subnet_pool_id" yaml:"subnet_pool_id"` +} + +// SubnetPoolSiloLinkResultsPage is a single page of results +// +// Required fields: +// - Items +type SubnetPoolSiloLinkResultsPage struct { + // Items is list of items on this page of results + Items []SubnetPoolSiloLink `json:"items" yaml:"items"` + // NextPage is token used to fetch the next page of results (if any) + NextPage string `json:"next_page,omitempty" yaml:"next_page,omitempty"` +} + +// SubnetPoolSiloUpdate is update a subnet pool's silo link +// +// Required fields: +// - IsDefault +type SubnetPoolSiloUpdate struct { + // IsDefault is whether this is the default subnet pool for the silo + IsDefault *bool `json:"is_default" yaml:"is_default"` +} + +// SubnetPoolUpdate is update a subnet pool +type SubnetPoolUpdate struct { + Description string `json:"description,omitempty" yaml:"description,omitempty"` + Name Name `json:"name,omitempty" yaml:"name,omitempty"` +} + +// SubnetPoolUtilization is utilization information for a subnet pool +// +// Required fields: +// - Allocated +// - Capacity +type SubnetPoolUtilization struct { + // Allocated is number of addresses allocated from this pool + Allocated float64 `json:"allocated" yaml:"allocated"` + // Capacity is total capacity of this pool in addresses + Capacity float64 `json:"capacity" yaml:"capacity"` +} + +// SupportBundleCreate is the type definition for a SupportBundleCreate. +type SupportBundleCreate struct { + // UserComment is user comment for the support bundle + UserComment string `json:"user_comment,omitempty" yaml:"user_comment,omitempty"` +} + +// SupportBundleInfo is the type definition for a SupportBundleInfo. +// +// Required fields: +// - Id +// - ReasonForCreation +// - State +// - TimeCreated +type SupportBundleInfo struct { + Id string `json:"id" yaml:"id"` + ReasonForCreation string `json:"reason_for_creation" yaml:"reason_for_creation"` + ReasonForFailure string `json:"reason_for_failure,omitempty" yaml:"reason_for_failure,omitempty"` + State SupportBundleState `json:"state" yaml:"state"` + TimeCreated *time.Time `json:"time_created" yaml:"time_created"` + UserComment string `json:"user_comment,omitempty" yaml:"user_comment,omitempty"` +} + +// SupportBundleInfoResultsPage is a single page of results +// +// Required fields: +// - Items +type SupportBundleInfoResultsPage struct { + // Items is list of items on this page of results + Items []SupportBundleInfo `json:"items" yaml:"items"` + // NextPage is token used to fetch the next page of results (if any) + NextPage string `json:"next_page,omitempty" yaml:"next_page,omitempty"` +} + +// SupportBundleState is support Bundle still actively being collected. +// +// This is the initial state for a Support Bundle, and it will automatically transition to either "Failing" or +// "Active". +// +// If a user no longer wants to access a Support Bundle, they can request cancellation, which will transition to +// the "Destroying" state. +type SupportBundleState string + +// SupportBundleUpdate is the type definition for a SupportBundleUpdate. +type SupportBundleUpdate struct { + // UserComment is user comment for the support bundle + UserComment string `json:"user_comment,omitempty" yaml:"user_comment,omitempty"` +} + +// Switch is an operator's view of a Switch. +// +// Required fields: +// - Baseboard +// - Id +// - RackId +// - TimeCreated +// - TimeModified +type Switch struct { + // Baseboard is properties that uniquely identify an Oxide hardware component + Baseboard Baseboard `json:"baseboard" yaml:"baseboard"` + // Id is unique, immutable, system-controlled identifier for each resource + Id string `json:"id" yaml:"id"` + // RackId is the rack to which this Switch is currently attached + RackId string `json:"rack_id" yaml:"rack_id"` + // TimeCreated is timestamp when this resource was created + TimeCreated *time.Time `json:"time_created" yaml:"time_created"` + // TimeModified is timestamp when this resource was last modified + TimeModified *time.Time `json:"time_modified" yaml:"time_modified"` +} + +// SwitchBgpHistory is bGP message history for a particular switch. +// +// Required fields: +// - History +// - Switch +type SwitchBgpHistory struct { + // History is message history indexed by peer address. + History map[string]BgpMessageHistory `json:"history" yaml:"history"` + // Switch is switch this message history is associated with. + Switch SwitchLocation `json:"switch" yaml:"switch"` +} + +// SwitchInterfaceConfig is a switch port interface configuration for a port settings object. +// +// Required fields: +// - Id +// - InterfaceName +// - Kind +// - PortSettingsId +// - V6Enabled +type SwitchInterfaceConfig struct { + // Id is a unique identifier for this switch interface. + Id string `json:"id" yaml:"id"` + // InterfaceName is the name of this switch interface. + InterfaceName Name `json:"interface_name" yaml:"interface_name"` + // Kind is the switch interface kind. + Kind SwitchInterfaceKind2 `json:"kind" yaml:"kind"` + // PortSettingsId is the port settings object this switch interface configuration belongs to. + PortSettingsId string `json:"port_settings_id" yaml:"port_settings_id"` + // V6Enabled is whether or not IPv6 is enabled on this interface. + V6Enabled *bool `json:"v6_enabled" yaml:"v6_enabled"` +} + +// SwitchInterfaceConfigCreate is a layer-3 switch interface configuration. When IPv6 is enabled, a link local +// address will be created for the interface. // // Required fields: // - Kind @@ -10129,6 +10498,76 @@ type DiskFinalizeImportParams struct { Body *FinalizeDisk `json:"body,omitempty" yaml:"body,omitempty"` } +// ExternalSubnetListParams is the request parameters for ExternalSubnetList +// +// Required fields: +// - Project +type ExternalSubnetListParams struct { + Limit *int `json:"limit,omitempty" yaml:"limit,omitempty"` + PageToken string `json:"page_token,omitempty" yaml:"page_token,omitempty"` + Project NameOrId `json:"project,omitempty" yaml:"project,omitempty"` + SortBy NameOrIdSortMode `json:"sort_by,omitempty" yaml:"sort_by,omitempty"` +} + +// ExternalSubnetCreateParams is the request parameters for ExternalSubnetCreate +// +// Required fields: +// - Project +// - Body +type ExternalSubnetCreateParams struct { + Project NameOrId `json:"project,omitempty" yaml:"project,omitempty"` + Body *ExternalSubnetCreate `json:"body,omitempty" yaml:"body,omitempty"` +} + +// ExternalSubnetDeleteParams is the request parameters for ExternalSubnetDelete +// +// Required fields: +// - ExternalSubnet +type ExternalSubnetDeleteParams struct { + ExternalSubnet NameOrId `json:"external_subnet,omitempty" yaml:"external_subnet,omitempty"` + Project NameOrId `json:"project,omitempty" yaml:"project,omitempty"` +} + +// ExternalSubnetViewParams is the request parameters for ExternalSubnetView +// +// Required fields: +// - ExternalSubnet +type ExternalSubnetViewParams struct { + ExternalSubnet NameOrId `json:"external_subnet,omitempty" yaml:"external_subnet,omitempty"` + Project NameOrId `json:"project,omitempty" yaml:"project,omitempty"` +} + +// ExternalSubnetUpdateParams is the request parameters for ExternalSubnetUpdate +// +// Required fields: +// - ExternalSubnet +// - Body +type ExternalSubnetUpdateParams struct { + ExternalSubnet NameOrId `json:"external_subnet,omitempty" yaml:"external_subnet,omitempty"` + Project NameOrId `json:"project,omitempty" yaml:"project,omitempty"` + Body *ExternalSubnetUpdate `json:"body,omitempty" yaml:"body,omitempty"` +} + +// ExternalSubnetAttachParams is the request parameters for ExternalSubnetAttach +// +// Required fields: +// - ExternalSubnet +// - Body +type ExternalSubnetAttachParams struct { + ExternalSubnet NameOrId `json:"external_subnet,omitempty" yaml:"external_subnet,omitempty"` + Project NameOrId `json:"project,omitempty" yaml:"project,omitempty"` + Body *ExternalSubnetAttach `json:"body,omitempty" yaml:"body,omitempty"` +} + +// ExternalSubnetDetachParams is the request parameters for ExternalSubnetDetach +// +// Required fields: +// - ExternalSubnet +type ExternalSubnetDetachParams struct { + ExternalSubnet NameOrId `json:"external_subnet,omitempty" yaml:"external_subnet,omitempty"` + Project NameOrId `json:"project,omitempty" yaml:"project,omitempty"` +} + // FloatingIpListParams is the request parameters for FloatingIpList // // Required fields: @@ -10390,8 +10829,9 @@ type InstanceExternalIpListParams struct { // Required fields: // - Instance type InstanceEphemeralIpDetachParams struct { - Instance NameOrId `json:"instance,omitempty" yaml:"instance,omitempty"` - Project NameOrId `json:"project,omitempty" yaml:"project,omitempty"` + Instance NameOrId `json:"instance,omitempty" yaml:"instance,omitempty"` + IpVersion IpVersion `json:"ip_version,omitempty" yaml:"ip_version,omitempty"` + Project NameOrId `json:"project,omitempty" yaml:"project,omitempty"` } // InstanceEphemeralIpAttachParams is the request parameters for InstanceEphemeralIpAttach @@ -10958,6 +11398,25 @@ type RackViewParams struct { RackId string `json:"rack_id,omitempty" yaml:"rack_id,omitempty"` } +// RackMembershipStatusParams is the request parameters for RackMembershipStatus +// +// Required fields: +// - RackId +type RackMembershipStatusParams struct { + RackId string `json:"rack_id,omitempty" yaml:"rack_id,omitempty"` + Version RackMembershipVersion `json:"version,omitempty" yaml:"version,omitempty"` +} + +// RackMembershipAddSledsParams is the request parameters for RackMembershipAddSleds +// +// Required fields: +// - RackId +// - Body +type RackMembershipAddSledsParams struct { + RackId string `json:"rack_id,omitempty" yaml:"rack_id,omitempty"` + Body *RackMembershipAddSledsRequest `json:"body,omitempty" yaml:"body,omitempty"` +} + // SledListParams is the request parameters for SledList type SledListParams struct { Limit *int `json:"limit,omitempty" yaml:"limit,omitempty"` @@ -11659,6 +12118,129 @@ type SiloQuotasUpdateParams struct { Body *SiloQuotasUpdate `json:"body,omitempty" yaml:"body,omitempty"` } +// SubnetPoolListParams is the request parameters for SubnetPoolList +type SubnetPoolListParams struct { + Limit *int `json:"limit,omitempty" yaml:"limit,omitempty"` + PageToken string `json:"page_token,omitempty" yaml:"page_token,omitempty"` + SortBy NameOrIdSortMode `json:"sort_by,omitempty" yaml:"sort_by,omitempty"` +} + +// SubnetPoolCreateParams is the request parameters for SubnetPoolCreate +// +// Required fields: +// - Body +type SubnetPoolCreateParams struct { + Body *SubnetPoolCreate `json:"body,omitempty" yaml:"body,omitempty"` +} + +// SubnetPoolDeleteParams is the request parameters for SubnetPoolDelete +// +// Required fields: +// - Pool +type SubnetPoolDeleteParams struct { + Pool NameOrId `json:"pool,omitempty" yaml:"pool,omitempty"` +} + +// SubnetPoolViewParams is the request parameters for SubnetPoolView +// +// Required fields: +// - Pool +type SubnetPoolViewParams struct { + Pool NameOrId `json:"pool,omitempty" yaml:"pool,omitempty"` +} + +// SubnetPoolUpdateParams is the request parameters for SubnetPoolUpdate +// +// Required fields: +// - Pool +// - Body +type SubnetPoolUpdateParams struct { + Pool NameOrId `json:"pool,omitempty" yaml:"pool,omitempty"` + Body *SubnetPoolUpdate `json:"body,omitempty" yaml:"body,omitempty"` +} + +// SubnetPoolMemberListParams is the request parameters for SubnetPoolMemberList +// +// Required fields: +// - Pool +type SubnetPoolMemberListParams struct { + Pool NameOrId `json:"pool,omitempty" yaml:"pool,omitempty"` + Limit *int `json:"limit,omitempty" yaml:"limit,omitempty"` + PageToken string `json:"page_token,omitempty" yaml:"page_token,omitempty"` + SortBy NameOrIdSortMode `json:"sort_by,omitempty" yaml:"sort_by,omitempty"` +} + +// SubnetPoolMemberAddParams is the request parameters for SubnetPoolMemberAdd +// +// Required fields: +// - Pool +// - Body +type SubnetPoolMemberAddParams struct { + Pool NameOrId `json:"pool,omitempty" yaml:"pool,omitempty"` + Body *SubnetPoolMemberAdd `json:"body,omitempty" yaml:"body,omitempty"` +} + +// SubnetPoolMemberRemoveParams is the request parameters for SubnetPoolMemberRemove +// +// Required fields: +// - Pool +// - Body +type SubnetPoolMemberRemoveParams struct { + Pool NameOrId `json:"pool,omitempty" yaml:"pool,omitempty"` + Body *SubnetPoolMemberRemove `json:"body,omitempty" yaml:"body,omitempty"` +} + +// SubnetPoolSiloListParams is the request parameters for SubnetPoolSiloList +// +// Required fields: +// - Pool +type SubnetPoolSiloListParams struct { + Pool NameOrId `json:"pool,omitempty" yaml:"pool,omitempty"` + Limit *int `json:"limit,omitempty" yaml:"limit,omitempty"` + PageToken string `json:"page_token,omitempty" yaml:"page_token,omitempty"` + SortBy IdSortMode `json:"sort_by,omitempty" yaml:"sort_by,omitempty"` +} + +// SubnetPoolSiloLinkParams is the request parameters for SubnetPoolSiloLink +// +// Required fields: +// - Pool +// - Body +type SubnetPoolSiloLinkParams struct { + Pool NameOrId `json:"pool,omitempty" yaml:"pool,omitempty"` + Body *SubnetPoolLinkSilo `json:"body,omitempty" yaml:"body,omitempty"` +} + +// SubnetPoolSiloUnlinkParams is the request parameters for SubnetPoolSiloUnlink +// +// Required fields: +// - Pool +// - Silo +type SubnetPoolSiloUnlinkParams struct { + Pool NameOrId `json:"pool,omitempty" yaml:"pool,omitempty"` + Silo NameOrId `json:"silo,omitempty" yaml:"silo,omitempty"` +} + +// SubnetPoolSiloUpdateParams is the request parameters for SubnetPoolSiloUpdate +// +// Required fields: +// - Pool +// - Silo +// - Body +type SubnetPoolSiloUpdateParams struct { + Pool NameOrId `json:"pool,omitempty" yaml:"pool,omitempty"` + Silo NameOrId `json:"silo,omitempty" yaml:"silo,omitempty"` + Body *SubnetPoolSiloUpdate `json:"body,omitempty" yaml:"body,omitempty"` +} + +// SubnetPoolUtilizationViewParams is the request parameters for SubnetPoolUtilizationView +// +// Required fields: +// - Pool +type SubnetPoolUtilizationViewParams struct { + Pool NameOrId `json:"pool,omitempty" yaml:"pool,omitempty"` +} + // SystemTimeseriesQueryParams is the request parameters for SystemTimeseriesQuery // // Required fields: @@ -12737,6 +13319,78 @@ func (p *DiskFinalizeImportParams) Validate() error { return nil } +// Validate verifies all required fields for ExternalSubnetListParams are set +func (p *ExternalSubnetListParams) Validate() error { + v := new(Validator) + if !v.IsValid() { + return fmt.Errorf("validation error:\n%v", v.Error()) + } + return nil +} + +// Validate verifies all required fields for ExternalSubnetCreateParams are set +func (p *ExternalSubnetCreateParams) Validate() error { + v := new(Validator) + v.HasRequiredObj(p.Body, "Body") + v.HasRequiredStr(string(p.Project), "Project") + if !v.IsValid() { + return fmt.Errorf("validation error:\n%v", v.Error()) + } + return nil +} + +// Validate verifies all required fields for ExternalSubnetDeleteParams are set +func (p *ExternalSubnetDeleteParams) Validate() error { + v := new(Validator) + v.HasRequiredStr(string(p.ExternalSubnet), "ExternalSubnet") + if !v.IsValid() { + return fmt.Errorf("validation error:\n%v", v.Error()) + } + return nil +} + +// Validate verifies all required fields for ExternalSubnetViewParams are set +func (p *ExternalSubnetViewParams) Validate() error { + v := new(Validator) + v.HasRequiredStr(string(p.ExternalSubnet), "ExternalSubnet") + if !v.IsValid() { + return fmt.Errorf("validation error:\n%v", v.Error()) + } + return nil +} + +// Validate verifies all required fields for ExternalSubnetUpdateParams are set +func (p *ExternalSubnetUpdateParams) Validate() error { + v := new(Validator) + v.HasRequiredObj(p.Body, "Body") + v.HasRequiredStr(string(p.ExternalSubnet), "ExternalSubnet") + if !v.IsValid() { + return fmt.Errorf("validation error:\n%v", v.Error()) + } + return nil +} + +// Validate verifies all required fields for ExternalSubnetAttachParams are set +func (p *ExternalSubnetAttachParams) Validate() error { + v := new(Validator) + v.HasRequiredObj(p.Body, "Body") + v.HasRequiredStr(string(p.ExternalSubnet), "ExternalSubnet") + if !v.IsValid() { + return fmt.Errorf("validation error:\n%v", v.Error()) + } + return nil +} + +// Validate verifies all required fields for ExternalSubnetDetachParams are set +func (p *ExternalSubnetDetachParams) Validate() error { + v := new(Validator) + v.HasRequiredStr(string(p.ExternalSubnet), "ExternalSubnet") + if !v.IsValid() { + return fmt.Errorf("validation error:\n%v", v.Error()) + } + return nil +} + // Validate verifies all required fields for FloatingIpListParams are set func (p *FloatingIpListParams) Validate() error { v := new(Validator) @@ -13582,6 +14236,27 @@ func (p *RackViewParams) Validate() error { return nil } +// Validate verifies all required fields for RackMembershipStatusParams are set +func (p *RackMembershipStatusParams) Validate() error { + v := new(Validator) + v.HasRequiredStr(string(p.RackId), "RackId") + if !v.IsValid() { + return fmt.Errorf("validation error:\n%v", v.Error()) + } + return nil +} + +// Validate verifies all required fields for RackMembershipAddSledsParams are set +func (p *RackMembershipAddSledsParams) Validate() error { + v := new(Validator) + v.HasRequiredObj(p.Body, "Body") + v.HasRequiredStr(string(p.RackId), "RackId") + if !v.IsValid() { + return fmt.Errorf("validation error:\n%v", v.Error()) + } + return nil +} + // Validate verifies all required fields for SledListParams are set func (p *SledListParams) Validate() error { v := new(Validator) @@ -14379,6 +15054,142 @@ func (p *SiloQuotasUpdateParams) Validate() error { return nil } +// Validate verifies all required fields for SubnetPoolListParams are set +func (p *SubnetPoolListParams) Validate() error { + v := new(Validator) + if !v.IsValid() { + return fmt.Errorf("validation error:\n%v", v.Error()) + } + return nil +} + +// Validate verifies all required fields for SubnetPoolCreateParams are set +func (p *SubnetPoolCreateParams) Validate() error { + v := new(Validator) + v.HasRequiredObj(p.Body, "Body") + if !v.IsValid() { + return fmt.Errorf("validation error:\n%v", v.Error()) + } + return nil +} + +// Validate verifies all required fields for SubnetPoolDeleteParams are set +func (p *SubnetPoolDeleteParams) Validate() error { + v := new(Validator) + v.HasRequiredStr(string(p.Pool), "Pool") + if !v.IsValid() { + return fmt.Errorf("validation error:\n%v", v.Error()) + } + return nil +} + +// Validate verifies all required fields for SubnetPoolViewParams are set +func (p *SubnetPoolViewParams) Validate() error { + v := new(Validator) + v.HasRequiredStr(string(p.Pool), "Pool") + if !v.IsValid() { + return fmt.Errorf("validation error:\n%v", v.Error()) + } + return nil +} + +// Validate verifies all required fields for SubnetPoolUpdateParams are set +func (p *SubnetPoolUpdateParams) Validate() error { + v := new(Validator) + v.HasRequiredObj(p.Body, "Body") + v.HasRequiredStr(string(p.Pool), "Pool") + if !v.IsValid() { + return fmt.Errorf("validation error:\n%v", v.Error()) + } + return nil +} + +// Validate verifies all required fields for SubnetPoolMemberListParams are set +func (p *SubnetPoolMemberListParams) Validate() error { + v := new(Validator) + v.HasRequiredStr(string(p.Pool), "Pool") + if !v.IsValid() { + return fmt.Errorf("validation error:\n%v", v.Error()) + } + return nil +} + +// Validate verifies all required fields for SubnetPoolMemberAddParams are set +func (p *SubnetPoolMemberAddParams) Validate() error { + v := new(Validator) + v.HasRequiredObj(p.Body, "Body") + v.HasRequiredStr(string(p.Pool), "Pool") + if !v.IsValid() { + return fmt.Errorf("validation error:\n%v", v.Error()) + } + return nil +} + +// Validate verifies all required fields for SubnetPoolMemberRemoveParams are set +func (p *SubnetPoolMemberRemoveParams) Validate() error { + v := new(Validator) + v.HasRequiredObj(p.Body, "Body") + v.HasRequiredStr(string(p.Pool), "Pool") + if !v.IsValid() { + return fmt.Errorf("validation error:\n%v", v.Error()) + } + return nil +} + +// Validate verifies all required fields for SubnetPoolSiloListParams are set +func (p *SubnetPoolSiloListParams) Validate() error { + v := new(Validator) + v.HasRequiredStr(string(p.Pool), "Pool") + if !v.IsValid() { + return fmt.Errorf("validation error:\n%v", v.Error()) + } + return nil +} + +// Validate verifies all required fields for SubnetPoolSiloLinkParams are set +func (p *SubnetPoolSiloLinkParams) Validate() error { + v := new(Validator) + v.HasRequiredObj(p.Body, "Body") + v.HasRequiredStr(string(p.Pool), "Pool") + if !v.IsValid() { + return fmt.Errorf("validation error:\n%v", v.Error()) + } + return nil +} + +// Validate verifies all required fields for SubnetPoolSiloUnlinkParams are set +func (p *SubnetPoolSiloUnlinkParams) Validate() error { + v := new(Validator) + v.HasRequiredStr(string(p.Pool), "Pool") + v.HasRequiredStr(string(p.Silo), "Silo") + if !v.IsValid() { + return fmt.Errorf("validation error:\n%v", v.Error()) + } + return nil +} + +// Validate verifies all required fields for SubnetPoolSiloUpdateParams are set +func (p *SubnetPoolSiloUpdateParams) Validate() error { + v := new(Validator) + v.HasRequiredObj(p.Body, "Body") + v.HasRequiredStr(string(p.Pool), "Pool") + v.HasRequiredStr(string(p.Silo), "Silo") + if !v.IsValid() { + return fmt.Errorf("validation error:\n%v", v.Error()) + } + return nil +} + +// Validate verifies all required fields for SubnetPoolUtilizationViewParams are set +func (p *SubnetPoolUtilizationViewParams) Validate() error { + v := new(Validator) + v.HasRequiredStr(string(p.Pool), "Pool") + if !v.IsValid() { + return fmt.Errorf("validation error:\n%v", v.Error()) + } + return nil +} + // Validate verifies all required fields for SystemTimeseriesQueryParams are set func (p *SystemTimeseriesQueryParams) Validate() error { v := new(Validator) @@ -14882,18 +15693,18 @@ func (p *WebhookSecretsDeleteParams) Validate() error { return nil } +// AddressAllocatorTypeExplicit represents the AddressAllocatorType `"explicit"`. +const AddressAllocatorTypeExplicit AddressAllocatorType = "explicit" + +// AddressAllocatorTypeAuto represents the AddressAllocatorType `"auto"`. +const AddressAllocatorTypeAuto AddressAllocatorType = "auto" + // AddressLotKindInfra represents the AddressLotKind `"infra"`. const AddressLotKindInfra AddressLotKind = "infra" // AddressLotKindPool represents the AddressLotKind `"pool"`. const AddressLotKindPool AddressLotKind = "pool" -// AddressSelectorTypeExplicit represents the AddressSelectorType `"explicit"`. -const AddressSelectorTypeExplicit AddressSelectorType = "explicit" - -// AddressSelectorTypeAuto represents the AddressSelectorType `"auto"`. -const AddressSelectorTypeAuto AddressSelectorType = "auto" - // AffinityGroupMemberTypeInstance represents the AffinityGroupMemberType `"instance"`. const AffinityGroupMemberTypeInstance AffinityGroupMemberType = "instance" @@ -14954,6 +15765,15 @@ const AuditLogEntryResultKindError AuditLogEntryResultKind = "error" // AuditLogEntryResultKindUnknown represents the AuditLogEntryResultKind `"unknown"`. const AuditLogEntryResultKindUnknown AuditLogEntryResultKind = "unknown" +// AuthMethodSessionCookie represents the AuthMethod `"session_cookie"`. +const AuthMethodSessionCookie AuthMethod = "session_cookie" + +// AuthMethodAccessToken represents the AuthMethod `"access_token"`. +const AuthMethodAccessToken AuthMethod = "access_token" + +// AuthMethodScimToken represents the AuthMethod `"scim_token"`. +const AuthMethodScimToken AuthMethod = "scim_token" + // AuthzScopeFleet represents the AuthzScope `"fleet"`. const AuthzScopeFleet AuthzScope = "fleet" @@ -15260,6 +16080,12 @@ const ExternalIpCreateTypeEphemeral ExternalIpCreateType = "ephemeral" // ExternalIpCreateTypeFloating represents the ExternalIpCreateType `"floating"`. const ExternalIpCreateTypeFloating ExternalIpCreateType = "floating" +// ExternalSubnetAllocatorTypeExplicit represents the ExternalSubnetAllocatorType `"explicit"`. +const ExternalSubnetAllocatorTypeExplicit ExternalSubnetAllocatorType = "explicit" + +// ExternalSubnetAllocatorTypeAuto represents the ExternalSubnetAllocatorType `"auto"`. +const ExternalSubnetAllocatorTypeAuto ExternalSubnetAllocatorType = "auto" + // FailureDomainSled represents the FailureDomain `"sled"`. const FailureDomainSled FailureDomain = "sled" @@ -15614,6 +16440,15 @@ const ProjectRoleLimitedCollaborator ProjectRole = "limited_collaborator" // ProjectRoleViewer represents the ProjectRole `"viewer"`. const ProjectRoleViewer ProjectRole = "viewer" +// RackMembershipChangeStateInProgress represents the RackMembershipChangeState `"in_progress"`. +const RackMembershipChangeStateInProgress RackMembershipChangeState = "in_progress" + +// RackMembershipChangeStateCommitted represents the RackMembershipChangeState `"committed"`. +const RackMembershipChangeStateCommitted RackMembershipChangeState = "committed" + +// RackMembershipChangeStateAborted represents the RackMembershipChangeState `"aborted"`. +const RackMembershipChangeStateAborted RackMembershipChangeState = "aborted" + // RouteDestinationTypeIp represents the RouteDestinationType `"ip"`. const RouteDestinationTypeIp RouteDestinationType = "ip" @@ -15920,18 +16755,18 @@ const WebhookDeliveryAttemptResultFailedUnreachable WebhookDeliveryAttemptResult // WebhookDeliveryAttemptResultFailedTimeout represents the WebhookDeliveryAttemptResult `"failed_timeout"`. const WebhookDeliveryAttemptResultFailedTimeout WebhookDeliveryAttemptResult = "failed_timeout" +// AddressAllocatorTypeCollection is the collection of all AddressAllocatorType values. +var AddressAllocatorTypeCollection = []AddressAllocatorType{ + AddressAllocatorTypeAuto, + AddressAllocatorTypeExplicit, +} + // AddressLotKindCollection is the collection of all AddressLotKind values. var AddressLotKindCollection = []AddressLotKind{ AddressLotKindInfra, AddressLotKindPool, } -// AddressSelectorTypeCollection is the collection of all AddressSelectorType values. -var AddressSelectorTypeCollection = []AddressSelectorType{ - AddressSelectorTypeAuto, - AddressSelectorTypeExplicit, -} - // AffinityGroupMemberTypeCollection is the collection of all AffinityGroupMemberType values. var AffinityGroupMemberTypeCollection = []AffinityGroupMemberType{ AffinityGroupMemberTypeInstance, @@ -15988,6 +16823,13 @@ var AuditLogEntryResultKindCollection = []AuditLogEntryResultKind{ AuditLogEntryResultKindUnknown, } +// AuthMethodCollection is the collection of all AuthMethod values. +var AuthMethodCollection = []AuthMethod{ + AuthMethodAccessToken, + AuthMethodScimToken, + AuthMethodSessionCookie, +} + // AuthzScopeCollection is the collection of all AuthzScope values. var AuthzScopeCollection = []AuthzScope{ AuthzScopeFleet, @@ -16178,6 +17020,12 @@ var ExternalIpKindCollection = []ExternalIpKind{ ExternalIpKindSnat, } +// ExternalSubnetAllocatorTypeCollection is the collection of all ExternalSubnetAllocatorType values. +var ExternalSubnetAllocatorTypeCollection = []ExternalSubnetAllocatorType{ + ExternalSubnetAllocatorTypeAuto, + ExternalSubnetAllocatorTypeExplicit, +} + // FailureDomainCollection is the collection of all FailureDomain values. var FailureDomainCollection = []FailureDomain{ FailureDomainSled, @@ -16448,6 +17296,13 @@ var ProjectRoleCollection = []ProjectRole{ ProjectRoleViewer, } +// RackMembershipChangeStateCollection is the collection of all RackMembershipChangeState values. +var RackMembershipChangeStateCollection = []RackMembershipChangeState{ + RackMembershipChangeStateAborted, + RackMembershipChangeStateCommitted, + RackMembershipChangeStateInProgress, +} + // RouteDestinationTypeCollection is the collection of all RouteDestinationType values. var RouteDestinationTypeCollection = []RouteDestinationType{ RouteDestinationTypeIp, diff --git a/oxide/version.go b/oxide/version.go index 017a3ee..0c0fcdb 100644 --- a/oxide/version.go +++ b/oxide/version.go @@ -17,4 +17,4 @@ const sdkVersion = "v0.8.0" // for [Client]. It is purposefully unexported to prevent external users from // reading it. The value of this comes from the OpenAPI specification associated // with the OMICRON_VERSION file in the root of this repository. -const openAPIVersion = "2026010800.0.0" +const openAPIVersion = "2026012300.0.0"