@@ -343,6 +343,43 @@ func (enum *ListJobsRequestOrderBy) UnmarshalJSON(data []byte) error {
343343 return nil
344344}
345345
346+ type ListModelsRequestOrderBy string
347+
348+ const (
349+ ListModelsRequestOrderByCreatedAtDesc = ListModelsRequestOrderBy ("created_at_desc" )
350+ ListModelsRequestOrderByCreatedAtAsc = ListModelsRequestOrderBy ("created_at_asc" )
351+ )
352+
353+ func (enum ListModelsRequestOrderBy ) String () string {
354+ if enum == "" {
355+ // return default value if empty
356+ return string (ListModelsRequestOrderByCreatedAtDesc )
357+ }
358+ return string (enum )
359+ }
360+
361+ func (enum ListModelsRequestOrderBy ) Values () []ListModelsRequestOrderBy {
362+ return []ListModelsRequestOrderBy {
363+ "created_at_desc" ,
364+ "created_at_asc" ,
365+ }
366+ }
367+
368+ func (enum ListModelsRequestOrderBy ) MarshalJSON () ([]byte , error ) {
369+ return []byte (fmt .Sprintf (`"%s"` , enum )), nil
370+ }
371+
372+ func (enum * ListModelsRequestOrderBy ) UnmarshalJSON (data []byte ) error {
373+ tmp := ""
374+
375+ if err := json .Unmarshal (data , & tmp ); err != nil {
376+ return err
377+ }
378+
379+ * enum = ListModelsRequestOrderBy (ListModelsRequestOrderBy (tmp ).String ())
380+ return nil
381+ }
382+
346383type ListPlatformsRequestOrderBy string
347384
348385const (
@@ -1026,6 +1063,27 @@ type Job struct {
10261063
10271064 // ResultDistribution: result of the job, if the job is finished.
10281065 ResultDistribution * string `json:"result_distribution"`
1066+
1067+ // ModelID: computation model ID executed by the job.
1068+ ModelID * string `json:"model_id"`
1069+
1070+ // Parameters: execution parameters for this job.
1071+ Parameters * string `json:"parameters"`
1072+ }
1073+
1074+ // Model: model.
1075+ type Model struct {
1076+ // ID: unique ID of the model.
1077+ ID string `json:"id"`
1078+
1079+ // CreatedAt: time at which the model was created.
1080+ CreatedAt * time.Time `json:"created_at"`
1081+
1082+ // URL: storage URL of the model.
1083+ URL * string `json:"url"`
1084+
1085+ // ProjectID: project ID in which the model has been created.
1086+ ProjectID string `json:"project_id"`
10291087}
10301088
10311089// Platform: platform.
@@ -1215,6 +1273,9 @@ type Session struct {
12151273
12161274 // BookingID: an optional booking unique ID of an attached booking.
12171275 BookingID * string `json:"booking_id"`
1276+
1277+ // ModelID: default computation model ID to be executed by job assigned to this session.
1278+ ModelID * string `json:"model_id"`
12181279}
12191280
12201281// CancelJobRequest: cancel job request.
@@ -1245,6 +1306,21 @@ type CreateJobRequest struct {
12451306
12461307 // MaxDuration: maximum duration of the job.
12471308 MaxDuration * scw.Duration `json:"max_duration,omitempty"`
1309+
1310+ // ModelID: computation model ID to be executed by the job.
1311+ ModelID * string `json:"model_id,omitempty"`
1312+
1313+ // Parameters: execution parameters for this job.
1314+ Parameters * string `json:"parameters,omitempty"`
1315+ }
1316+
1317+ // CreateModelRequest: create model request.
1318+ type CreateModelRequest struct {
1319+ // ProjectID: project ID to attach this model.
1320+ ProjectID string `json:"project_id"`
1321+
1322+ // Payload: the serialized model data.
1323+ Payload * string `json:"payload,omitempty"`
12481324}
12491325
12501326// CreateProcessRequest: create process request.
@@ -1293,6 +1369,9 @@ type CreateSessionRequest struct {
12931369
12941370 // BookingDemand: a booking demand to schedule the session, only applicable if the platform is bookable.
12951371 BookingDemand * CreateSessionRequestBookingDemand `json:"booking_demand,omitempty"`
1372+
1373+ // ModelID: default computation model ID to be executed by job assigned to this session.
1374+ ModelID * string `json:"model_id,omitempty"`
12961375}
12971376
12981377// DeleteJobRequest: delete job request.
@@ -1337,6 +1416,12 @@ type GetJobRequest struct {
13371416 JobID string `json:"-"`
13381417}
13391418
1419+ // GetModelRequest: get model request.
1420+ type GetModelRequest struct {
1421+ // ModelID: unique ID of the model.
1422+ ModelID string `json:"-"`
1423+ }
1424+
13401425// GetPlatformRequest: get platform request.
13411426type GetPlatformRequest struct {
13421427 // PlatformID: unique ID of the platform.
@@ -1546,6 +1631,50 @@ func (r *ListJobsResponse) UnsafeAppend(res any) (uint64, error) {
15461631 return uint64 (len (results .Jobs )), nil
15471632}
15481633
1634+ // ListModelsRequest: list models request.
1635+ type ListModelsRequest struct {
1636+ // ProjectID: list models belonging to this project ID.
1637+ ProjectID string `json:"-"`
1638+
1639+ // Page: page number.
1640+ Page * int32 `json:"-"`
1641+
1642+ // PageSize: maximum number of results to return per page.
1643+ PageSize * uint32 `json:"-"`
1644+
1645+ // OrderBy: sort order of the returned results.
1646+ // Default value: created_at_desc
1647+ OrderBy ListModelsRequestOrderBy `json:"-"`
1648+ }
1649+
1650+ // ListModelsResponse: list models response.
1651+ type ListModelsResponse struct {
1652+ // TotalCount: total number of models.
1653+ TotalCount uint64 `json:"total_count"`
1654+
1655+ // Models: list of models.
1656+ Models []* Model `json:"models"`
1657+ }
1658+
1659+ // UnsafeGetTotalCount should not be used
1660+ // Internal usage only
1661+ func (r * ListModelsResponse ) UnsafeGetTotalCount () uint64 {
1662+ return r .TotalCount
1663+ }
1664+
1665+ // UnsafeAppend should not be used
1666+ // Internal usage only
1667+ func (r * ListModelsResponse ) UnsafeAppend (res any ) (uint64 , error ) {
1668+ results , ok := res .(* ListModelsResponse )
1669+ if ! ok {
1670+ return 0 , errors .New ("%T type cannot be appended to type %T" , res , r )
1671+ }
1672+
1673+ r .Models = append (r .Models , results .Models ... )
1674+ r .TotalCount += uint64 (len (results .Models ))
1675+ return uint64 (len (results .Models )), nil
1676+ }
1677+
15491678// ListPlatformsRequest: list platforms request.
15501679type ListPlatformsRequest struct {
15511680 // ProviderName: list platforms with this provider name.
@@ -2642,3 +2771,88 @@ func (s *API) UpdateBooking(req *UpdateBookingRequest, opts ...scw.RequestOption
26422771 }
26432772 return & resp , nil
26442773}
2774+
2775+ // CreateModel: Create and register a new model that can be executed through next jobs. A model can also be assigned to a Session.
2776+ func (s * API ) CreateModel (req * CreateModelRequest , opts ... scw.RequestOption ) (* Model , error ) {
2777+ var err error
2778+
2779+ if req .ProjectID == "" {
2780+ defaultProjectID , _ := s .client .GetDefaultProjectID ()
2781+ req .ProjectID = defaultProjectID
2782+ }
2783+
2784+ scwReq := & scw.ScalewayRequest {
2785+ Method : "POST" ,
2786+ Path : "/qaas/v1alpha1/models" ,
2787+ }
2788+
2789+ err = scwReq .SetBody (req )
2790+ if err != nil {
2791+ return nil , err
2792+ }
2793+
2794+ var resp Model
2795+
2796+ err = s .client .Do (scwReq , & resp , opts ... )
2797+ if err != nil {
2798+ return nil , err
2799+ }
2800+ return & resp , nil
2801+ }
2802+
2803+ // GetModel: Retrieve information about of the provided **model ID**.
2804+ func (s * API ) GetModel (req * GetModelRequest , opts ... scw.RequestOption ) (* Model , error ) {
2805+ var err error
2806+
2807+ if fmt .Sprint (req .ModelID ) == "" {
2808+ return nil , errors .New ("field ModelID cannot be empty in request" )
2809+ }
2810+
2811+ scwReq := & scw.ScalewayRequest {
2812+ Method : "GET" ,
2813+ Path : "/qaas/v1alpha1/models/" + fmt .Sprint (req .ModelID ) + "" ,
2814+ }
2815+
2816+ var resp Model
2817+
2818+ err = s .client .Do (scwReq , & resp , opts ... )
2819+ if err != nil {
2820+ return nil , err
2821+ }
2822+ return & resp , nil
2823+ }
2824+
2825+ // ListModels: Retrieve information about all models of the provided **project ID**.
2826+ func (s * API ) ListModels (req * ListModelsRequest , opts ... scw.RequestOption ) (* ListModelsResponse , error ) {
2827+ var err error
2828+
2829+ if req .ProjectID == "" {
2830+ defaultProjectID , _ := s .client .GetDefaultProjectID ()
2831+ req .ProjectID = defaultProjectID
2832+ }
2833+
2834+ defaultPageSize , exist := s .client .GetDefaultPageSize ()
2835+ if (req .PageSize == nil || * req .PageSize == 0 ) && exist {
2836+ req .PageSize = & defaultPageSize
2837+ }
2838+
2839+ query := url.Values {}
2840+ parameter .AddToQuery (query , "project_id" , req .ProjectID )
2841+ parameter .AddToQuery (query , "page" , req .Page )
2842+ parameter .AddToQuery (query , "page_size" , req .PageSize )
2843+ parameter .AddToQuery (query , "order_by" , req .OrderBy )
2844+
2845+ scwReq := & scw.ScalewayRequest {
2846+ Method : "GET" ,
2847+ Path : "/qaas/v1alpha1/models" ,
2848+ Query : query ,
2849+ }
2850+
2851+ var resp ListModelsResponse
2852+
2853+ err = s .client .Do (scwReq , & resp , opts ... )
2854+ if err != nil {
2855+ return nil , err
2856+ }
2857+ return & resp , nil
2858+ }
0 commit comments