1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package cloudsearchdomain
4
5import (
6	"context"
7	"fmt"
8	smithy "github.com/aws/smithy-go"
9	"github.com/aws/smithy-go/middleware"
10)
11
12type validateOpSearch struct {
13}
14
15func (*validateOpSearch) ID() string {
16	return "OperationInputValidation"
17}
18
19func (m *validateOpSearch) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
20	out middleware.InitializeOutput, metadata middleware.Metadata, err error,
21) {
22	input, ok := in.Parameters.(*SearchInput)
23	if !ok {
24		return out, metadata, fmt.Errorf("unknown input parameters type %T", in.Parameters)
25	}
26	if err := validateOpSearchInput(input); err != nil {
27		return out, metadata, err
28	}
29	return next.HandleInitialize(ctx, in)
30}
31
32type validateOpSuggest struct {
33}
34
35func (*validateOpSuggest) ID() string {
36	return "OperationInputValidation"
37}
38
39func (m *validateOpSuggest) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
40	out middleware.InitializeOutput, metadata middleware.Metadata, err error,
41) {
42	input, ok := in.Parameters.(*SuggestInput)
43	if !ok {
44		return out, metadata, fmt.Errorf("unknown input parameters type %T", in.Parameters)
45	}
46	if err := validateOpSuggestInput(input); err != nil {
47		return out, metadata, err
48	}
49	return next.HandleInitialize(ctx, in)
50}
51
52type validateOpUploadDocuments struct {
53}
54
55func (*validateOpUploadDocuments) ID() string {
56	return "OperationInputValidation"
57}
58
59func (m *validateOpUploadDocuments) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
60	out middleware.InitializeOutput, metadata middleware.Metadata, err error,
61) {
62	input, ok := in.Parameters.(*UploadDocumentsInput)
63	if !ok {
64		return out, metadata, fmt.Errorf("unknown input parameters type %T", in.Parameters)
65	}
66	if err := validateOpUploadDocumentsInput(input); err != nil {
67		return out, metadata, err
68	}
69	return next.HandleInitialize(ctx, in)
70}
71
72func addOpSearchValidationMiddleware(stack *middleware.Stack) error {
73	return stack.Initialize.Add(&validateOpSearch{}, middleware.After)
74}
75
76func addOpSuggestValidationMiddleware(stack *middleware.Stack) error {
77	return stack.Initialize.Add(&validateOpSuggest{}, middleware.After)
78}
79
80func addOpUploadDocumentsValidationMiddleware(stack *middleware.Stack) error {
81	return stack.Initialize.Add(&validateOpUploadDocuments{}, middleware.After)
82}
83
84func validateOpSearchInput(v *SearchInput) error {
85	if v == nil {
86		return nil
87	}
88	invalidParams := smithy.InvalidParamsError{Context: "SearchInput"}
89	if v.Query == nil {
90		invalidParams.Add(smithy.NewErrParamRequired("Query"))
91	}
92	if invalidParams.Len() > 0 {
93		return invalidParams
94	} else {
95		return nil
96	}
97}
98
99func validateOpSuggestInput(v *SuggestInput) error {
100	if v == nil {
101		return nil
102	}
103	invalidParams := smithy.InvalidParamsError{Context: "SuggestInput"}
104	if v.Query == nil {
105		invalidParams.Add(smithy.NewErrParamRequired("Query"))
106	}
107	if v.Suggester == nil {
108		invalidParams.Add(smithy.NewErrParamRequired("Suggester"))
109	}
110	if invalidParams.Len() > 0 {
111		return invalidParams
112	} else {
113		return nil
114	}
115}
116
117func validateOpUploadDocumentsInput(v *UploadDocumentsInput) error {
118	if v == nil {
119		return nil
120	}
121	invalidParams := smithy.InvalidParamsError{Context: "UploadDocumentsInput"}
122	if v.Documents == nil {
123		invalidParams.Add(smithy.NewErrParamRequired("Documents"))
124	}
125	if len(v.ContentType) == 0 {
126		invalidParams.Add(smithy.NewErrParamRequired("ContentType"))
127	}
128	if invalidParams.Len() > 0 {
129		return invalidParams
130	} else {
131		return nil
132	}
133}
134