Skip to content

Commit 3844574

Browse files
feat(webhosting): update public v1 hosting message (scaleway#2348)
Co-authored-by: Jonathan R. <[email protected]>
1 parent cdff8a8 commit 3844574

File tree

1 file changed

+132
-91
lines changed

1 file changed

+132
-91
lines changed

api/webhosting/v1/webhosting_sdk.go

Lines changed: 132 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -40,42 +40,42 @@ var (
4040
_ = namegenerator.GetRandomName
4141
)
4242

43-
type HostingDNSStatus string
43+
type DNSRecordsStatus string
4444

4545
const (
46-
HostingDNSStatusUnknownDNSStatus = HostingDNSStatus("unknown_dns_status")
47-
HostingDNSStatusValid = HostingDNSStatus("valid")
48-
HostingDNSStatusInvalid = HostingDNSStatus("invalid")
46+
DNSRecordsStatusUnknownStatus = DNSRecordsStatus("unknown_status")
47+
DNSRecordsStatusValid = DNSRecordsStatus("valid")
48+
DNSRecordsStatusInvalid = DNSRecordsStatus("invalid")
4949
)
5050

51-
func (enum HostingDNSStatus) String() string {
51+
func (enum DNSRecordsStatus) String() string {
5252
if enum == "" {
5353
// return default value if empty
54-
return "unknown_dns_status"
54+
return "unknown_status"
5555
}
5656
return string(enum)
5757
}
5858

59-
func (enum HostingDNSStatus) Values() []HostingDNSStatus {
60-
return []HostingDNSStatus{
61-
"unknown_dns_status",
59+
func (enum DNSRecordsStatus) Values() []DNSRecordsStatus {
60+
return []DNSRecordsStatus{
61+
"unknown_status",
6262
"valid",
6363
"invalid",
6464
}
6565
}
6666

67-
func (enum HostingDNSStatus) MarshalJSON() ([]byte, error) {
67+
func (enum DNSRecordsStatus) MarshalJSON() ([]byte, error) {
6868
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
6969
}
7070

71-
func (enum *HostingDNSStatus) UnmarshalJSON(data []byte) error {
71+
func (enum *DNSRecordsStatus) UnmarshalJSON(data []byte) error {
7272
tmp := ""
7373

7474
if err := json.Unmarshal(data, &tmp); err != nil {
7575
return err
7676
}
7777

78-
*enum = HostingDNSStatus(HostingDNSStatus(tmp).String())
78+
*enum = DNSRecordsStatus(DNSRecordsStatus(tmp).String())
7979
return nil
8080
}
8181

@@ -520,6 +520,54 @@ func (enum *OfferOptionWarning) UnmarshalJSON(data []byte) error {
520520
return nil
521521
}
522522

523+
type PlatformPlatformGroup string
524+
525+
const (
526+
PlatformPlatformGroupUnknownGroup = PlatformPlatformGroup("unknown_group")
527+
PlatformPlatformGroupDefault = PlatformPlatformGroup("default")
528+
PlatformPlatformGroupPremium = PlatformPlatformGroup("premium")
529+
)
530+
531+
func (enum PlatformPlatformGroup) String() string {
532+
if enum == "" {
533+
// return default value if empty
534+
return "unknown_group"
535+
}
536+
return string(enum)
537+
}
538+
539+
func (enum PlatformPlatformGroup) Values() []PlatformPlatformGroup {
540+
return []PlatformPlatformGroup{
541+
"unknown_group",
542+
"default",
543+
"premium",
544+
}
545+
}
546+
547+
func (enum PlatformPlatformGroup) MarshalJSON() ([]byte, error) {
548+
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
549+
}
550+
551+
func (enum *PlatformPlatformGroup) UnmarshalJSON(data []byte) error {
552+
tmp := ""
553+
554+
if err := json.Unmarshal(data, &tmp); err != nil {
555+
return err
556+
}
557+
558+
*enum = PlatformPlatformGroup(PlatformPlatformGroup(tmp).String())
559+
return nil
560+
}
561+
562+
// PlatformControlPanelURLs: platform control panel ur ls.
563+
type PlatformControlPanelURLs struct {
564+
// Dashboard: URL to connect to the hosting control panel dashboard.
565+
Dashboard string `json:"dashboard"`
566+
567+
// Webmail: URL to connect to the hosting Webmail interface.
568+
Webmail string `json:"webmail"`
569+
}
570+
523571
// OfferOption: offer option.
524572
type OfferOption struct {
525573
// ID: option ID.
@@ -546,6 +594,15 @@ type OfferOption struct {
546594
QuotaWarning OfferOptionWarning `json:"quota_warning"`
547595
}
548596

597+
// PlatformControlPanel: platform control panel.
598+
type PlatformControlPanel struct {
599+
// Name: name of the control panel.
600+
Name string `json:"name"`
601+
602+
// URLs: URL to connect to cPanel dashboard and to Webmail interface.
603+
URLs *PlatformControlPanelURLs `json:"urls"`
604+
}
605+
549606
// CreateHostingRequestDomainConfiguration: create hosting request domain configuration.
550607
type CreateHostingRequestDomainConfiguration struct {
551608
UpdateNameservers bool `json:"update_nameservers"`
@@ -566,24 +623,62 @@ type OfferOptionRequest struct {
566623
Quantity int64 `json:"quantity"`
567624
}
568625

569-
// HostingCpanelURLs: hosting cpanel ur ls.
570-
type HostingCpanelURLs struct {
571-
Dashboard string `json:"dashboard"`
626+
// HostingUser: hosting user.
627+
type HostingUser struct {
628+
// Username: main Web Hosting cPanel username.
629+
Username string `json:"username"`
572630

573-
Webmail string `json:"webmail"`
631+
// OneTimePassword: one-time-password used for the first login or reset password, empty after first use.
632+
OneTimePassword *string `json:"one_time_password"`
633+
634+
// ContactEmail: contact email used for the hosting.
635+
ContactEmail string `json:"contact_email"`
574636
}
575637

576-
// HostingOption: hosting option.
577-
type HostingOption struct {
578-
// ID: option ID.
638+
// Offer: offer.
639+
type Offer struct {
640+
// ID: offer ID.
579641
ID string `json:"id"`
580642

581-
// Name: option name.
582-
// Default value: unknown_name
583-
Name OfferOptionName `json:"name"`
643+
// BillingOperationPath: unique identifier used for billing.
644+
BillingOperationPath string `json:"billing_operation_path"`
645+
646+
// Options: options available for the offer.
647+
Options []*OfferOption `json:"options"`
584648

585-
// Quantity: option quantity.
586-
Quantity int32 `json:"quantity"`
649+
// Price: price of the offer.
650+
Price *scw.Money `json:"price"`
651+
652+
// Available: if a hosting_id was specified in the call, defines whether the offer is available for a specified hosting plan to migrate (update) to.
653+
Available bool `json:"available"`
654+
655+
// ControlPanelName: name of the control panel.
656+
ControlPanelName string `json:"control_panel_name"`
657+
658+
// EndOfLife: indicates if the offer has reached its end of life.
659+
EndOfLife bool `json:"end_of_life"`
660+
}
661+
662+
// Platform: platform.
663+
type Platform struct {
664+
// Hostname: hostname of the host platform.
665+
Hostname string `json:"hostname"`
666+
667+
// Number: number of the host platform.
668+
Number int32 `json:"number"`
669+
670+
// GroupName: group name of the hosting's host platform.
671+
// Default value: unknown_group
672+
GroupName PlatformPlatformGroup `json:"group_name"`
673+
674+
// IPv4: iPv4 address of the hosting's host platform.
675+
IPv4 net.IP `json:"ipv4"`
676+
677+
// IPv6: iPv6 address of the hosting's host platform.
678+
IPv6 net.IP `json:"ipv6"`
679+
680+
// ControlPanel: details of the platform control panel.
681+
ControlPanel *PlatformControlPanel `json:"control_panel"`
587682
}
588683

589684
// ControlPanel: control panel.
@@ -665,30 +760,6 @@ type MailAccount struct {
665760
Username string `json:"username"`
666761
}
667762

668-
// Offer: offer.
669-
type Offer struct {
670-
// ID: offer ID.
671-
ID string `json:"id"`
672-
673-
// BillingOperationPath: unique identifier used for billing.
674-
BillingOperationPath string `json:"billing_operation_path"`
675-
676-
// Options: options available for the offer.
677-
Options []*OfferOption `json:"options"`
678-
679-
// Price: price of the offer.
680-
Price *scw.Money `json:"price"`
681-
682-
// Available: if a hosting_id was specified in the call, defines whether the offer is available for a specified hosting plan to migrate (update) to.
683-
Available bool `json:"available"`
684-
685-
// ControlPanelName: name of the control panel.
686-
ControlPanelName string `json:"control_panel_name"`
687-
688-
// EndOfLife: indicates if the offer has reached its end of life.
689-
EndOfLife bool `json:"end_of_life"`
690-
}
691-
692763
// Website: website.
693764
type Website struct {
694765
// Domain: the domain of the website.
@@ -956,60 +1027,30 @@ type Hosting struct {
9561027
// Default value: unknown_status
9571028
Status HostingStatus `json:"status"`
9581029

959-
// PlatformHostname: hostname of the host platform.
960-
PlatformHostname string `json:"platform_hostname"`
961-
962-
// PlatformNumber: number of the host platform.
963-
PlatformNumber int32 `json:"platform_number"`
964-
965-
// OfferID: ID of the active offer for the Web Hosting plan.
966-
OfferID string `json:"offer_id"`
967-
968-
// OfferName: name of the active offer for the Web Hosting plan.
969-
OfferName string `json:"offer_name"`
970-
9711030
// Domain: main domain associated with the Web Hosting plan.
9721031
Domain string `json:"domain"`
9731032

1033+
// Offer: details of the Web Hosting plan offer and options.
1034+
Offer *Offer `json:"offer"`
1035+
1036+
// Platform: details of the hosting platform.
1037+
Platform *Platform `json:"platform"`
1038+
9741039
// Tags: list of tags associated with the Web Hosting plan.
9751040
Tags []string `json:"tags"`
9761041

977-
// Options: list of the Web Hosting plan options.
978-
Options []*HostingOption `json:"options"`
979-
9801042
// DNSStatus: DNS status of the Web Hosting plan.
981-
// Default value: unknown_dns_status
982-
DNSStatus HostingDNSStatus `json:"dns_status"`
983-
984-
// CpanelURLs: URL to connect to cPanel dashboard and to Webmail interface.
985-
CpanelURLs *HostingCpanelURLs `json:"cpanel_urls"`
986-
987-
// Username: main Web Hosting cPanel username.
988-
Username string `json:"username"`
989-
990-
// OfferEndOfLife: indicates if the hosting offer has reached its end of life.
991-
OfferEndOfLife bool `json:"offer_end_of_life"`
992-
993-
// ControlPanelName: name of the control panel.
994-
ControlPanelName string `json:"control_panel_name"`
995-
996-
// PlatformGroup: group of the hosting's host server/platform.
997-
PlatformGroup string `json:"platform_group"`
998-
999-
// IPv4: iPv4 address of the hosting's host server.
1000-
IPv4 string `json:"ipv4"`
1043+
// Default value: unknown_status
1044+
DNSStatus DNSRecordsStatus `json:"dns_status"`
10011045

1002-
// IPv6: iPv6 address of the hosting's host server.
1003-
IPv6 string `json:"ipv6"`
1046+
// IPv4: current IPv4 address of the hosting.
1047+
IPv4 net.IP `json:"ipv4"`
10041048

10051049
// Protected: whether the hosting is protected or not.
10061050
Protected bool `json:"protected"`
10071051

1008-
// OneTimePassword: one-time-password used for the first login or reset password, empty after first use.
1009-
OneTimePassword string `json:"one_time_password"`
1010-
1011-
// ContactEmail: contact email used for the hosting.
1012-
ContactEmail string `json:"contact_email"`
1052+
// User: details of the hosting user.
1053+
User *HostingUser `json:"user"`
10131054

10141055
// Region: region where the Web Hosting plan is hosted.
10151056
Region scw.Region `json:"region"`
@@ -2067,7 +2108,7 @@ func NewHostingAPI(client *scw.Client) *HostingAPI {
20672108
}
20682109
}
20692110
func (s *HostingAPI) Regions() []scw.Region {
2070-
return []scw.Region{scw.RegionFrPar, scw.RegionNlAms}
2111+
return []scw.Region{scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw}
20712112
}
20722113

20732114
// CreateHosting: Order a Web Hosting plan, specifying the offer type required via the `offer_id` parameter.

0 commit comments

Comments
 (0)