1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package alexaforbusiness 4 5import ( 6 "context" 7 "fmt" 8 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 9 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 10 "github.com/aws/aws-sdk-go-v2/service/alexaforbusiness/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Creates a recurring schedule for usage reports to deliver to the specified S3 16// location with a specified daily or weekly interval. 17func (c *Client) CreateBusinessReportSchedule(ctx context.Context, params *CreateBusinessReportScheduleInput, optFns ...func(*Options)) (*CreateBusinessReportScheduleOutput, error) { 18 if params == nil { 19 params = &CreateBusinessReportScheduleInput{} 20 } 21 22 result, metadata, err := c.invokeOperation(ctx, "CreateBusinessReportSchedule", params, optFns, addOperationCreateBusinessReportScheduleMiddlewares) 23 if err != nil { 24 return nil, err 25 } 26 27 out := result.(*CreateBusinessReportScheduleOutput) 28 out.ResultMetadata = metadata 29 return out, nil 30} 31 32type CreateBusinessReportScheduleInput struct { 33 34 // The content range of the reports. 35 // 36 // This member is required. 37 ContentRange *types.BusinessReportContentRange 38 39 // The format of the generated report (individual CSV files or zipped files of 40 // individual files). 41 // 42 // This member is required. 43 Format types.BusinessReportFormat 44 45 // The client request token. 46 ClientRequestToken *string 47 48 // The recurrence of the reports. If this isn't specified, the report will only be 49 // delivered one time when the API is called. 50 Recurrence *types.BusinessReportRecurrence 51 52 // The S3 bucket name of the output reports. If this isn't specified, the report 53 // can be retrieved from a download link by calling ListBusinessReportSchedule. 54 S3BucketName *string 55 56 // The S3 key where the report is delivered. 57 S3KeyPrefix *string 58 59 // The name identifier of the schedule. 60 ScheduleName *string 61 62 // The tags for the business report schedule. 63 Tags []types.Tag 64} 65 66type CreateBusinessReportScheduleOutput struct { 67 68 // The ARN of the business report schedule. 69 ScheduleArn *string 70 71 // Metadata pertaining to the operation's result. 72 ResultMetadata middleware.Metadata 73} 74 75func addOperationCreateBusinessReportScheduleMiddlewares(stack *middleware.Stack, options Options) (err error) { 76 err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateBusinessReportSchedule{}, middleware.After) 77 if err != nil { 78 return err 79 } 80 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateBusinessReportSchedule{}, middleware.After) 81 if err != nil { 82 return err 83 } 84 if err = addSetLoggerMiddleware(stack, options); err != nil { 85 return err 86 } 87 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 88 return err 89 } 90 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 91 return err 92 } 93 if err = addResolveEndpointMiddleware(stack, options); err != nil { 94 return err 95 } 96 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 97 return err 98 } 99 if err = addRetryMiddlewares(stack, options); err != nil { 100 return err 101 } 102 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 103 return err 104 } 105 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 106 return err 107 } 108 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 109 return err 110 } 111 if err = addClientUserAgent(stack); err != nil { 112 return err 113 } 114 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 115 return err 116 } 117 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 118 return err 119 } 120 if err = addIdempotencyToken_opCreateBusinessReportScheduleMiddleware(stack, options); err != nil { 121 return err 122 } 123 if err = addOpCreateBusinessReportScheduleValidationMiddleware(stack); err != nil { 124 return err 125 } 126 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateBusinessReportSchedule(options.Region), middleware.Before); err != nil { 127 return err 128 } 129 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 130 return err 131 } 132 if err = addResponseErrorMiddleware(stack); err != nil { 133 return err 134 } 135 if err = addRequestResponseLogging(stack, options); err != nil { 136 return err 137 } 138 return nil 139} 140 141type idempotencyToken_initializeOpCreateBusinessReportSchedule struct { 142 tokenProvider IdempotencyTokenProvider 143} 144 145func (*idempotencyToken_initializeOpCreateBusinessReportSchedule) ID() string { 146 return "OperationIdempotencyTokenAutoFill" 147} 148 149func (m *idempotencyToken_initializeOpCreateBusinessReportSchedule) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( 150 out middleware.InitializeOutput, metadata middleware.Metadata, err error, 151) { 152 if m.tokenProvider == nil { 153 return next.HandleInitialize(ctx, in) 154 } 155 156 input, ok := in.Parameters.(*CreateBusinessReportScheduleInput) 157 if !ok { 158 return out, metadata, fmt.Errorf("expected middleware input to be of type *CreateBusinessReportScheduleInput ") 159 } 160 161 if input.ClientRequestToken == nil { 162 t, err := m.tokenProvider.GetIdempotencyToken() 163 if err != nil { 164 return out, metadata, err 165 } 166 input.ClientRequestToken = &t 167 } 168 return next.HandleInitialize(ctx, in) 169} 170func addIdempotencyToken_opCreateBusinessReportScheduleMiddleware(stack *middleware.Stack, cfg Options) error { 171 return stack.Initialize.Add(&idempotencyToken_initializeOpCreateBusinessReportSchedule{tokenProvider: cfg.IdempotencyTokenProvider}, middleware.Before) 172} 173 174func newServiceMetadataMiddleware_opCreateBusinessReportSchedule(region string) *awsmiddleware.RegisterServiceMetadata { 175 return &awsmiddleware.RegisterServiceMetadata{ 176 Region: region, 177 ServiceID: ServiceID, 178 SigningName: "a4b", 179 OperationName: "CreateBusinessReportSchedule", 180 } 181} 182