1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package comprehendmedical 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/comprehendmedical/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Starts an asynchronous job to detect protected health information (PHI). Use the 16// DescribePHIDetectionJob operation to track the status of a job. 17func (c *Client) StartPHIDetectionJob(ctx context.Context, params *StartPHIDetectionJobInput, optFns ...func(*Options)) (*StartPHIDetectionJobOutput, error) { 18 if params == nil { 19 params = &StartPHIDetectionJobInput{} 20 } 21 22 result, metadata, err := c.invokeOperation(ctx, "StartPHIDetectionJob", params, optFns, addOperationStartPHIDetectionJobMiddlewares) 23 if err != nil { 24 return nil, err 25 } 26 27 out := result.(*StartPHIDetectionJobOutput) 28 out.ResultMetadata = metadata 29 return out, nil 30} 31 32type StartPHIDetectionJobInput struct { 33 34 // The Amazon Resource Name (ARN) of the AWS Identity and Access Management (IAM) 35 // role that grants Amazon Comprehend Medical read access to your input data. For 36 // more information, see Role-Based Permissions Required for Asynchronous 37 // Operations 38 // (https://docs.aws.amazon.com/comprehend/latest/dg/access-control-managing-permissions-med.html#auth-role-permissions-med). 39 // 40 // This member is required. 41 DataAccessRoleArn *string 42 43 // Specifies the format and location of the input data for the job. 44 // 45 // This member is required. 46 InputDataConfig *types.InputDataConfig 47 48 // The language of the input documents. All documents must be in the same language. 49 // 50 // This member is required. 51 LanguageCode types.LanguageCode 52 53 // Specifies where to send the output files. 54 // 55 // This member is required. 56 OutputDataConfig *types.OutputDataConfig 57 58 // A unique identifier for the request. If you don't set the client request token, 59 // Amazon Comprehend Medical generates one. 60 ClientRequestToken *string 61 62 // The identifier of the job. 63 JobName *string 64 65 // An AWS Key Management Service key to encrypt your output files. If you do not 66 // specify a key, the files are written in plain text. 67 KMSKey *string 68} 69 70type StartPHIDetectionJobOutput struct { 71 72 // The identifier generated for the job. To get the status of a job, use this 73 // identifier with the DescribePHIDetectionJob operation. 74 JobId *string 75 76 // Metadata pertaining to the operation's result. 77 ResultMetadata middleware.Metadata 78} 79 80func addOperationStartPHIDetectionJobMiddlewares(stack *middleware.Stack, options Options) (err error) { 81 err = stack.Serialize.Add(&awsAwsjson11_serializeOpStartPHIDetectionJob{}, middleware.After) 82 if err != nil { 83 return err 84 } 85 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpStartPHIDetectionJob{}, middleware.After) 86 if err != nil { 87 return err 88 } 89 if err = addSetLoggerMiddleware(stack, options); err != nil { 90 return err 91 } 92 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 93 return err 94 } 95 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 96 return err 97 } 98 if err = addResolveEndpointMiddleware(stack, options); err != nil { 99 return err 100 } 101 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 102 return err 103 } 104 if err = addRetryMiddlewares(stack, options); err != nil { 105 return err 106 } 107 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 108 return err 109 } 110 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 111 return err 112 } 113 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 114 return err 115 } 116 if err = addClientUserAgent(stack); err != nil { 117 return err 118 } 119 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 120 return err 121 } 122 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 123 return err 124 } 125 if err = addIdempotencyToken_opStartPHIDetectionJobMiddleware(stack, options); err != nil { 126 return err 127 } 128 if err = addOpStartPHIDetectionJobValidationMiddleware(stack); err != nil { 129 return err 130 } 131 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opStartPHIDetectionJob(options.Region), middleware.Before); err != nil { 132 return err 133 } 134 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 135 return err 136 } 137 if err = addResponseErrorMiddleware(stack); err != nil { 138 return err 139 } 140 if err = addRequestResponseLogging(stack, options); err != nil { 141 return err 142 } 143 return nil 144} 145 146type idempotencyToken_initializeOpStartPHIDetectionJob struct { 147 tokenProvider IdempotencyTokenProvider 148} 149 150func (*idempotencyToken_initializeOpStartPHIDetectionJob) ID() string { 151 return "OperationIdempotencyTokenAutoFill" 152} 153 154func (m *idempotencyToken_initializeOpStartPHIDetectionJob) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( 155 out middleware.InitializeOutput, metadata middleware.Metadata, err error, 156) { 157 if m.tokenProvider == nil { 158 return next.HandleInitialize(ctx, in) 159 } 160 161 input, ok := in.Parameters.(*StartPHIDetectionJobInput) 162 if !ok { 163 return out, metadata, fmt.Errorf("expected middleware input to be of type *StartPHIDetectionJobInput ") 164 } 165 166 if input.ClientRequestToken == nil { 167 t, err := m.tokenProvider.GetIdempotencyToken() 168 if err != nil { 169 return out, metadata, err 170 } 171 input.ClientRequestToken = &t 172 } 173 return next.HandleInitialize(ctx, in) 174} 175func addIdempotencyToken_opStartPHIDetectionJobMiddleware(stack *middleware.Stack, cfg Options) error { 176 return stack.Initialize.Add(&idempotencyToken_initializeOpStartPHIDetectionJob{tokenProvider: cfg.IdempotencyTokenProvider}, middleware.Before) 177} 178 179func newServiceMetadataMiddleware_opStartPHIDetectionJob(region string) *awsmiddleware.RegisterServiceMetadata { 180 return &awsmiddleware.RegisterServiceMetadata{ 181 Region: region, 182 ServiceID: ServiceID, 183 SigningName: "comprehendmedical", 184 OperationName: "StartPHIDetectionJob", 185 } 186} 187