@@ -1989,6 +1989,18 @@ type Hosting struct {
19891989 DomainInfo * HostingDomain `json:"domain_info"`
19901990}
19911991
1992+ // HostingAPIAddCustomDomainRequest: hosting api add custom domain request.
1993+ type HostingAPIAddCustomDomainRequest struct {
1994+ // Region: region to target. If none is passed will use default region from the config.
1995+ Region scw.Region `json:"-"`
1996+
1997+ // HostingID: hosting ID to which the custom domain is attached to.
1998+ HostingID string `json:"-"`
1999+
2000+ // DomainName: the custom domain name to attach to the hosting.
2001+ DomainName string `json:"domain_name"`
2002+ }
2003+
19922004// HostingAPICreateHostingRequest: hosting api create hosting request.
19932005type HostingAPICreateHostingRequest struct {
19942006 // Region: region to target. If none is passed will use default region from the config.
@@ -2102,6 +2114,15 @@ type HostingAPIListHostingsRequest struct {
21022114 Subdomain * string `json:"-"`
21032115}
21042116
2117+ // HostingAPIRemoveCustomDomainRequest: hosting api remove custom domain request.
2118+ type HostingAPIRemoveCustomDomainRequest struct {
2119+ // Region: region to target. If none is passed will use default region from the config.
2120+ Region scw.Region `json:"-"`
2121+
2122+ // HostingID: hosting ID to which the custom domain is detached from.
2123+ HostingID string `json:"-"`
2124+ }
2125+
21052126// HostingAPIResetHostingPasswordRequest: hosting api reset hosting password request.
21062127type HostingAPIResetHostingPasswordRequest struct {
21072128 // Region: region to target. If none is passed will use default region from the config.
@@ -3816,6 +3837,78 @@ func (s *HostingAPI) GetResourceSummary(req *HostingAPIGetResourceSummaryRequest
38163837 return & resp , nil
38173838}
38183839
3840+ // AddCustomDomain: Attach a custom domain to a webhosting.
3841+ func (s * HostingAPI ) AddCustomDomain (req * HostingAPIAddCustomDomainRequest , opts ... scw.RequestOption ) (* HostingSummary , error ) {
3842+ var err error
3843+
3844+ if req .Region == "" {
3845+ defaultRegion , _ := s .client .GetDefaultRegion ()
3846+ req .Region = defaultRegion
3847+ }
3848+
3849+ if fmt .Sprint (req .Region ) == "" {
3850+ return nil , errors .New ("field Region cannot be empty in request" )
3851+ }
3852+
3853+ if fmt .Sprint (req .HostingID ) == "" {
3854+ return nil , errors .New ("field HostingID cannot be empty in request" )
3855+ }
3856+
3857+ scwReq := & scw.ScalewayRequest {
3858+ Method : "POST" ,
3859+ Path : "/webhosting/v1/regions/" + fmt .Sprint (req .Region ) + "/hostings/" + fmt .Sprint (req .HostingID ) + "/add-custom-domain" ,
3860+ }
3861+
3862+ err = scwReq .SetBody (req )
3863+ if err != nil {
3864+ return nil , err
3865+ }
3866+
3867+ var resp HostingSummary
3868+
3869+ err = s .client .Do (scwReq , & resp , opts ... )
3870+ if err != nil {
3871+ return nil , err
3872+ }
3873+ return & resp , nil
3874+ }
3875+
3876+ // RemoveCustomDomain: Detach a custom domain from a webhosting.
3877+ func (s * HostingAPI ) RemoveCustomDomain (req * HostingAPIRemoveCustomDomainRequest , opts ... scw.RequestOption ) (* HostingSummary , error ) {
3878+ var err error
3879+
3880+ if req .Region == "" {
3881+ defaultRegion , _ := s .client .GetDefaultRegion ()
3882+ req .Region = defaultRegion
3883+ }
3884+
3885+ if fmt .Sprint (req .Region ) == "" {
3886+ return nil , errors .New ("field Region cannot be empty in request" )
3887+ }
3888+
3889+ if fmt .Sprint (req .HostingID ) == "" {
3890+ return nil , errors .New ("field HostingID cannot be empty in request" )
3891+ }
3892+
3893+ scwReq := & scw.ScalewayRequest {
3894+ Method : "POST" ,
3895+ Path : "/webhosting/v1/regions/" + fmt .Sprint (req .Region ) + "/hostings/" + fmt .Sprint (req .HostingID ) + "/remove-custom-domain" ,
3896+ }
3897+
3898+ err = scwReq .SetBody (req )
3899+ if err != nil {
3900+ return nil , err
3901+ }
3902+
3903+ var resp HostingSummary
3904+
3905+ err = s .client .Do (scwReq , & resp , opts ... )
3906+ if err != nil {
3907+ return nil , err
3908+ }
3909+ return & resp , nil
3910+ }
3911+
38193912// This API allows you to manage your FTP accounts for your Web Hosting services.
38203913type FtpAccountAPI struct {
38213914 client * scw.Client
0 commit comments