Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions api/lb/v1/lb_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,18 @@ type ACLMatch struct {
Invert bool `json:"invert"`
}

// ACLSpec: acl spec
type ACLSpec struct {
// Name: name of your ACL resource
Name string `json:"name"`
// Action: action to undertake when an ACL filter matches
Action *ACLAction `json:"action"`
// Match: the ACL match rule. At least `ip_subnet` or `http_filter` and `http_filter_value` are required
Match *ACLMatch `json:"match"`
// Index: order between your Acls (ascending order, 0 is first acl executed)
Index int32 `json:"index"`
}

// Backend: backend
type Backend struct {
ID string `json:"id"`
Expand Down Expand Up @@ -1536,6 +1548,14 @@ type RouteMatch struct {
Sni *string `json:"sni"`
}

// SetACLsResponse: set acls response
type SetACLsResponse struct {
// ACLs: list of ACLs object (see ACL object description)
ACLs []*ACL `json:"acls"`
// TotalCount: the total number of items
TotalCount uint32 `json:"total_count"`
}

// Subscriber: subscriber
type Subscriber struct {
// ID: subscriber ID
Expand Down Expand Up @@ -6498,6 +6518,51 @@ func (s *ZonedAPI) DeleteACL(req *ZonedAPIDeleteACLRequest, opts ...scw.RequestO
return nil
}

type ZonedAPISetACLsRequest struct {
Zone scw.Zone `json:"-"`
// FrontendID: the Frontend to change ACL to
FrontendID string `json:"-"`
// ACLs: array of ACLs to erease the existing ACLs
ACLs []*ACLSpec `json:"acls"`
}

// SetACLs: set all ACLs for a given frontend
func (s *ZonedAPI) SetACLs(req *ZonedAPISetACLsRequest, opts ...scw.RequestOption) (*SetACLsResponse, error) {
var err error

if req.Zone == "" {
defaultZone, _ := s.client.GetDefaultZone()
req.Zone = defaultZone
}

if fmt.Sprint(req.Zone) == "" {
return nil, errors.New("field Zone cannot be empty in request")
}

if fmt.Sprint(req.FrontendID) == "" {
return nil, errors.New("field FrontendID cannot be empty in request")
}

scwReq := &scw.ScalewayRequest{
Method: "PUT",
Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/frontends/" + fmt.Sprint(req.FrontendID) + "/acls",
Headers: http.Header{},
}

err = scwReq.SetBody(req)
if err != nil {
return nil, err
}

var resp SetACLsResponse

err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}

type ZonedAPICreateCertificateRequest struct {
Zone scw.Zone `json:"-"`
// LBID: load balancer ID
Expand Down