@@ -2824,6 +2824,30 @@ type Session struct {
28242824 URL string `json:"url"`
28252825}
28262826
2827+ // WebsiteAPICreateWebsiteRequest: website api create website request.
2828+ type WebsiteAPICreateWebsiteRequest struct {
2829+ // Region: region to target. If none is passed will use default region from the config.
2830+ Region scw.Region `json:"-"`
2831+
2832+ // HostingID: hosting ID to which the website is attached to.
2833+ HostingID string `json:"-"`
2834+
2835+ // DomainName: the new domain name or subdomain to use for the website.
2836+ DomainName string `json:"domain_name"`
2837+ }
2838+
2839+ // WebsiteAPIDeleteWebsiteRequest: website api delete website request.
2840+ type WebsiteAPIDeleteWebsiteRequest struct {
2841+ // Region: region to target. If none is passed will use default region from the config.
2842+ Region scw.Region `json:"-"`
2843+
2844+ // HostingID: hosting ID to which the website is detached from.
2845+ HostingID string `json:"-"`
2846+
2847+ // DomainName: the new domain name or subdomain attached to the website.
2848+ DomainName string `json:"-"`
2849+ }
2850+
28272851// WebsiteAPIListWebsitesRequest: website api list websites request.
28282852type WebsiteAPIListWebsitesRequest struct {
28292853 // Region: region to target. If none is passed will use default region from the config.
@@ -4154,7 +4178,7 @@ func (s *HostingAPI) GetResourceSummary(req *HostingAPIGetResourceSummaryRequest
41544178 return & resp , nil
41554179}
41564180
4157- // AddCustomDomain: Attach a custom domain to a webhosting.
4181+ // AddCustomDomain: Attach a custom domain to a webhosting as an alias to the main domain .
41584182func (s * HostingAPI ) AddCustomDomain (req * HostingAPIAddCustomDomainRequest , opts ... scw.RequestOption ) (* HostingSummary , error ) {
41594183 var err error
41604184
@@ -4705,3 +4729,72 @@ func (s *WebsiteAPI) ListWebsites(req *WebsiteAPIListWebsitesRequest, opts ...sc
47054729 }
47064730 return & resp , nil
47074731}
4732+
4733+ // CreateWebsite: Create a new website and attach it to a webhosting.
4734+ func (s * WebsiteAPI ) CreateWebsite (req * WebsiteAPICreateWebsiteRequest , opts ... scw.RequestOption ) (* Website , error ) {
4735+ var err error
4736+
4737+ if req .Region == "" {
4738+ defaultRegion , _ := s .client .GetDefaultRegion ()
4739+ req .Region = defaultRegion
4740+ }
4741+
4742+ if fmt .Sprint (req .Region ) == "" {
4743+ return nil , errors .New ("field Region cannot be empty in request" )
4744+ }
4745+
4746+ if fmt .Sprint (req .HostingID ) == "" {
4747+ return nil , errors .New ("field HostingID cannot be empty in request" )
4748+ }
4749+
4750+ scwReq := & scw.ScalewayRequest {
4751+ Method : "POST" ,
4752+ Path : "/webhosting/v1/regions/" + fmt .Sprint (req .Region ) + "/hostings/" + fmt .Sprint (req .HostingID ) + "/websites" ,
4753+ }
4754+
4755+ err = scwReq .SetBody (req )
4756+ if err != nil {
4757+ return nil , err
4758+ }
4759+
4760+ var resp Website
4761+
4762+ err = s .client .Do (scwReq , & resp , opts ... )
4763+ if err != nil {
4764+ return nil , err
4765+ }
4766+ return & resp , nil
4767+ }
4768+
4769+ // DeleteWebsite: Delete a website from a webhosting.
4770+ func (s * WebsiteAPI ) DeleteWebsite (req * WebsiteAPIDeleteWebsiteRequest , opts ... scw.RequestOption ) error {
4771+ var err error
4772+
4773+ if req .Region == "" {
4774+ defaultRegion , _ := s .client .GetDefaultRegion ()
4775+ req .Region = defaultRegion
4776+ }
4777+
4778+ if fmt .Sprint (req .Region ) == "" {
4779+ return errors .New ("field Region cannot be empty in request" )
4780+ }
4781+
4782+ if fmt .Sprint (req .HostingID ) == "" {
4783+ return errors .New ("field HostingID cannot be empty in request" )
4784+ }
4785+
4786+ if fmt .Sprint (req .DomainName ) == "" {
4787+ return errors .New ("field DomainName cannot be empty in request" )
4788+ }
4789+
4790+ scwReq := & scw.ScalewayRequest {
4791+ Method : "DELETE" ,
4792+ Path : "/webhosting/v1/regions/" + fmt .Sprint (req .Region ) + "/hostings/" + fmt .Sprint (req .HostingID ) + "/websites/" + fmt .Sprint (req .DomainName ) + "" ,
4793+ }
4794+
4795+ err = s .client .Do (scwReq , nil , opts ... )
4796+ if err != nil {
4797+ return err
4798+ }
4799+ return nil
4800+ }
0 commit comments