@@ -568,6 +568,15 @@ type CreateHostingRequest struct {
568568DomainConfiguration * CreateHostingRequestDomainConfiguration `json:"domain_configuration,omitempty"`
569569}
570570
571+ // CreateSessionRequest: create session request.
572+ type CreateSessionRequest struct {
573+ // Region: region to target. If none is passed will use default region from the config.
574+ Region scw.Region `json:"-"`
575+
576+ // HostingID: hosting ID.
577+ HostingID string `json:"-"`
578+ }
579+
571580// DNSRecords: dns records.
572581type DNSRecords struct {
573582// Records: list of DNS records.
@@ -747,6 +756,12 @@ type RestoreHostingRequest struct {
747756HostingID string `json:"-"`
748757}
749758
759+ // Session: session.
760+ type Session struct {
761+ // URL: logged user's session URL.
762+ URL string `json:"url"`
763+ }
764+
750765// UpdateHostingRequest: update hosting request.
751766type UpdateHostingRequest struct {
752767// Region: region to target. If none is passed will use default region from the config.
@@ -1103,3 +1118,39 @@ func (s *API) ListControlPanels(req *ListControlPanelsRequest, opts ...scw.Reque
11031118}
11041119return & resp , nil
11051120}
1121+
1122+ // CreateSession: Create a user session.
1123+ func (s * API ) CreateSession (req * CreateSessionRequest , opts ... scw.RequestOption ) (* Session , error ) {
1124+ var err error
1125+
1126+ if req .Region == "" {
1127+ defaultRegion , _ := s .client .GetDefaultRegion ()
1128+ req .Region = defaultRegion
1129+ }
1130+
1131+ if fmt .Sprint (req .Region ) == "" {
1132+ return nil , errors .New ("field Region cannot be empty in request" )
1133+ }
1134+
1135+ if fmt .Sprint (req .HostingID ) == "" {
1136+ return nil , errors .New ("field HostingID cannot be empty in request" )
1137+ }
1138+
1139+ scwReq := & scw.ScalewayRequest {
1140+ Method : "POST" ,
1141+ Path : "/webhosting/v1alpha1/regions/" + fmt .Sprint (req .Region ) + "/hostings/" + fmt .Sprint (req .HostingID ) + "/sessions" ,
1142+ }
1143+
1144+ err = scwReq .SetBody (req )
1145+ if err != nil {
1146+ return nil , err
1147+ }
1148+
1149+ var resp Session
1150+
1151+ err = s .client .Do (scwReq , & resp , opts ... )
1152+ if err != nil {
1153+ return nil , err
1154+ }
1155+ return & resp , nil
1156+ }
0 commit comments