Skip to content

Commit cfe16ea

Browse files
authored
feat(edge_services): add ListPipelinesWithStages (scaleway#2253)
1 parent c0de89f commit cfe16ea

File tree

1 file changed

+128
-0
lines changed

1 file changed

+128
-0
lines changed

api/edge_services/v1alpha1/edge_services_sdk.go

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,47 @@ func (enum *ListPipelinesRequestOrderBy) UnmarshalJSON(data []byte) error {
283283
return nil
284284
}
285285

286+
type ListPipelinesWithStagesRequestOrderBy string
287+
288+
const (
289+
ListPipelinesWithStagesRequestOrderByCreatedAtAsc = ListPipelinesWithStagesRequestOrderBy("created_at_asc")
290+
ListPipelinesWithStagesRequestOrderByCreatedAtDesc = ListPipelinesWithStagesRequestOrderBy("created_at_desc")
291+
ListPipelinesWithStagesRequestOrderByNameAsc = ListPipelinesWithStagesRequestOrderBy("name_asc")
292+
ListPipelinesWithStagesRequestOrderByNameDesc = ListPipelinesWithStagesRequestOrderBy("name_desc")
293+
)
294+
295+
func (enum ListPipelinesWithStagesRequestOrderBy) String() string {
296+
if enum == "" {
297+
// return default value if empty
298+
return "created_at_asc"
299+
}
300+
return string(enum)
301+
}
302+
303+
func (enum ListPipelinesWithStagesRequestOrderBy) Values() []ListPipelinesWithStagesRequestOrderBy {
304+
return []ListPipelinesWithStagesRequestOrderBy{
305+
"created_at_asc",
306+
"created_at_desc",
307+
"name_asc",
308+
"name_desc",
309+
}
310+
}
311+
312+
func (enum ListPipelinesWithStagesRequestOrderBy) MarshalJSON() ([]byte, error) {
313+
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
314+
}
315+
316+
func (enum *ListPipelinesWithStagesRequestOrderBy) UnmarshalJSON(data []byte) error {
317+
tmp := ""
318+
319+
if err := json.Unmarshal(data, &tmp); err != nil {
320+
return err
321+
}
322+
323+
*enum = ListPipelinesWithStagesRequestOrderBy(ListPipelinesWithStagesRequestOrderBy(tmp).String())
324+
return nil
325+
}
326+
286327
type ListPurgeRequestsRequestOrderBy string
287328

288329
const (
@@ -935,6 +976,19 @@ type PlanDetails struct {
935976
PipelineLimit uint32 `json:"pipeline_limit"`
936977
}
937978

979+
// PipelineStages: pipeline stages.
980+
type PipelineStages struct {
981+
Pipeline *Pipeline `json:"pipeline"`
982+
983+
DNSStages []*DNSStage `json:"dns_stages"`
984+
985+
TLSStages []*TLSStage `json:"tls_stages"`
986+
987+
CacheStages []*CacheStage `json:"cache_stages"`
988+
989+
BackendStages []*BackendStage `json:"backend_stages"`
990+
}
991+
938992
// PurgeRequest: purge request.
939993
type PurgeRequest struct {
940994
// ID: ID of the purge request.
@@ -1425,6 +1479,48 @@ func (r *ListPipelinesResponse) UnsafeAppend(res interface{}) (uint64, error) {
14251479
return uint64(len(results.Pipelines)), nil
14261480
}
14271481

1482+
// ListPipelinesWithStagesRequest: list pipelines with stages request.
1483+
type ListPipelinesWithStagesRequest struct {
1484+
// OrderBy: default value: created_at_asc
1485+
OrderBy ListPipelinesWithStagesRequestOrderBy `json:"-"`
1486+
1487+
Page *int32 `json:"-"`
1488+
1489+
PageSize *uint32 `json:"-"`
1490+
1491+
Name *string `json:"-"`
1492+
1493+
OrganizationID *string `json:"-"`
1494+
1495+
ProjectID *string `json:"-"`
1496+
}
1497+
1498+
// ListPipelinesWithStagesResponse: list pipelines with stages response.
1499+
type ListPipelinesWithStagesResponse struct {
1500+
Pipelines []*PipelineStages `json:"pipelines"`
1501+
1502+
TotalCount uint64 `json:"total_count"`
1503+
}
1504+
1505+
// UnsafeGetTotalCount should not be used
1506+
// Internal usage only
1507+
func (r *ListPipelinesWithStagesResponse) UnsafeGetTotalCount() uint64 {
1508+
return r.TotalCount
1509+
}
1510+
1511+
// UnsafeAppend should not be used
1512+
// Internal usage only
1513+
func (r *ListPipelinesWithStagesResponse) UnsafeAppend(res interface{}) (uint64, error) {
1514+
results, ok := res.(*ListPipelinesWithStagesResponse)
1515+
if !ok {
1516+
return 0, errors.New("%T type cannot be appended to type %T", res, r)
1517+
}
1518+
1519+
r.Pipelines = append(r.Pipelines, results.Pipelines...)
1520+
r.TotalCount += uint64(len(results.Pipelines))
1521+
return uint64(len(results.Pipelines)), nil
1522+
}
1523+
14281524
// ListPlansResponse: list plans response.
14291525
type ListPlansResponse struct {
14301526
TotalCount uint64 `json:"total_count"`
@@ -1746,6 +1842,38 @@ func (s *API) GetPipeline(req *GetPipelineRequest, opts ...scw.RequestOption) (*
17461842
return &resp, nil
17471843
}
17481844

1845+
// ListPipelinesWithStages:
1846+
func (s *API) ListPipelinesWithStages(req *ListPipelinesWithStagesRequest, opts ...scw.RequestOption) (*ListPipelinesWithStagesResponse, error) {
1847+
var err error
1848+
1849+
defaultPageSize, exist := s.client.GetDefaultPageSize()
1850+
if (req.PageSize == nil || *req.PageSize == 0) && exist {
1851+
req.PageSize = &defaultPageSize
1852+
}
1853+
1854+
query := url.Values{}
1855+
parameter.AddToQuery(query, "order_by", req.OrderBy)
1856+
parameter.AddToQuery(query, "page", req.Page)
1857+
parameter.AddToQuery(query, "page_size", req.PageSize)
1858+
parameter.AddToQuery(query, "name", req.Name)
1859+
parameter.AddToQuery(query, "organization_id", req.OrganizationID)
1860+
parameter.AddToQuery(query, "project_id", req.ProjectID)
1861+
1862+
scwReq := &scw.ScalewayRequest{
1863+
Method: "GET",
1864+
Path: "/edge-services/v1alpha1/pipelines-stages",
1865+
Query: query,
1866+
}
1867+
1868+
var resp ListPipelinesWithStagesResponse
1869+
1870+
err = s.client.Do(scwReq, &resp, opts...)
1871+
if err != nil {
1872+
return nil, err
1873+
}
1874+
return &resp, nil
1875+
}
1876+
17491877
// UpdatePipeline: Update the parameters of an existing pipeline, specified by its `pipeline_id`. Parameters which can be updated include the `name`, `description` and `dns_stage_id`.
17501878
func (s *API) UpdatePipeline(req *UpdatePipelineRequest, opts ...scw.RequestOption) (*Pipeline, error) {
17511879
var err error

0 commit comments

Comments
 (0)