@@ -485,6 +485,51 @@ func (enum *ListWebhooksRequestOrderBy) UnmarshalJSON(data []byte) error {
485485return nil
486486}
487487
488+ type ProjectSettingsPeriodicReportFrequency string
489+
490+ const (
491+ // If unspecified, the frequency is unknown by default.
492+ ProjectSettingsPeriodicReportFrequencyUnknownFrequency = ProjectSettingsPeriodicReportFrequency ("unknown_frequency" )
493+ // The periodic report is sent once a month.
494+ ProjectSettingsPeriodicReportFrequencyMonthly = ProjectSettingsPeriodicReportFrequency ("monthly" )
495+ // The periodic report is sent once a week.
496+ ProjectSettingsPeriodicReportFrequencyWeekly = ProjectSettingsPeriodicReportFrequency ("weekly" )
497+ // The periodic report is sent once a day.
498+ ProjectSettingsPeriodicReportFrequencyDaily = ProjectSettingsPeriodicReportFrequency ("daily" )
499+ )
500+
501+ func (enum ProjectSettingsPeriodicReportFrequency ) String () string {
502+ if enum == "" {
503+ // return default value if empty
504+ return "unknown_frequency"
505+ }
506+ return string (enum )
507+ }
508+
509+ func (enum ProjectSettingsPeriodicReportFrequency ) Values () []ProjectSettingsPeriodicReportFrequency {
510+ return []ProjectSettingsPeriodicReportFrequency {
511+ "unknown_frequency" ,
512+ "monthly" ,
513+ "weekly" ,
514+ "daily" ,
515+ }
516+ }
517+
518+ func (enum ProjectSettingsPeriodicReportFrequency ) MarshalJSON () ([]byte , error ) {
519+ return []byte (fmt .Sprintf (`"%s"` , enum )), nil
520+ }
521+
522+ func (enum * ProjectSettingsPeriodicReportFrequency ) UnmarshalJSON (data []byte ) error {
523+ tmp := ""
524+
525+ if err := json .Unmarshal (data , & tmp ); err != nil {
526+ return err
527+ }
528+
529+ * enum = ProjectSettingsPeriodicReportFrequency (ProjectSettingsPeriodicReportFrequency (tmp ).String ())
530+ return nil
531+ }
532+
488533type WebhookEventStatus string
489534
490535const (
@@ -886,6 +931,38 @@ type Webhook struct {
886931UpdatedAt * time.Time `json:"updated_at"`
887932}
888933
934+ // ProjectSettingsPeriodicReport: project settings periodic report.
935+ type ProjectSettingsPeriodicReport struct {
936+ // Enabled: enable or disable periodic report notifications.
937+ Enabled bool `json:"enabled"`
938+
939+ // Frequency: at which frequency you receive periodic report notifications.
940+ // Default value: unknown_frequency
941+ Frequency ProjectSettingsPeriodicReportFrequency `json:"frequency"`
942+
943+ // SendingHour: at which hour you receive periodic report notifications.
944+ SendingHour uint32 `json:"sending_hour"`
945+
946+ // SendingDay: on which day you receive periodic report notifications (1-7 weekly, 1-28 monthly).
947+ SendingDay uint32 `json:"sending_day"`
948+ }
949+
950+ // UpdateProjectSettingsRequestUpdatePeriodicReport: update project settings request update periodic report.
951+ type UpdateProjectSettingsRequestUpdatePeriodicReport struct {
952+ // Enabled: (Optional) Enable or disable periodic report notifications.
953+ Enabled * bool `json:"enabled"`
954+
955+ // Frequency: (Optional) At which frequency you receive periodic report notifications.
956+ // Default value: unknown_frequency
957+ Frequency * ProjectSettingsPeriodicReportFrequency `json:"frequency"`
958+
959+ // SendingHour: (Optional) At which hour you receive periodic report notifications.
960+ SendingHour * uint32 `json:"sending_hour"`
961+
962+ // SendingDay: (Optional) On which day you receive periodic report notifications (1-7 weekly, 1-28 monthly).
963+ SendingDay * uint32 `json:"sending_day"`
964+ }
965+
889966// CancelEmailRequest: cancel email request.
890967type CancelEmailRequest struct {
891968// Region: region to target. If none is passed will use default region from the config.
@@ -1042,6 +1119,15 @@ type GetEmailRequest struct {
10421119EmailID string `json:"-"`
10431120}
10441121
1122+ // GetProjectSettingsRequest: get project settings request.
1123+ type GetProjectSettingsRequest struct {
1124+ // Region: region to target. If none is passed will use default region from the config.
1125+ Region scw.Region `json:"-"`
1126+
1127+ // ProjectID: ID of the project.
1128+ ProjectID string `json:"-"`
1129+ }
1130+
10451131// GetStatisticsRequest: get statistics request.
10461132type GetStatisticsRequest struct {
10471133// Region: region to target. If none is passed will use default region from the config.
@@ -1320,6 +1406,12 @@ func (r *ListWebhooksResponse) UnsafeAppend(res interface{}) (uint64, error) {
13201406return uint64 (len (results .Webhooks )), nil
13211407}
13221408
1409+ // ProjectSettings: project settings.
1410+ type ProjectSettings struct {
1411+ // PeriodicReport: information about your periodic report.
1412+ PeriodicReport * ProjectSettingsPeriodicReport `json:"periodic_report"`
1413+ }
1414+
13231415// RevokeDomainRequest: revoke domain request.
13241416type RevokeDomainRequest struct {
13251417// Region: region to target. If none is passed will use default region from the config.
@@ -1362,6 +1454,18 @@ type UpdateDomainRequest struct {
13621454Autoconfig * bool `json:"autoconfig,omitempty"`
13631455}
13641456
1457+ // UpdateProjectSettingsRequest: update project settings request.
1458+ type UpdateProjectSettingsRequest struct {
1459+ // Region: region to target. If none is passed will use default region from the config.
1460+ Region scw.Region `json:"-"`
1461+
1462+ // ProjectID: ID of the project.
1463+ ProjectID string `json:"-"`
1464+
1465+ // PeriodicReport: periodic report update details - all fields are optional.
1466+ PeriodicReport * UpdateProjectSettingsRequestUpdatePeriodicReport `json:"periodic_report,omitempty"`
1467+ }
1468+
13651469// UpdateWebhookRequest: update webhook request.
13661470type UpdateWebhookRequest struct {
13671471// Region: region to target. If none is passed will use default region from the config.
@@ -2053,3 +2157,80 @@ func (s *API) ListWebhookEvents(req *ListWebhookEventsRequest, opts ...scw.Reque
20532157}
20542158return & resp , nil
20552159}
2160+
2161+ // GetProjectSettings: Retrieve the project settings including periodic reports.
2162+ func (s * API ) GetProjectSettings (req * GetProjectSettingsRequest , opts ... scw.RequestOption ) (* ProjectSettings , error ) {
2163+ var err error
2164+
2165+ if req .Region == "" {
2166+ defaultRegion , _ := s .client .GetDefaultRegion ()
2167+ req .Region = defaultRegion
2168+ }
2169+
2170+ if req .ProjectID == "" {
2171+ defaultProjectID , _ := s .client .GetDefaultProjectID ()
2172+ req .ProjectID = defaultProjectID
2173+ }
2174+
2175+ if fmt .Sprint (req .Region ) == "" {
2176+ return nil , errors .New ("field Region cannot be empty in request" )
2177+ }
2178+
2179+ if fmt .Sprint (req .ProjectID ) == "" {
2180+ return nil , errors .New ("field ProjectID cannot be empty in request" )
2181+ }
2182+
2183+ scwReq := & scw.ScalewayRequest {
2184+ Method : "GET" ,
2185+ Path : "/transactional-email/v1alpha1/regions/" + fmt .Sprint (req .Region ) + "/project/" + fmt .Sprint (req .ProjectID ) + "/settings" ,
2186+ }
2187+
2188+ var resp ProjectSettings
2189+
2190+ err = s .client .Do (scwReq , & resp , opts ... )
2191+ if err != nil {
2192+ return nil , err
2193+ }
2194+ return & resp , nil
2195+ }
2196+
2197+ // UpdateProjectSettings: Update the project settings including periodic reports.
2198+ func (s * API ) UpdateProjectSettings (req * UpdateProjectSettingsRequest , opts ... scw.RequestOption ) (* ProjectSettings , error ) {
2199+ var err error
2200+
2201+ if req .Region == "" {
2202+ defaultRegion , _ := s .client .GetDefaultRegion ()
2203+ req .Region = defaultRegion
2204+ }
2205+
2206+ if req .ProjectID == "" {
2207+ defaultProjectID , _ := s .client .GetDefaultProjectID ()
2208+ req .ProjectID = defaultProjectID
2209+ }
2210+
2211+ if fmt .Sprint (req .Region ) == "" {
2212+ return nil , errors .New ("field Region cannot be empty in request" )
2213+ }
2214+
2215+ if fmt .Sprint (req .ProjectID ) == "" {
2216+ return nil , errors .New ("field ProjectID cannot be empty in request" )
2217+ }
2218+
2219+ scwReq := & scw.ScalewayRequest {
2220+ Method : "PATCH" ,
2221+ Path : "/transactional-email/v1alpha1/regions/" + fmt .Sprint (req .Region ) + "/project/" + fmt .Sprint (req .ProjectID ) + "/settings" ,
2222+ }
2223+
2224+ err = scwReq .SetBody (req )
2225+ if err != nil {
2226+ return nil , err
2227+ }
2228+
2229+ var resp ProjectSettings
2230+
2231+ err = s .client .Do (scwReq , & resp , opts ... )
2232+ if err != nil {
2233+ return nil , err
2234+ }
2235+ return & resp , nil
2236+ }
0 commit comments