Skip to content

Commit 6d62825

Browse files
authored
feat(dedibox): provide ListIPv6Blocks endpoint (#2760)
1 parent 0f67e6f commit 6d62825

File tree

1 file changed

+79
-26
lines changed

1 file changed

+79
-26
lines changed

api/dedibox/v1/dedibox_sdk.go

Lines changed: 79 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3400,6 +3400,31 @@ type ListIPv6BlockSubnetsAvailableResponseSubnet struct {
34003400
Cidr uint32 `json:"cidr"`
34013401
}
34023402

3403+
// IPv6Block: i pv6 block.
3404+
type IPv6Block struct {
3405+
// ID: ID of the IPv6.
3406+
ID uint64 `json:"id"`
3407+
3408+
// Address: address of the IPv6.
3409+
Address net.IP `json:"address"`
3410+
3411+
// Duid: dUID of the IPv6.
3412+
Duid string `json:"duid"`
3413+
3414+
// Nameservers: DNS linked to the IPv6.
3415+
Nameservers []string `json:"nameservers"`
3416+
3417+
// Cidr: classless InterDomain Routing notation of the IPv6.
3418+
Cidr uint32 `json:"cidr"`
3419+
3420+
// Subnets: all IPv6 subnets.
3421+
Subnets []*IPv6Block `json:"subnets"`
3422+
3423+
// DelegationStatus: the nameservers delegation status.
3424+
// Default value: unknown_status
3425+
DelegationStatus IPv6BlockDelegationStatus `json:"delegation_status"`
3426+
}
3427+
34033428
// InvoiceSummary: invoice summary.
34043429
type InvoiceSummary struct {
34053430
ID uint64 `json:"id"`
@@ -4207,31 +4232,6 @@ type GetServiceRequest struct {
42074232
ServiceID uint64 `json:"-"`
42084233
}
42094234

4210-
// IPv6Block: i pv6 block.
4211-
type IPv6Block struct {
4212-
// ID: ID of the IPv6.
4213-
ID uint64 `json:"id"`
4214-
4215-
// Address: address of the IPv6.
4216-
Address net.IP `json:"address"`
4217-
4218-
// Duid: dUID of the IPv6.
4219-
Duid string `json:"duid"`
4220-
4221-
// Nameservers: DNS linked to the IPv6.
4222-
Nameservers []string `json:"nameservers"`
4223-
4224-
// Cidr: classless InterDomain Routing notation of the IPv6.
4225-
Cidr uint32 `json:"cidr"`
4226-
4227-
// Subnets: all IPv6 subnets.
4228-
Subnets []*IPv6Block `json:"subnets"`
4229-
4230-
// DelegationStatus: the nameservers delegation status.
4231-
// Default value: unknown_status
4232-
DelegationStatus IPv6BlockDelegationStatus `json:"delegation_status"`
4233-
}
4234-
42354235
// IPv6BlockAPICreateIPv6BlockRequest: i pv6 block api create i pv6 block request.
42364236
type IPv6BlockAPICreateIPv6BlockRequest struct {
42374237
// ProjectID: ID of the project.
@@ -4274,6 +4274,11 @@ type IPv6BlockAPIListIPv6BlockSubnetsAvailableRequest struct {
42744274
BlockID uint64 `json:"-"`
42754275
}
42764276

4277+
// IPv6BlockAPIListIPv6BlocksRequest: i pv6 block api list i pv6 blocks request.
4278+
type IPv6BlockAPIListIPv6BlocksRequest struct {
4279+
ProjectID *string `json:"-"`
4280+
}
4281+
42774282
// IPv6BlockAPIUpdateIPv6BlockRequest: i pv6 block api update i pv6 block request.
42784283
type IPv6BlockAPIUpdateIPv6BlockRequest struct {
42794284
// BlockID: ID of the IPv6 block.
@@ -4455,6 +4460,32 @@ func (r *ListIPv6BlockSubnetsAvailableResponse) UnsafeAppend(res any) (uint32, e
44554460
return uint32(len(results.SubnetAvailables)), nil
44564461
}
44574462

4463+
// ListIPv6BlocksResponse: list i pv6 blocks response.
4464+
type ListIPv6BlocksResponse struct {
4465+
TotalCount uint32 `json:"total_count"`
4466+
4467+
IPv6Blocks []*IPv6Block `json:"ipv6_blocks"`
4468+
}
4469+
4470+
// UnsafeGetTotalCount should not be used
4471+
// Internal usage only
4472+
func (r *ListIPv6BlocksResponse) UnsafeGetTotalCount() uint32 {
4473+
return r.TotalCount
4474+
}
4475+
4476+
// UnsafeAppend should not be used
4477+
// Internal usage only
4478+
func (r *ListIPv6BlocksResponse) UnsafeAppend(res any) (uint32, error) {
4479+
results, ok := res.(*ListIPv6BlocksResponse)
4480+
if !ok {
4481+
return 0, errors.New("%T type cannot be appended to type %T", res, r)
4482+
}
4483+
4484+
r.IPv6Blocks = append(r.IPv6Blocks, results.IPv6Blocks...)
4485+
r.TotalCount += uint32(len(results.IPv6Blocks))
4486+
return uint32(len(results.IPv6Blocks)), nil
4487+
}
4488+
44584489
// ListInvoicesResponse: list invoices response.
44594490
type ListInvoicesResponse struct {
44604491
TotalCount uint32 `json:"total_count"`
@@ -7758,7 +7789,29 @@ func (s *IPv6BlockAPI) CreateIPv6Block(req *IPv6BlockAPICreateIPv6BlockRequest,
77587789
return &resp, nil
77597790
}
77607791

7761-
// GetIPv6Block: Get the IPv6 block associated with the given ID.
7792+
// ListIPv6Blocks: List IPv6 blocks associated given project ID.
7793+
func (s *IPv6BlockAPI) ListIPv6Blocks(req *IPv6BlockAPIListIPv6BlocksRequest, opts ...scw.RequestOption) (*ListIPv6BlocksResponse, error) {
7794+
var err error
7795+
7796+
query := url.Values{}
7797+
parameter.AddToQuery(query, "project_id", req.ProjectID)
7798+
7799+
scwReq := &scw.ScalewayRequest{
7800+
Method: "GET",
7801+
Path: "/dedibox/v1/ipv6-blocks",
7802+
Query: query,
7803+
}
7804+
7805+
var resp ListIPv6BlocksResponse
7806+
7807+
err = s.client.Do(scwReq, &resp, opts...)
7808+
if err != nil {
7809+
return nil, err
7810+
}
7811+
return &resp, nil
7812+
}
7813+
7814+
// GetIPv6Block: Get the first IPv6 block associated with the given project ID.
77627815
func (s *IPv6BlockAPI) GetIPv6Block(req *IPv6BlockAPIGetIPv6BlockRequest, opts ...scw.RequestOption) (*IPv6Block, error) {
77637816
var err error
77647817

0 commit comments

Comments
 (0)