@@ -972,6 +972,91 @@ func (usageReports *UsageReportsV4) DeleteReportsSnapshotConfigWithContext(ctx c
972
972
return
973
973
}
974
974
975
+ // ValidateReportsSnapshotConfig : Verify billing to COS authorization
976
+ // Verify billing service to COS bucket authorization for the given account_id. If COS bucket information is not
977
+ // provided, COS bucket information is retrieved from the configuration file.
978
+ func (usageReports * UsageReportsV4 ) ValidateReportsSnapshotConfig (validateReportsSnapshotConfigOptions * ValidateReportsSnapshotConfigOptions ) (result * SnapshotConfigValidateResponse , response * core.DetailedResponse , err error ) {
979
+ return usageReports .ValidateReportsSnapshotConfigWithContext (context .Background (), validateReportsSnapshotConfigOptions )
980
+ }
981
+
982
+ // ValidateReportsSnapshotConfigWithContext is an alternate form of the ValidateReportsSnapshotConfig method which supports a Context parameter
983
+ func (usageReports * UsageReportsV4 ) ValidateReportsSnapshotConfigWithContext (ctx context.Context , validateReportsSnapshotConfigOptions * ValidateReportsSnapshotConfigOptions ) (result * SnapshotConfigValidateResponse , response * core.DetailedResponse , err error ) {
984
+ err = core .ValidateNotNil (validateReportsSnapshotConfigOptions , "validateReportsSnapshotConfigOptions cannot be nil" )
985
+ if err != nil {
986
+ return
987
+ }
988
+ err = core .ValidateStruct (validateReportsSnapshotConfigOptions , "validateReportsSnapshotConfigOptions" )
989
+ if err != nil {
990
+ return
991
+ }
992
+
993
+ builder := core .NewRequestBuilder (core .POST )
994
+ builder = builder .WithContext (ctx )
995
+ builder .EnableGzipCompression = usageReports .GetEnableGzipCompression ()
996
+ _ , err = builder .ResolveRequestURL (usageReports .Service .Options .URL , `/v1/billing-reports-snapshot-config/validate` , nil )
997
+ if err != nil {
998
+ return
999
+ }
1000
+
1001
+ for headerName , headerValue := range validateReportsSnapshotConfigOptions .Headers {
1002
+ builder .AddHeader (headerName , headerValue )
1003
+ }
1004
+
1005
+ sdkHeaders := common .GetSdkHeaders ("usage_reports" , "V4" , "ValidateReportsSnapshotConfig" )
1006
+ for headerName , headerValue := range sdkHeaders {
1007
+ builder .AddHeader (headerName , headerValue )
1008
+ }
1009
+ builder .AddHeader ("Accept" , "application/json" )
1010
+ builder .AddHeader ("Content-Type" , "application/json" )
1011
+
1012
+ body := make (map [string ]interface {})
1013
+ if validateReportsSnapshotConfigOptions .AccountID != nil {
1014
+ body ["account_id" ] = validateReportsSnapshotConfigOptions .AccountID
1015
+ }
1016
+ if validateReportsSnapshotConfigOptions .Interval != nil {
1017
+ body ["interval" ] = validateReportsSnapshotConfigOptions .Interval
1018
+ }
1019
+ if validateReportsSnapshotConfigOptions .CosBucket != nil {
1020
+ body ["cos_bucket" ] = validateReportsSnapshotConfigOptions .CosBucket
1021
+ }
1022
+ if validateReportsSnapshotConfigOptions .CosLocation != nil {
1023
+ body ["cos_location" ] = validateReportsSnapshotConfigOptions .CosLocation
1024
+ }
1025
+ if validateReportsSnapshotConfigOptions .CosReportsFolder != nil {
1026
+ body ["cos_reports_folder" ] = validateReportsSnapshotConfigOptions .CosReportsFolder
1027
+ }
1028
+ if validateReportsSnapshotConfigOptions .ReportTypes != nil {
1029
+ body ["report_types" ] = validateReportsSnapshotConfigOptions .ReportTypes
1030
+ }
1031
+ if validateReportsSnapshotConfigOptions .Versioning != nil {
1032
+ body ["versioning" ] = validateReportsSnapshotConfigOptions .Versioning
1033
+ }
1034
+ _ , err = builder .SetBodyContentJSON (body )
1035
+ if err != nil {
1036
+ return
1037
+ }
1038
+
1039
+ request , err := builder .Build ()
1040
+ if err != nil {
1041
+ return
1042
+ }
1043
+
1044
+ var rawResponse map [string ]json.RawMessage
1045
+ response , err = usageReports .Service .Request (request , & rawResponse )
1046
+ if err != nil {
1047
+ return
1048
+ }
1049
+ if rawResponse != nil {
1050
+ err = core .UnmarshalModel (rawResponse , "" , & result , UnmarshalSnapshotConfigValidateResponse )
1051
+ if err != nil {
1052
+ return
1053
+ }
1054
+ response .Result = result
1055
+ }
1056
+
1057
+ return
1058
+ }
1059
+
975
1060
// GetReportsSnapshot : Fetch the current or past snapshots
976
1061
// Returns the billing reports snapshots captured for the given Account Id in the specific time period.
977
1062
func (usageReports * UsageReportsV4 ) GetReportsSnapshot (getReportsSnapshotOptions * GetReportsSnapshotOptions ) (result * SnapshotList , response * core.DetailedResponse , err error ) {
@@ -3407,6 +3492,37 @@ func UnmarshalSnapshotConfig(m map[string]json.RawMessage, result interface{}) (
3407
3492
return
3408
3493
}
3409
3494
3495
+ // SnapshotConfigValidateResponse : Validated billing service to COS bucket authorization.
3496
+ type SnapshotConfigValidateResponse struct {
3497
+ // Account ID for which billing report snapshot is configured.
3498
+ AccountID * string `json:"account_id,omitempty"`
3499
+
3500
+ // The name of the COS bucket to store the snapshot of the billing reports.
3501
+ CosBucket * string `json:"cos_bucket,omitempty"`
3502
+
3503
+ // Region of the COS instance.
3504
+ CosLocation * string `json:"cos_location,omitempty"`
3505
+ }
3506
+
3507
+ // UnmarshalSnapshotConfigValidateResponse unmarshals an instance of SnapshotConfigValidateResponse from the specified map of raw messages.
3508
+ func UnmarshalSnapshotConfigValidateResponse (m map [string ]json.RawMessage , result interface {}) (err error ) {
3509
+ obj := new (SnapshotConfigValidateResponse )
3510
+ err = core .UnmarshalPrimitive (m , "account_id" , & obj .AccountID )
3511
+ if err != nil {
3512
+ return
3513
+ }
3514
+ err = core .UnmarshalPrimitive (m , "cos_bucket" , & obj .CosBucket )
3515
+ if err != nil {
3516
+ return
3517
+ }
3518
+ err = core .UnmarshalPrimitive (m , "cos_location" , & obj .CosLocation )
3519
+ if err != nil {
3520
+ return
3521
+ }
3522
+ reflect .ValueOf (result ).Elem ().Set (reflect .ValueOf (obj ))
3523
+ return
3524
+ }
3525
+
3410
3526
// Subscription : Subscription struct
3411
3527
type Subscription struct {
3412
3528
// The ID of the subscription.
@@ -3700,6 +3816,111 @@ func (options *UpdateReportsSnapshotConfigOptions) SetHeaders(param map[string]s
3700
3816
return options
3701
3817
}
3702
3818
3819
+ // ValidateReportsSnapshotConfigOptions : The ValidateReportsSnapshotConfig options.
3820
+ type ValidateReportsSnapshotConfigOptions struct {
3821
+ // Account ID for which billing report snapshot is configured.
3822
+ AccountID * string `json:"account_id" validate:"required"`
3823
+
3824
+ // Frequency of taking the snapshot of the billing reports.
3825
+ Interval * string `json:"interval,omitempty"`
3826
+
3827
+ // The name of the COS bucket to store the snapshot of the billing reports.
3828
+ CosBucket * string `json:"cos_bucket,omitempty"`
3829
+
3830
+ // Region of the COS instance.
3831
+ CosLocation * string `json:"cos_location,omitempty"`
3832
+
3833
+ // The billing reports root folder to store the billing reports snapshots. Defaults to "IBMCloud-Billing-Reports".
3834
+ CosReportsFolder * string `json:"cos_reports_folder,omitempty"`
3835
+
3836
+ // The type of billing reports to take snapshot of. Possible values are [account_summary, enterprise_summary,
3837
+ // account_resource_instance_usage].
3838
+ ReportTypes []string `json:"report_types,omitempty"`
3839
+
3840
+ // A new version of report is created or the existing report version is overwritten with every update. Defaults to
3841
+ // "new".
3842
+ Versioning * string `json:"versioning,omitempty"`
3843
+
3844
+ // Allows users to set headers on API requests
3845
+ Headers map [string ]string
3846
+ }
3847
+
3848
+ // Constants associated with the ValidateReportsSnapshotConfigOptions.Interval property.
3849
+ // Frequency of taking the snapshot of the billing reports.
3850
+ const (
3851
+ ValidateReportsSnapshotConfigOptionsIntervalDailyConst = "daily"
3852
+ )
3853
+
3854
+ // Constants associated with the ValidateReportsSnapshotConfigOptions.ReportTypes property.
3855
+ const (
3856
+ ValidateReportsSnapshotConfigOptionsReportTypesAccountResourceInstanceUsageConst = "account_resource_instance_usage"
3857
+ ValidateReportsSnapshotConfigOptionsReportTypesAccountSummaryConst = "account_summary"
3858
+ ValidateReportsSnapshotConfigOptionsReportTypesEnterpriseSummaryConst = "enterprise_summary"
3859
+ )
3860
+
3861
+ // Constants associated with the ValidateReportsSnapshotConfigOptions.Versioning property.
3862
+ // A new version of report is created or the existing report version is overwritten with every update. Defaults to
3863
+ // "new".
3864
+ const (
3865
+ ValidateReportsSnapshotConfigOptionsVersioningNewConst = "new"
3866
+ ValidateReportsSnapshotConfigOptionsVersioningOverwriteConst = "overwrite"
3867
+ )
3868
+
3869
+ // NewValidateReportsSnapshotConfigOptions : Instantiate ValidateReportsSnapshotConfigOptions
3870
+ func (* UsageReportsV4 ) NewValidateReportsSnapshotConfigOptions (accountID string ) * ValidateReportsSnapshotConfigOptions {
3871
+ return & ValidateReportsSnapshotConfigOptions {
3872
+ AccountID : core .StringPtr (accountID ),
3873
+ }
3874
+ }
3875
+
3876
+ // SetAccountID : Allow user to set AccountID
3877
+ func (_options * ValidateReportsSnapshotConfigOptions ) SetAccountID (accountID string ) * ValidateReportsSnapshotConfigOptions {
3878
+ _options .AccountID = core .StringPtr (accountID )
3879
+ return _options
3880
+ }
3881
+
3882
+ // SetInterval : Allow user to set Interval
3883
+ func (_options * ValidateReportsSnapshotConfigOptions ) SetInterval (interval string ) * ValidateReportsSnapshotConfigOptions {
3884
+ _options .Interval = core .StringPtr (interval )
3885
+ return _options
3886
+ }
3887
+
3888
+ // SetCosBucket : Allow user to set CosBucket
3889
+ func (_options * ValidateReportsSnapshotConfigOptions ) SetCosBucket (cosBucket string ) * ValidateReportsSnapshotConfigOptions {
3890
+ _options .CosBucket = core .StringPtr (cosBucket )
3891
+ return _options
3892
+ }
3893
+
3894
+ // SetCosLocation : Allow user to set CosLocation
3895
+ func (_options * ValidateReportsSnapshotConfigOptions ) SetCosLocation (cosLocation string ) * ValidateReportsSnapshotConfigOptions {
3896
+ _options .CosLocation = core .StringPtr (cosLocation )
3897
+ return _options
3898
+ }
3899
+
3900
+ // SetCosReportsFolder : Allow user to set CosReportsFolder
3901
+ func (_options * ValidateReportsSnapshotConfigOptions ) SetCosReportsFolder (cosReportsFolder string ) * ValidateReportsSnapshotConfigOptions {
3902
+ _options .CosReportsFolder = core .StringPtr (cosReportsFolder )
3903
+ return _options
3904
+ }
3905
+
3906
+ // SetReportTypes : Allow user to set ReportTypes
3907
+ func (_options * ValidateReportsSnapshotConfigOptions ) SetReportTypes (reportTypes []string ) * ValidateReportsSnapshotConfigOptions {
3908
+ _options .ReportTypes = reportTypes
3909
+ return _options
3910
+ }
3911
+
3912
+ // SetVersioning : Allow user to set Versioning
3913
+ func (_options * ValidateReportsSnapshotConfigOptions ) SetVersioning (versioning string ) * ValidateReportsSnapshotConfigOptions {
3914
+ _options .Versioning = core .StringPtr (versioning )
3915
+ return _options
3916
+ }
3917
+
3918
+ // SetHeaders : Allow user to set Headers
3919
+ func (options * ValidateReportsSnapshotConfigOptions ) SetHeaders (param map [string ]string ) * ValidateReportsSnapshotConfigOptions {
3920
+ options .Headers = param
3921
+ return options
3922
+ }
3923
+
3703
3924
// GetResourceUsageAccountPager can be used to simplify the use of the "GetResourceUsageAccount" method.
3704
3925
type GetResourceUsageAccountPager struct {
3705
3926
hasNext bool
0 commit comments