diff --git a/.dockerignore b/.dockerignore index 5b7c40ee..2c7b1d54 100644 --- a/.dockerignore +++ b/.dockerignore @@ -40,6 +40,8 @@ mocks/ out/ serviceAPIs/ test/ +docs/ +internal/test/ **/*_test.go Taskfile.yml scripts/ diff --git a/.mockery.yml b/.mockery.yml index 67ff5220..2d14758f 100644 --- a/.mockery.yml +++ b/.mockery.yml @@ -12,3 +12,7 @@ packages: queryorchestration/internal/server/runner: interfaces: Controller: + queryorchestration/pkg/queryService: + interfaces: + ClientWithResponsesInterface: + ClientInterface: diff --git a/api/docInitRunner/runner_test.go b/api/docInitRunner/runner_test.go index 60ef43ed..5fa7c0a0 100644 --- a/api/docInitRunner/runner_test.go +++ b/api/docInitRunner/runner_test.go @@ -48,14 +48,12 @@ func TestDocInitRunner(t *testing.T) { assert.NotNil(t, runner) t.Run("valid", func(t *testing.T) { - j := client.Client{ - ID: uuid.New(), - } + clientId := uuid.New() bucketName := "bucketName" - location := fmt.Sprintf("%s/aaa", j.ID.String()) + location := fmt.Sprintf("%s/aaa", clientId) docinfo := document.Document{ ID: uuid.New(), - ClientID: j.ID, + ClientID: clientId, Hash: "example_hash", } doc := S3EventNotification{ @@ -81,11 +79,11 @@ func TestDocInitRunner(t *testing.T) { Body: &body, } - pool.ExpectQuery("name: GetDocumentIDByHash :one").WithArgs(docinfo.Hash, database.MustToDBUUID(j.ID)).WillReturnRows( + pool.ExpectQuery("name: GetDocumentIDByHash :one").WithArgs(docinfo.Hash, database.MustToDBUUID(clientId)).WillReturnRows( pgxmock.NewRows([]string{"id"}), ) pool.ExpectBegin() - pool.ExpectQuery("name: CreateDocument :one").WithArgs(database.MustToDBUUID(j.ID), docinfo.Hash). + pool.ExpectQuery("name: CreateDocument :one").WithArgs(database.MustToDBUUID(clientId), docinfo.Hash). WillReturnRows( pgxmock.NewRows([]string{"id"}). AddRow(database.MustToDBUUID(docinfo.ID)), diff --git a/api/docSyncRunner/runner_test.go b/api/docSyncRunner/runner_test.go index 9a0cff45..1f28d3c5 100644 --- a/api/docSyncRunner/runner_test.go +++ b/api/docSyncRunner/runner_test.go @@ -76,8 +76,8 @@ func TestDocInitRunner(t *testing.T) { ) pool.ExpectQuery("name: GetClient :one").WithArgs(database.MustToDBUUID(j.ID)). WillReturnRows( - pgxmock.NewRows([]string{"id", "name", "canSync"}). - AddRow(database.MustToDBUUID(j.ID), "client_name", true), + pgxmock.NewRows([]string{"id", "externalId", "name", "canSync"}). + AddRow(database.MustToDBUUID(j.ID), "client_id", "client_name", true), ) mockSQS.EXPECT(). diff --git a/api/queryService/api.gen.go b/api/queryService/api.gen.go index 3747dd1a..fa8f3058 100644 --- a/api/queryService/api.gen.go +++ b/api/queryService/api.gen.go @@ -51,106 +51,139 @@ const ( JSONEXTRACTOR QueryType = "JSON_EXTRACTOR" ) -// ClientCreate defines model for ClientCreate. +// ClientCanSync If the client is allowing active syncs +type ClientCanSync = bool + +// ClientCreate The properties for creation. type ClientCreate struct { + // Id The client external id + Id ClientID `json:"id"` + // Name The client name - Name string `json:"name"` + Name ClientName `json:"name"` } +// ClientID The client external id +type ClientID = string + +// ClientIDBody The client id. +type ClientIDBody struct { + // Id The client external id + Id ClientID `json:"id"` +} + +// ClientName The client name +type ClientName = string + // ClientStatus Specifies the status of a client. type ClientStatus string -// ClientStatusBody defines model for ClientStatusBody. +// ClientStatusBody A client status information object. type ClientStatusBody struct { - // ClientId The client id - ClientId openapi_types.UUID `json:"client_id"` - // Status Specifies the status of a client. Status ClientStatus `json:"status"` } -// ClientUpdate defines model for ClientUpdate. +// ClientUID The client internal unique id +type ClientUID = openapi_types.UUID + +// ClientUpdate The properties that may be updated. type ClientUpdate struct { // CanSync If the client is allowing active syncs - CanSync *bool `json:"can_sync,omitempty"` + CanSync *ClientCanSync `json:"can_sync,omitempty"` // Name The client name - Name *string `json:"name,omitempty"` + Name *ClientName `json:"name,omitempty"` } +// CodeVersion The desired code version. +type CodeVersion = int32 + // Collector Collector model. type Collector struct { - // ActiveVersion The active version of the collector. - ActiveVersion int32 `json:"active_version"` + // ActiveVersion The desired version. + ActiveVersion Version `json:"active_version"` - // ClientId The ID of the associated client. - ClientId openapi_types.UUID `json:"client_id"` + // ClientId The client external id + ClientId ClientID `json:"client_id"` // Fields The fields in the collector. - Fields []CollectorField `json:"fields"` + Fields CollectorFields `json:"fields"` - // LatestVersion The latest version of the collector. - LatestVersion int32 `json:"latest_version"` + // LatestVersion The desired version. + LatestVersion Version `json:"latest_version"` - // MinimumCleanerVersion The minimum version for the document cleaner. - MinimumCleanerVersion int32 `json:"minimum_cleaner_version"` + // MinimumCleanerVersion The desired code version. + MinimumCleanerVersion CodeVersion `json:"minimum_cleaner_version"` - // MinimumTextVersion The minimum version for the text parser. - MinimumTextVersion int32 `json:"minimum_text_version"` + // MinimumTextVersion The desired code version. + MinimumTextVersion CodeVersion `json:"minimum_text_version"` } // CollectorField The field properties for the collector. type CollectorField struct { // Name The output field name. - Name string `json:"name"` + Name CollectorFieldName `json:"name"` - // QueryId The query id that will populate the result. - QueryId openapi_types.UUID `json:"query_id"` + // QueryId The query id. + QueryId QueryID `json:"query_id"` } +// CollectorFieldName The output field name. +type CollectorFieldName = string + +// CollectorFields The fields in the collector. +type CollectorFields = []CollectorField + // CollectorSet Payload for updating a Collector. type CollectorSet struct { - // ActiveVersion The active version of the collector. - ActiveVersion *int32 `json:"active_version,omitempty"` + // ActiveVersion The desired version. + ActiveVersion *Version `json:"active_version,omitempty"` // Fields The fields in the collector. - Fields *[]CollectorField `json:"fields,omitempty"` + Fields *CollectorFields `json:"fields,omitempty"` - // MinimumCleanerVersion The minimum version for the document cleaner. - MinimumCleanerVersion *int32 `json:"minimum_cleaner_version,omitempty"` + // MinimumCleanerVersion The desired code version. + MinimumCleanerVersion *CodeVersion `json:"minimum_cleaner_version,omitempty"` - // MinimumTextVersion The minimum version for the text parser. - MinimumTextVersion *int32 `json:"minimum_text_version,omitempty"` + // MinimumTextVersion The desired code version. + MinimumTextVersion *CodeVersion `json:"minimum_text_version,omitempty"` } -// DocClient defines model for DocClient. +// DocClient The properties of a client. type DocClient struct { // CanSync If the client is allowing active syncs - CanSync bool `json:"can_sync"` + CanSync ClientCanSync `json:"can_sync"` - // Id The client id - Id openapi_types.UUID `json:"id"` + // Id The client external id + Id ClientID `json:"id"` // Name The client name - Name string `json:"name"` + Name ClientName `json:"name"` + + // Uid The client internal unique id + Uid ClientUID `json:"uid"` } -// Document defines model for Document. +// Document The document properties. type Document struct { // Bucket The bucket containing the document Bucket string `json:"bucket"` - // Id The document id - Id openapi_types.UUID `json:"id"` + // Id The document id. + Id DocumentID `json:"id"` // Key The path to the document Key string `json:"key"` } +// DocumentID The document id. +type DocumentID = openapi_types.UUID + // ExportDetails Payload for export trigger response. type ExportDetails struct { - // ClientId The client id relative to the export. - ClientId openapi_types.UUID `json:"client_id"` + // ClientId The client external id + ClientId ClientID `json:"client_id"` // OutputLocation The location in which the export zip file will be found. OutputLocation *string `json:"output_location,omitempty"` @@ -159,6 +192,9 @@ type ExportDetails struct { Status ExportStatus `json:"status"` } +// ExportID The export id. +type ExportID = openapi_types.UUID + // ExportStatus The possible export states. type ExportStatus string @@ -182,8 +218,8 @@ type FieldFilter struct { // Condition The possible field filtering conditions. Condition FieldFilterCondition `json:"condition"` - // FieldName The name of the field in question. - FieldName string `json:"field_name"` + // FieldName The output field name. + FieldName CollectorFieldName `json:"field_name"` // Values The values useful to the filter. Values []string `json:"values"` @@ -192,7 +228,7 @@ type FieldFilter struct { // FieldFilterCondition The possible field filtering conditions. type FieldFilterCondition string -// IdMessage defines model for IdMessage. +// IdMessage A single uuid. type IdMessage struct { // Id Unique identifier for entity. Id openapi_types.UUID `json:"id"` @@ -201,55 +237,61 @@ type IdMessage struct { // ListDocuments The documents in the client. type ListDocuments = []Document -// ListQueries defines model for ListQueries. +// ListQueries A set of queries. type ListQueries struct { // Queries List of queries. Queries []Query `json:"queries"` } -// Query defines model for Query. +// Query A logic unit of execution. type Query struct { - // ActiveVersion The active version of the query. - ActiveVersion int32 `json:"active_version"` + // ActiveVersion The desired version. + ActiveVersion Version `json:"active_version"` // Config Configuration for the query. - Config *string `json:"config,omitempty"` + Config *QueryConfig `json:"config,omitempty"` - // Id Unique identifier for the query. - Id openapi_types.UUID `json:"id"` + // Id The query id. + Id QueryID `json:"id"` - // LatestVersion The latest version of the query. - LatestVersion int32 `json:"latest_version"` + // LatestVersion The desired version. + LatestVersion Version `json:"latest_version"` // RequiredQueries List of required query IDs. - RequiredQueries *[]openapi_types.UUID `json:"required_queries,omitempty"` + RequiredQueries *RequiredQueryIDs `json:"required_queries,omitempty"` // Type Specifies the type of the query. Type QueryType `json:"type"` } -// QueryCreate defines model for QueryCreate. +// QueryConfig Configuration for the query. +type QueryConfig = string + +// QueryCreate The parameters required to create a query. type QueryCreate struct { - // Config Configuration for the new query. - Config *string `json:"config,omitempty"` + // Config Configuration for the query. + Config *QueryConfig `json:"config,omitempty"` // RequiredQueries List of required query IDs. - RequiredQueries *[]openapi_types.UUID `json:"required_queries,omitempty"` + RequiredQueries *RequiredQueryIDs `json:"required_queries,omitempty"` // Type Specifies the type of the query. Type QueryType `json:"type"` } -// QueryTestRequest defines model for QueryTestRequest. -type QueryTestRequest struct { - // DocumentId ID of the document to test against. - DocumentId openapi_types.UUID `json:"document_id"` +// QueryID The query id. +type QueryID = openapi_types.UUID - // QueryVersion Version of the query to use for testing. - QueryVersion int32 `json:"query_version"` +// QueryTestRequest The properties for a query test request. +type QueryTestRequest struct { + // DocumentId The document id. + DocumentId DocumentID `json:"document_id"` + + // QueryVersion The desired version. + QueryVersion Version `json:"query_version"` } -// QueryTestResponse defines model for QueryTestResponse. +// QueryTestResponse The response from a query test. type QueryTestResponse struct { // Value Result of the query test. Value string `json:"value"` @@ -258,18 +300,24 @@ type QueryTestResponse struct { // QueryType Specifies the type of the query. type QueryType string -// QueryUpdate defines model for QueryUpdate. +// QueryUpdate The properties that may be updated for a query. type QueryUpdate struct { - // ActiveVersion Updated active version. - ActiveVersion *int32 `json:"active_version,omitempty"` + // ActiveVersion The desired version. + ActiveVersion *Version `json:"active_version,omitempty"` - // Config Updated configuration for the query. - Config *string `json:"config,omitempty"` + // Config Configuration for the query. + Config *QueryConfig `json:"config,omitempty"` - // RequiredQueries Updated list of required query IDs. - RequiredQueries *[]openapi_types.UUID `json:"required_queries,omitempty"` + // RequiredQueries List of required query IDs. + RequiredQueries *RequiredQueryIDs `json:"required_queries,omitempty"` } +// RequiredQueryIDs List of required query IDs. +type RequiredQueryIDs = []QueryID + +// Version The desired version. +type Version = int32 + // CreateClientJSONRequestBody defines body for CreateClient for application/json ContentType. type CreateClientJSONRequestBody = ClientCreate @@ -298,28 +346,28 @@ type ServerInterface interface { CreateClient(ctx echo.Context) error // Get a client by ID // (GET /client/{id}) - GetClient(ctx echo.Context, id openapi_types.UUID) error + GetClient(ctx echo.Context, id ClientID) error // Update a client // (PATCH /client/{id}) - UpdateClient(ctx echo.Context, id openapi_types.UUID) error + UpdateClient(ctx echo.Context, id ClientID) error // Get a collector by client ID // (GET /client/{id}/collector) - GetCollectorByClientId(ctx echo.Context, id openapi_types.UUID) error + GetCollectorByClientId(ctx echo.Context, id ClientID) error // Set a collector // (PATCH /client/{id}/collector) - SetCollectorByClientId(ctx echo.Context, id openapi_types.UUID) error + SetCollectorByClientId(ctx echo.Context, id ClientID) error // List the documents for a client // (GET /client/{id}/documents) - ListDocumentsByClientId(ctx echo.Context, id openapi_types.UUID) error - // Check export state. - // (GET /client/{id}/export) - ExportState(ctx echo.Context, id openapi_types.UUID) error + ListDocumentsByClientId(ctx echo.Context, id ClientID) error // Trigger an export // (POST /client/{id}/export) - TriggerExport(ctx echo.Context, id openapi_types.UUID) error + TriggerExport(ctx echo.Context, id ClientID) error // Get client sync status // (GET /client/{id}/status) - GetStatusByClientId(ctx echo.Context, id openapi_types.UUID) error + GetStatusByClientId(ctx echo.Context, id ClientID) error + // Check export state. + // (GET /export/{id}) + ExportState(ctx echo.Context, id ExportID) error // List queries // (GET /query) ListQueries(ctx echo.Context) error @@ -328,13 +376,13 @@ type ServerInterface interface { CreateQuery(ctx echo.Context) error // Get a query by ID // (GET /query/{id}) - GetQuery(ctx echo.Context, id openapi_types.UUID) error + GetQuery(ctx echo.Context, id QueryID) error // Update a query // (PATCH /query/{id}) - UpdateQuery(ctx echo.Context, id openapi_types.UUID) error + UpdateQuery(ctx echo.Context, id QueryID) error // Test a query // (POST /query/{id}/test) - TestQuery(ctx echo.Context, id openapi_types.UUID) error + TestQuery(ctx echo.Context, id QueryID) error } // ServerInterfaceWrapper converts echo contexts to parameters. @@ -355,7 +403,7 @@ func (w *ServerInterfaceWrapper) CreateClient(ctx echo.Context) error { func (w *ServerInterfaceWrapper) GetClient(ctx echo.Context) error { var err error // ------------- Path parameter "id" ------------- - var id openapi_types.UUID + var id ClientID err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { @@ -371,7 +419,7 @@ func (w *ServerInterfaceWrapper) GetClient(ctx echo.Context) error { func (w *ServerInterfaceWrapper) UpdateClient(ctx echo.Context) error { var err error // ------------- Path parameter "id" ------------- - var id openapi_types.UUID + var id ClientID err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { @@ -387,7 +435,7 @@ func (w *ServerInterfaceWrapper) UpdateClient(ctx echo.Context) error { func (w *ServerInterfaceWrapper) GetCollectorByClientId(ctx echo.Context) error { var err error // ------------- Path parameter "id" ------------- - var id openapi_types.UUID + var id ClientID err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { @@ -403,7 +451,7 @@ func (w *ServerInterfaceWrapper) GetCollectorByClientId(ctx echo.Context) error func (w *ServerInterfaceWrapper) SetCollectorByClientId(ctx echo.Context) error { var err error // ------------- Path parameter "id" ------------- - var id openapi_types.UUID + var id ClientID err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { @@ -419,7 +467,7 @@ func (w *ServerInterfaceWrapper) SetCollectorByClientId(ctx echo.Context) error func (w *ServerInterfaceWrapper) ListDocumentsByClientId(ctx echo.Context) error { var err error // ------------- Path parameter "id" ------------- - var id openapi_types.UUID + var id ClientID err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { @@ -431,27 +479,11 @@ func (w *ServerInterfaceWrapper) ListDocumentsByClientId(ctx echo.Context) error return err } -// ExportState converts echo context to params. -func (w *ServerInterfaceWrapper) ExportState(ctx echo.Context) error { - var err error - // ------------- Path parameter "id" ------------- - var id openapi_types.UUID - - err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err)) - } - - // Invoke the callback with all the unmarshaled arguments - err = w.Handler.ExportState(ctx, id) - return err -} - // TriggerExport converts echo context to params. func (w *ServerInterfaceWrapper) TriggerExport(ctx echo.Context) error { var err error // ------------- Path parameter "id" ------------- - var id openapi_types.UUID + var id ClientID err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { @@ -467,7 +499,7 @@ func (w *ServerInterfaceWrapper) TriggerExport(ctx echo.Context) error { func (w *ServerInterfaceWrapper) GetStatusByClientId(ctx echo.Context) error { var err error // ------------- Path parameter "id" ------------- - var id openapi_types.UUID + var id ClientID err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { @@ -479,6 +511,22 @@ func (w *ServerInterfaceWrapper) GetStatusByClientId(ctx echo.Context) error { return err } +// ExportState converts echo context to params. +func (w *ServerInterfaceWrapper) ExportState(ctx echo.Context) error { + var err error + // ------------- Path parameter "id" ------------- + var id ExportID + + err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err)) + } + + // Invoke the callback with all the unmarshaled arguments + err = w.Handler.ExportState(ctx, id) + return err +} + // ListQueries converts echo context to params. func (w *ServerInterfaceWrapper) ListQueries(ctx echo.Context) error { var err error @@ -501,7 +549,7 @@ func (w *ServerInterfaceWrapper) CreateQuery(ctx echo.Context) error { func (w *ServerInterfaceWrapper) GetQuery(ctx echo.Context) error { var err error // ------------- Path parameter "id" ------------- - var id openapi_types.UUID + var id QueryID err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { @@ -517,7 +565,7 @@ func (w *ServerInterfaceWrapper) GetQuery(ctx echo.Context) error { func (w *ServerInterfaceWrapper) UpdateQuery(ctx echo.Context) error { var err error // ------------- Path parameter "id" ------------- - var id openapi_types.UUID + var id QueryID err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { @@ -533,7 +581,7 @@ func (w *ServerInterfaceWrapper) UpdateQuery(ctx echo.Context) error { func (w *ServerInterfaceWrapper) TestQuery(ctx echo.Context) error { var err error // ------------- Path parameter "id" ------------- - var id openapi_types.UUID + var id QueryID err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { @@ -579,9 +627,9 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL router.GET(baseURL+"/client/:id/collector", wrapper.GetCollectorByClientId) router.PATCH(baseURL+"/client/:id/collector", wrapper.SetCollectorByClientId) router.GET(baseURL+"/client/:id/documents", wrapper.ListDocumentsByClientId) - router.GET(baseURL+"/client/:id/export", wrapper.ExportState) router.POST(baseURL+"/client/:id/export", wrapper.TriggerExport) router.GET(baseURL+"/client/:id/status", wrapper.GetStatusByClientId) + router.GET(baseURL+"/export/:id", wrapper.ExportState) router.GET(baseURL+"/query", wrapper.ListQueries) router.POST(baseURL+"/query", wrapper.CreateQuery) router.GET(baseURL+"/query/:id", wrapper.GetQuery) @@ -593,47 +641,53 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/+RbX2/juBH/KoTaR8PO3d6T3/aS7MLFNtkm3uKKa2DQ1NjmLU0qJOXEDfzdC/4RJVmU", - "rDh2bou+RRY5f38zHM4oLwkR60xw4Fol45dEkRWssf3zklHg+lIC1mCeMykykJqCfcvx2v6agiKSZpoK", - "noyT6QoQsfuQXTBI9DaDZJwoLSlfJrvdIJHwmFMJaTL+3VF5CKvE/A8gOtkNPPN7jXWummzuMyB0QUEh", - "vQKk7CokFgh75sNkkADP14bF5GZ2/6+by2SQ3NxO7Z/XV5WHyc3nigCFmHUBfhXptmkBx2pG004z0DQZ", - "JAsh11gn4yTP7XODmwqK/lXCIhknfxmVfhl5p4xqRtk3ZSlOINdu2G9ZGvUqwXymtpw0VZosrK0LrRTC", - "jIknypcIE003gMw2Veo2F4IB5obl8VBpSi8YA6KFbNILr9BapMAMBOq6OTlnG5DK7ogJ5HXxawykrNIF", - "6WHVl5TrDz+XYlOuYQnSSHkAGZOrgjBWShCKNaQV4B4Ey4ICS1WctnuHKG8KTjWsD0Os2PHJEEpKH2Ap", - "8dY8M6xB6W4zujVvNeOacrrO1zNigASym6VfHHguhLRMU0HytQGZp/JK3hqe9XGMzU6UYal68uwIZ+/w", - "dou0yNtw1mA/CB66YsxBoB1mqIyvoHXNx31PDJHrLNeeqFk2jMH+MQe5bQ0q+xbRFOkV1uiJMoYykeXG", - "AFYwCSpnfeIrdkJVmHda7B50U7qveMsETq2JcpN3bdJEl+2Wer9M9eemkv+7AG8g50oQdyC/01F8kmLl", - "NKWfpe1XBl0f4jayDm6aaJ6T77GIM6K4d4gIrjHlxjhVsMTUarNNAFg/63yHbZxOhvUKaXFAjpiVvJ6O", - "dsxE18+ZkPoKNKZMdWcgsEuRlnS5BGnSYia4gmYS6lveIgkMW9h53RyHXpWMS/wzJgjW7cWEf2sy0dOK", - "klWFC/oPzdCCMnAZfw5oIXKe2vr/Ga8zZvl9GI9GL86IM4O43egFnjVIjtksqLkbbbfb7XqdpuatIW5+", - "HBK1+Tc/vmR3nnlbyV6jEYeWUIrOWbCKIQaqegsyojHQYFhRPsukWEpQJkksMGWQRu9AjvHUQaUbVh5P", - "NgnxCgTqmLJHymxBmQYZUeWTfeHudERkgOZYQYpMzrWlga8TNpjlTrte55A9fhzp2CFE+RKUEeAYucJm", - "cxDgNZj9TbWBp7PivhUrlpVG5rU5xAPBYQvmpG4lRRVaUNmTWPM0ip1PVdu1mMVVM0SwfM2bSUTwlBah", - "3dNJl2FPUaDM2k8c86YofhxIKDe1YLsNHXri1Nw7lCtY5KzIZw4WNbg1iNZBtRfmFR0GFYsEUR66DX9Z", - "tWFH7Dv1F8EpgVMtETBQaqZX2PBf2t6OLB4JEwrSmSlY5AazZJCIDHj1mcFCz5rLJF2uYr9TTliegk3G", - "7q9Ylpmkfwel8DLSjogdPt84fcwB0RS4pgsK0h1rXFO9fX1531LRf6FKF3WH6i4Lygo53OB7paVQ1kRy", - "kmH/jxykN0PdKI/li7pUZpeJBb+gtySG0/Ygigu2MXM5Cg1Jj7/H2OtW326L4Au6jDWEzO+5dMVDUbUH", - "yr3qvzjY4hK2FTnHN0xeY4XCVbOD8ChW+ivz5KqOlIP67IPVPfeA2NQsjBa4lkSjOdEwXSv02prUr4MG", - "h6cOePyvGtjubrXcFJS+A3tgNs1XpLjoJaDsYoYLkjkwDYzxElOu+l0BXGOlNTj+GYkIwydX4PxmTnq+", - "PKbDVtVuX44D9nJ3pqbB7IHeVOLO9p72dABnoO7jyRFsl8Yjo2s6YnY2EkpRDfzt/vZmdv3b9O7j5fT2", - "Lhkkl7c30+vfprNP3758iZ7Wlm/b+OBQwnf70r2k/8Y8XxAlr8z3hwO6oMzOEtiRCtxeRxaiKcnHr5MQ", - "ZnX9rD/QrSQrUNrrrkBuKHEVgKbaXoJj6z5+nZgqtPBW8tPwYnhh7+UZcJzRZJx8GF4MP5iyHuuVVXJE", - "yn6VUJHmi8vFCmGbT32b4Ilqd23PpNjQFFKUumbF0FWZTqBJGvb7rpjzEihdjOCI4Nqzx1nGqGsNjP5Q", - "Dm4uHfabo/lDY1ePOS1zsD+4GLc6/3zx08l4l9WuZbxnO2ctYiVLkcoJAaUWOWPbofHLLxcXkUTMN5jZ", - "Poy1FJqL1Kw218V8vcamMPNGrfnEYAMvlckCfq7oUJM8mK3ezaMXmu4My2Wsz3YHWlLYWGcrl3RI4fH5", - "FlGt0OSq6eHPoCvurdn54mR2Ljur7XYOGOxr2uolv27gz6DD9NnoPrnqsK8Jp4JQMv69e0boaWqBpDe3", - "TTpmoQnKook6dpVUHciDirEO3YsebJCTVVsaVK6xQ+15W4trg6nWcHab3yGc/ZnUK5wjrvaQyH3KP13o", - "ObkCOPqH3YhUh92vCMAwCPcx6H3VForF8l+3TqBJes64LCf4sbgMovcOzZjJfTBW7RBsULV/ObZ7RWQG", - "SvGZ53sG5j3oQpxS2cMhed/u9DMEZ3U22is4f+n6tkOBPmFs3teB0o2N/fBMq/2hA+FpYFJUkWXjaL6t", - "ZvhYfNb6UO8ToPXWV8fhGdQwir3ND/bmrGtNNRNckZwZJHtjzAZGZ4rZfbC4iUgrUi5XQL47mJBcSiOs", - "neHYj9qq85Q6PMrJEJwTEvXxYgQSbgFaYYXmAByFadNx+dtaozbLGlYg4JU+rpoqLXmeRB29Ek041dSW", - "UJXJZSaFyWJNp/p5m1PzTFm5Ptn7ka5A17X59EkrMa9uGVAdoNqP33La2yPTqy0nxVepvWow/5np+xRg", - "+x+2tqd4r8KJr0neFBUjve2qFL5EOGMqfywGHAfLcFYfwlRH2HaITCTVICmOn/XF0OfM53vBJuL6j/sa", - "nMLt9nx/DLoVzrY9qZqve3SUXO/t1Q0lN6I6TzatziB+pFzqen5n7iY9esO2ODVEzxGtJOfq7k5S6dcz", - "xYufjrZZ9+Q9pKB07a7aDJX+NU9ogf/ZTaNK6PboGZ09Yt/YMXL+P2PD6FWRNdLFCO+HAUY0mV8/A8ld", - "NrezQplz9587bXm9/mHVXqkMSp8dJtURaX+snJq/HzlG8tDUmtF/3v6m+tjObg/CzuwBuYkD7KsUaU7C", - "FApkMkhyyZJxstI6U+PRCGd06L/NHBKxHm1+SgxaPLd9ereFv5X7zhRSpIUv+VSJ1nrZuBv0JFM0eaqU", - "9hs/fYmV7aBAq9Gs6EurLJU8pZoP+lJxl5wKlfolZ/ew+28AAAD//9G30tr+NwAA", + "H4sIAAAAAAAC/8xb61PjOBL/V1S++5gHmcDw+MYCu5WrPZgD5mqv9qiUI7cT7TiWkeTM5Kbyv1/p5aeU", + "OBnC7jfAUqv71091i+8BpsuMppAKHlx9D7KQhUsQwNRvNwmBVExu5c8RcMxIJghNg6vgeQEIq69ocjsI", + "egGRf81CsQh6QRouIbgKSBT0AgavOWEQBVeC5dALOF7AMpQE/84gDq6Cvw1LDob6Kx8WB282veDuW0aZ", + "lwtQX4/CRXGw5OJfObC1j4nJLaIxEgtAr3LZ27NiT99IVhjwjKYclI4m6SpMSPQIrzlw0WbPfEdML0Az", + "Gq0HSiJDu1T0TZg+rVPsoKFlMwonHIVJQr+SdI5CLMgKEF+nmAe9QKwzKeiM0gTCNNj0LGUGoQA3dhmj", + "GTBBgKOYMoTlUkJTiWH5SW4lUXezsZh3WX8vV2pcrWp+17pSNF4KsejsD8CilGqHY8A3ASwNE6Rowbdw", + "mSWSzPX1dQkVF4yk8yrNn2i03kqXRD+GTVtSv4j3BkUvMwqiunQMBPgFfBKhyHmb5lMGmMTSCqSpcbVK", + "OlVoTpIyQ5ovJcuT++nTf+5vgl5w//Csfry7rfwyuf+lIpKbATfK11Yscz5JY8qWyh6RhqYNPS8E2g2/", + "Eb6pAkPCr4bPO0yNpMbU8pS85tC0uJPR5dnF2Rj3L+Io6p+f46g/G3/E/Q9nZx9OR7MoisbjoBdoWYOr", + "IM8VAQ+An7OoizOLRSjQMlyjGaBcbXHYLQ7TKTcxZzd8NkAd5t5tbGkE/wbGFfsuaSLgUkUI0wjQSq8c", + "VIEiqRh/KJGSapgD07STBLCgrE25+ISWNIKkDYoOqtNVydo2Ka0Em16grWG6X6CMCSTRbvu1TP+sl296", + "QRIK4OIANpckJct8OcUySQDrSqGqrgoVAd/EQSQaTliCV2DiZ9VzfAuUXlOZTh+vYes2RcVRM1eqpGw3", + "t+2ok4/Uzta+0gtUFdPBjsqypI6lyQoFmd1S+xMNzUWWCwOAJDxwhqaGffpBlFG9jRwRsNzTCYIypoSM", + "hesaG0/gqMU+heuEhpHSnQqJqoRCN34VHhwKDvbqv45ztizmlmIduHbmnkbd8EY557gFaC/Iux7w2V3G", + "aQo9632FnC9uLPOlF8rIfK1g2sZxluMv4CGgvyFMUxGSVJq5qJB1OfBu2S3LGt4v4KmS5Z0LCbrjQBd6", + "RiBNextovmqsgE2X6I0C7CSK+7NxfNE/H59e9C/D2ag/grOz2TgeXUB03qUA0zfSWxAhSfj2+GLuxYKR", + "+RwYsndGhzscUjTooDxNKA6Ft3yyX2XA/bogeKF0Yhj7H8lQTBJAX0mSyBoxpnnagI2Pr4bD71otU2nV", + "m+F3e6uaFnxvhuv1er1cRpH8KonLPw4wX/03dYHYrWDXUHsK9mqtsKV479S58NgK9E+js1H/fDTG/csL", + "gP7px1O4GF+MRvFo3N1WfNct5SmUczJLCk6kJNrR7UVL4pKAgEg1NKYZo3MGXBZGcUgSiJzXLH3wsza8", + "7UZqrFOlwdSw0bZQlcumMUlsX6pO8Gf1QV8bMc0AzUIOEaKpqRlMAbEKk1xL1ynXq4yoSbsSPUnnwCUD", + "h/BVbEZlv60tNqTR1H/TSkIukPwsk11BcOAxeCa8pAhHMWEdibXTsitRV7HzwKIrH0yTfJm2QxJNIyI6", + "lAyVg26KPbb6mR5e/2pbcQOvv6GcQ5wnNtFoI6gZV0sNdRNqRJQKx72K/AUrL9thvqkitsXTtUfEhQqK", + "k2punwDnU7EI5flz1bpj9lecUA7RVDUcVmES9AKaQVr9PYFYTNvLGJkvXH8nKU7ySPeQ9E+umDKJ/gmc", + "h3Nw9Ww4SecJIBkIfZ2x+pbPtksCqSAxAaYzZiqIWA92x9ZuDbRfCRe2YODb64XySlKUrJ1iVFHEOQKU", + "PF5ez4jLjq8RByF9/VWvaMP26tsq6TZ2duJVXRV3uoE91gWopuCQJaFzglGeEsUYfAOcuzvIhzdWaBqT", + "eScRb/TSThVtcX3+gWaKRW9a0di2rY9mvTmblyrpwOuzXOisnRWJVrejJZdXrzcFws1mmfx7znQhaZse", + "xZSlFSg0sW3jhiLjIiuEDOJq7AAoLEm3UtL+FvDn60bt9oLuq0wVBv5LDMQfz/rnH88/9i8iuOxfnp6O", + "z8LL8Xh8HnYpTDW3wIV3ZuUYCxnFIGlNdpbV1pINqNN9b5O6U7Wv9zXArp7eJOnVgQZCX87cSNirG4oZ", + "XdaAaAOgqoU2mUfgeSJqM8qCwPbkpgn6uTfWuW2WI3e2xqO21PjH08P99O6358frm+eHx6AX3DzcP9/9", + "9jz9+fOvvzpLAXXu4TOIqjX92Rnix+ODq/purfLm8CIAaouY3O6ZzrXvNCuPTiOVfaYpG3Xfiqkj93+a", + "FEVUPUMo/tADwwvgwmQPDmxFsK5ZBBEqqLnWXX+ayMLbihGMBieDE9X1yCANMxJcBePByUDewrNQLBRW", + "Q1x0JjPqimk6J3EUohS+2rndVyJ0UyRjdEUiiFCkezsDXVhrhiZRsd/0P7XpABd2jIlpKszxYZYlRDde", + "hn9wrYd9Xl2Y5KlQd+lP8efOnbjKXfnIoflk4cPJ6I15NlNzB8/6u2ExQjzHGDiP8yRZD6RKT09OfEcU", + "PA8bbyzU44l8uQxlOWoUU9OrtK9wzmV8M3NfbXnBi9xqTGX4nUQbefbc1UR9BMEIrJTBcB1OsbWa2RoR", + "wc2Tl7qV/AKiYiI1zE/eDPOyD+8HvLDjN8H4FxCFeUnxJ7dbIO7VXjH97j64XFLpa74oh8YLx41RJQ+u", + "u1SEq8FN1Yel7r2uqze/g+uarLjDdQU1ubCDo544ApkW26bTI3iUFqMaTzp60xBXp+57+FUxkTeuVXva", + "1vYwu/yntbGd6JjuVj4lcLlbwfpRPK4KTAFKVSHlvPOY7vcEwh5fsrTb8Z78ujqCC1ZHv7tdcAaqB+Mc", + "4+/yytNtj0ok1SM45VPdILbbQNMvo2ofbIdfSjQSU6CWDbLZuvoE0eWYtX7b+3hmvcW3JRkWYkjB3kgh", + "qogXtS6ivtq0ombB4ps4aVO3emrTfDy8r99T99tVIojKu5XBYcaotO22AZiJkx4/HcnJ67Mtj5cbRo0X", + "K+QH71oUl91yB4d3tcHwcTK4Aagc6lWs0cwlvbGiHM92CBR8nWL7WLNT7javP98ncTffm/ojhBHh7XO4", + "fc9a4nScyllqUat6+73mZgH4i9YdzhmzsqsGUW0EXNdcOcyGY2qs/r7C7zyLkKMZQIqKAflbXSYlPLV5", + "/GCL6+yrr/IfGpS+Xu1AZWelnNSHPtUJu5pxY0YEMBK6s7IdQx05E9tjHGq7bkrwljn4tRDP6kk1lWpq", + "6tAS0j24vTtCeip2nGxXHaYc0g96rfD2F8h8utf3Xq0gK7zHKAoHPKAPpE1lexuotIsjuZwZ6PpgPsZ1", + "tJC7dgdte9teQbHoZO/X/am4a4fmz9G9dHvrRzdr7NMVe+e0vfhiFnJAN0gr+z2aQXv501CYweIP2IIz", + "Zt+p1wXKHfUoMk/1a2Nf+K6/8GrcWICLo1tGddLqMY/GaHWfS8vJMZg101AXt5pHnidvdY1WFHdbl9wD", + "bGXtqPGkkdEox8WMCVjQC3KWBFfBQoiMXw2HYUYGZpI+wHQ5XI2UjZnTmvQerJXIvJooz5JpVVXbvPx/", + "0nr5vul1JGPbNVVKzRZOV2JlY6eg1eo2dKVV1lGGUk0HXano2rlCpV40b142/w8AAP//JXKOSfQ8AAA=", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/api/queryService/client.go b/api/queryService/client.go index d79c20e1..36a28961 100644 --- a/api/queryService/client.go +++ b/api/queryService/client.go @@ -7,7 +7,6 @@ import ( "queryorchestration/internal/client" "github.com/labstack/echo/v4" - "github.com/oapi-codegen/runtime/types" ) func (s *Controllers) CreateClient(ctx echo.Context) error { @@ -16,37 +15,40 @@ func (s *Controllers) CreateClient(ctx echo.Context) error { return echo.NewHTTPError(http.StatusBadRequest, err) } - id, err := s.svc.Client.Create(ctx.Request().Context(), req.Name) + _, err := s.svc.Client.Create(ctx.Request().Context(), client.CreateParams{ + Name: req.Name, + ExternalId: req.Id, + }) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unable to create client: %s", err)) } - return ctx.JSON(http.StatusCreated, IdMessage{ - Id: id, + return ctx.JSON(http.StatusCreated, ClientIDBody{ + Id: req.Id, }) } -func (s *Controllers) GetClient(ctx echo.Context, id types.UUID) error { - client, err := s.svc.Client.Get(ctx.Request().Context(), id) +func (s *Controllers) GetClient(ctx echo.Context, id string) error { + client, err := s.svc.Client.GetByExternalId(ctx.Request().Context(), id) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unable to get client: %s", err)) } return ctx.JSON(http.StatusOK, DocClient{ - Id: client.ID, + Id: client.ExternalID, + Uid: client.ID, Name: client.Name, CanSync: client.CanSync, }) } -func (s *Controllers) UpdateClient(ctx echo.Context, id types.UUID) error { +func (s *Controllers) UpdateClient(ctx echo.Context, id string) error { req := ClientUpdate{} if err := ctx.Bind(&req); err != nil { return echo.NewHTTPError(http.StatusBadRequest, err) } - err := s.svc.Client.Update(ctx.Request().Context(), &client.Update{ - ID: id, + err := s.svc.Client.UpdateByExternalId(ctx.Request().Context(), id, &client.Update{ Name: req.Name, CanSync: req.CanSync, }) diff --git a/api/queryService/client_test.go b/api/queryService/client_test.go index 257f1174..cfdd9163 100644 --- a/api/queryService/client_test.go +++ b/api/queryService/client_test.go @@ -36,6 +36,7 @@ func TestCreateClient(t *testing.T) { body := queryservice.ClientCreate{ Name: "example_name", + Id: "external_id", } bodyBytes, err := json.Marshal(body) assert.NoError(t, err) @@ -46,17 +47,15 @@ func TestCreateClient(t *testing.T) { rec := httptest.NewRecorder() ctx := e.NewContext(req, rec) - id := uuid.New() - - pool.ExpectQuery("name: CreateClient :one").WithArgs(body.Name).WillReturnRows( + pool.ExpectQuery("name: CreateClient :one").WithArgs(body.Id, body.Name).WillReturnRows( pgxmock.NewRows([]string{"id"}). - AddRow(database.MustToDBUUID(id)), + AddRow(database.MustToDBUUID(uuid.New())), ) err = cons.CreateClient(ctx) assert.NoError(t, err) assert.Equal(t, http.StatusCreated, rec.Code) - assert.Equal(t, fmt.Sprintf("{\"id\":\"%s\"}\n", id), rec.Body.String()) + assert.Equal(t, fmt.Sprintf("{\"id\":\"%s\"}\n", body.Id), rec.Body.String()) } func TestGetClient(t *testing.T) { @@ -76,13 +75,14 @@ func TestGetClient(t *testing.T) { rec := httptest.NewRecorder() ctx := e.NewContext(req, rec) - id := uuid.New() + id := "client_id" + clientUid := uuid.New() ctx.Set("id", id) - pool.ExpectQuery("name: GetClient :one").WithArgs(database.MustToDBUUID(id)).WillReturnRows( - pgxmock.NewRows([]string{"id", "name", "canSync"}). - AddRow(database.MustToDBUUID(id), "client_name", true), + pool.ExpectQuery("name: GetClientByExternalId :one").WithArgs(id).WillReturnRows( + pgxmock.NewRows([]string{"id", "externalId", "name", "canSync"}). + AddRow(database.MustToDBUUID(clientUid), "client_id", "client_name", true), ) err = cons.GetClient(ctx, id) @@ -94,6 +94,7 @@ func TestGetClient(t *testing.T) { assert.NoError(t, err) assert.EqualExportedValues(t, queryservice.DocClient{ Id: id, + Uid: clientUid, Name: "client_name", CanSync: true, }, res) @@ -124,16 +125,22 @@ func TestUpdateClient(t *testing.T) { rec := httptest.NewRecorder() ctx := e.NewContext(req, rec) - id := uuid.New() + id := "clientid" ctx.Set("id", id) - pool.ExpectQuery("name: GetClient :one").WithArgs(database.MustToDBUUID(id)).WillReturnRows( - pgxmock.NewRows([]string{"id", "name", "canSync"}). - AddRow(database.MustToDBUUID(id), "client_name", true), + intid := uuid.New() + + pool.ExpectQuery("name: GetClientByExternalId :one").WithArgs(id).WillReturnRows( + pgxmock.NewRows([]string{"id", "externalId", "name", "canSync"}). + AddRow(database.MustToDBUUID(intid), "clientid", "client_name", true), + ) + pool.ExpectQuery("name: GetClient :one").WithArgs(database.MustToDBUUID(intid)).WillReturnRows( + pgxmock.NewRows([]string{"id", "externalId", "name", "canSync"}). + AddRow(database.MustToDBUUID(intid), "clientid", "client_name", true), ) pool.ExpectBegin() - pool.ExpectExec("name: AddClientCanSync :exec").WithArgs(*body.CanSync, database.MustToDBUUID(id)). + pool.ExpectExec("name: AddClientCanSync :exec").WithArgs(*body.CanSync, database.MustToDBUUID(intid)). WillReturnResult(pgxmock.NewResult("", 1)) pool.ExpectCommit() diff --git a/api/queryService/collector.go b/api/queryService/collector.go index 74d6ebb1..2406ce0d 100644 --- a/api/queryService/collector.go +++ b/api/queryService/collector.go @@ -8,11 +8,10 @@ import ( "github.com/google/uuid" "github.com/labstack/echo/v4" - "github.com/oapi-codegen/runtime/types" ) -func (s *Controllers) GetCollectorByClientId(ctx echo.Context, clientId types.UUID) error { - coll, err := s.svc.Collector.GetByClientID(ctx.Request().Context(), clientId) +func (s *Controllers) GetCollectorByClientId(ctx echo.Context, clientId string) error { + coll, err := s.svc.Collector.GetByClientExternalID(ctx.Request().Context(), clientId) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unable to get collector: %s", err)) } @@ -28,7 +27,7 @@ func (s *Controllers) GetCollectorByClientId(ctx echo.Context, clientId types.UU } return ctx.JSON(http.StatusOK, Collector{ - ClientId: coll.ClientID, + ClientId: clientId, MinimumCleanerVersion: coll.MinCleanVersion, MinimumTextVersion: coll.MinTextVersion, ActiveVersion: coll.ActiveVersion, @@ -37,7 +36,7 @@ func (s *Controllers) GetCollectorByClientId(ctx echo.Context, clientId types.UU }) } -func (s *Controllers) SetCollectorByClientId(ctx echo.Context, clientId types.UUID) error { +func (s *Controllers) SetCollectorByClientId(ctx echo.Context, clientId string) error { req := CollectorSet{} if err := ctx.Bind(&req); err != nil { return echo.NewHTTPError(http.StatusBadRequest, err) @@ -52,8 +51,7 @@ func (s *Controllers) SetCollectorByClientId(ctx echo.Context, clientId types.UU fields = &fs } - err := s.svc.CollectorSet.SetByClientId(ctx.Request().Context(), &collectorset.SetParams{ - ClientID: clientId, + err := s.svc.CollectorSet.SetByClientExternalId(ctx.Request().Context(), clientId, &collectorset.SetParams{ ActiveVersion: req.ActiveVersion, MinCleanVersion: req.MinimumCleanerVersion, MinTextVersion: req.MinimumTextVersion, diff --git a/api/queryService/collector_test.go b/api/queryService/collector_test.go index 3b67d220..ed671fb2 100644 --- a/api/queryService/collector_test.go +++ b/api/queryService/collector_test.go @@ -78,8 +78,14 @@ func TestSetCollector(t *testing.T) { }), }) - ctx.Set("id", current.ClientID) + id := "clientid" + ctx.Set("id", id) + + pool.ExpectQuery("name: GetClientByExternalId :one").WithArgs(id).WillReturnRows( + pgxmock.NewRows([]string{"id", "externalId", "name", "can_sync"}). + AddRow(database.MustToDBUUID(current.ClientID), id, "name", true), + ) pool.ExpectQuery("name: GetCollectorByClientID :one").WithArgs(database.MustToDBUUID(current.ClientID)). WillReturnRows( pgxmock.NewRows([]string{"clientId", "minCleanVersion", "minTextVersion", "activeVersion", "latestVersion", "fields"}). @@ -113,7 +119,7 @@ func TestSetCollector(t *testing.T) { ). Return(&sqs.SendMessageOutput{}, nil) - err = cons.SetCollectorByClientId(ctx, current.ClientID) + err = cons.SetCollectorByClientId(ctx, id) assert.NoError(t, err) assert.Equal(t, http.StatusOK, rec.Code) assert.Empty(t, rec.Body.String()) @@ -142,13 +148,15 @@ func TestGetCollectorByclientId(t *testing.T) { MinTextVersion: int32(2), } - pool.ExpectQuery("name: GetCollectorByClientID :one").WithArgs(database.MustToDBUUID(coll.ClientID)). + id := "clientid" + + pool.ExpectQuery("name: GetCollectorByClientExternalID :one").WithArgs(id). WillReturnRows( pgxmock.NewRows([]string{"clientId", "minCleanVersion", "minTextVersion", "activeVersion", "latestVersion", "fields"}). AddRow(database.MustToDBUUID(coll.ClientID), coll.MinCleanVersion, coll.MinTextVersion, int32(1), int32(2), []byte("")), ) - err = cons.GetCollectorByClientId(ctx, coll.ClientID) + err = cons.GetCollectorByClientId(ctx, id) assert.NoError(t, err) assert.Equal(t, http.StatusOK, rec.Code) @@ -156,7 +164,7 @@ func TestGetCollectorByclientId(t *testing.T) { err = json.Unmarshal(rec.Body.Bytes(), &res) assert.NoError(t, err) assert.EqualExportedValues(t, queryservice.Collector{ - ClientId: coll.ClientID, + ClientId: id, MinimumCleanerVersion: coll.MinCleanVersion, MinimumTextVersion: coll.MinTextVersion, ActiveVersion: int32(1), diff --git a/api/queryService/documents.go b/api/queryService/documents.go index c9dd5e27..32071136 100644 --- a/api/queryService/documents.go +++ b/api/queryService/documents.go @@ -5,11 +5,10 @@ import ( "net/http" "github.com/labstack/echo/v4" - "github.com/oapi-codegen/runtime/types" ) -func (s *Controllers) ListDocumentsByClientId(ctx echo.Context, clientId types.UUID) error { - documents, err := s.svc.Document.ListByClientId(ctx.Request().Context(), clientId) +func (s *Controllers) ListDocumentsByClientId(ctx echo.Context, clientId string) error { + documents, err := s.svc.Document.ListByClientExternalId(ctx.Request().Context(), clientId) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unable to list documents: %s", err)) } diff --git a/api/queryService/documents_test.go b/api/queryService/documents_test.go index 210cebc5..20b292a6 100644 --- a/api/queryService/documents_test.go +++ b/api/queryService/documents_test.go @@ -35,7 +35,7 @@ func TestListDocumentsByClientId(t *testing.T) { mockSQS := queuemock.NewMockSQSClient(t) cfg.QueueClient = mockSQS - clientId := uuid.New() + clientId := "clientid" e := echo.New() req := httptest.NewRequest(http.MethodPost, "/", strings.NewReader("")) @@ -56,7 +56,7 @@ func TestListDocumentsByClientId(t *testing.T) { }, } - pool.ExpectQuery("name: ListDocumentsByClientId :many").WithArgs(database.MustToDBUUID(clientId)). + pool.ExpectQuery("name: ListDocumentsByClientExternalId :many").WithArgs(clientId). WillReturnRows( pgxmock.NewRows([]string{"id", "bucket", "key"}). AddRow(database.MustToDBUUID(doc[0].Id), doc[0].Bucket, doc[0].Key), diff --git a/api/queryService/export.go b/api/queryService/export.go index 431a53b7..aa0af464 100644 --- a/api/queryService/export.go +++ b/api/queryService/export.go @@ -7,7 +7,7 @@ import ( "github.com/oapi-codegen/runtime/types" ) -func (s *Controllers) TriggerExport(ctx echo.Context, id types.UUID) error { +func (s *Controllers) TriggerExport(ctx echo.Context, clientId string) error { return ctx.JSON(http.StatusOK, map[string]string{"status": "export triggered"}) } diff --git a/api/queryService/export_test.go b/api/queryService/export_test.go index e0354963..b0542607 100644 --- a/api/queryService/export_test.go +++ b/api/queryService/export_test.go @@ -22,9 +22,7 @@ func TestTriggerExport(t *testing.T) { cons := queryservice.NewControllers(validator.New(), &queryservice.Services{}) - id := uuid.New() - - err := cons.TriggerExport(ctx, id) + err := cons.TriggerExport(ctx, "clientid") assert.NoError(t, err) assert.Equal(t, http.StatusOK, rec.Code) assert.NotEmpty(t, rec.Body.String()) diff --git a/api/queryService/status.go b/api/queryService/status.go index c295d76e..fa9a11ae 100644 --- a/api/queryService/status.go +++ b/api/queryService/status.go @@ -5,17 +5,15 @@ import ( "net/http" "github.com/labstack/echo/v4" - "github.com/oapi-codegen/runtime/types" ) -func (s *Controllers) GetStatusByClientId(ctx echo.Context, id types.UUID) error { - status, err := s.svc.Client.GetStatus(ctx.Request().Context(), id) +func (s *Controllers) GetStatusByClientId(ctx echo.Context, id string) error { + status, err := s.svc.Client.GetStatusByExternalId(ctx.Request().Context(), id) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unable to find client: %s", err)) } return ctx.JSON(http.StatusOK, ClientStatusBody{ - ClientId: id, - Status: parseClientStatus(status), + Status: parseClientStatus(status), }) } diff --git a/api/queryService/status_test.go b/api/queryService/status_test.go index 72e6dfc9..0e058c8e 100644 --- a/api/queryService/status_test.go +++ b/api/queryService/status_test.go @@ -38,17 +38,18 @@ func TestGetClientStatus(t *testing.T) { ctx := e.NewContext(req, rec) clientId := uuid.New() + id := "clientid" - pool.ExpectQuery("name: GetClient :one").WithArgs(database.MustToDBUUID(clientId)).WillReturnRows( - pgxmock.NewRows([]string{"id", "name", "can_sync"}). - AddRow(database.MustToDBUUID(clientId), "name", true), + pool.ExpectQuery("name: GetClientByExternalId :one").WithArgs(id).WillReturnRows( + pgxmock.NewRows([]string{"id", "externalId", "name", "can_sync"}). + AddRow(database.MustToDBUUID(clientId), id, "name", true), ) pool.ExpectQuery("name: IsClientSynced :one").WithArgs(database.MustToDBUUID(clientId)).WillReturnRows( pgxmock.NewRows([]string{"issynced"}). AddRow(true), ) - err = cons.GetStatusByClientId(ctx, clientId) + err = cons.GetStatusByClientId(ctx, id) assert.NoError(t, err) assert.Equal(t, http.StatusOK, rec.Code) @@ -56,7 +57,6 @@ func TestGetClientStatus(t *testing.T) { err = json.Unmarshal(rec.Body.Bytes(), &res) assert.NoError(t, err) assert.EqualExportedValues(t, queryservice.ClientStatusBody{ - ClientId: clientId, - Status: queryservice.INSYNC, + Status: queryservice.INSYNC, }, res) } diff --git a/database/migrations/00000000000003_clients.up.sql b/database/migrations/00000000000003_clients.up.sql index 7ef486f5..2c7a124a 100644 --- a/database/migrations/00000000000003_clients.up.sql +++ b/database/migrations/00000000000003_clients.up.sql @@ -1,7 +1,9 @@ CREATE TABLE clients ( id uuid primary key DEFAULT uuid_generate_v7(), + externalId varchar(255) not null, name TEXT not null, - UNIQUE (name) + UNIQUE (name), + UNIQUE (externalId) ); CREATE TABLE clientCanSync ( @@ -9,4 +11,4 @@ CREATE TABLE clientCanSync ( clientId uuid not null, canSync boolean not null, foreign key (clientId) references clients(id) -); \ No newline at end of file +); diff --git a/database/migrations/00000000000102_job_views.up.sql b/database/migrations/00000000000102_job_views.up.sql index fe6b16a8..70ada117 100644 --- a/database/migrations/00000000000102_job_views.up.sql +++ b/database/migrations/00000000000102_job_views.up.sql @@ -88,3 +88,8 @@ SELECT FROM clients c LEFT JOIN RankedExtractions r on r.clientId = c.id and r.row_num = 1; +CREATE VIEW fullClients as +SELECT c.id, c.externalId, c.name, cs.canSync + FROM clients as c + JOIN currentClientCanSync as cs on cs.clientId = c.id; + diff --git a/database/queries/client.sql b/database/queries/client.sql index b939a2a5..08efff02 100644 --- a/database/queries/client.sql +++ b/database/queries/client.sql @@ -1,11 +1,11 @@ -- name: CreateClient :one -INSERT INTO clients (name) VALUES ($1) RETURNING id; +INSERT INTO clients (externalId, name) VALUES ($1, $2) RETURNING id; -- name: GetClient :one -SELECT c.id, c.name, cs.canSync - FROM clients as c - JOIN currentClientCanSync as cs on cs.clientId = c.id - WHERE c.id = $1; +SELECT * FROM fullClients WHERE id = $1; + +-- name: GetClientByExternalId :one +SELECT * FROM fullClients WHERE externalId = $1; -- name: UpdateClient :exec UPDATE clients SET name = $1 WHERE id = $2; diff --git a/database/queries/collector.sql b/database/queries/collector.sql index 6e946f16..5c0b7d05 100644 --- a/database/queries/collector.sql +++ b/database/queries/collector.sql @@ -4,6 +4,14 @@ SELECT * FROM collectorQueryDependencyTree WHERE clientId = @clientId; -- name: GetCollectorByClientID :one SELECT * FROM fullActiveCollectors WHERE clientId = @clientId LIMIT 1; +-- name: GetCollectorByClientExternalID :one +WITH client as ( + SELECT id from clients where externalId = @clientId +) +SELECT fc.* + FROM fullActiveCollectors as fc + JOIN client as c ON fc.clientId = c.id LIMIT 1; + -- name: AddLatestCollectorVersion :one INSERT INTO collectorVersions (clientId) VALUES ($1) RETURNING id; diff --git a/database/queries/document.sql b/database/queries/document.sql index 2921756a..aa58f0a9 100644 --- a/database/queries/document.sql +++ b/database/queries/document.sql @@ -1,9 +1,14 @@ -- name: GetDocument :one SELECT id, clientId, hash FROM documents WHERE id = $1 LIMIT 1; --- name: ListDocumentsByClientId :many -WITH docs as ( - SELECT id from documents where clientId = @clientId +-- name: ListDocumentsByClientExternalId :many +WITH client as ( + SELECT id from clients where externalId = @clientId +), +docs as ( + SELECT d.id + from documents as d + JOIN client as c on d.clientId = c.id ), entries as ( SELECT diff --git a/internal/client/create.go b/internal/client/create.go index 172210e6..26ceb2eb 100644 --- a/internal/client/create.go +++ b/internal/client/create.go @@ -2,22 +2,63 @@ package client import ( "context" + "errors" + "regexp" + "strings" "queryorchestration/internal/database" + "queryorchestration/internal/database/repository" "github.com/google/uuid" ) -func (s *Service) Create(ctx context.Context, name string) (uuid.UUID, error) { - err := normalizeName(&name) +type CreateParams struct { + Name string + ExternalId string +} + +func (s *Service) Create(ctx context.Context, params CreateParams) (uuid.UUID, error) { + err := s.normalizeCreate(¶ms) if err != nil { return uuid.Nil, err } - id, err := s.cfg.GetDBQueries().CreateClient(ctx, name) + id, err := s.cfg.GetDBQueries().CreateClient(ctx, &repository.CreateClientParams{ + Name: params.Name, + Externalid: params.ExternalId, + }) if err != nil { return uuid.Nil, err } return database.MustToUUID(id), nil } + +func (s *Service) normalizeCreate(params *CreateParams) error { + err := normalizeName(¶ms.Name) + if err != nil { + return err + } + + err = normalizeExternalID(¶ms.ExternalId) + if err != nil { + return err + } + + return nil +} + +func normalizeExternalID(id *string) error { + if id == nil { + return nil + } + + trim := strings.TrimSpace(*id) + pattern := regexp.MustCompile(`^[a-zA-Z0-9\_]+$`) + if !pattern.MatchString(trim) { + return errors.New("invalid external id") + } + + *id = trim + return nil +} diff --git a/internal/client/create_test.go b/internal/client/create_test.go index 5bd0f4d9..003f36b9 100644 --- a/internal/client/create_test.go +++ b/internal/client/create_test.go @@ -1,10 +1,9 @@ -package client_test +package client import ( "context" "testing" - "queryorchestration/internal/client" "queryorchestration/internal/database" "queryorchestration/internal/database/repository" "queryorchestration/internal/serviceconfig" @@ -24,18 +23,66 @@ func TestCreate(t *testing.T) { cfg.DBPool = pool cfg.DBQueries = repository.New(pool) - svc := client.New(cfg) + svc := New(cfg) - name := "client_name" + params := CreateParams{ + Name: "client_name", + ExternalId: "external_id", + } aid := uuid.New() - pool.ExpectQuery("name: CreateClient :one").WithArgs(name). + pool.ExpectQuery("name: CreateClient :one").WithArgs(params.ExternalId, params.Name). WillReturnRows( pgxmock.NewRows([]string{"id"}). AddRow(database.MustToDBUUID(aid)), ) - id, err := svc.Create(ctx, name) + id, err := svc.Create(ctx, params) assert.NoError(t, err) assert.Equal(t, aid, id) } + +func TestNormalizeCreate(t *testing.T) { + cfg := &serviceconfig.BaseConfig{} + + svc := New(cfg) + + t.Run("no change", func(t *testing.T) { + params := &CreateParams{ + Name: "client_name", + ExternalId: "external_id", + } + + err := svc.normalizeCreate(params) + assert.NoError(t, err) + assert.Equal(t, "client_name", params.Name) + assert.Equal(t, "external_id", params.ExternalId) + }) + t.Run("all change", func(t *testing.T) { + params := &CreateParams{ + Name: " client_name", + ExternalId: " external_id", + } + + err := svc.normalizeCreate(params) + assert.NoError(t, err) + assert.Equal(t, "client_name", params.Name) + assert.Equal(t, "external_id", params.ExternalId) + }) +} + +func TestNormalizeExternalID(t *testing.T) { + externalIds := []string{ + "ABC", + "ABC_XYZ", + "A12B", + } + + for _, id := range externalIds { + assert.Nil(t, normalizeExternalID(&id)) + } + + id := " ABC\t" + assert.Nil(t, normalizeExternalID(&id)) + assert.Equal(t, "ABC", id) +} diff --git a/internal/client/get.go b/internal/client/get.go index e1b06705..edbe93a8 100644 --- a/internal/client/get.go +++ b/internal/client/get.go @@ -4,6 +4,7 @@ import ( "context" "queryorchestration/internal/database" + "queryorchestration/internal/database/repository" "github.com/google/uuid" ) @@ -14,9 +15,23 @@ func (s *Service) Get(ctx context.Context, id uuid.UUID) (*Client, error) { return nil, err } - return &Client{ - ID: database.MustToUUID(client.ID), - Name: client.Name, - CanSync: client.Cansync, - }, nil + return parseFullClient(client), nil +} + +func (s *Service) GetByExternalId(ctx context.Context, id string) (*Client, error) { + client, err := s.cfg.GetDBQueries().GetClientByExternalId(ctx, id) + if err != nil { + return nil, err + } + + return parseFullClient(client), nil +} + +func parseFullClient(client *repository.Fullclient) *Client { + return &Client{ + ID: database.MustToUUID(client.ID), + ExternalID: client.Externalid, + Name: client.Name, + CanSync: client.Cansync, + } } diff --git a/internal/client/get_test.go b/internal/client/get_test.go index bc95c8b5..60c68169 100644 --- a/internal/client/get_test.go +++ b/internal/client/get_test.go @@ -1,11 +1,10 @@ -package client_test +package client import ( "context" "errors" "testing" - "queryorchestration/internal/client" "queryorchestration/internal/database" "queryorchestration/internal/database/repository" "queryorchestration/internal/serviceconfig" @@ -25,22 +24,23 @@ func TestGet(t *testing.T) { cfg.DBPool = pool cfg.DBQueries = repository.New(pool) - svc := client.New(cfg) + svc := New(cfg) id := uuid.New() pool.ExpectQuery("name: GetClient :one").WithArgs(database.MustToDBUUID(id)). WillReturnRows( - pgxmock.NewRows([]string{"id", "name", "canSync"}). - AddRow(database.MustToDBUUID(id), "client_name", false), + pgxmock.NewRows([]string{"id", "externalId", "name", "canSync"}). + AddRow(database.MustToDBUUID(id), "client_id", "client_name", false), ) cli, err := svc.Get(ctx, id) assert.NoError(t, err) - assert.EqualExportedValues(t, &client.Client{ - ID: id, - Name: "client_name", - CanSync: false, + assert.EqualExportedValues(t, &Client{ + ID: id, + ExternalID: "client_id", + Name: "client_name", + CanSync: false, }, cli) dberr := "database failure" @@ -50,3 +50,56 @@ func TestGet(t *testing.T) { _, err = svc.Get(ctx, id) assert.EqualError(t, err, dberr) } + +func TestGetByExternalId(t *testing.T) { + ctx := context.Background() + + pool, err := pgxmock.NewPool() + require.NoError(t, err) + cfg := &serviceconfig.BaseConfig{} + cfg.DBPool = pool + cfg.DBQueries = repository.New(pool) + + svc := New(cfg) + + id := uuid.New() + externalId := "clientId" + + pool.ExpectQuery("name: GetClientByExternalId :one").WithArgs(externalId). + WillReturnRows( + pgxmock.NewRows([]string{"id", "externalId", "name", "canSync"}). + AddRow(database.MustToDBUUID(id), "client_id", "client_name", false), + ) + + cli, err := svc.GetByExternalId(ctx, externalId) + assert.NoError(t, err) + assert.EqualExportedValues(t, &Client{ + ID: id, + ExternalID: "client_id", + Name: "client_name", + CanSync: false, + }, cli) + + dberr := "database failure" + pool.ExpectQuery("name: GetClient :one").WithArgs(database.MustToDBUUID(id)). + WillReturnError(errors.New(dberr)) + + _, err = svc.Get(ctx, id) + assert.EqualError(t, err, dberr) +} + +func TestParseFullClient(t *testing.T) { + in := &repository.Fullclient{ + ID: database.MustToDBUUID(uuid.New()), + Externalid: "external_id", + Name: "name", + Cansync: true, + } + out := parseFullClient(in) + assert.EqualExportedValues(t, &Client{ + ID: database.MustToUUID(in.ID), + ExternalID: "external_id", + Name: "name", + CanSync: true, + }, out) +} diff --git a/internal/client/service.go b/internal/client/service.go index d80e4f46..9ae99ecc 100644 --- a/internal/client/service.go +++ b/internal/client/service.go @@ -1,7 +1,6 @@ package client import ( - "errors" "fmt" "regexp" "strings" @@ -12,9 +11,10 @@ import ( ) type Client struct { - ID uuid.UUID - Name string - CanSync bool + ID uuid.UUID + ExternalID string + Name string + CanSync bool } func (c *Client) normalizeCanSyncUpdate(n **bool) { @@ -50,19 +50,14 @@ func normalizeName(name *string) error { } uname := strings.TrimSpace(*name) - - if uname == "" { - return errors.New("name required") - } - spacere := regexp.MustCompile(`\s+`) uname = spacere.ReplaceAllString(uname, " ") - reg := `^[a-zA-Z0-9\_\- ]+$` + reg := `^[a-zA-Z0-9\_\- \(\)\.\,]+$` alphanumeric := regexp.MustCompile(reg) if !alphanumeric.MatchString(uname) { - return fmt.Errorf("name must have regex: %s", reg) + return fmt.Errorf(`"%s" must have regex: %s`, uname, reg) } *name = uname diff --git a/internal/client/serviceprivate_test.go b/internal/client/serviceprivate_test.go index 3ce9f00e..000b962a 100644 --- a/internal/client/serviceprivate_test.go +++ b/internal/client/serviceprivate_test.go @@ -8,44 +8,29 @@ import ( ) func TestNormalizeName(t *testing.T) { - name := "name" + names := map[string]string{ + "name": "name", + " name\t": "name", + "name second": "name second", + "name\t second": "name second", + "name_second": "name_second", + "name-second": "name-second", + "name123": "name123", + "Name One - Two": "Name One - Two", + "Name, Inc.": "Name, Inc.", + "Namer - Two": "Namer - Two", + "Name (Hello One)": "Name (Hello One)", + "Name (Hello One) Bye": "Name (Hello One) Bye", + } + for key, value := range names { + err := normalizeName(&key) + assert.NoError(t, err) + assert.Equal(t, value, key) + } + + name := "" err := normalizeName(&name) - assert.NoError(t, err) - assert.Equal(t, "name", name) - - name = "" - err = normalizeName(&name) assert.Error(t, err) - - name = " name\t" - err = normalizeName(&name) - assert.NoError(t, err) - assert.Equal(t, "name", name) - - name = "name second" - err = normalizeName(&name) - assert.NoError(t, err) - assert.Equal(t, "name second", name) - - name = "name\t second" - err = normalizeName(&name) - assert.NoError(t, err) - assert.Equal(t, "name second", name) - - name = "name_second" - err = normalizeName(&name) - assert.NoError(t, err) - assert.Equal(t, "name_second", name) - - name = "name-second" - err = normalizeName(&name) - assert.NoError(t, err) - assert.Equal(t, "name-second", name) - - name = "name123" - err = normalizeName(&name) - assert.NoError(t, err) - assert.Equal(t, "name123", name) } func TestNormalizeCanSyncUpdate(t *testing.T) { diff --git a/internal/client/status.go b/internal/client/status.go index 81a8f902..88b1cb1a 100644 --- a/internal/client/status.go +++ b/internal/client/status.go @@ -2,10 +2,6 @@ package client import ( "context" - - "queryorchestration/internal/database" - - "github.com/google/uuid" ) type Status string @@ -16,15 +12,15 @@ const ( IN_SYNC Status = "in_sync" ) -func (s *Service) GetStatus(ctx context.Context, id uuid.UUID) (Status, error) { - client, err := s.cfg.GetDBQueries().GetClient(ctx, database.MustToDBUUID(id)) +func (s *Service) GetStatusByExternalId(ctx context.Context, id string) (Status, error) { + client, err := s.cfg.GetDBQueries().GetClientByExternalId(ctx, id) if err != nil { return NOT_SYNCING, err } else if !client.Cansync { return NOT_SYNCING, nil } - issynced, err := s.cfg.GetDBQueries().IsClientSynced(ctx, database.MustToDBUUID(id)) + issynced, err := s.cfg.GetDBQueries().IsClientSynced(ctx, client.ID) if err != nil { return NOT_SYNCING, err } else if issynced { diff --git a/internal/client/status_test.go b/internal/client/status_test.go index 061f49cc..5bcccc93 100644 --- a/internal/client/status_test.go +++ b/internal/client/status_test.go @@ -16,7 +16,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestGetStatus(t *testing.T) { +func TestGetStatusByExternalId(t *testing.T) { ctx := context.Background() pool, err := pgxmock.NewPool() @@ -27,52 +27,53 @@ func TestGetStatus(t *testing.T) { svc := client.New(cfg) + externalId := "clientid" clientId := uuid.New() t.Run("is synced", func(t *testing.T) { - pool.ExpectQuery("name: GetClient :one").WithArgs(database.MustToDBUUID(clientId)).WillReturnRows( - pgxmock.NewRows([]string{"id", "name", "can_sync"}). - AddRow(database.MustToDBUUID(clientId), "name", true), + pool.ExpectQuery("name: GetClientByExternalId :one").WithArgs(externalId).WillReturnRows( + pgxmock.NewRows([]string{"id", "externalId", "name", "can_sync"}). + AddRow(database.MustToDBUUID(clientId), externalId, "name", true), ) pool.ExpectQuery("name: IsClientSynced :one").WithArgs(database.MustToDBUUID(clientId)).WillReturnRows( pgxmock.NewRows([]string{"issynced"}). AddRow(true), ) - issynced, err := svc.GetStatus(ctx, clientId) + issynced, err := svc.GetStatusByExternalId(ctx, externalId) assert.NoError(t, err) assert.Equal(t, client.IN_SYNC, issynced) }) t.Run("not synced", func(t *testing.T) { - pool.ExpectQuery("name: GetClient :one").WithArgs(database.MustToDBUUID(clientId)).WillReturnRows( - pgxmock.NewRows([]string{"id", "name", "can_sync"}). - AddRow(database.MustToDBUUID(clientId), "name", true), + pool.ExpectQuery("name: GetClientByExternalId :one").WithArgs(externalId).WillReturnRows( + pgxmock.NewRows([]string{"id", "externalId", "name", "can_sync"}). + AddRow(database.MustToDBUUID(clientId), externalId, "name", true), ) pool.ExpectQuery("name: IsClientSynced :one").WithArgs(database.MustToDBUUID(clientId)).WillReturnRows( pgxmock.NewRows([]string{"issynced"}). AddRow(false), ) - issynced, err := svc.GetStatus(ctx, clientId) + issynced, err := svc.GetStatusByExternalId(ctx, externalId) assert.NoError(t, err) assert.Equal(t, client.NOT_SYNCED, issynced) }) t.Run("not syncing", func(t *testing.T) { - pool.ExpectQuery("name: GetClient :one").WithArgs(database.MustToDBUUID(clientId)).WillReturnRows( - pgxmock.NewRows([]string{"id", "name", "can_sync"}). - AddRow(database.MustToDBUUID(clientId), "name", false), + pool.ExpectQuery("name: GetClientByExternalId :one").WithArgs(externalId).WillReturnRows( + pgxmock.NewRows([]string{"id", "externalId", "name", "can_sync"}). + AddRow(database.MustToDBUUID(clientId), "id", "name", false), ) - issynced, err := svc.GetStatus(ctx, clientId) + issynced, err := svc.GetStatusByExternalId(ctx, externalId) assert.NoError(t, err) assert.Equal(t, client.NOT_SYNCING, issynced) }) t.Run("db error", func(t *testing.T) { errStr := "db fail" - pool.ExpectQuery("name: GetClient :one").WithArgs(database.MustToDBUUID(clientId)). + pool.ExpectQuery("name: GetClientByExternalId :one").WithArgs(externalId). WillReturnError(errors.New(errStr)) - _, err = svc.GetStatus(ctx, clientId) + _, err = svc.GetStatusByExternalId(ctx, externalId) assert.EqualError(t, err, errStr) }) } diff --git a/internal/client/update.go b/internal/client/update.go index 873064fa..c100cbf3 100644 --- a/internal/client/update.go +++ b/internal/client/update.go @@ -12,24 +12,13 @@ import ( "github.com/google/uuid" ) -type Update struct { - ID uuid.UUID - Name *string - CanSync *bool -} - -func (s *Service) Update(ctx context.Context, entity *Update) error { - current, err := s.Get(ctx, entity.ID) +func (s *Service) UpdateByExternalId(ctx context.Context, id string, entity *Update) error { + client, err := s.cfg.GetDBQueries().GetClientByExternalId(ctx, id) if err != nil { return err } - err = s.normalizeUpdateParams(current, entity) - if err != nil { - return err - } - - err = s.submitUpdate(ctx, entity) + err = s.Update(ctx, database.MustToUUID(client.ID), entity) if err != nil { return err } @@ -37,9 +26,33 @@ func (s *Service) Update(ctx context.Context, entity *Update) error { return nil } -func (s *Service) submitUpdate(ctx context.Context, entity *Update) error { +type Update struct { + Name *string + CanSync *bool +} + +func (s *Service) Update(ctx context.Context, id uuid.UUID, entity *Update) error { + current, err := s.Get(ctx, id) + if err != nil { + return err + } + + err = s.normalizeUpdateParams(id, current, entity) + if err != nil { + return err + } + + err = s.submitUpdate(ctx, id, entity) + if err != nil { + return err + } + + return nil +} + +func (s *Service) submitUpdate(ctx context.Context, id uuid.UUID, entity *Update) error { return s.cfg.ExecuteDBTransaction(ctx, func(ctx context.Context, q *repository.Queries) error { - id := database.MustToDBUUID(entity.ID) + id := database.MustToDBUUID(id) if entity.Name != nil { err := q.UpdateClient(ctx, &repository.UpdateClientParams{ @@ -67,8 +80,8 @@ func (s *Service) submitUpdate(ctx context.Context, entity *Update) error { }) } -func (s *Service) normalizeUpdateParams(current *Client, entity *Update) error { - if entity == nil || current == nil || current.ID != entity.ID { +func (s *Service) normalizeUpdateParams(id uuid.UUID, current *Client, entity *Update) error { + if entity == nil || current == nil || current.ID != id { return errors.New("no updates presented") } diff --git a/internal/client/update_test.go b/internal/client/update_test.go index cbe89163..0e513d56 100644 --- a/internal/client/update_test.go +++ b/internal/client/update_test.go @@ -30,9 +30,7 @@ func TestUpdate(t *testing.T) { Name: "example_name", CanSync: false, } - update := Update{ - ID: c.ID, - } + update := Update{} pool.ExpectQuery("name: GetClient :one").WithArgs(database.MustToDBUUID(c.ID)). WillReturnRows( @@ -40,7 +38,7 @@ func TestUpdate(t *testing.T) { AddRow(database.MustToDBUUID(c.ID), c.Name, c.CanSync), ) - err = svc.Update(ctx, &update) + err = svc.Update(ctx, c.ID, &update) assert.Error(t, err) c.CanSync = false @@ -52,7 +50,7 @@ func TestUpdate(t *testing.T) { AddRow(database.MustToDBUUID(c.ID), c.Name, c.CanSync), ) - err = svc.Update(ctx, &update) + err = svc.Update(ctx, c.ID, &update) assert.Error(t, err) c.Name = "updated_name" @@ -63,17 +61,17 @@ func TestUpdate(t *testing.T) { pgxmock.NewRows([]string{"id", "name", "canSync"}). AddRow(database.MustToDBUUID(c.ID), c.Name, c.CanSync), ) - pool.ExpectExec("name: UpdateClient :exec").WithArgs(*update.Name, database.MustToDBUUID(update.ID)). + pool.ExpectExec("name: UpdateClient :exec").WithArgs(*update.Name, database.MustToDBUUID(c.ID)). WillReturnResult(pgxmock.NewResult("", 1)) - err = svc.Update(ctx, &update) + err = svc.Update(ctx, c.ID, &update) assert.Error(t, err) } func TestNormalizeUpdateParams(t *testing.T) { svc := Service{} - err := svc.normalizeUpdateParams(nil, nil) + err := svc.normalizeUpdateParams(uuid.Nil, nil, nil) assert.Error(t, err) current := &Client{ @@ -82,32 +80,29 @@ func TestNormalizeUpdateParams(t *testing.T) { } update := &Update{} - err = svc.normalizeUpdateParams(current, update) + err = svc.normalizeUpdateParams(current.ID, current, update) assert.Error(t, err) n := "updated_client" cs := true update = &Update{ - ID: current.ID, Name: &n, CanSync: &cs, } - err = svc.normalizeUpdateParams(current, update) + err = svc.normalizeUpdateParams(current.ID, current, update) assert.NoError(t, err) n = "updated_client" cs = true assert.EqualExportedValues(t, Update{ - ID: current.ID, Name: &n, CanSync: &cs, }, *update) update = &Update{ - ID: current.ID, Name: ¤t.Name, CanSync: ¤t.CanSync, } - err = svc.normalizeUpdateParams(current, update) + err = svc.normalizeUpdateParams(current.ID, current, update) assert.Error(t, err) } @@ -127,25 +122,23 @@ func TestSubmitUpdate(t *testing.T) { Name: "example_name", CanSync: false, } - update := Update{ - ID: c.ID, - } + update := Update{} pool.ExpectBegin() pool.ExpectCommit() - err = svc.submitUpdate(ctx, &update) + err = svc.submitUpdate(ctx, c.ID, &update) assert.NoError(t, err) c.CanSync = true update.CanSync = &c.CanSync pool.ExpectBegin() - pool.ExpectExec("name: AddClientCanSync :exec").WithArgs(*update.CanSync, database.MustToDBUUID(update.ID)). + pool.ExpectExec("name: AddClientCanSync :exec").WithArgs(*update.CanSync, database.MustToDBUUID(c.ID)). WillReturnResult(pgxmock.NewResult("", 1)) pool.ExpectCommit() - err = svc.submitUpdate(ctx, &update) + err = svc.submitUpdate(ctx, c.ID, &update) assert.NoError(t, err) c.Name = "updated_name" @@ -153,10 +146,77 @@ func TestSubmitUpdate(t *testing.T) { update.CanSync = nil pool.ExpectBegin() - pool.ExpectExec("name: UpdateClient :exec").WithArgs(*update.Name, database.MustToDBUUID(update.ID)). + pool.ExpectExec("name: UpdateClient :exec").WithArgs(*update.Name, database.MustToDBUUID(c.ID)). WillReturnResult(pgxmock.NewResult("", 1)) pool.ExpectCommit() - err = svc.submitUpdate(ctx, &update) + err = svc.submitUpdate(ctx, c.ID, &update) assert.NoError(t, err) } + +func TestUpdateByExternalId(t *testing.T) { + ctx := context.Background() + + pool, err := pgxmock.NewPool() + require.NoError(t, err) + cfg := &serviceconfig.BaseConfig{} + cfg.DBPool = pool + cfg.DBQueries = repository.New(pool) + + svc := New(cfg) + + c := Client{ + ID: uuid.New(), + ExternalID: "extarnal_id", + Name: "example_name", + CanSync: false, + } + t.Run("no update", func(t *testing.T) { + update := Update{} + + pool.ExpectQuery("name: GetClientByExternalId :one").WithArgs(c.ExternalID). + WillReturnRows( + pgxmock.NewRows([]string{"id", "externalId", "name", "canSync"}). + AddRow(database.MustToDBUUID(c.ID), c.ExternalID, c.Name, c.CanSync), + ) + + pool.ExpectQuery("name: GetClient :one").WithArgs(database.MustToDBUUID(c.ID)). + WillReturnRows( + pgxmock.NewRows([]string{"id", "externalId", "name", "canSync"}). + AddRow(database.MustToDBUUID(c.ID), c.ExternalID, c.Name, c.CanSync), + ) + + err = svc.UpdateByExternalId(ctx, c.ExternalID, &update) + assert.Error(t, err) + }) + t.Run("no update", func(t *testing.T) { + update := Update{} + c.CanSync = false + update.CanSync = &c.CanSync + + pool.ExpectQuery("name: GetClient :one").WithArgs(database.MustToDBUUID(c.ID)). + WillReturnRows( + pgxmock.NewRows([]string{"id", "name", "canSync"}). + AddRow(database.MustToDBUUID(c.ID), c.Name, c.CanSync), + ) + + err = svc.UpdateByExternalId(ctx, c.ExternalID, &update) + assert.Error(t, err) + }) + t.Run("no update", func(t *testing.T) { + update := Update{} + c.Name = "updated_name" + update.Name = &c.Name + + pool.ExpectQuery("name: GetClient :one").WithArgs(database.MustToDBUUID(c.ID)). + WillReturnRows( + pgxmock.NewRows([]string{"id", "name", "canSync"}). + AddRow(database.MustToDBUUID(c.ID), c.Name, c.CanSync), + ) + pool.ExpectExec("name: UpdateClient :exec").WithArgs(*update.Name, database.MustToDBUUID(c.ID)). + WillReturnResult(pgxmock.NewResult("", 1)) + + err = svc.UpdateByExternalId(ctx, c.ExternalID, &update) + assert.Error(t, err) + }) +} diff --git a/internal/collector/get.go b/internal/collector/get.go index 62a03b5d..05a2d055 100644 --- a/internal/collector/get.go +++ b/internal/collector/get.go @@ -9,6 +9,15 @@ import ( "github.com/google/uuid" ) +func (s *Service) GetByClientExternalID(ctx context.Context, clientID string) (*Collector, error) { + dbColl, err := s.cfg.GetDBQueries().GetCollectorByClientExternalID(ctx, clientID) + if err != nil { + return nil, err + } + + return parseDBCollector(dbColl) +} + func (s *Service) GetByClientID(ctx context.Context, clientID uuid.UUID) (*Collector, error) { dbColl, err := s.cfg.GetDBQueries().GetCollectorByClientID(ctx, database.MustToDBUUID(clientID)) if err != nil { diff --git a/internal/collector/set/set.go b/internal/collector/set/set.go index f1472f88..7a5d78a9 100644 --- a/internal/collector/set/set.go +++ b/internal/collector/set/set.go @@ -16,21 +16,34 @@ import ( "github.com/jackc/pgx/v5/pgtype" ) +func (s *Service) SetByClientExternalId(ctx context.Context, id string, params *SetParams) error { + client, err := s.cfg.GetDBQueries().GetClientByExternalId(ctx, id) + if err != nil { + return nil + } + + err = s.SetByClientId(ctx, database.MustToUUID(client.ID), params) + if err != nil { + return nil + } + + return nil +} + type SetParams struct { - ClientID uuid.UUID ActiveVersion *int32 MinCleanVersion *int32 MinTextVersion *int32 Fields *map[string]uuid.UUID } -func (s *Service) SetByClientId(ctx context.Context, params *SetParams) error { - current, err := s.svc.Collector.GetByClientID(ctx, params.ClientID) +func (s *Service) SetByClientId(ctx context.Context, id uuid.UUID, params *SetParams) error { + current, err := s.svc.Collector.GetByClientID(ctx, id) if err != nil { return err } - dbparams, err := s.getSetParams(ctx, current, params) + dbparams, err := s.getSetParams(ctx, id, current, params) if err != nil { return err } @@ -69,7 +82,7 @@ type dbSetParams struct { Fields *map[string]pgtype.UUID } -func (s *Service) getSetParams(ctx context.Context, current *collector.Collector, params *SetParams) (*dbSetParams, error) { +func (s *Service) getSetParams(ctx context.Context, id uuid.UUID, current *collector.Collector, params *SetParams) (*dbSetParams, error) { err := s.normalizeCodeVersions(current, params) if err != nil { return nil, err @@ -101,7 +114,7 @@ func (s *Service) getSetParams(ctx context.Context, current *collector.Collector } return &dbSetParams{ - ClientID: database.MustToDBUUID(params.ClientID), + ClientID: database.MustToDBUUID(id), ActiveVersion: params.ActiveVersion, MinCleanVersion: params.MinCleanVersion, MinTextVersion: params.MinTextVersion, diff --git a/internal/collector/set/set_test.go b/internal/collector/set/set_test.go index 8cfb05e7..fc9bb307 100644 --- a/internal/collector/set/set_test.go +++ b/internal/collector/set/set_test.go @@ -52,12 +52,11 @@ func TestSet(t *testing.T) { av := int32(2) mv := int32(1) update := collectorset.SetParams{ - ClientID: current.ClientID, ActiveVersion: &av, MinCleanVersion: &mv, } - pool.ExpectQuery("name: GetCollectorByClientID :one").WithArgs(database.MustToDBUUID(update.ClientID)). + pool.ExpectQuery("name: GetCollectorByClientID :one").WithArgs(database.MustToDBUUID(current.ClientID)). WillReturnRows( pgxmock.NewRows([]string{"clientId", "minCleanVersion", "minTextVersion", "activeVersion", "latestVersion", "fields"}). AddRow(database.MustToDBUUID(current.ClientID), current.MinCleanVersion, current.MinTextVersion, current.ActiveVersion, current.LatestVersion, []byte("")), @@ -78,13 +77,13 @@ func TestSet(t *testing.T) { SendMessage( mock.Anything, mock.MatchedBy(func(in *sqs.SendMessageInput) bool { - return *in.QueueUrl == cfg.ClientSyncURL && *in.MessageBody == fmt.Sprintf("{\"id\":\"%s\"}", update.ClientID.String()) + return *in.QueueUrl == cfg.ClientSyncURL && *in.MessageBody == fmt.Sprintf("{\"id\":\"%s\"}", current.ClientID.String()) }), mock.Anything, ). Return(&sqs.SendMessageOutput{}, nil) - err = svc.SetByClientId(ctx, &update) + err = svc.SetByClientId(ctx, current.ClientID, &update) assert.NoError(t, err) }) t.Run("no collector", func(t *testing.T) { @@ -94,12 +93,11 @@ func TestSet(t *testing.T) { av := int32(1) mv := int32(1) update := collectorset.SetParams{ - ClientID: current.ClientID, ActiveVersion: &av, MinCleanVersion: &mv, } - pool.ExpectQuery("name: GetCollectorByClientID :one").WithArgs(database.MustToDBUUID(update.ClientID)). + pool.ExpectQuery("name: GetCollectorByClientID :one").WithArgs(database.MustToDBUUID(current.ClientID)). WillReturnRows( pgxmock.NewRows([]string{"clientId", "minCleanVersion", "minTextVersion", "activeVersion", "latestVersion", "fields"}). AddRow(database.MustToDBUUID(current.ClientID), current.MinCleanVersion, current.MinTextVersion, current.ActiveVersion, current.LatestVersion, []byte("")), @@ -120,13 +118,125 @@ func TestSet(t *testing.T) { SendMessage( mock.Anything, mock.MatchedBy(func(in *sqs.SendMessageInput) bool { - return *in.QueueUrl == cfg.ClientSyncURL && *in.MessageBody == fmt.Sprintf("{\"id\":\"%s\"}", update.ClientID.String()) + return *in.QueueUrl == cfg.ClientSyncURL && *in.MessageBody == fmt.Sprintf("{\"id\":\"%s\"}", current.ClientID.String()) }), mock.Anything, ). Return(&sqs.SendMessageOutput{}, nil) - err = svc.SetByClientId(ctx, &update) + err = svc.SetByClientId(ctx, current.ClientID, &update) + assert.NoError(t, err) + }) +} + +func TestSetByExternalId(t *testing.T) { + ctx := context.Background() + + pool, err := pgxmock.NewPool() + require.NoError(t, err) + cfg := &CollectorSetConfig{} + cfg.DBPool = pool + cfg.DBQueries = repository.New(pool) + mockSQS := queuemock.NewMockSQSClient(t) + cfg.QueueClient = mockSQS + cfg.ClientSyncURL = "here" + + svc := collectorset.New(cfg, &collectorset.Services{ + Collector: collector.New(cfg), + }) + + externalId := "client_id" + + t.Run("valid", func(t *testing.T) { + current := collector.Collector{ + ClientID: uuid.New(), + ActiveVersion: 1, + LatestVersion: 4, + } + av := int32(2) + mv := int32(1) + update := collectorset.SetParams{ + ActiveVersion: &av, + MinCleanVersion: &mv, + } + + pool.ExpectQuery("name: GetClientByExternalId :one").WithArgs(externalId).WillReturnRows( + pgxmock.NewRows([]string{"id", "externalId", "name", "can_sync"}). + AddRow(database.MustToDBUUID(current.ClientID), externalId, "name", true), + ) + pool.ExpectQuery("name: GetCollectorByClientID :one").WithArgs(database.MustToDBUUID(current.ClientID)). + WillReturnRows( + pgxmock.NewRows([]string{"clientId", "minCleanVersion", "minTextVersion", "activeVersion", "latestVersion", "fields"}). + AddRow(database.MustToDBUUID(current.ClientID), current.MinCleanVersion, current.MinTextVersion, current.ActiveVersion, current.LatestVersion, []byte("")), + ) + pool.ExpectBeginTx(pgx.TxOptions{}) + rv := current.LatestVersion + 1 + pool.ExpectQuery("name: AddLatestCollectorVersion :one").WithArgs(database.MustToDBUUID(current.ClientID)).WillReturnRows( + pgxmock.NewRows([]string{"version"}). + AddRow(rv), + ) + pool.ExpectExec("name: SetActiveCollectorVersion :exec").WithArgs(database.MustToDBUUID(current.ClientID), int32(2)). + WillReturnResult(pgxmock.NewResult("", 1)) + pool.ExpectExec("name: SetCollectorCleanVersion :exec").WithArgs(database.MustToDBUUID(current.ClientID), rv, *update.MinCleanVersion). + WillReturnResult(pgxmock.NewResult("", 1)) + pool.ExpectCommit() + + mockSQS.EXPECT(). + SendMessage( + mock.Anything, + mock.MatchedBy(func(in *sqs.SendMessageInput) bool { + return *in.QueueUrl == cfg.ClientSyncURL && *in.MessageBody == fmt.Sprintf("{\"id\":\"%s\"}", current.ClientID.String()) + }), + mock.Anything, + ). + Return(&sqs.SendMessageOutput{}, nil) + + err = svc.SetByClientExternalId(ctx, externalId, &update) + assert.NoError(t, err) + }) + t.Run("no collector", func(t *testing.T) { + current := collector.Collector{ + ClientID: uuid.New(), + } + av := int32(1) + mv := int32(1) + update := collectorset.SetParams{ + ActiveVersion: &av, + MinCleanVersion: &mv, + } + + pool.ExpectQuery("name: GetClientByExternalId :one").WithArgs(externalId).WillReturnRows( + pgxmock.NewRows([]string{"id", "externalId", "name", "can_sync"}). + AddRow(database.MustToDBUUID(current.ClientID), externalId, "name", true), + ) + pool.ExpectQuery("name: GetCollectorByClientID :one").WithArgs(database.MustToDBUUID(current.ClientID)). + WillReturnRows( + pgxmock.NewRows([]string{"clientId", "minCleanVersion", "minTextVersion", "activeVersion", "latestVersion", "fields"}). + AddRow(database.MustToDBUUID(current.ClientID), current.MinCleanVersion, current.MinTextVersion, current.ActiveVersion, current.LatestVersion, []byte("")), + ) + pool.ExpectBeginTx(pgx.TxOptions{}) + rv := current.LatestVersion + 1 + pool.ExpectQuery("name: AddLatestCollectorVersion :one").WithArgs(database.MustToDBUUID(current.ClientID)).WillReturnRows( + pgxmock.NewRows([]string{"version"}). + AddRow(rv), + ) + pool.ExpectExec("name: SetActiveCollectorVersion :exec").WithArgs(database.MustToDBUUID(current.ClientID), int32(1)). + WillReturnResult(pgxmock.NewResult("", 1)) + pool.ExpectExec("name: SetCollectorCleanVersion :exec").WithArgs(database.MustToDBUUID(current.ClientID), rv, *update.MinCleanVersion). + WillReturnResult(pgxmock.NewResult("", 1)) + pool.ExpectCommit() + + mockSQS.EXPECT(). + SendMessage( + mock.Anything, + mock.MatchedBy(func(in *sqs.SendMessageInput) bool { + return *in.QueueUrl == cfg.ClientSyncURL && *in.MessageBody == fmt.Sprintf("{\"id\":\"%s\"}", current.ClientID.String()) + }), + mock.Anything, + ). + Return(&sqs.SendMessageOutput{}, nil) + + err = svc.SetByClientExternalId(ctx, externalId, &update) assert.NoError(t, err) }) } diff --git a/internal/collector/set/setprivate_test.go b/internal/collector/set/setprivate_test.go index cb9db766..2d2099ac 100644 --- a/internal/collector/set/setprivate_test.go +++ b/internal/collector/set/setprivate_test.go @@ -54,7 +54,6 @@ func TestGetSetParams(t *testing.T) { LatestVersion: 10, } params := SetParams{ - ClientID: uuid.New(), ActiveVersion: &aV, MinCleanVersion: &minCleanV, MinTextVersion: &minTextV, @@ -68,10 +67,12 @@ func TestGetSetParams(t *testing.T) { AddRow(true), ) - dbparams, err := svc.getSetParams(ctx, ¤t, ¶ms) + clientId := uuid.New() + + dbparams, err := svc.getSetParams(ctx, clientId, ¤t, ¶ms) assert.NoError(t, err) assert.EqualExportedValues(t, &dbSetParams{ - ClientID: database.MustToDBUUID(params.ClientID), + ClientID: database.MustToDBUUID(clientId), ActiveVersion: &aV, MinCleanVersion: &minCleanV, MinTextVersion: &minTextV, @@ -82,7 +83,7 @@ func TestGetSetParams(t *testing.T) { (*params.Fields)["second_key"] = (*params.Fields)["example_key"] assert.Len(t, *params.Fields, 2) - _, err = svc.getSetParams(ctx, ¤t, ¶ms) + _, err = svc.getSetParams(ctx, clientId, ¤t, ¶ms) assert.Error(t, err) }) @@ -101,10 +102,8 @@ func TestGetSetParams(t *testing.T) { } current := collector.Collector{} - params := SetParams{ - ClientID: current.ClientID, - } - _, err = svc.getSetParams(ctx, ¤t, ¶ms) + params := SetParams{} + _, err = svc.getSetParams(ctx, current.ClientID, ¤t, ¶ms) assert.EqualError(t, err, "no changes") }) @@ -128,10 +127,9 @@ func TestGetSetParams(t *testing.T) { } version := int32(5) params := SetParams{ - ClientID: current.ClientID, ActiveVersion: &version, } - _, err = svc.getSetParams(ctx, ¤t, ¶ms) + _, err = svc.getSetParams(ctx, current.ClientID, ¤t, ¶ms) assert.EqualError(t, err, "no changes") }) @@ -155,12 +153,11 @@ func TestGetSetParams(t *testing.T) { }, } params := SetParams{ - ClientID: current.ClientID, Fields: &map[string]uuid.UUID{ "example": current.Fields["example"], }, } - _, err = svc.getSetParams(ctx, ¤t, ¶ms) + _, err = svc.getSetParams(ctx, current.ClientID, ¤t, ¶ms) assert.EqualError(t, err, "no changes") }) } diff --git a/internal/database/repository/clean_test.go b/internal/database/repository/clean_test.go index 8dce52ac..32a80eb3 100644 --- a/internal/database/repository/clean_test.go +++ b/internal/database/repository/clean_test.go @@ -30,7 +30,10 @@ func TestClean(t *testing.T) { queries := cfg.GetDBQueries() - clientId, err := queries.CreateClient(ctx, "example_client") + clientId, err := queries.CreateClient(ctx, &repository.CreateClientParams{ + Name: "example_client", + Externalid: "EXAMPLE", + }) assert.NoError(t, err) hash := "example_hash" diff --git a/internal/database/repository/client.sql.go b/internal/database/repository/client.sql.go index b69ed43b..51bb3afa 100644 --- a/internal/database/repository/client.sql.go +++ b/internal/database/repository/client.sql.go @@ -29,42 +29,59 @@ func (q *Queries) AddClientCanSync(ctx context.Context, arg *AddClientCanSyncPar } const createClient = `-- name: CreateClient :one -INSERT INTO clients (name) VALUES ($1) RETURNING id +INSERT INTO clients (externalId, name) VALUES ($1, $2) RETURNING id ` +type CreateClientParams struct { + Externalid string `db:"externalid"` + Name string `db:"name"` +} + // CreateClient // -// INSERT INTO clients (name) VALUES ($1) RETURNING id -func (q *Queries) CreateClient(ctx context.Context, name string) (pgtype.UUID, error) { - row := q.db.QueryRow(ctx, createClient, name) +// INSERT INTO clients (externalId, name) VALUES ($1, $2) RETURNING id +func (q *Queries) CreateClient(ctx context.Context, arg *CreateClientParams) (pgtype.UUID, error) { + row := q.db.QueryRow(ctx, createClient, arg.Externalid, arg.Name) var id pgtype.UUID err := row.Scan(&id) return id, err } const getClient = `-- name: GetClient :one -SELECT c.id, c.name, cs.canSync - FROM clients as c - JOIN currentClientCanSync as cs on cs.clientId = c.id - WHERE c.id = $1 +SELECT id, externalid, name, cansync FROM fullClients WHERE id = $1 ` -type GetClientRow struct { - ID pgtype.UUID `db:"id"` - Name string `db:"name"` - Cansync bool `db:"cansync"` -} - // GetClient // -// SELECT c.id, c.name, cs.canSync -// FROM clients as c -// JOIN currentClientCanSync as cs on cs.clientId = c.id -// WHERE c.id = $1 -func (q *Queries) GetClient(ctx context.Context, id pgtype.UUID) (*GetClientRow, error) { +// SELECT id, externalid, name, cansync FROM fullClients WHERE id = $1 +func (q *Queries) GetClient(ctx context.Context, id pgtype.UUID) (*Fullclient, error) { row := q.db.QueryRow(ctx, getClient, id) - var i GetClientRow - err := row.Scan(&i.ID, &i.Name, &i.Cansync) + var i Fullclient + err := row.Scan( + &i.ID, + &i.Externalid, + &i.Name, + &i.Cansync, + ) + return &i, err +} + +const getClientByExternalId = `-- name: GetClientByExternalId :one +SELECT id, externalid, name, cansync FROM fullClients WHERE externalId = $1 +` + +// GetClientByExternalId +// +// SELECT id, externalid, name, cansync FROM fullClients WHERE externalId = $1 +func (q *Queries) GetClientByExternalId(ctx context.Context, externalid string) (*Fullclient, error) { + row := q.db.QueryRow(ctx, getClientByExternalId, externalid) + var i Fullclient + err := row.Scan( + &i.ID, + &i.Externalid, + &i.Name, + &i.Cansync, + ) return &i, err } diff --git a/internal/database/repository/client_test.go b/internal/database/repository/client_test.go index 772f9139..7761bb80 100644 --- a/internal/database/repository/client_test.go +++ b/internal/database/repository/client_test.go @@ -30,30 +30,42 @@ func TestClient(t *testing.T) { queries := cfg.GetDBQueries() - id, err := queries.CreateClient(ctx, "example_client") + name := "example_name" + externalId := "EXAMPLE" + id, err := queries.CreateClient(ctx, &repository.CreateClientParams{ + Name: name, + Externalid: externalId, + }) assert.NoError(t, err) assert.NotEmpty(t, id) client, err := queries.GetClient(ctx, id) assert.NoError(t, err) - assert.EqualExportedValues(t, &repository.GetClientRow{ - ID: id, - Name: "example_client", - Cansync: false, + assert.EqualExportedValues(t, &repository.Fullclient{ + ID: id, + Name: name, + Externalid: externalId, + Cansync: false, }, client) + externalClient, err := queries.GetClientByExternalId(ctx, externalId) + assert.NoError(t, err) + assert.EqualExportedValues(t, client, externalClient) + + name = "updated_client" err = queries.UpdateClient(ctx, &repository.UpdateClientParams{ ID: id, - Name: "updated_client", + Name: name, }) assert.NoError(t, err) client, err = queries.GetClient(ctx, id) assert.NoError(t, err) - assert.EqualExportedValues(t, &repository.GetClientRow{ - ID: id, - Name: "updated_client", - Cansync: false, + assert.EqualExportedValues(t, &repository.Fullclient{ + ID: id, + Name: name, + Externalid: externalId, + Cansync: false, }, client) err = queries.AddClientCanSync(ctx, &repository.AddClientCanSyncParams{ @@ -64,9 +76,31 @@ func TestClient(t *testing.T) { client, err = queries.GetClient(ctx, id) assert.NoError(t, err) - assert.EqualExportedValues(t, &repository.GetClientRow{ - ID: id, - Name: "updated_client", - Cansync: true, + assert.EqualExportedValues(t, &repository.Fullclient{ + ID: id, + Name: name, + Externalid: externalId, + Cansync: true, }, client) + + _, err = queries.CreateClient(ctx, &repository.CreateClientParams{ + Name: name, + Externalid: externalId, + }) + assert.Error(t, err) + _, err = queries.CreateClient(ctx, &repository.CreateClientParams{ + Name: name, + Externalid: "definitely different", + }) + assert.Error(t, err) + _, err = queries.CreateClient(ctx, &repository.CreateClientParams{ + Name: "100 different", + Externalid: externalId, + }) + assert.Error(t, err) + _, err = queries.CreateClient(ctx, &repository.CreateClientParams{ + Name: "sameid", + Externalid: "sameid", + }) + assert.NoError(t, err) } diff --git a/internal/database/repository/collector.sql.go b/internal/database/repository/collector.sql.go index a275daed..aa146853 100644 --- a/internal/database/repository/collector.sql.go +++ b/internal/database/repository/collector.sql.go @@ -49,6 +49,37 @@ func (q *Queries) AddLatestCollectorVersion(ctx context.Context, clientid pgtype return id, err } +const getCollectorByClientExternalID = `-- name: GetCollectorByClientExternalID :one +WITH client as ( + SELECT id from clients where externalId = $1 +) +SELECT fc.clientid, fc.mincleanversion, fc.mintextversion, fc.activeversion, fc.latestversion, fc.fields + FROM fullActiveCollectors as fc + JOIN client as c ON fc.clientId = c.id LIMIT 1 +` + +// GetCollectorByClientExternalID +// +// WITH client as ( +// SELECT id from clients where externalId = $1 +// ) +// SELECT fc.clientid, fc.mincleanversion, fc.mintextversion, fc.activeversion, fc.latestversion, fc.fields +// FROM fullActiveCollectors as fc +// JOIN client as c ON fc.clientId = c.id LIMIT 1 +func (q *Queries) GetCollectorByClientExternalID(ctx context.Context, clientid string) (*Fullactivecollector, error) { + row := q.db.QueryRow(ctx, getCollectorByClientExternalID, clientid) + var i Fullactivecollector + err := row.Scan( + &i.Clientid, + &i.Mincleanversion, + &i.Mintextversion, + &i.Activeversion, + &i.Latestversion, + &i.Fields, + ) + return &i, err +} + const getCollectorByClientID = `-- name: GetCollectorByClientID :one SELECT clientid, mincleanversion, mintextversion, activeversion, latestversion, fields FROM fullActiveCollectors WHERE clientId = $1 LIMIT 1 ` diff --git a/internal/database/repository/collector_test.go b/internal/database/repository/collector_test.go index a0d06455..6c8815dd 100644 --- a/internal/database/repository/collector_test.go +++ b/internal/database/repository/collector_test.go @@ -52,7 +52,10 @@ func TestCollector(t *testing.T) { }) assert.NoError(t, err) - clientId, err := queries.CreateClient(ctx, "example_client") + clientId, err := queries.CreateClient(ctx, &repository.CreateClientParams{ + Name: "example_client", + Externalid: "EXAMPLE", + }) assert.NoError(t, err) minCleanVersion := int32(2) minTextVersion := int32(4) diff --git a/internal/database/repository/document.sql.go b/internal/database/repository/document.sql.go index d256d4b7..3117c232 100644 --- a/internal/database/repository/document.sql.go +++ b/internal/database/repository/document.sql.go @@ -139,9 +139,14 @@ func (q *Queries) ListDocumentIDsBatch(ctx context.Context, arg *ListDocumentIDs return items, nil } -const listDocumentsByClientId = `-- name: ListDocumentsByClientId :many -WITH docs as ( - SELECT id from documents where clientId = $1 +const listDocumentsByClientExternalId = `-- name: ListDocumentsByClientExternalId :many +WITH client as ( + SELECT id from clients where externalId = $1 +), +docs as ( + SELECT d.id + from documents as d + JOIN client as c on d.clientId = c.id ), entries as ( SELECT @@ -155,16 +160,21 @@ entries as ( SELECT documentId as id, bucket, key from entries WHERE rowNumber = 1 ` -type ListDocumentsByClientIdRow struct { +type ListDocumentsByClientExternalIdRow struct { ID pgtype.UUID `db:"id"` Bucket string `db:"bucket"` Key string `db:"key"` } -// ListDocumentsByClientId +// ListDocumentsByClientExternalId // -// WITH docs as ( -// SELECT id from documents where clientId = $1 +// WITH client as ( +// SELECT id from clients where externalId = $1 +// ), +// docs as ( +// SELECT d.id +// from documents as d +// JOIN client as c on d.clientId = c.id // ), // entries as ( // SELECT @@ -176,15 +186,15 @@ type ListDocumentsByClientIdRow struct { // JOIN documentEntries de on d.id = de.documentId // ) // SELECT documentId as id, bucket, key from entries WHERE rowNumber = 1 -func (q *Queries) ListDocumentsByClientId(ctx context.Context, clientid pgtype.UUID) ([]*ListDocumentsByClientIdRow, error) { - rows, err := q.db.Query(ctx, listDocumentsByClientId, clientid) +func (q *Queries) ListDocumentsByClientExternalId(ctx context.Context, clientid string) ([]*ListDocumentsByClientExternalIdRow, error) { + rows, err := q.db.Query(ctx, listDocumentsByClientExternalId, clientid) if err != nil { return nil, err } defer rows.Close() - items := []*ListDocumentsByClientIdRow{} + items := []*ListDocumentsByClientExternalIdRow{} for rows.Next() { - var i ListDocumentsByClientIdRow + var i ListDocumentsByClientExternalIdRow if err := rows.Scan(&i.ID, &i.Bucket, &i.Key); err != nil { return nil, err } diff --git a/internal/database/repository/document_test.go b/internal/database/repository/document_test.go index f43a03fe..dd321b6e 100644 --- a/internal/database/repository/document_test.go +++ b/internal/database/repository/document_test.go @@ -30,10 +30,14 @@ func TestDocument(t *testing.T) { queries := cfg.GetDBQueries() - clientId, err := queries.CreateClient(ctx, "example_client") + externalId := "example_id" + clientId, err := queries.CreateClient(ctx, &repository.CreateClientParams{ + Name: "example_name", + Externalid: externalId, + }) assert.NoError(t, err) - docs, err := queries.ListDocumentsByClientId(ctx, clientId) + docs, err := queries.ListDocumentsByClientExternalId(ctx, externalId) assert.NoError(t, err) assert.Len(t, docs, 0) @@ -54,7 +58,7 @@ func TestDocument(t *testing.T) { }) assert.NoError(t, err) - docs, err = queries.ListDocumentsByClientId(ctx, clientId) + docs, err = queries.ListDocumentsByClientExternalId(ctx, externalId) assert.NoError(t, err) assert.Len(t, docs, 1) assert.Equal(t, bucketone, docs[0].Bucket) @@ -76,17 +80,21 @@ func TestDocument(t *testing.T) { }) assert.NoError(t, err) - docs, err = queries.ListDocumentsByClientId(ctx, clientId) + docs, err = queries.ListDocumentsByClientExternalId(ctx, externalId) assert.NoError(t, err) assert.Len(t, docs, 2) - clientTwoId, err := queries.CreateClient(ctx, "client two") + externalTwoId := "EXAMPLE TWO" + clientTwoId, err := queries.CreateClient(ctx, &repository.CreateClientParams{ + Name: "example_name_two", + Externalid: externalTwoId, + }) assert.NoError(t, err) - docs, err = queries.ListDocumentsByClientId(ctx, clientId) + docs, err = queries.ListDocumentsByClientExternalId(ctx, externalId) assert.NoError(t, err) assert.Len(t, docs, 2) - docs, err = queries.ListDocumentsByClientId(ctx, clientTwoId) + docs, err = queries.ListDocumentsByClientExternalId(ctx, externalTwoId) assert.NoError(t, err) assert.Len(t, docs, 0) @@ -105,10 +113,10 @@ func TestDocument(t *testing.T) { }) assert.NoError(t, err) - docs, err = queries.ListDocumentsByClientId(ctx, clientId) + docs, err = queries.ListDocumentsByClientExternalId(ctx, externalId) assert.NoError(t, err) assert.Len(t, docs, 2) - docs, err = queries.ListDocumentsByClientId(ctx, clientTwoId) + docs, err = queries.ListDocumentsByClientExternalId(ctx, externalTwoId) assert.NoError(t, err) assert.Len(t, docs, 1) assert.Equal(t, bucketthree, docs[0].Bucket) diff --git a/internal/database/repository/job_test.go b/internal/database/repository/job_test.go index 448f303b..1366ecf3 100644 --- a/internal/database/repository/job_test.go +++ b/internal/database/repository/job_test.go @@ -30,7 +30,10 @@ func TestListClientDocumentIDs(t *testing.T) { queries := cfg.GetDBQueries() - id, err := queries.CreateClient(ctx, "example_client") + id, err := queries.CreateClient(ctx, &repository.CreateClientParams{ + Name: "example_client", + Externalid: "EXAMPLE", + }) assert.NoError(t, err) ids, err := queries.ListDocumentIDsBatch(ctx, &repository.ListDocumentIDsBatchParams{ @@ -158,7 +161,10 @@ func TestClientSync(t *testing.T) { }) assert.NoError(t, err) - clientId, err := queries.CreateClient(ctx, "example_client") + clientId, err := queries.CreateClient(ctx, &repository.CreateClientParams{ + Name: "example_client", + Externalid: "EXAMPLE", + }) assert.NoError(t, err) _, err = queries.AddLatestCollectorVersion(ctx, clientId) diff --git a/internal/database/repository/models.go b/internal/database/repository/models.go index 5d4c40c3..d4ed5004 100644 --- a/internal/database/repository/models.go +++ b/internal/database/repository/models.go @@ -179,8 +179,9 @@ func (e Querytype) Valid() bool { } type Client struct { - ID pgtype.UUID `db:"id"` - Name string `db:"name"` + ID pgtype.UUID `db:"id"` + Externalid string `db:"externalid"` + Name string `db:"name"` } type Clientcansync struct { @@ -343,6 +344,13 @@ type Fullactivequery struct { Requiredids []pgtype.UUID `db:"requiredids"` } +type Fullclient struct { + ID pgtype.UUID `db:"id"` + Externalid string `db:"externalid"` + Name string `db:"name"` + Cansync bool `db:"cansync"` +} + type Query struct { ID pgtype.UUID `db:"id"` Type Querytype `db:"type"` diff --git a/internal/database/repository/query_test.go b/internal/database/repository/query_test.go index 117e2deb..defec16a 100644 --- a/internal/database/repository/query_test.go +++ b/internal/database/repository/query_test.go @@ -249,7 +249,10 @@ func TestQueryDependencyTree(t *testing.T) { queries := cfg.GetDBQueries() - clientID, err := queries.CreateClient(ctx, "example_client") + clientID, err := queries.CreateClient(ctx, &repository.CreateClientParams{ + Name: "example_client", + Externalid: "EXAMPLE", + }) assert.NoError(t, err) version, err := queries.AddLatestCollectorVersion(ctx, clientID) assert.NoError(t, err) @@ -535,7 +538,10 @@ func TestListQueryClients(t *testing.T) { assert.NoError(t, err) assert.ElementsMatch(t, []pgtype.UUID{}, clients) - clientOneID, err := queries.CreateClient(ctx, "example_client") + clientOneID, err := queries.CreateClient(ctx, &repository.CreateClientParams{ + Name: "example_client", + Externalid: "EXAMPLE", + }) assert.NoError(t, err) versionOne, err := queries.AddLatestCollectorVersion(ctx, clientOneID) assert.NoError(t, err) @@ -556,7 +562,10 @@ func TestListQueryClients(t *testing.T) { assert.NoError(t, err) assert.ElementsMatch(t, []pgtype.UUID{clientOneID}, clients) - clientTwoID, err := queries.CreateClient(ctx, "client dos") + clientTwoID, err := queries.CreateClient(ctx, &repository.CreateClientParams{ + Name: "example_client_dos", + Externalid: "EXAMPLE DOS", + }) assert.NoError(t, err) versionTwo, err := queries.AddLatestCollectorVersion(ctx, clientTwoID) assert.NoError(t, err) diff --git a/internal/database/repository/result_test.go b/internal/database/repository/result_test.go index b444a6e3..6639115e 100644 --- a/internal/database/repository/result_test.go +++ b/internal/database/repository/result_test.go @@ -41,7 +41,10 @@ func TestResults(t *testing.T) { }) assert.NoError(t, err) - clientId, err := queries.CreateClient(ctx, "example_client") + clientId, err := queries.CreateClient(ctx, &repository.CreateClientParams{ + Name: "example_client", + Externalid: "EXAMPLE", + }) assert.NoError(t, err) issynced, err := queries.IsClientSynced(ctx, clientId) @@ -164,7 +167,10 @@ func TestResultValues(t *testing.T) { jsonQueryID, err := queries.CreateQuery(ctx, repository.Querytype(repository.QuerytypeJsonExtractor)) assert.NoError(t, err) - clientId, err := queries.CreateClient(ctx, "example_client") + clientId, err := queries.CreateClient(ctx, &repository.CreateClientParams{ + Name: "example_client", + Externalid: "EXAMPLE", + }) assert.NoError(t, err) documentID, err := queries.CreateDocument(ctx, &repository.CreateDocumentParams{ Clientid: clientId, @@ -369,7 +375,10 @@ func TestUnsyncedNoDepsQueries(t *testing.T) { queries := cfg.GetDBQueries() - clientId, err := queries.CreateClient(ctx, "example_client") + clientId, err := queries.CreateClient(ctx, &repository.CreateClientParams{ + Name: "example_client", + Externalid: "EXAMPLE", + }) assert.NoError(t, err) version, err := queries.AddLatestCollectorVersion(ctx, clientId) assert.NoError(t, err) diff --git a/internal/database/repository/text_test.go b/internal/database/repository/text_test.go index be6c280e..da41144b 100644 --- a/internal/database/repository/text_test.go +++ b/internal/database/repository/text_test.go @@ -31,7 +31,10 @@ func TestTextExtraction(t *testing.T) { queries := cfg.GetDBQueries() - clientId, err := queries.CreateClient(ctx, "example_client") + clientId, err := queries.CreateClient(ctx, &repository.CreateClientParams{ + Name: "example_client", + Externalid: "EXAMPLE", + }) assert.NoError(t, err) hash := "example_hash" diff --git a/internal/document/list.go b/internal/document/list.go index 21271802..6855d2c6 100644 --- a/internal/document/list.go +++ b/internal/document/list.go @@ -14,8 +14,8 @@ type DocumentInList struct { Key string } -func (s *Service) ListByClientId(ctx context.Context, id uuid.UUID) ([]*DocumentInList, error) { - documents, err := s.cfg.GetDBQueries().ListDocumentsByClientId(ctx, database.MustToDBUUID(id)) +func (s *Service) ListByClientExternalId(ctx context.Context, id string) ([]*DocumentInList, error) { + documents, err := s.cfg.GetDBQueries().ListDocumentsByClientExternalId(ctx, id) if err != nil { return nil, err } diff --git a/internal/document/list_test.go b/internal/document/list_test.go index 8e88df36..7eceef16 100644 --- a/internal/document/list_test.go +++ b/internal/document/list_test.go @@ -26,7 +26,7 @@ func TestListByClientId(t *testing.T) { svc := document.New(cfg) - clientId := uuid.New() + clientId := "externalId" doc := []*document.DocumentInList{ { ID: uuid.New(), @@ -35,13 +35,13 @@ func TestListByClientId(t *testing.T) { }, } - pool.ExpectQuery("name: ListDocumentsByClientId :many").WithArgs(database.MustToDBUUID(clientId)). + pool.ExpectQuery("name: ListDocumentsByClientExternalId :many").WithArgs(clientId). WillReturnRows( pgxmock.NewRows([]string{"id", "bucket", "key"}). AddRow(database.MustToDBUUID(doc[0].ID), doc[0].Bucket, doc[0].Key), ) - adoc, err := svc.ListByClientId(ctx, clientId) + adoc, err := svc.ListByClientExternalId(ctx, clientId) assert.NoError(t, err) assert.Equal(t, doc, adoc) } diff --git a/internal/document/sync/sync_test.go b/internal/document/sync/sync_test.go index 906ca8d7..dd73beba 100644 --- a/internal/document/sync/sync_test.go +++ b/internal/document/sync/sync_test.go @@ -54,8 +54,8 @@ func TestSync(t *testing.T) { AddRow(database.MustToDBUUID(doc.ID), database.MustToDBUUID(doc.ClientID), doc.Hash), ) pool.ExpectQuery("name: GetClient :one").WithArgs(database.MustToDBUUID(j.ID)).WillReturnRows( - pgxmock.NewRows([]string{"id", "name", "canSync"}). - AddRow(database.MustToDBUUID(j.ID), "client_name", true), + pgxmock.NewRows([]string{"id", "externalId", "name", "canSync"}). + AddRow(database.MustToDBUUID(j.ID), "id", "client_name", true), ) mockSQS.EXPECT(). diff --git a/internal/serviceconfig/database/transaction_test.go b/internal/serviceconfig/database/transaction_test.go index 1f9d7465..4110f000 100644 --- a/internal/serviceconfig/database/transaction_test.go +++ b/internal/serviceconfig/database/transaction_test.go @@ -25,9 +25,10 @@ func TestExecuteTransaction(t *testing.T) { clientID := database.MustToDBUUID(uuid.New()) clientName := "example_client" + externalId := "example_id" pool.ExpectBegin() - pool.ExpectQuery("name: CreateClient :one").WithArgs(clientName). + pool.ExpectQuery("name: CreateClient :one").WithArgs(externalId, clientName). WillReturnRows( pgxmock.NewRows([]string{"id"}). AddRow(clientID), @@ -35,7 +36,10 @@ func TestExecuteTransaction(t *testing.T) { pool.ExpectCommit() err = cfg.ExecuteDBTransaction(ctx, func(ctx context.Context, q *repository.Queries) error { - id, err := q.CreateClient(ctx, "example_client") + id, err := q.CreateClient(ctx, &repository.CreateClientParams{ + Name: clientName, + Externalid: externalId, + }) assert.NoError(t, err) assert.Equal(t, clientID, id) diff --git a/internal/test/ecosystem.go b/internal/test/ecosystem.go index 972fdac3..4e63cec3 100644 --- a/internal/test/ecosystem.go +++ b/internal/test/ecosystem.go @@ -2,11 +2,15 @@ package test import ( "context" + "os" + "path" "testing" "queryorchestration/internal/serviceconfig" "queryorchestration/internal/serviceconfig/aws" "queryorchestration/internal/serviceconfig/database" + "queryorchestration/internal/serviceconfig/objectstore" + queryservice "queryorchestration/pkg/queryService" "github.com/stretchr/testify/require" "github.com/testcontainers/testcontainers-go" @@ -22,12 +26,15 @@ type EcosystemNetworkConfig struct { Runners []*RunnerNetworkConfig Services []*ServiceNetworkConfig Cfg serviceconfig.ConfigProvider - Network *testcontainers.DockerNetwork - AWSContainer *AWSContainerConfig + Dependencies *Dependencies } func CreateRunnersAndServicesNetwork(t testing.TB, ctx context.Context, ncfg *EcosystemNetworkConfig) (*EcosystemConfig, func()) { - network := ncfg.Network + if ncfg.Dependencies == nil { + ncfg.Dependencies = &Dependencies{} + } + + network := ncfg.Dependencies.Network var ncleanup func() if network == nil { network, ncleanup = CreateNetwork(t, ctx) @@ -53,7 +60,7 @@ func CreateRunnersAndServicesNetwork(t testing.TB, ctx context.Context, ncfg *Ec } var qcleanup func() - if ncfg.AWSContainer == nil { + if ncfg.Dependencies.AWSConfig == nil { _, qcleanup = CreateAWSContainer(t, ctx, &CreateAWSConfig{ Network: network, Cfg: ncfg.Cfg, @@ -61,23 +68,21 @@ func CreateRunnersAndServicesNetwork(t testing.TB, ctx context.Context, ncfg *Ec } if ncfg.Cfg.GetQueueClient() == nil { - err := ncfg.Cfg.SetQueueClient(ctx) - require.NoError(t, err) + SetQueueClient(t, ctx, ncfg.Cfg) } qs := make(map[string]*Container, len(ncfg.Runners)) qclean := make([]func(), len(ncfg.Runners)) for i, r := range ncfg.Runners { - url := r.QueueURL - if url == nil { - u := CreateQueue(t, ctx, ncfg.Cfg, r.Name) - url = &u + url := ncfg.Dependencies.QueueURLs[r.Name] + if url == "" { + url = CreateQueue(t, ctx, ncfg.Cfg, r.Name) } c, ccleanup := CreateRunner(t, ctx, &RunnerConfig{ Name: r.Name, Env: r.Env, - QueueURL: *url, + QueueURL: url, Cfg: ncfg.Cfg, Network: network, }) @@ -106,6 +111,12 @@ func CreateRunnersAndServicesNetwork(t testing.TB, ctx context.Context, ncfg *Ec } } +func SetCfgProviderWithBasePath(t testing.TB, cfg serviceconfig.ConfigProvider, basePath string) { + SetCfgProvider(t, cfg) + + cfg.SetBasePath(path.Join(os.Getenv("PWD"), basePath)) +} + func SetCfgProvider(t testing.TB, cfg serviceconfig.ConfigProvider) { cfg.SetAWSConfig(&aws.AWSConfig{ AWSKeyID: "test", @@ -227,3 +238,137 @@ func CreateRunnerNetwork(t testing.TB, ctx context.Context, rcfg *RunnerNetworkC } } } + +type FullDependenciesConfig interface { + serviceconfig.ConfigProvider + objectstore.ConfigProvider +} + +type Dependencies struct { + BucketName string + QueueURLs map[string]string + Network *testcontainers.DockerNetwork + AWSConfig *AWSContainerConfig +} + +func CreateFullDependencies(t testing.TB, ctx context.Context, cfg FullDependenciesConfig) (Dependencies, func()) { + network, ncleanup := CreateNetwork(t, ctx) + + acfg, clean := CreateAWSContainer(t, ctx, &CreateAWSConfig{ + Cfg: cfg, + Network: network, + }) + + SetQueueClient(t, ctx, cfg) + SetStoreClient(t, ctx, cfg, acfg.ExternalEndpoint) + + urls := map[string]string{} + urls[DocInitRunner] = CreateQueue(t, ctx, cfg, DocInitRunner) + urls[DocSyncRunner] = CreateQueue(t, ctx, cfg, DocSyncRunner) + urls[DocCleanRunner] = CreateQueue(t, ctx, cfg, DocCleanRunner) + urls[DocTextRunner] = CreateQueue(t, ctx, cfg, DocTextRunner) + urls[QuerySyncRunner] = CreateQueue(t, ctx, cfg, QuerySyncRunner) + urls[QueryRunner] = CreateQueue(t, ctx, cfg, QueryRunner) + urls[ClientSyncRunner] = CreateQueue(t, ctx, cfg, ClientSyncRunner) + urls[QueryVersionSyncRunner] = CreateQueue(t, ctx, cfg, QueryVersionSyncRunner) + + bucketName := "docinitbucket" + CreateBucket(t, ctx, cfg, bucketName) + SetBucketNotifs(t, ctx, cfg, bucketName) + + return Dependencies{ + BucketName: bucketName, + QueueURLs: urls, + Network: network, + AWSConfig: acfg, + }, func() { + ncleanup() + clean() + } +} + +type Network struct { + Dependencies Dependencies + Network EcosystemConfig + Client *queryservice.ClientWithResponses +} + +func CreateFullNetwork(t testing.TB, ctx context.Context, cfg FullDependenciesConfig) (Network, func()) { + deps, clean := CreateFullDependencies(t, ctx, cfg) + + net, cleanup := CreateRunnersAndServicesNetwork(t, ctx, &EcosystemNetworkConfig{ + Cfg: cfg, + Dependencies: &deps, + Runners: []*RunnerNetworkConfig{ + { + Name: DocInitRunner, + Env: map[string]string{ + "DOCUMENT_SYNC_URL": deps.QueueURLs[DocSyncRunner], + }, + }, + { + Name: DocSyncRunner, + Env: map[string]string{ + "DOCUMENT_CLEAN_URL": deps.QueueURLs[DocCleanRunner], + }, + }, + { + Name: DocCleanRunner, + Env: map[string]string{ + "DOCUMENT_TEXT_URL": deps.QueueURLs[DocTextRunner], + }, + }, + { + Name: DocTextRunner, + Env: map[string]string{ + "QUERY_SYNC_URL": deps.QueueURLs[QuerySyncRunner], + }, + }, + { + Name: QuerySyncRunner, + Env: map[string]string{ + "QUERY_URL": deps.QueueURLs[QueryRunner], + }, + }, + { + Name: QueryRunner, + Env: map[string]string{ + "QUERY_URL": deps.QueueURLs[QueryRunner], + }, + }, + { + Name: ClientSyncRunner, + Env: map[string]string{ + "DOCUMENT_SYNC_URL": deps.QueueURLs[DocSyncRunner], + }, + }, + { + Name: QueryVersionSyncRunner, + Env: map[string]string{ + "CLIENT_SYNC_URL": deps.QueueURLs[ClientSyncRunner], + }, + }, + }, + Services: []*ServiceNetworkConfig{ + { + Name: QueryService, + Env: map[string]string{ + "CLIENT_SYNC_URL": deps.QueueURLs[ClientSyncRunner], + "QUERY_VERSION_SYNC_URL": deps.QueueURLs[QueryVersionSyncRunner], + }, + }, + }, + }) + + qService, err := queryservice.NewClientWithResponses(net.Services[QueryService].URI) + require.NoError(t, err) + + return Network{ + Dependencies: deps, + Network: *net, + Client: qService, + }, func() { + cleanup() + clean() + } +} diff --git a/internal/test/ecosystem_test.go b/internal/test/ecosystem_test.go index 777b2749..b41ceb53 100644 --- a/internal/test/ecosystem_test.go +++ b/internal/test/ecosystem_test.go @@ -2,11 +2,10 @@ package test import ( "context" - "os" - "path" "testing" "queryorchestration/internal/serviceconfig" + "queryorchestration/internal/serviceconfig/objectstore" "github.com/stretchr/testify/assert" ) @@ -60,8 +59,7 @@ func TestCreateRunnersAndServicesNetwork(t *testing.T) { } ctx := context.Background() cfg := &serviceconfig.BaseConfig{} - SetCfgProvider(t, cfg) - cfg.SetBasePath(path.Join(os.Getenv("PWD"), "../..")) + SetCfgProviderWithBasePath(t, cfg, "../..") conn, cleanup := CreateRunnersAndServicesNetwork(t, ctx, &EcosystemNetworkConfig{ Cfg: cfg, @@ -103,3 +101,40 @@ func TestCreateBaseConfig(t *testing.T) { assert.Equal(t, "invalid_name", cfg.DBName) assert.True(t, cfg.DBNoSSL) } + +type FullDepsConfig struct { + serviceconfig.BaseConfig + objectstore.ObjectStoreConfig +} + +func TestCreateFullDependencies(t *testing.T) { + if testing.Short() { + t.Skip("Skipping long test in short mode") + } + ctx := context.Background() + cfg := &FullDepsConfig{} + SetCfgProviderWithBasePath(t, cfg, "../..") + + conn, cleanup := CreateFullDependencies(t, ctx, cfg) + + assert.NotNil(t, conn) + assert.NotNil(t, cleanup) + + cleanup() +} + +func TestCreateNetwork(t *testing.T) { + if testing.Short() { + t.Skip("Skipping long test in short mode") + } + ctx := context.Background() + cfg := &FullDepsConfig{} + SetCfgProviderWithBasePath(t, cfg, "../..") + + conn, cleanup := CreateFullNetwork(t, ctx, cfg) + + assert.NotNil(t, conn) + assert.NotNil(t, cleanup) + + cleanup() +} diff --git a/internal/test/objectstore.go b/internal/test/objectstore.go index 34ff465f..07ef56dc 100644 --- a/internal/test/objectstore.go +++ b/internal/test/objectstore.go @@ -2,12 +2,16 @@ package test import ( "context" + "fmt" + "io" "testing" objectstore "queryorchestration/internal/serviceconfig/objectstore" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/s3" + awstypes "github.com/aws/aws-sdk-go-v2/service/s3/types" + "github.com/oapi-codegen/runtime/types" "github.com/stretchr/testify/require" ) @@ -21,9 +25,40 @@ func CreateBucket(t testing.TB, ctx context.Context, cfg objectstore.ConfigProvi require.NoError(t, err) } -func CreateStoreClient(t testing.TB, ctx context.Context, cfg objectstore.ConfigProvider, endpoint string) { +func SetBucketNotifs(t testing.TB, ctx context.Context, cfg objectstore.ConfigProvider, name string) { + arn := fmt.Sprintf("arn:aws:sqs:%s:000000000000:%s", cfg.GetAWSRegion(), DocInitRunner) + _, err := cfg.GetStoreClient().PutBucketNotificationConfiguration(ctx, &s3.PutBucketNotificationConfigurationInput{ + Bucket: &name, + NotificationConfiguration: &awstypes.NotificationConfiguration{ + QueueConfigurations: []awstypes.QueueConfiguration{ + { + QueueArn: &arn, + Events: []awstypes.Event{ + awstypes.EventS3ObjectCreated, + }, + }, + }, + }, + }) + require.NoError(t, err) + +} + +func SetStoreClient(t testing.TB, ctx context.Context, cfg objectstore.ConfigProvider, endpoint string) { cfg.SetS3Endpoint(endpoint) cfg.SetS3UsePathStyle(true) err := cfg.SetStoreClient(ctx) require.NoError(t, err) } + +func PutObject(t testing.TB, ctx context.Context, cfg objectstore.ConfigProvider, clientId types.UUID, bucket string, filename string, file io.Reader) string { + location := fmt.Sprintf("%s/%s", clientId, filename) + _, err := cfg.GetStoreClient().PutObject(ctx, &s3.PutObjectInput{ + Bucket: &bucket, + Key: &location, + Body: file, + }) + require.NoError(t, err) + + return location +} diff --git a/internal/test/objectstore_test.go b/internal/test/objectstore_test.go index b534702e..55a41bdc 100644 --- a/internal/test/objectstore_test.go +++ b/internal/test/objectstore_test.go @@ -2,12 +2,18 @@ package test import ( "context" + "fmt" + "strings" "testing" "queryorchestration/internal/serviceconfig" objectstore "queryorchestration/internal/serviceconfig/objectstore" + objectstoremock "queryorchestration/mocks/objectstore" + "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/google/uuid" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" ) type StoreConfig struct { @@ -29,7 +35,7 @@ func TestCreateBucket(t *testing.T) { }) defer cleanup() - CreateStoreClient(t, ctx, cfg, acfg.ExternalEndpoint) + SetStoreClient(t, ctx, cfg, acfg.ExternalEndpoint) CreateBucket(t, ctx, cfg, "myname") } @@ -48,6 +54,34 @@ func TestCreateStoreClient(t *testing.T) { }) defer cleanup() - CreateStoreClient(t, ctx, cfg, acfg.ExternalEndpoint) + SetStoreClient(t, ctx, cfg, acfg.ExternalEndpoint) assert.NotNil(t, cfg.GetStoreClient()) } + +func TestPutObject(t *testing.T) { + ctx := context.Background() + + cfg := &StoreConfig{} + SetCfgProvider(t, cfg) + mockS3 := objectstoremock.NewMockS3Client(t) + cfg.StoreClient = mockS3 + + clientId := uuid.New() + bucketName := "bucket" + file := strings.NewReader("hello") + filename := "hello" + expectedLocation := fmt.Sprintf("%s/%s", clientId, filename) + + mockS3.EXPECT(). + PutObject( + mock.Anything, + mock.MatchedBy(func(in *s3.PutObjectInput) bool { + return *in.Bucket == bucketName && *in.Key == expectedLocation + }), + mock.Anything, + ). + Return(&s3.PutObjectOutput{}, nil) + + location := PutObject(t, ctx, cfg, clientId, bucketName, filename, file) + assert.Equal(t, expectedLocation, location) +} diff --git a/internal/test/queryService/service.go b/internal/test/queryService/service.go new file mode 100644 index 00000000..7d6ab2f4 --- /dev/null +++ b/internal/test/queryService/service.go @@ -0,0 +1,29 @@ +package queryservicetest + +import ( + "context" + "testing" + + queryservice "queryorchestration/pkg/queryService" + + "github.com/stretchr/testify/require" +) + +func CreateClientWithSync(t testing.TB, ctx context.Context, client queryservice.ClientWithResponsesInterface) *queryservice.DocClient { + clientCreateRes, err := client.CreateClientWithResponse(ctx, queryservice.ClientCreate{ + Name: "example_name", + Id: "ID", + }) + require.NoError(t, err) + + canSync := true + _, err = client.UpdateClientWithResponse(ctx, clientCreateRes.JSON201.Id, queryservice.ClientUpdate{ + CanSync: &canSync, + }) + require.NoError(t, err) + + clientRes, err := client.GetClientWithResponse(ctx, clientCreateRes.JSON201.Id) + require.NoError(t, err) + + return clientRes.JSON200 +} diff --git a/internal/test/queryService/service_test.go b/internal/test/queryService/service_test.go new file mode 100644 index 00000000..ecde52c7 --- /dev/null +++ b/internal/test/queryService/service_test.go @@ -0,0 +1,62 @@ +package queryservicetest_test + +import ( + "context" + "testing" + + queryservicetest "queryorchestration/internal/test/queryService" + queryservicemock "queryorchestration/mocks/queryservice" + queryservice "queryorchestration/pkg/queryService" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" +) + +func TestCreateClientWithSync(t *testing.T) { + ctx := context.Background() + + svcClient := queryservicemock.NewMockClientWithResponsesInterface(t) + + svcClient.EXPECT().CreateClientWithResponse( + mock.Anything, + mock.MatchedBy(func(create queryservice.ClientCreate) bool { + return create.Name == "example_name" && create.Id == "ID" + }), + mock.Anything, + ).Return(&queryservice.CreateClientResponse{ + JSON201: &queryservice.ClientIDBody{ + Id: "ID", + }, + }, nil) + + svcClient.EXPECT().UpdateClientWithResponse( + mock.Anything, + mock.MatchedBy(func(id string) bool { + return id == "ID" + }), + mock.MatchedBy(func(create queryservice.ClientUpdate) bool { + return *create.CanSync == true + }), + mock.Anything, + ).Return(&queryservice.UpdateClientResponse{}, nil) + + svcClient.EXPECT().GetClientWithResponse( + mock.Anything, + mock.MatchedBy(func(id string) bool { + return id == "ID" + }), + mock.Anything, + ).Return(&queryservice.GetClientResponse{ + JSON200: &queryservice.DocClient{ + Id: "ID", + }, + }, nil) + + client := queryservicetest.CreateClientWithSync(t, ctx, svcClient) + + assert.NotNil(t, client) + assert.NotNil(t, client) + assert.EqualExportedValues(t, queryservice.DocClient{ + Id: "ID", + }, *client) +} diff --git a/internal/test/queue.go b/internal/test/queue.go index 35d5c84e..091489e3 100644 --- a/internal/test/queue.go +++ b/internal/test/queue.go @@ -15,6 +15,11 @@ import ( "github.com/stretchr/testify/require" ) +func SetQueueClient(t testing.TB, ctx context.Context, cfg queue.ConfigProvider) { + err := cfg.SetQueueClient(ctx) + require.NoError(t, err) +} + func CreateQueue(t testing.TB, ctx context.Context, cfg serviceconfig.ConfigProvider, name string) string { queueM, err := cfg.GetQueueClient().CreateQueue(ctx, &sqs.CreateQueueInput{ QueueName: aws.String(name), diff --git a/mocks/queryservice/mock_ClientInterface.go b/mocks/queryservice/mock_ClientInterface.go new file mode 100644 index 00000000..8430a69d --- /dev/null +++ b/mocks/queryservice/mock_ClientInterface.go @@ -0,0 +1,1613 @@ +// Code generated by mockery v2.52.3. DO NOT EDIT. + +package queryservicemock + +import ( + context "context" + http "net/http" + + io "io" + + mock "github.com/stretchr/testify/mock" + + queryservice "queryorchestration/pkg/queryService" + + uuid "github.com/google/uuid" +) + +// MockClientInterface is an autogenerated mock type for the ClientInterface type +type MockClientInterface struct { + mock.Mock +} + +type MockClientInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *MockClientInterface) EXPECT() *MockClientInterface_Expecter { + return &MockClientInterface_Expecter{mock: &_m.Mock} +} + +// CreateClient provides a mock function with given fields: ctx, body, reqEditors +func (_m *MockClientInterface) CreateClient(ctx context.Context, body queryservice.ClientCreate, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CreateClient") + } + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, queryservice.ClientCreate, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + return rf(ctx, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, queryservice.ClientCreate, ...queryservice.RequestEditorFn) *http.Response); ok { + r0 = rf(ctx, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, queryservice.ClientCreate, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientInterface_CreateClient_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateClient' +type MockClientInterface_CreateClient_Call struct { + *mock.Call +} + +// CreateClient is a helper method to define mock.On call +// - ctx context.Context +// - body queryservice.ClientCreate +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientInterface_Expecter) CreateClient(ctx interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_CreateClient_Call { + return &MockClientInterface_CreateClient_Call{Call: _e.mock.On("CreateClient", + append([]interface{}{ctx, body}, reqEditors...)...)} +} + +func (_c *MockClientInterface_CreateClient_Call) Run(run func(ctx context.Context, body queryservice.ClientCreate, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_CreateClient_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(queryservice.ClientCreate), variadicArgs...) + }) + return _c +} + +func (_c *MockClientInterface_CreateClient_Call) Return(_a0 *http.Response, _a1 error) *MockClientInterface_CreateClient_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientInterface_CreateClient_Call) RunAndReturn(run func(context.Context, queryservice.ClientCreate, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_CreateClient_Call { + _c.Call.Return(run) + return _c +} + +// CreateClientWithBody provides a mock function with given fields: ctx, contentType, body, reqEditors +func (_m *MockClientInterface) CreateClientWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CreateClientWithBody") + } + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + return rf(ctx, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) *http.Response); ok { + r0 = rf(ctx, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientInterface_CreateClientWithBody_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateClientWithBody' +type MockClientInterface_CreateClientWithBody_Call struct { + *mock.Call +} + +// CreateClientWithBody is a helper method to define mock.On call +// - ctx context.Context +// - contentType string +// - body io.Reader +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientInterface_Expecter) CreateClientWithBody(ctx interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_CreateClientWithBody_Call { + return &MockClientInterface_CreateClientWithBody_Call{Call: _e.mock.On("CreateClientWithBody", + append([]interface{}{ctx, contentType, body}, reqEditors...)...)} +} + +func (_c *MockClientInterface_CreateClientWithBody_Call) Run(run func(ctx context.Context, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_CreateClientWithBody_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + for i, a := range args[3:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(string), args[2].(io.Reader), variadicArgs...) + }) + return _c +} + +func (_c *MockClientInterface_CreateClientWithBody_Call) Return(_a0 *http.Response, _a1 error) *MockClientInterface_CreateClientWithBody_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientInterface_CreateClientWithBody_Call) RunAndReturn(run func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_CreateClientWithBody_Call { + _c.Call.Return(run) + return _c +} + +// CreateQuery provides a mock function with given fields: ctx, body, reqEditors +func (_m *MockClientInterface) CreateQuery(ctx context.Context, body queryservice.QueryCreate, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CreateQuery") + } + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, queryservice.QueryCreate, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + return rf(ctx, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, queryservice.QueryCreate, ...queryservice.RequestEditorFn) *http.Response); ok { + r0 = rf(ctx, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, queryservice.QueryCreate, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientInterface_CreateQuery_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateQuery' +type MockClientInterface_CreateQuery_Call struct { + *mock.Call +} + +// CreateQuery is a helper method to define mock.On call +// - ctx context.Context +// - body queryservice.QueryCreate +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientInterface_Expecter) CreateQuery(ctx interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_CreateQuery_Call { + return &MockClientInterface_CreateQuery_Call{Call: _e.mock.On("CreateQuery", + append([]interface{}{ctx, body}, reqEditors...)...)} +} + +func (_c *MockClientInterface_CreateQuery_Call) Run(run func(ctx context.Context, body queryservice.QueryCreate, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_CreateQuery_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(queryservice.QueryCreate), variadicArgs...) + }) + return _c +} + +func (_c *MockClientInterface_CreateQuery_Call) Return(_a0 *http.Response, _a1 error) *MockClientInterface_CreateQuery_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientInterface_CreateQuery_Call) RunAndReturn(run func(context.Context, queryservice.QueryCreate, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_CreateQuery_Call { + _c.Call.Return(run) + return _c +} + +// CreateQueryWithBody provides a mock function with given fields: ctx, contentType, body, reqEditors +func (_m *MockClientInterface) CreateQueryWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CreateQueryWithBody") + } + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + return rf(ctx, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) *http.Response); ok { + r0 = rf(ctx, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientInterface_CreateQueryWithBody_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateQueryWithBody' +type MockClientInterface_CreateQueryWithBody_Call struct { + *mock.Call +} + +// CreateQueryWithBody is a helper method to define mock.On call +// - ctx context.Context +// - contentType string +// - body io.Reader +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientInterface_Expecter) CreateQueryWithBody(ctx interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_CreateQueryWithBody_Call { + return &MockClientInterface_CreateQueryWithBody_Call{Call: _e.mock.On("CreateQueryWithBody", + append([]interface{}{ctx, contentType, body}, reqEditors...)...)} +} + +func (_c *MockClientInterface_CreateQueryWithBody_Call) Run(run func(ctx context.Context, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_CreateQueryWithBody_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + for i, a := range args[3:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(string), args[2].(io.Reader), variadicArgs...) + }) + return _c +} + +func (_c *MockClientInterface_CreateQueryWithBody_Call) Return(_a0 *http.Response, _a1 error) *MockClientInterface_CreateQueryWithBody_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientInterface_CreateQueryWithBody_Call) RunAndReturn(run func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_CreateQueryWithBody_Call { + _c.Call.Return(run) + return _c +} + +// ExportState provides a mock function with given fields: ctx, id, reqEditors +func (_m *MockClientInterface) ExportState(ctx context.Context, id uuid.UUID, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for ExportState") + } + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + return rf(ctx, id, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) *http.Response); ok { + r0 = rf(ctx, id, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientInterface_ExportState_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ExportState' +type MockClientInterface_ExportState_Call struct { + *mock.Call +} + +// ExportState is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientInterface_Expecter) ExportState(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientInterface_ExportState_Call { + return &MockClientInterface_ExportState_Call{Call: _e.mock.On("ExportState", + append([]interface{}{ctx, id}, reqEditors...)...)} +} + +func (_c *MockClientInterface_ExportState_Call) Run(run func(ctx context.Context, id uuid.UUID, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_ExportState_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(uuid.UUID), variadicArgs...) + }) + return _c +} + +func (_c *MockClientInterface_ExportState_Call) Return(_a0 *http.Response, _a1 error) *MockClientInterface_ExportState_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientInterface_ExportState_Call) RunAndReturn(run func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_ExportState_Call { + _c.Call.Return(run) + return _c +} + +// GetClient provides a mock function with given fields: ctx, id, reqEditors +func (_m *MockClientInterface) GetClient(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for GetClient") + } + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + return rf(ctx, id, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) *http.Response); ok { + r0 = rf(ctx, id, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientInterface_GetClient_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetClient' +type MockClientInterface_GetClient_Call struct { + *mock.Call +} + +// GetClient is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientInterface_Expecter) GetClient(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientInterface_GetClient_Call { + return &MockClientInterface_GetClient_Call{Call: _e.mock.On("GetClient", + append([]interface{}{ctx, id}, reqEditors...)...)} +} + +func (_c *MockClientInterface_GetClient_Call) Run(run func(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_GetClient_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(string), variadicArgs...) + }) + return _c +} + +func (_c *MockClientInterface_GetClient_Call) Return(_a0 *http.Response, _a1 error) *MockClientInterface_GetClient_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientInterface_GetClient_Call) RunAndReturn(run func(context.Context, string, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_GetClient_Call { + _c.Call.Return(run) + return _c +} + +// GetCollectorByClientId provides a mock function with given fields: ctx, id, reqEditors +func (_m *MockClientInterface) GetCollectorByClientId(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for GetCollectorByClientId") + } + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + return rf(ctx, id, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) *http.Response); ok { + r0 = rf(ctx, id, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientInterface_GetCollectorByClientId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetCollectorByClientId' +type MockClientInterface_GetCollectorByClientId_Call struct { + *mock.Call +} + +// GetCollectorByClientId is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientInterface_Expecter) GetCollectorByClientId(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientInterface_GetCollectorByClientId_Call { + return &MockClientInterface_GetCollectorByClientId_Call{Call: _e.mock.On("GetCollectorByClientId", + append([]interface{}{ctx, id}, reqEditors...)...)} +} + +func (_c *MockClientInterface_GetCollectorByClientId_Call) Run(run func(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_GetCollectorByClientId_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(string), variadicArgs...) + }) + return _c +} + +func (_c *MockClientInterface_GetCollectorByClientId_Call) Return(_a0 *http.Response, _a1 error) *MockClientInterface_GetCollectorByClientId_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientInterface_GetCollectorByClientId_Call) RunAndReturn(run func(context.Context, string, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_GetCollectorByClientId_Call { + _c.Call.Return(run) + return _c +} + +// GetQuery provides a mock function with given fields: ctx, id, reqEditors +func (_m *MockClientInterface) GetQuery(ctx context.Context, id uuid.UUID, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for GetQuery") + } + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + return rf(ctx, id, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) *http.Response); ok { + r0 = rf(ctx, id, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientInterface_GetQuery_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetQuery' +type MockClientInterface_GetQuery_Call struct { + *mock.Call +} + +// GetQuery is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientInterface_Expecter) GetQuery(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientInterface_GetQuery_Call { + return &MockClientInterface_GetQuery_Call{Call: _e.mock.On("GetQuery", + append([]interface{}{ctx, id}, reqEditors...)...)} +} + +func (_c *MockClientInterface_GetQuery_Call) Run(run func(ctx context.Context, id uuid.UUID, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_GetQuery_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(uuid.UUID), variadicArgs...) + }) + return _c +} + +func (_c *MockClientInterface_GetQuery_Call) Return(_a0 *http.Response, _a1 error) *MockClientInterface_GetQuery_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientInterface_GetQuery_Call) RunAndReturn(run func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_GetQuery_Call { + _c.Call.Return(run) + return _c +} + +// GetStatusByClientId provides a mock function with given fields: ctx, id, reqEditors +func (_m *MockClientInterface) GetStatusByClientId(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for GetStatusByClientId") + } + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + return rf(ctx, id, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) *http.Response); ok { + r0 = rf(ctx, id, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientInterface_GetStatusByClientId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetStatusByClientId' +type MockClientInterface_GetStatusByClientId_Call struct { + *mock.Call +} + +// GetStatusByClientId is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientInterface_Expecter) GetStatusByClientId(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientInterface_GetStatusByClientId_Call { + return &MockClientInterface_GetStatusByClientId_Call{Call: _e.mock.On("GetStatusByClientId", + append([]interface{}{ctx, id}, reqEditors...)...)} +} + +func (_c *MockClientInterface_GetStatusByClientId_Call) Run(run func(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_GetStatusByClientId_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(string), variadicArgs...) + }) + return _c +} + +func (_c *MockClientInterface_GetStatusByClientId_Call) Return(_a0 *http.Response, _a1 error) *MockClientInterface_GetStatusByClientId_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientInterface_GetStatusByClientId_Call) RunAndReturn(run func(context.Context, string, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_GetStatusByClientId_Call { + _c.Call.Return(run) + return _c +} + +// ListDocumentsByClientId provides a mock function with given fields: ctx, id, reqEditors +func (_m *MockClientInterface) ListDocumentsByClientId(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for ListDocumentsByClientId") + } + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + return rf(ctx, id, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) *http.Response); ok { + r0 = rf(ctx, id, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientInterface_ListDocumentsByClientId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListDocumentsByClientId' +type MockClientInterface_ListDocumentsByClientId_Call struct { + *mock.Call +} + +// ListDocumentsByClientId is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientInterface_Expecter) ListDocumentsByClientId(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientInterface_ListDocumentsByClientId_Call { + return &MockClientInterface_ListDocumentsByClientId_Call{Call: _e.mock.On("ListDocumentsByClientId", + append([]interface{}{ctx, id}, reqEditors...)...)} +} + +func (_c *MockClientInterface_ListDocumentsByClientId_Call) Run(run func(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_ListDocumentsByClientId_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(string), variadicArgs...) + }) + return _c +} + +func (_c *MockClientInterface_ListDocumentsByClientId_Call) Return(_a0 *http.Response, _a1 error) *MockClientInterface_ListDocumentsByClientId_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientInterface_ListDocumentsByClientId_Call) RunAndReturn(run func(context.Context, string, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_ListDocumentsByClientId_Call { + _c.Call.Return(run) + return _c +} + +// ListQueries provides a mock function with given fields: ctx, reqEditors +func (_m *MockClientInterface) ListQueries(ctx context.Context, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for ListQueries") + } + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + return rf(ctx, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, ...queryservice.RequestEditorFn) *http.Response); ok { + r0 = rf(ctx, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientInterface_ListQueries_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListQueries' +type MockClientInterface_ListQueries_Call struct { + *mock.Call +} + +// ListQueries is a helper method to define mock.On call +// - ctx context.Context +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientInterface_Expecter) ListQueries(ctx interface{}, reqEditors ...interface{}) *MockClientInterface_ListQueries_Call { + return &MockClientInterface_ListQueries_Call{Call: _e.mock.On("ListQueries", + append([]interface{}{ctx}, reqEditors...)...)} +} + +func (_c *MockClientInterface_ListQueries_Call) Run(run func(ctx context.Context, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_ListQueries_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-1) + for i, a := range args[1:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), variadicArgs...) + }) + return _c +} + +func (_c *MockClientInterface_ListQueries_Call) Return(_a0 *http.Response, _a1 error) *MockClientInterface_ListQueries_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientInterface_ListQueries_Call) RunAndReturn(run func(context.Context, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_ListQueries_Call { + _c.Call.Return(run) + return _c +} + +// SetCollectorByClientId provides a mock function with given fields: ctx, id, body, reqEditors +func (_m *MockClientInterface) SetCollectorByClientId(ctx context.Context, id string, body queryservice.CollectorSet, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for SetCollectorByClientId") + } + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, queryservice.CollectorSet, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + return rf(ctx, id, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, queryservice.CollectorSet, ...queryservice.RequestEditorFn) *http.Response); ok { + r0 = rf(ctx, id, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, queryservice.CollectorSet, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientInterface_SetCollectorByClientId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetCollectorByClientId' +type MockClientInterface_SetCollectorByClientId_Call struct { + *mock.Call +} + +// SetCollectorByClientId is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - body queryservice.CollectorSet +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientInterface_Expecter) SetCollectorByClientId(ctx interface{}, id interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_SetCollectorByClientId_Call { + return &MockClientInterface_SetCollectorByClientId_Call{Call: _e.mock.On("SetCollectorByClientId", + append([]interface{}{ctx, id, body}, reqEditors...)...)} +} + +func (_c *MockClientInterface_SetCollectorByClientId_Call) Run(run func(ctx context.Context, id string, body queryservice.CollectorSet, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_SetCollectorByClientId_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + for i, a := range args[3:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(string), args[2].(queryservice.CollectorSet), variadicArgs...) + }) + return _c +} + +func (_c *MockClientInterface_SetCollectorByClientId_Call) Return(_a0 *http.Response, _a1 error) *MockClientInterface_SetCollectorByClientId_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientInterface_SetCollectorByClientId_Call) RunAndReturn(run func(context.Context, string, queryservice.CollectorSet, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_SetCollectorByClientId_Call { + _c.Call.Return(run) + return _c +} + +// SetCollectorByClientIdWithBody provides a mock function with given fields: ctx, id, contentType, body, reqEditors +func (_m *MockClientInterface) SetCollectorByClientIdWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for SetCollectorByClientIdWithBody") + } + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + return rf(ctx, id, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) *http.Response); ok { + r0 = rf(ctx, id, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientInterface_SetCollectorByClientIdWithBody_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetCollectorByClientIdWithBody' +type MockClientInterface_SetCollectorByClientIdWithBody_Call struct { + *mock.Call +} + +// SetCollectorByClientIdWithBody is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - contentType string +// - body io.Reader +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientInterface_Expecter) SetCollectorByClientIdWithBody(ctx interface{}, id interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_SetCollectorByClientIdWithBody_Call { + return &MockClientInterface_SetCollectorByClientIdWithBody_Call{Call: _e.mock.On("SetCollectorByClientIdWithBody", + append([]interface{}{ctx, id, contentType, body}, reqEditors...)...)} +} + +func (_c *MockClientInterface_SetCollectorByClientIdWithBody_Call) Run(run func(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_SetCollectorByClientIdWithBody_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-4) + for i, a := range args[4:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(io.Reader), variadicArgs...) + }) + return _c +} + +func (_c *MockClientInterface_SetCollectorByClientIdWithBody_Call) Return(_a0 *http.Response, _a1 error) *MockClientInterface_SetCollectorByClientIdWithBody_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientInterface_SetCollectorByClientIdWithBody_Call) RunAndReturn(run func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_SetCollectorByClientIdWithBody_Call { + _c.Call.Return(run) + return _c +} + +// TestQuery provides a mock function with given fields: ctx, id, body, reqEditors +func (_m *MockClientInterface) TestQuery(ctx context.Context, id uuid.UUID, body queryservice.QueryTestRequest, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for TestQuery") + } + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, queryservice.QueryTestRequest, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + return rf(ctx, id, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, queryservice.QueryTestRequest, ...queryservice.RequestEditorFn) *http.Response); ok { + r0 = rf(ctx, id, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, queryservice.QueryTestRequest, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientInterface_TestQuery_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TestQuery' +type MockClientInterface_TestQuery_Call struct { + *mock.Call +} + +// TestQuery is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +// - body queryservice.QueryTestRequest +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientInterface_Expecter) TestQuery(ctx interface{}, id interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_TestQuery_Call { + return &MockClientInterface_TestQuery_Call{Call: _e.mock.On("TestQuery", + append([]interface{}{ctx, id, body}, reqEditors...)...)} +} + +func (_c *MockClientInterface_TestQuery_Call) Run(run func(ctx context.Context, id uuid.UUID, body queryservice.QueryTestRequest, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_TestQuery_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + for i, a := range args[3:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(queryservice.QueryTestRequest), variadicArgs...) + }) + return _c +} + +func (_c *MockClientInterface_TestQuery_Call) Return(_a0 *http.Response, _a1 error) *MockClientInterface_TestQuery_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientInterface_TestQuery_Call) RunAndReturn(run func(context.Context, uuid.UUID, queryservice.QueryTestRequest, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_TestQuery_Call { + _c.Call.Return(run) + return _c +} + +// TestQueryWithBody provides a mock function with given fields: ctx, id, contentType, body, reqEditors +func (_m *MockClientInterface) TestQueryWithBody(ctx context.Context, id uuid.UUID, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for TestQueryWithBody") + } + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + return rf(ctx, id, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) *http.Response); ok { + r0 = rf(ctx, id, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientInterface_TestQueryWithBody_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TestQueryWithBody' +type MockClientInterface_TestQueryWithBody_Call struct { + *mock.Call +} + +// TestQueryWithBody is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +// - contentType string +// - body io.Reader +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientInterface_Expecter) TestQueryWithBody(ctx interface{}, id interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_TestQueryWithBody_Call { + return &MockClientInterface_TestQueryWithBody_Call{Call: _e.mock.On("TestQueryWithBody", + append([]interface{}{ctx, id, contentType, body}, reqEditors...)...)} +} + +func (_c *MockClientInterface_TestQueryWithBody_Call) Run(run func(ctx context.Context, id uuid.UUID, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_TestQueryWithBody_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-4) + for i, a := range args[4:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(string), args[3].(io.Reader), variadicArgs...) + }) + return _c +} + +func (_c *MockClientInterface_TestQueryWithBody_Call) Return(_a0 *http.Response, _a1 error) *MockClientInterface_TestQueryWithBody_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientInterface_TestQueryWithBody_Call) RunAndReturn(run func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_TestQueryWithBody_Call { + _c.Call.Return(run) + return _c +} + +// TriggerExport provides a mock function with given fields: ctx, id, body, reqEditors +func (_m *MockClientInterface) TriggerExport(ctx context.Context, id string, body queryservice.ExportTrigger, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for TriggerExport") + } + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, queryservice.ExportTrigger, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + return rf(ctx, id, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, queryservice.ExportTrigger, ...queryservice.RequestEditorFn) *http.Response); ok { + r0 = rf(ctx, id, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, queryservice.ExportTrigger, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientInterface_TriggerExport_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TriggerExport' +type MockClientInterface_TriggerExport_Call struct { + *mock.Call +} + +// TriggerExport is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - body queryservice.ExportTrigger +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientInterface_Expecter) TriggerExport(ctx interface{}, id interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_TriggerExport_Call { + return &MockClientInterface_TriggerExport_Call{Call: _e.mock.On("TriggerExport", + append([]interface{}{ctx, id, body}, reqEditors...)...)} +} + +func (_c *MockClientInterface_TriggerExport_Call) Run(run func(ctx context.Context, id string, body queryservice.ExportTrigger, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_TriggerExport_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + for i, a := range args[3:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(string), args[2].(queryservice.ExportTrigger), variadicArgs...) + }) + return _c +} + +func (_c *MockClientInterface_TriggerExport_Call) Return(_a0 *http.Response, _a1 error) *MockClientInterface_TriggerExport_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientInterface_TriggerExport_Call) RunAndReturn(run func(context.Context, string, queryservice.ExportTrigger, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_TriggerExport_Call { + _c.Call.Return(run) + return _c +} + +// TriggerExportWithBody provides a mock function with given fields: ctx, id, contentType, body, reqEditors +func (_m *MockClientInterface) TriggerExportWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for TriggerExportWithBody") + } + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + return rf(ctx, id, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) *http.Response); ok { + r0 = rf(ctx, id, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientInterface_TriggerExportWithBody_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TriggerExportWithBody' +type MockClientInterface_TriggerExportWithBody_Call struct { + *mock.Call +} + +// TriggerExportWithBody is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - contentType string +// - body io.Reader +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientInterface_Expecter) TriggerExportWithBody(ctx interface{}, id interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_TriggerExportWithBody_Call { + return &MockClientInterface_TriggerExportWithBody_Call{Call: _e.mock.On("TriggerExportWithBody", + append([]interface{}{ctx, id, contentType, body}, reqEditors...)...)} +} + +func (_c *MockClientInterface_TriggerExportWithBody_Call) Run(run func(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_TriggerExportWithBody_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-4) + for i, a := range args[4:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(io.Reader), variadicArgs...) + }) + return _c +} + +func (_c *MockClientInterface_TriggerExportWithBody_Call) Return(_a0 *http.Response, _a1 error) *MockClientInterface_TriggerExportWithBody_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientInterface_TriggerExportWithBody_Call) RunAndReturn(run func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_TriggerExportWithBody_Call { + _c.Call.Return(run) + return _c +} + +// UpdateClient provides a mock function with given fields: ctx, id, body, reqEditors +func (_m *MockClientInterface) UpdateClient(ctx context.Context, id string, body queryservice.ClientUpdate, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateClient") + } + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, queryservice.ClientUpdate, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + return rf(ctx, id, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, queryservice.ClientUpdate, ...queryservice.RequestEditorFn) *http.Response); ok { + r0 = rf(ctx, id, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, queryservice.ClientUpdate, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientInterface_UpdateClient_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateClient' +type MockClientInterface_UpdateClient_Call struct { + *mock.Call +} + +// UpdateClient is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - body queryservice.ClientUpdate +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientInterface_Expecter) UpdateClient(ctx interface{}, id interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_UpdateClient_Call { + return &MockClientInterface_UpdateClient_Call{Call: _e.mock.On("UpdateClient", + append([]interface{}{ctx, id, body}, reqEditors...)...)} +} + +func (_c *MockClientInterface_UpdateClient_Call) Run(run func(ctx context.Context, id string, body queryservice.ClientUpdate, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_UpdateClient_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + for i, a := range args[3:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(string), args[2].(queryservice.ClientUpdate), variadicArgs...) + }) + return _c +} + +func (_c *MockClientInterface_UpdateClient_Call) Return(_a0 *http.Response, _a1 error) *MockClientInterface_UpdateClient_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientInterface_UpdateClient_Call) RunAndReturn(run func(context.Context, string, queryservice.ClientUpdate, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_UpdateClient_Call { + _c.Call.Return(run) + return _c +} + +// UpdateClientWithBody provides a mock function with given fields: ctx, id, contentType, body, reqEditors +func (_m *MockClientInterface) UpdateClientWithBody(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateClientWithBody") + } + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + return rf(ctx, id, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) *http.Response); ok { + r0 = rf(ctx, id, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientInterface_UpdateClientWithBody_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateClientWithBody' +type MockClientInterface_UpdateClientWithBody_Call struct { + *mock.Call +} + +// UpdateClientWithBody is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - contentType string +// - body io.Reader +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientInterface_Expecter) UpdateClientWithBody(ctx interface{}, id interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_UpdateClientWithBody_Call { + return &MockClientInterface_UpdateClientWithBody_Call{Call: _e.mock.On("UpdateClientWithBody", + append([]interface{}{ctx, id, contentType, body}, reqEditors...)...)} +} + +func (_c *MockClientInterface_UpdateClientWithBody_Call) Run(run func(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_UpdateClientWithBody_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-4) + for i, a := range args[4:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(io.Reader), variadicArgs...) + }) + return _c +} + +func (_c *MockClientInterface_UpdateClientWithBody_Call) Return(_a0 *http.Response, _a1 error) *MockClientInterface_UpdateClientWithBody_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientInterface_UpdateClientWithBody_Call) RunAndReturn(run func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_UpdateClientWithBody_Call { + _c.Call.Return(run) + return _c +} + +// UpdateQuery provides a mock function with given fields: ctx, id, body, reqEditors +func (_m *MockClientInterface) UpdateQuery(ctx context.Context, id uuid.UUID, body queryservice.QueryUpdate, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateQuery") + } + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, queryservice.QueryUpdate, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + return rf(ctx, id, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, queryservice.QueryUpdate, ...queryservice.RequestEditorFn) *http.Response); ok { + r0 = rf(ctx, id, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, queryservice.QueryUpdate, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientInterface_UpdateQuery_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateQuery' +type MockClientInterface_UpdateQuery_Call struct { + *mock.Call +} + +// UpdateQuery is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +// - body queryservice.QueryUpdate +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientInterface_Expecter) UpdateQuery(ctx interface{}, id interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_UpdateQuery_Call { + return &MockClientInterface_UpdateQuery_Call{Call: _e.mock.On("UpdateQuery", + append([]interface{}{ctx, id, body}, reqEditors...)...)} +} + +func (_c *MockClientInterface_UpdateQuery_Call) Run(run func(ctx context.Context, id uuid.UUID, body queryservice.QueryUpdate, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_UpdateQuery_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + for i, a := range args[3:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(queryservice.QueryUpdate), variadicArgs...) + }) + return _c +} + +func (_c *MockClientInterface_UpdateQuery_Call) Return(_a0 *http.Response, _a1 error) *MockClientInterface_UpdateQuery_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientInterface_UpdateQuery_Call) RunAndReturn(run func(context.Context, uuid.UUID, queryservice.QueryUpdate, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_UpdateQuery_Call { + _c.Call.Return(run) + return _c +} + +// UpdateQueryWithBody provides a mock function with given fields: ctx, id, contentType, body, reqEditors +func (_m *MockClientInterface) UpdateQueryWithBody(ctx context.Context, id uuid.UUID, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*http.Response, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateQueryWithBody") + } + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)); ok { + return rf(ctx, id, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) *http.Response); ok { + r0 = rf(ctx, id, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientInterface_UpdateQueryWithBody_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateQueryWithBody' +type MockClientInterface_UpdateQueryWithBody_Call struct { + *mock.Call +} + +// UpdateQueryWithBody is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +// - contentType string +// - body io.Reader +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientInterface_Expecter) UpdateQueryWithBody(ctx interface{}, id interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientInterface_UpdateQueryWithBody_Call { + return &MockClientInterface_UpdateQueryWithBody_Call{Call: _e.mock.On("UpdateQueryWithBody", + append([]interface{}{ctx, id, contentType, body}, reqEditors...)...)} +} + +func (_c *MockClientInterface_UpdateQueryWithBody_Call) Run(run func(ctx context.Context, id uuid.UUID, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientInterface_UpdateQueryWithBody_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-4) + for i, a := range args[4:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(string), args[3].(io.Reader), variadicArgs...) + }) + return _c +} + +func (_c *MockClientInterface_UpdateQueryWithBody_Call) Return(_a0 *http.Response, _a1 error) *MockClientInterface_UpdateQueryWithBody_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientInterface_UpdateQueryWithBody_Call) RunAndReturn(run func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) (*http.Response, error)) *MockClientInterface_UpdateQueryWithBody_Call { + _c.Call.Return(run) + return _c +} + +// NewMockClientInterface creates a new instance of MockClientInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockClientInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *MockClientInterface { + mock := &MockClientInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/queryservice/mock_ClientWithResponsesInterface.go b/mocks/queryservice/mock_ClientWithResponsesInterface.go new file mode 100644 index 00000000..524ad16e --- /dev/null +++ b/mocks/queryservice/mock_ClientWithResponsesInterface.go @@ -0,0 +1,1611 @@ +// Code generated by mockery v2.52.3. DO NOT EDIT. + +package queryservicemock + +import ( + context "context" + io "io" + + mock "github.com/stretchr/testify/mock" + + queryservice "queryorchestration/pkg/queryService" + + uuid "github.com/google/uuid" +) + +// MockClientWithResponsesInterface is an autogenerated mock type for the ClientWithResponsesInterface type +type MockClientWithResponsesInterface struct { + mock.Mock +} + +type MockClientWithResponsesInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *MockClientWithResponsesInterface) EXPECT() *MockClientWithResponsesInterface_Expecter { + return &MockClientWithResponsesInterface_Expecter{mock: &_m.Mock} +} + +// CreateClientWithBodyWithResponse provides a mock function with given fields: ctx, contentType, body, reqEditors +func (_m *MockClientWithResponsesInterface) CreateClientWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*queryservice.CreateClientResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CreateClientWithBodyWithResponse") + } + + var r0 *queryservice.CreateClientResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.CreateClientResponse, error)); ok { + return rf(ctx, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) *queryservice.CreateClientResponse); ok { + r0 = rf(ctx, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*queryservice.CreateClientResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateClientWithBodyWithResponse' +type MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call struct { + *mock.Call +} + +// CreateClientWithBodyWithResponse is a helper method to define mock.On call +// - ctx context.Context +// - contentType string +// - body io.Reader +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientWithResponsesInterface_Expecter) CreateClientWithBodyWithResponse(ctx interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call { + return &MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call{Call: _e.mock.On("CreateClientWithBodyWithResponse", + append([]interface{}{ctx, contentType, body}, reqEditors...)...)} +} + +func (_c *MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call) Run(run func(ctx context.Context, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + for i, a := range args[3:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(string), args[2].(io.Reader), variadicArgs...) + }) + return _c +} + +func (_c *MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call) Return(_a0 *queryservice.CreateClientResponse, _a1 error) *MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call) RunAndReturn(run func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.CreateClientResponse, error)) *MockClientWithResponsesInterface_CreateClientWithBodyWithResponse_Call { + _c.Call.Return(run) + return _c +} + +// CreateClientWithResponse provides a mock function with given fields: ctx, body, reqEditors +func (_m *MockClientWithResponsesInterface) CreateClientWithResponse(ctx context.Context, body queryservice.ClientCreate, reqEditors ...queryservice.RequestEditorFn) (*queryservice.CreateClientResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CreateClientWithResponse") + } + + var r0 *queryservice.CreateClientResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, queryservice.ClientCreate, ...queryservice.RequestEditorFn) (*queryservice.CreateClientResponse, error)); ok { + return rf(ctx, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, queryservice.ClientCreate, ...queryservice.RequestEditorFn) *queryservice.CreateClientResponse); ok { + r0 = rf(ctx, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*queryservice.CreateClientResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, queryservice.ClientCreate, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientWithResponsesInterface_CreateClientWithResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateClientWithResponse' +type MockClientWithResponsesInterface_CreateClientWithResponse_Call struct { + *mock.Call +} + +// CreateClientWithResponse is a helper method to define mock.On call +// - ctx context.Context +// - body queryservice.ClientCreate +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientWithResponsesInterface_Expecter) CreateClientWithResponse(ctx interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_CreateClientWithResponse_Call { + return &MockClientWithResponsesInterface_CreateClientWithResponse_Call{Call: _e.mock.On("CreateClientWithResponse", + append([]interface{}{ctx, body}, reqEditors...)...)} +} + +func (_c *MockClientWithResponsesInterface_CreateClientWithResponse_Call) Run(run func(ctx context.Context, body queryservice.ClientCreate, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_CreateClientWithResponse_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(queryservice.ClientCreate), variadicArgs...) + }) + return _c +} + +func (_c *MockClientWithResponsesInterface_CreateClientWithResponse_Call) Return(_a0 *queryservice.CreateClientResponse, _a1 error) *MockClientWithResponsesInterface_CreateClientWithResponse_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientWithResponsesInterface_CreateClientWithResponse_Call) RunAndReturn(run func(context.Context, queryservice.ClientCreate, ...queryservice.RequestEditorFn) (*queryservice.CreateClientResponse, error)) *MockClientWithResponsesInterface_CreateClientWithResponse_Call { + _c.Call.Return(run) + return _c +} + +// CreateQueryWithBodyWithResponse provides a mock function with given fields: ctx, contentType, body, reqEditors +func (_m *MockClientWithResponsesInterface) CreateQueryWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*queryservice.CreateQueryResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CreateQueryWithBodyWithResponse") + } + + var r0 *queryservice.CreateQueryResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.CreateQueryResponse, error)); ok { + return rf(ctx, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) *queryservice.CreateQueryResponse); ok { + r0 = rf(ctx, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*queryservice.CreateQueryResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateQueryWithBodyWithResponse' +type MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call struct { + *mock.Call +} + +// CreateQueryWithBodyWithResponse is a helper method to define mock.On call +// - ctx context.Context +// - contentType string +// - body io.Reader +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientWithResponsesInterface_Expecter) CreateQueryWithBodyWithResponse(ctx interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call { + return &MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call{Call: _e.mock.On("CreateQueryWithBodyWithResponse", + append([]interface{}{ctx, contentType, body}, reqEditors...)...)} +} + +func (_c *MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call) Run(run func(ctx context.Context, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + for i, a := range args[3:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(string), args[2].(io.Reader), variadicArgs...) + }) + return _c +} + +func (_c *MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call) Return(_a0 *queryservice.CreateQueryResponse, _a1 error) *MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call) RunAndReturn(run func(context.Context, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.CreateQueryResponse, error)) *MockClientWithResponsesInterface_CreateQueryWithBodyWithResponse_Call { + _c.Call.Return(run) + return _c +} + +// CreateQueryWithResponse provides a mock function with given fields: ctx, body, reqEditors +func (_m *MockClientWithResponsesInterface) CreateQueryWithResponse(ctx context.Context, body queryservice.QueryCreate, reqEditors ...queryservice.RequestEditorFn) (*queryservice.CreateQueryResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for CreateQueryWithResponse") + } + + var r0 *queryservice.CreateQueryResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, queryservice.QueryCreate, ...queryservice.RequestEditorFn) (*queryservice.CreateQueryResponse, error)); ok { + return rf(ctx, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, queryservice.QueryCreate, ...queryservice.RequestEditorFn) *queryservice.CreateQueryResponse); ok { + r0 = rf(ctx, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*queryservice.CreateQueryResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, queryservice.QueryCreate, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientWithResponsesInterface_CreateQueryWithResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateQueryWithResponse' +type MockClientWithResponsesInterface_CreateQueryWithResponse_Call struct { + *mock.Call +} + +// CreateQueryWithResponse is a helper method to define mock.On call +// - ctx context.Context +// - body queryservice.QueryCreate +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientWithResponsesInterface_Expecter) CreateQueryWithResponse(ctx interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_CreateQueryWithResponse_Call { + return &MockClientWithResponsesInterface_CreateQueryWithResponse_Call{Call: _e.mock.On("CreateQueryWithResponse", + append([]interface{}{ctx, body}, reqEditors...)...)} +} + +func (_c *MockClientWithResponsesInterface_CreateQueryWithResponse_Call) Run(run func(ctx context.Context, body queryservice.QueryCreate, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_CreateQueryWithResponse_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(queryservice.QueryCreate), variadicArgs...) + }) + return _c +} + +func (_c *MockClientWithResponsesInterface_CreateQueryWithResponse_Call) Return(_a0 *queryservice.CreateQueryResponse, _a1 error) *MockClientWithResponsesInterface_CreateQueryWithResponse_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientWithResponsesInterface_CreateQueryWithResponse_Call) RunAndReturn(run func(context.Context, queryservice.QueryCreate, ...queryservice.RequestEditorFn) (*queryservice.CreateQueryResponse, error)) *MockClientWithResponsesInterface_CreateQueryWithResponse_Call { + _c.Call.Return(run) + return _c +} + +// ExportStateWithResponse provides a mock function with given fields: ctx, id, reqEditors +func (_m *MockClientWithResponsesInterface) ExportStateWithResponse(ctx context.Context, id uuid.UUID, reqEditors ...queryservice.RequestEditorFn) (*queryservice.ExportStateResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for ExportStateWithResponse") + } + + var r0 *queryservice.ExportStateResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) (*queryservice.ExportStateResponse, error)); ok { + return rf(ctx, id, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) *queryservice.ExportStateResponse); ok { + r0 = rf(ctx, id, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*queryservice.ExportStateResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientWithResponsesInterface_ExportStateWithResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ExportStateWithResponse' +type MockClientWithResponsesInterface_ExportStateWithResponse_Call struct { + *mock.Call +} + +// ExportStateWithResponse is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientWithResponsesInterface_Expecter) ExportStateWithResponse(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_ExportStateWithResponse_Call { + return &MockClientWithResponsesInterface_ExportStateWithResponse_Call{Call: _e.mock.On("ExportStateWithResponse", + append([]interface{}{ctx, id}, reqEditors...)...)} +} + +func (_c *MockClientWithResponsesInterface_ExportStateWithResponse_Call) Run(run func(ctx context.Context, id uuid.UUID, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_ExportStateWithResponse_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(uuid.UUID), variadicArgs...) + }) + return _c +} + +func (_c *MockClientWithResponsesInterface_ExportStateWithResponse_Call) Return(_a0 *queryservice.ExportStateResponse, _a1 error) *MockClientWithResponsesInterface_ExportStateWithResponse_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientWithResponsesInterface_ExportStateWithResponse_Call) RunAndReturn(run func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) (*queryservice.ExportStateResponse, error)) *MockClientWithResponsesInterface_ExportStateWithResponse_Call { + _c.Call.Return(run) + return _c +} + +// GetClientWithResponse provides a mock function with given fields: ctx, id, reqEditors +func (_m *MockClientWithResponsesInterface) GetClientWithResponse(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn) (*queryservice.GetClientResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for GetClientWithResponse") + } + + var r0 *queryservice.GetClientResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) (*queryservice.GetClientResponse, error)); ok { + return rf(ctx, id, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) *queryservice.GetClientResponse); ok { + r0 = rf(ctx, id, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*queryservice.GetClientResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientWithResponsesInterface_GetClientWithResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetClientWithResponse' +type MockClientWithResponsesInterface_GetClientWithResponse_Call struct { + *mock.Call +} + +// GetClientWithResponse is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientWithResponsesInterface_Expecter) GetClientWithResponse(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_GetClientWithResponse_Call { + return &MockClientWithResponsesInterface_GetClientWithResponse_Call{Call: _e.mock.On("GetClientWithResponse", + append([]interface{}{ctx, id}, reqEditors...)...)} +} + +func (_c *MockClientWithResponsesInterface_GetClientWithResponse_Call) Run(run func(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_GetClientWithResponse_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(string), variadicArgs...) + }) + return _c +} + +func (_c *MockClientWithResponsesInterface_GetClientWithResponse_Call) Return(_a0 *queryservice.GetClientResponse, _a1 error) *MockClientWithResponsesInterface_GetClientWithResponse_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientWithResponsesInterface_GetClientWithResponse_Call) RunAndReturn(run func(context.Context, string, ...queryservice.RequestEditorFn) (*queryservice.GetClientResponse, error)) *MockClientWithResponsesInterface_GetClientWithResponse_Call { + _c.Call.Return(run) + return _c +} + +// GetCollectorByClientIdWithResponse provides a mock function with given fields: ctx, id, reqEditors +func (_m *MockClientWithResponsesInterface) GetCollectorByClientIdWithResponse(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn) (*queryservice.GetCollectorByClientIdResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for GetCollectorByClientIdWithResponse") + } + + var r0 *queryservice.GetCollectorByClientIdResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) (*queryservice.GetCollectorByClientIdResponse, error)); ok { + return rf(ctx, id, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) *queryservice.GetCollectorByClientIdResponse); ok { + r0 = rf(ctx, id, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*queryservice.GetCollectorByClientIdResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetCollectorByClientIdWithResponse' +type MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call struct { + *mock.Call +} + +// GetCollectorByClientIdWithResponse is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientWithResponsesInterface_Expecter) GetCollectorByClientIdWithResponse(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call { + return &MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call{Call: _e.mock.On("GetCollectorByClientIdWithResponse", + append([]interface{}{ctx, id}, reqEditors...)...)} +} + +func (_c *MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call) Run(run func(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(string), variadicArgs...) + }) + return _c +} + +func (_c *MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call) Return(_a0 *queryservice.GetCollectorByClientIdResponse, _a1 error) *MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call) RunAndReturn(run func(context.Context, string, ...queryservice.RequestEditorFn) (*queryservice.GetCollectorByClientIdResponse, error)) *MockClientWithResponsesInterface_GetCollectorByClientIdWithResponse_Call { + _c.Call.Return(run) + return _c +} + +// GetQueryWithResponse provides a mock function with given fields: ctx, id, reqEditors +func (_m *MockClientWithResponsesInterface) GetQueryWithResponse(ctx context.Context, id uuid.UUID, reqEditors ...queryservice.RequestEditorFn) (*queryservice.GetQueryResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for GetQueryWithResponse") + } + + var r0 *queryservice.GetQueryResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) (*queryservice.GetQueryResponse, error)); ok { + return rf(ctx, id, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) *queryservice.GetQueryResponse); ok { + r0 = rf(ctx, id, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*queryservice.GetQueryResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientWithResponsesInterface_GetQueryWithResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetQueryWithResponse' +type MockClientWithResponsesInterface_GetQueryWithResponse_Call struct { + *mock.Call +} + +// GetQueryWithResponse is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientWithResponsesInterface_Expecter) GetQueryWithResponse(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_GetQueryWithResponse_Call { + return &MockClientWithResponsesInterface_GetQueryWithResponse_Call{Call: _e.mock.On("GetQueryWithResponse", + append([]interface{}{ctx, id}, reqEditors...)...)} +} + +func (_c *MockClientWithResponsesInterface_GetQueryWithResponse_Call) Run(run func(ctx context.Context, id uuid.UUID, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_GetQueryWithResponse_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(uuid.UUID), variadicArgs...) + }) + return _c +} + +func (_c *MockClientWithResponsesInterface_GetQueryWithResponse_Call) Return(_a0 *queryservice.GetQueryResponse, _a1 error) *MockClientWithResponsesInterface_GetQueryWithResponse_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientWithResponsesInterface_GetQueryWithResponse_Call) RunAndReturn(run func(context.Context, uuid.UUID, ...queryservice.RequestEditorFn) (*queryservice.GetQueryResponse, error)) *MockClientWithResponsesInterface_GetQueryWithResponse_Call { + _c.Call.Return(run) + return _c +} + +// GetStatusByClientIdWithResponse provides a mock function with given fields: ctx, id, reqEditors +func (_m *MockClientWithResponsesInterface) GetStatusByClientIdWithResponse(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn) (*queryservice.GetStatusByClientIdResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for GetStatusByClientIdWithResponse") + } + + var r0 *queryservice.GetStatusByClientIdResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) (*queryservice.GetStatusByClientIdResponse, error)); ok { + return rf(ctx, id, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) *queryservice.GetStatusByClientIdResponse); ok { + r0 = rf(ctx, id, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*queryservice.GetStatusByClientIdResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetStatusByClientIdWithResponse' +type MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call struct { + *mock.Call +} + +// GetStatusByClientIdWithResponse is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientWithResponsesInterface_Expecter) GetStatusByClientIdWithResponse(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call { + return &MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call{Call: _e.mock.On("GetStatusByClientIdWithResponse", + append([]interface{}{ctx, id}, reqEditors...)...)} +} + +func (_c *MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call) Run(run func(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(string), variadicArgs...) + }) + return _c +} + +func (_c *MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call) Return(_a0 *queryservice.GetStatusByClientIdResponse, _a1 error) *MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call) RunAndReturn(run func(context.Context, string, ...queryservice.RequestEditorFn) (*queryservice.GetStatusByClientIdResponse, error)) *MockClientWithResponsesInterface_GetStatusByClientIdWithResponse_Call { + _c.Call.Return(run) + return _c +} + +// ListDocumentsByClientIdWithResponse provides a mock function with given fields: ctx, id, reqEditors +func (_m *MockClientWithResponsesInterface) ListDocumentsByClientIdWithResponse(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn) (*queryservice.ListDocumentsByClientIdResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for ListDocumentsByClientIdWithResponse") + } + + var r0 *queryservice.ListDocumentsByClientIdResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) (*queryservice.ListDocumentsByClientIdResponse, error)); ok { + return rf(ctx, id, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, ...queryservice.RequestEditorFn) *queryservice.ListDocumentsByClientIdResponse); ok { + r0 = rf(ctx, id, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*queryservice.ListDocumentsByClientIdResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListDocumentsByClientIdWithResponse' +type MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call struct { + *mock.Call +} + +// ListDocumentsByClientIdWithResponse is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientWithResponsesInterface_Expecter) ListDocumentsByClientIdWithResponse(ctx interface{}, id interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call { + return &MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call{Call: _e.mock.On("ListDocumentsByClientIdWithResponse", + append([]interface{}{ctx, id}, reqEditors...)...)} +} + +func (_c *MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call) Run(run func(ctx context.Context, id string, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-2) + for i, a := range args[2:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(string), variadicArgs...) + }) + return _c +} + +func (_c *MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call) Return(_a0 *queryservice.ListDocumentsByClientIdResponse, _a1 error) *MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call) RunAndReturn(run func(context.Context, string, ...queryservice.RequestEditorFn) (*queryservice.ListDocumentsByClientIdResponse, error)) *MockClientWithResponsesInterface_ListDocumentsByClientIdWithResponse_Call { + _c.Call.Return(run) + return _c +} + +// ListQueriesWithResponse provides a mock function with given fields: ctx, reqEditors +func (_m *MockClientWithResponsesInterface) ListQueriesWithResponse(ctx context.Context, reqEditors ...queryservice.RequestEditorFn) (*queryservice.ListQueriesResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for ListQueriesWithResponse") + } + + var r0 *queryservice.ListQueriesResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, ...queryservice.RequestEditorFn) (*queryservice.ListQueriesResponse, error)); ok { + return rf(ctx, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, ...queryservice.RequestEditorFn) *queryservice.ListQueriesResponse); ok { + r0 = rf(ctx, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*queryservice.ListQueriesResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientWithResponsesInterface_ListQueriesWithResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListQueriesWithResponse' +type MockClientWithResponsesInterface_ListQueriesWithResponse_Call struct { + *mock.Call +} + +// ListQueriesWithResponse is a helper method to define mock.On call +// - ctx context.Context +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientWithResponsesInterface_Expecter) ListQueriesWithResponse(ctx interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_ListQueriesWithResponse_Call { + return &MockClientWithResponsesInterface_ListQueriesWithResponse_Call{Call: _e.mock.On("ListQueriesWithResponse", + append([]interface{}{ctx}, reqEditors...)...)} +} + +func (_c *MockClientWithResponsesInterface_ListQueriesWithResponse_Call) Run(run func(ctx context.Context, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_ListQueriesWithResponse_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-1) + for i, a := range args[1:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), variadicArgs...) + }) + return _c +} + +func (_c *MockClientWithResponsesInterface_ListQueriesWithResponse_Call) Return(_a0 *queryservice.ListQueriesResponse, _a1 error) *MockClientWithResponsesInterface_ListQueriesWithResponse_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientWithResponsesInterface_ListQueriesWithResponse_Call) RunAndReturn(run func(context.Context, ...queryservice.RequestEditorFn) (*queryservice.ListQueriesResponse, error)) *MockClientWithResponsesInterface_ListQueriesWithResponse_Call { + _c.Call.Return(run) + return _c +} + +// SetCollectorByClientIdWithBodyWithResponse provides a mock function with given fields: ctx, id, contentType, body, reqEditors +func (_m *MockClientWithResponsesInterface) SetCollectorByClientIdWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*queryservice.SetCollectorByClientIdResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for SetCollectorByClientIdWithBodyWithResponse") + } + + var r0 *queryservice.SetCollectorByClientIdResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.SetCollectorByClientIdResponse, error)); ok { + return rf(ctx, id, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) *queryservice.SetCollectorByClientIdResponse); ok { + r0 = rf(ctx, id, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*queryservice.SetCollectorByClientIdResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetCollectorByClientIdWithBodyWithResponse' +type MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse_Call struct { + *mock.Call +} + +// SetCollectorByClientIdWithBodyWithResponse is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - contentType string +// - body io.Reader +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientWithResponsesInterface_Expecter) SetCollectorByClientIdWithBodyWithResponse(ctx interface{}, id interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse_Call { + return &MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse_Call{Call: _e.mock.On("SetCollectorByClientIdWithBodyWithResponse", + append([]interface{}{ctx, id, contentType, body}, reqEditors...)...)} +} + +func (_c *MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse_Call) Run(run func(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-4) + for i, a := range args[4:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(io.Reader), variadicArgs...) + }) + return _c +} + +func (_c *MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse_Call) Return(_a0 *queryservice.SetCollectorByClientIdResponse, _a1 error) *MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse_Call) RunAndReturn(run func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.SetCollectorByClientIdResponse, error)) *MockClientWithResponsesInterface_SetCollectorByClientIdWithBodyWithResponse_Call { + _c.Call.Return(run) + return _c +} + +// SetCollectorByClientIdWithResponse provides a mock function with given fields: ctx, id, body, reqEditors +func (_m *MockClientWithResponsesInterface) SetCollectorByClientIdWithResponse(ctx context.Context, id string, body queryservice.CollectorSet, reqEditors ...queryservice.RequestEditorFn) (*queryservice.SetCollectorByClientIdResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for SetCollectorByClientIdWithResponse") + } + + var r0 *queryservice.SetCollectorByClientIdResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, queryservice.CollectorSet, ...queryservice.RequestEditorFn) (*queryservice.SetCollectorByClientIdResponse, error)); ok { + return rf(ctx, id, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, queryservice.CollectorSet, ...queryservice.RequestEditorFn) *queryservice.SetCollectorByClientIdResponse); ok { + r0 = rf(ctx, id, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*queryservice.SetCollectorByClientIdResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, queryservice.CollectorSet, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetCollectorByClientIdWithResponse' +type MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call struct { + *mock.Call +} + +// SetCollectorByClientIdWithResponse is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - body queryservice.CollectorSet +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientWithResponsesInterface_Expecter) SetCollectorByClientIdWithResponse(ctx interface{}, id interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call { + return &MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call{Call: _e.mock.On("SetCollectorByClientIdWithResponse", + append([]interface{}{ctx, id, body}, reqEditors...)...)} +} + +func (_c *MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call) Run(run func(ctx context.Context, id string, body queryservice.CollectorSet, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + for i, a := range args[3:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(string), args[2].(queryservice.CollectorSet), variadicArgs...) + }) + return _c +} + +func (_c *MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call) Return(_a0 *queryservice.SetCollectorByClientIdResponse, _a1 error) *MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call) RunAndReturn(run func(context.Context, string, queryservice.CollectorSet, ...queryservice.RequestEditorFn) (*queryservice.SetCollectorByClientIdResponse, error)) *MockClientWithResponsesInterface_SetCollectorByClientIdWithResponse_Call { + _c.Call.Return(run) + return _c +} + +// TestQueryWithBodyWithResponse provides a mock function with given fields: ctx, id, contentType, body, reqEditors +func (_m *MockClientWithResponsesInterface) TestQueryWithBodyWithResponse(ctx context.Context, id uuid.UUID, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*queryservice.TestQueryResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for TestQueryWithBodyWithResponse") + } + + var r0 *queryservice.TestQueryResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.TestQueryResponse, error)); ok { + return rf(ctx, id, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) *queryservice.TestQueryResponse); ok { + r0 = rf(ctx, id, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*queryservice.TestQueryResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TestQueryWithBodyWithResponse' +type MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call struct { + *mock.Call +} + +// TestQueryWithBodyWithResponse is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +// - contentType string +// - body io.Reader +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientWithResponsesInterface_Expecter) TestQueryWithBodyWithResponse(ctx interface{}, id interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call { + return &MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call{Call: _e.mock.On("TestQueryWithBodyWithResponse", + append([]interface{}{ctx, id, contentType, body}, reqEditors...)...)} +} + +func (_c *MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call) Run(run func(ctx context.Context, id uuid.UUID, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-4) + for i, a := range args[4:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(string), args[3].(io.Reader), variadicArgs...) + }) + return _c +} + +func (_c *MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call) Return(_a0 *queryservice.TestQueryResponse, _a1 error) *MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call) RunAndReturn(run func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.TestQueryResponse, error)) *MockClientWithResponsesInterface_TestQueryWithBodyWithResponse_Call { + _c.Call.Return(run) + return _c +} + +// TestQueryWithResponse provides a mock function with given fields: ctx, id, body, reqEditors +func (_m *MockClientWithResponsesInterface) TestQueryWithResponse(ctx context.Context, id uuid.UUID, body queryservice.QueryTestRequest, reqEditors ...queryservice.RequestEditorFn) (*queryservice.TestQueryResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for TestQueryWithResponse") + } + + var r0 *queryservice.TestQueryResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, queryservice.QueryTestRequest, ...queryservice.RequestEditorFn) (*queryservice.TestQueryResponse, error)); ok { + return rf(ctx, id, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, queryservice.QueryTestRequest, ...queryservice.RequestEditorFn) *queryservice.TestQueryResponse); ok { + r0 = rf(ctx, id, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*queryservice.TestQueryResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, queryservice.QueryTestRequest, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientWithResponsesInterface_TestQueryWithResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TestQueryWithResponse' +type MockClientWithResponsesInterface_TestQueryWithResponse_Call struct { + *mock.Call +} + +// TestQueryWithResponse is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +// - body queryservice.QueryTestRequest +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientWithResponsesInterface_Expecter) TestQueryWithResponse(ctx interface{}, id interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_TestQueryWithResponse_Call { + return &MockClientWithResponsesInterface_TestQueryWithResponse_Call{Call: _e.mock.On("TestQueryWithResponse", + append([]interface{}{ctx, id, body}, reqEditors...)...)} +} + +func (_c *MockClientWithResponsesInterface_TestQueryWithResponse_Call) Run(run func(ctx context.Context, id uuid.UUID, body queryservice.QueryTestRequest, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_TestQueryWithResponse_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + for i, a := range args[3:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(queryservice.QueryTestRequest), variadicArgs...) + }) + return _c +} + +func (_c *MockClientWithResponsesInterface_TestQueryWithResponse_Call) Return(_a0 *queryservice.TestQueryResponse, _a1 error) *MockClientWithResponsesInterface_TestQueryWithResponse_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientWithResponsesInterface_TestQueryWithResponse_Call) RunAndReturn(run func(context.Context, uuid.UUID, queryservice.QueryTestRequest, ...queryservice.RequestEditorFn) (*queryservice.TestQueryResponse, error)) *MockClientWithResponsesInterface_TestQueryWithResponse_Call { + _c.Call.Return(run) + return _c +} + +// TriggerExportWithBodyWithResponse provides a mock function with given fields: ctx, id, contentType, body, reqEditors +func (_m *MockClientWithResponsesInterface) TriggerExportWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*queryservice.TriggerExportResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for TriggerExportWithBodyWithResponse") + } + + var r0 *queryservice.TriggerExportResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.TriggerExportResponse, error)); ok { + return rf(ctx, id, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) *queryservice.TriggerExportResponse); ok { + r0 = rf(ctx, id, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*queryservice.TriggerExportResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TriggerExportWithBodyWithResponse' +type MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call struct { + *mock.Call +} + +// TriggerExportWithBodyWithResponse is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - contentType string +// - body io.Reader +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientWithResponsesInterface_Expecter) TriggerExportWithBodyWithResponse(ctx interface{}, id interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call { + return &MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call{Call: _e.mock.On("TriggerExportWithBodyWithResponse", + append([]interface{}{ctx, id, contentType, body}, reqEditors...)...)} +} + +func (_c *MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call) Run(run func(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-4) + for i, a := range args[4:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(io.Reader), variadicArgs...) + }) + return _c +} + +func (_c *MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call) Return(_a0 *queryservice.TriggerExportResponse, _a1 error) *MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call) RunAndReturn(run func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.TriggerExportResponse, error)) *MockClientWithResponsesInterface_TriggerExportWithBodyWithResponse_Call { + _c.Call.Return(run) + return _c +} + +// TriggerExportWithResponse provides a mock function with given fields: ctx, id, body, reqEditors +func (_m *MockClientWithResponsesInterface) TriggerExportWithResponse(ctx context.Context, id string, body queryservice.ExportTrigger, reqEditors ...queryservice.RequestEditorFn) (*queryservice.TriggerExportResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for TriggerExportWithResponse") + } + + var r0 *queryservice.TriggerExportResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, queryservice.ExportTrigger, ...queryservice.RequestEditorFn) (*queryservice.TriggerExportResponse, error)); ok { + return rf(ctx, id, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, queryservice.ExportTrigger, ...queryservice.RequestEditorFn) *queryservice.TriggerExportResponse); ok { + r0 = rf(ctx, id, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*queryservice.TriggerExportResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, queryservice.ExportTrigger, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientWithResponsesInterface_TriggerExportWithResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TriggerExportWithResponse' +type MockClientWithResponsesInterface_TriggerExportWithResponse_Call struct { + *mock.Call +} + +// TriggerExportWithResponse is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - body queryservice.ExportTrigger +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientWithResponsesInterface_Expecter) TriggerExportWithResponse(ctx interface{}, id interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_TriggerExportWithResponse_Call { + return &MockClientWithResponsesInterface_TriggerExportWithResponse_Call{Call: _e.mock.On("TriggerExportWithResponse", + append([]interface{}{ctx, id, body}, reqEditors...)...)} +} + +func (_c *MockClientWithResponsesInterface_TriggerExportWithResponse_Call) Run(run func(ctx context.Context, id string, body queryservice.ExportTrigger, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_TriggerExportWithResponse_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + for i, a := range args[3:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(string), args[2].(queryservice.ExportTrigger), variadicArgs...) + }) + return _c +} + +func (_c *MockClientWithResponsesInterface_TriggerExportWithResponse_Call) Return(_a0 *queryservice.TriggerExportResponse, _a1 error) *MockClientWithResponsesInterface_TriggerExportWithResponse_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientWithResponsesInterface_TriggerExportWithResponse_Call) RunAndReturn(run func(context.Context, string, queryservice.ExportTrigger, ...queryservice.RequestEditorFn) (*queryservice.TriggerExportResponse, error)) *MockClientWithResponsesInterface_TriggerExportWithResponse_Call { + _c.Call.Return(run) + return _c +} + +// UpdateClientWithBodyWithResponse provides a mock function with given fields: ctx, id, contentType, body, reqEditors +func (_m *MockClientWithResponsesInterface) UpdateClientWithBodyWithResponse(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*queryservice.UpdateClientResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateClientWithBodyWithResponse") + } + + var r0 *queryservice.UpdateClientResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.UpdateClientResponse, error)); ok { + return rf(ctx, id, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) *queryservice.UpdateClientResponse); ok { + r0 = rf(ctx, id, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*queryservice.UpdateClientResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateClientWithBodyWithResponse' +type MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call struct { + *mock.Call +} + +// UpdateClientWithBodyWithResponse is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - contentType string +// - body io.Reader +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientWithResponsesInterface_Expecter) UpdateClientWithBodyWithResponse(ctx interface{}, id interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call { + return &MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call{Call: _e.mock.On("UpdateClientWithBodyWithResponse", + append([]interface{}{ctx, id, contentType, body}, reqEditors...)...)} +} + +func (_c *MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call) Run(run func(ctx context.Context, id string, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-4) + for i, a := range args[4:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(io.Reader), variadicArgs...) + }) + return _c +} + +func (_c *MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call) Return(_a0 *queryservice.UpdateClientResponse, _a1 error) *MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call) RunAndReturn(run func(context.Context, string, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.UpdateClientResponse, error)) *MockClientWithResponsesInterface_UpdateClientWithBodyWithResponse_Call { + _c.Call.Return(run) + return _c +} + +// UpdateClientWithResponse provides a mock function with given fields: ctx, id, body, reqEditors +func (_m *MockClientWithResponsesInterface) UpdateClientWithResponse(ctx context.Context, id string, body queryservice.ClientUpdate, reqEditors ...queryservice.RequestEditorFn) (*queryservice.UpdateClientResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateClientWithResponse") + } + + var r0 *queryservice.UpdateClientResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, queryservice.ClientUpdate, ...queryservice.RequestEditorFn) (*queryservice.UpdateClientResponse, error)); ok { + return rf(ctx, id, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, string, queryservice.ClientUpdate, ...queryservice.RequestEditorFn) *queryservice.UpdateClientResponse); ok { + r0 = rf(ctx, id, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*queryservice.UpdateClientResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, queryservice.ClientUpdate, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientWithResponsesInterface_UpdateClientWithResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateClientWithResponse' +type MockClientWithResponsesInterface_UpdateClientWithResponse_Call struct { + *mock.Call +} + +// UpdateClientWithResponse is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - body queryservice.ClientUpdate +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientWithResponsesInterface_Expecter) UpdateClientWithResponse(ctx interface{}, id interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_UpdateClientWithResponse_Call { + return &MockClientWithResponsesInterface_UpdateClientWithResponse_Call{Call: _e.mock.On("UpdateClientWithResponse", + append([]interface{}{ctx, id, body}, reqEditors...)...)} +} + +func (_c *MockClientWithResponsesInterface_UpdateClientWithResponse_Call) Run(run func(ctx context.Context, id string, body queryservice.ClientUpdate, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_UpdateClientWithResponse_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + for i, a := range args[3:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(string), args[2].(queryservice.ClientUpdate), variadicArgs...) + }) + return _c +} + +func (_c *MockClientWithResponsesInterface_UpdateClientWithResponse_Call) Return(_a0 *queryservice.UpdateClientResponse, _a1 error) *MockClientWithResponsesInterface_UpdateClientWithResponse_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientWithResponsesInterface_UpdateClientWithResponse_Call) RunAndReturn(run func(context.Context, string, queryservice.ClientUpdate, ...queryservice.RequestEditorFn) (*queryservice.UpdateClientResponse, error)) *MockClientWithResponsesInterface_UpdateClientWithResponse_Call { + _c.Call.Return(run) + return _c +} + +// UpdateQueryWithBodyWithResponse provides a mock function with given fields: ctx, id, contentType, body, reqEditors +func (_m *MockClientWithResponsesInterface) UpdateQueryWithBodyWithResponse(ctx context.Context, id uuid.UUID, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn) (*queryservice.UpdateQueryResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id, contentType, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateQueryWithBodyWithResponse") + } + + var r0 *queryservice.UpdateQueryResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.UpdateQueryResponse, error)); ok { + return rf(ctx, id, contentType, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) *queryservice.UpdateQueryResponse); ok { + r0 = rf(ctx, id, contentType, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*queryservice.UpdateQueryResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, contentType, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateQueryWithBodyWithResponse' +type MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call struct { + *mock.Call +} + +// UpdateQueryWithBodyWithResponse is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +// - contentType string +// - body io.Reader +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientWithResponsesInterface_Expecter) UpdateQueryWithBodyWithResponse(ctx interface{}, id interface{}, contentType interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call { + return &MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call{Call: _e.mock.On("UpdateQueryWithBodyWithResponse", + append([]interface{}{ctx, id, contentType, body}, reqEditors...)...)} +} + +func (_c *MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call) Run(run func(ctx context.Context, id uuid.UUID, contentType string, body io.Reader, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-4) + for i, a := range args[4:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(string), args[3].(io.Reader), variadicArgs...) + }) + return _c +} + +func (_c *MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call) Return(_a0 *queryservice.UpdateQueryResponse, _a1 error) *MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call) RunAndReturn(run func(context.Context, uuid.UUID, string, io.Reader, ...queryservice.RequestEditorFn) (*queryservice.UpdateQueryResponse, error)) *MockClientWithResponsesInterface_UpdateQueryWithBodyWithResponse_Call { + _c.Call.Return(run) + return _c +} + +// UpdateQueryWithResponse provides a mock function with given fields: ctx, id, body, reqEditors +func (_m *MockClientWithResponsesInterface) UpdateQueryWithResponse(ctx context.Context, id uuid.UUID, body queryservice.QueryUpdate, reqEditors ...queryservice.RequestEditorFn) (*queryservice.UpdateQueryResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, id, body) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for UpdateQueryWithResponse") + } + + var r0 *queryservice.UpdateQueryResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, queryservice.QueryUpdate, ...queryservice.RequestEditorFn) (*queryservice.UpdateQueryResponse, error)); ok { + return rf(ctx, id, body, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, queryservice.QueryUpdate, ...queryservice.RequestEditorFn) *queryservice.UpdateQueryResponse); ok { + r0 = rf(ctx, id, body, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*queryservice.UpdateQueryResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, queryservice.QueryUpdate, ...queryservice.RequestEditorFn) error); ok { + r1 = rf(ctx, id, body, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClientWithResponsesInterface_UpdateQueryWithResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateQueryWithResponse' +type MockClientWithResponsesInterface_UpdateQueryWithResponse_Call struct { + *mock.Call +} + +// UpdateQueryWithResponse is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +// - body queryservice.QueryUpdate +// - reqEditors ...queryservice.RequestEditorFn +func (_e *MockClientWithResponsesInterface_Expecter) UpdateQueryWithResponse(ctx interface{}, id interface{}, body interface{}, reqEditors ...interface{}) *MockClientWithResponsesInterface_UpdateQueryWithResponse_Call { + return &MockClientWithResponsesInterface_UpdateQueryWithResponse_Call{Call: _e.mock.On("UpdateQueryWithResponse", + append([]interface{}{ctx, id, body}, reqEditors...)...)} +} + +func (_c *MockClientWithResponsesInterface_UpdateQueryWithResponse_Call) Run(run func(ctx context.Context, id uuid.UUID, body queryservice.QueryUpdate, reqEditors ...queryservice.RequestEditorFn)) *MockClientWithResponsesInterface_UpdateQueryWithResponse_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]queryservice.RequestEditorFn, len(args)-3) + for i, a := range args[3:] { + if a != nil { + variadicArgs[i] = a.(queryservice.RequestEditorFn) + } + } + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(queryservice.QueryUpdate), variadicArgs...) + }) + return _c +} + +func (_c *MockClientWithResponsesInterface_UpdateQueryWithResponse_Call) Return(_a0 *queryservice.UpdateQueryResponse, _a1 error) *MockClientWithResponsesInterface_UpdateQueryWithResponse_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClientWithResponsesInterface_UpdateQueryWithResponse_Call) RunAndReturn(run func(context.Context, uuid.UUID, queryservice.QueryUpdate, ...queryservice.RequestEditorFn) (*queryservice.UpdateQueryResponse, error)) *MockClientWithResponsesInterface_UpdateQueryWithResponse_Call { + _c.Call.Return(run) + return _c +} + +// NewMockClientWithResponsesInterface creates a new instance of MockClientWithResponsesInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockClientWithResponsesInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *MockClientWithResponsesInterface { + mock := &MockClientWithResponsesInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/queryService/api.gen.go b/pkg/queryService/api.gen.go index a2951704..6c3f5857 100644 --- a/pkg/queryService/api.gen.go +++ b/pkg/queryService/api.gen.go @@ -49,106 +49,139 @@ const ( JSONEXTRACTOR QueryType = "JSON_EXTRACTOR" ) -// ClientCreate defines model for ClientCreate. +// ClientCanSync If the client is allowing active syncs +type ClientCanSync = bool + +// ClientCreate The properties for creation. type ClientCreate struct { + // Id The client external id + Id ClientID `json:"id"` + // Name The client name - Name string `json:"name"` + Name ClientName `json:"name"` } +// ClientID The client external id +type ClientID = string + +// ClientIDBody The client id. +type ClientIDBody struct { + // Id The client external id + Id ClientID `json:"id"` +} + +// ClientName The client name +type ClientName = string + // ClientStatus Specifies the status of a client. type ClientStatus string -// ClientStatusBody defines model for ClientStatusBody. +// ClientStatusBody A client status information object. type ClientStatusBody struct { - // ClientId The client id - ClientId openapi_types.UUID `json:"client_id"` - // Status Specifies the status of a client. Status ClientStatus `json:"status"` } -// ClientUpdate defines model for ClientUpdate. +// ClientUID The client internal unique id +type ClientUID = openapi_types.UUID + +// ClientUpdate The properties that may be updated. type ClientUpdate struct { // CanSync If the client is allowing active syncs - CanSync *bool `json:"can_sync,omitempty"` + CanSync *ClientCanSync `json:"can_sync,omitempty"` // Name The client name - Name *string `json:"name,omitempty"` + Name *ClientName `json:"name,omitempty"` } +// CodeVersion The desired code version. +type CodeVersion = int32 + // Collector Collector model. type Collector struct { - // ActiveVersion The active version of the collector. - ActiveVersion int32 `json:"active_version"` + // ActiveVersion The desired version. + ActiveVersion Version `json:"active_version"` - // ClientId The ID of the associated client. - ClientId openapi_types.UUID `json:"client_id"` + // ClientId The client external id + ClientId ClientID `json:"client_id"` // Fields The fields in the collector. - Fields []CollectorField `json:"fields"` + Fields CollectorFields `json:"fields"` - // LatestVersion The latest version of the collector. - LatestVersion int32 `json:"latest_version"` + // LatestVersion The desired version. + LatestVersion Version `json:"latest_version"` - // MinimumCleanerVersion The minimum version for the document cleaner. - MinimumCleanerVersion int32 `json:"minimum_cleaner_version"` + // MinimumCleanerVersion The desired code version. + MinimumCleanerVersion CodeVersion `json:"minimum_cleaner_version"` - // MinimumTextVersion The minimum version for the text parser. - MinimumTextVersion int32 `json:"minimum_text_version"` + // MinimumTextVersion The desired code version. + MinimumTextVersion CodeVersion `json:"minimum_text_version"` } // CollectorField The field properties for the collector. type CollectorField struct { // Name The output field name. - Name string `json:"name"` + Name CollectorFieldName `json:"name"` - // QueryId The query id that will populate the result. - QueryId openapi_types.UUID `json:"query_id"` + // QueryId The query id. + QueryId QueryID `json:"query_id"` } +// CollectorFieldName The output field name. +type CollectorFieldName = string + +// CollectorFields The fields in the collector. +type CollectorFields = []CollectorField + // CollectorSet Payload for updating a Collector. type CollectorSet struct { - // ActiveVersion The active version of the collector. - ActiveVersion *int32 `json:"active_version,omitempty"` + // ActiveVersion The desired version. + ActiveVersion *Version `json:"active_version,omitempty"` // Fields The fields in the collector. - Fields *[]CollectorField `json:"fields,omitempty"` + Fields *CollectorFields `json:"fields,omitempty"` - // MinimumCleanerVersion The minimum version for the document cleaner. - MinimumCleanerVersion *int32 `json:"minimum_cleaner_version,omitempty"` + // MinimumCleanerVersion The desired code version. + MinimumCleanerVersion *CodeVersion `json:"minimum_cleaner_version,omitempty"` - // MinimumTextVersion The minimum version for the text parser. - MinimumTextVersion *int32 `json:"minimum_text_version,omitempty"` + // MinimumTextVersion The desired code version. + MinimumTextVersion *CodeVersion `json:"minimum_text_version,omitempty"` } -// DocClient defines model for DocClient. +// DocClient The properties of a client. type DocClient struct { // CanSync If the client is allowing active syncs - CanSync bool `json:"can_sync"` + CanSync ClientCanSync `json:"can_sync"` - // Id The client id - Id openapi_types.UUID `json:"id"` + // Id The client external id + Id ClientID `json:"id"` // Name The client name - Name string `json:"name"` + Name ClientName `json:"name"` + + // Uid The client internal unique id + Uid ClientUID `json:"uid"` } -// Document defines model for Document. +// Document The document properties. type Document struct { // Bucket The bucket containing the document Bucket string `json:"bucket"` - // Id The document id - Id openapi_types.UUID `json:"id"` + // Id The document id. + Id DocumentID `json:"id"` // Key The path to the document Key string `json:"key"` } +// DocumentID The document id. +type DocumentID = openapi_types.UUID + // ExportDetails Payload for export trigger response. type ExportDetails struct { - // ClientId The client id relative to the export. - ClientId openapi_types.UUID `json:"client_id"` + // ClientId The client external id + ClientId ClientID `json:"client_id"` // OutputLocation The location in which the export zip file will be found. OutputLocation *string `json:"output_location,omitempty"` @@ -157,6 +190,9 @@ type ExportDetails struct { Status ExportStatus `json:"status"` } +// ExportID The export id. +type ExportID = openapi_types.UUID + // ExportStatus The possible export states. type ExportStatus string @@ -180,8 +216,8 @@ type FieldFilter struct { // Condition The possible field filtering conditions. Condition FieldFilterCondition `json:"condition"` - // FieldName The name of the field in question. - FieldName string `json:"field_name"` + // FieldName The output field name. + FieldName CollectorFieldName `json:"field_name"` // Values The values useful to the filter. Values []string `json:"values"` @@ -190,7 +226,7 @@ type FieldFilter struct { // FieldFilterCondition The possible field filtering conditions. type FieldFilterCondition string -// IdMessage defines model for IdMessage. +// IdMessage A single uuid. type IdMessage struct { // Id Unique identifier for entity. Id openapi_types.UUID `json:"id"` @@ -199,55 +235,61 @@ type IdMessage struct { // ListDocuments The documents in the client. type ListDocuments = []Document -// ListQueries defines model for ListQueries. +// ListQueries A set of queries. type ListQueries struct { // Queries List of queries. Queries []Query `json:"queries"` } -// Query defines model for Query. +// Query A logic unit of execution. type Query struct { - // ActiveVersion The active version of the query. - ActiveVersion int32 `json:"active_version"` + // ActiveVersion The desired version. + ActiveVersion Version `json:"active_version"` // Config Configuration for the query. - Config *string `json:"config,omitempty"` + Config *QueryConfig `json:"config,omitempty"` - // Id Unique identifier for the query. - Id openapi_types.UUID `json:"id"` + // Id The query id. + Id QueryID `json:"id"` - // LatestVersion The latest version of the query. - LatestVersion int32 `json:"latest_version"` + // LatestVersion The desired version. + LatestVersion Version `json:"latest_version"` // RequiredQueries List of required query IDs. - RequiredQueries *[]openapi_types.UUID `json:"required_queries,omitempty"` + RequiredQueries *RequiredQueryIDs `json:"required_queries,omitempty"` // Type Specifies the type of the query. Type QueryType `json:"type"` } -// QueryCreate defines model for QueryCreate. +// QueryConfig Configuration for the query. +type QueryConfig = string + +// QueryCreate The parameters required to create a query. type QueryCreate struct { - // Config Configuration for the new query. - Config *string `json:"config,omitempty"` + // Config Configuration for the query. + Config *QueryConfig `json:"config,omitempty"` // RequiredQueries List of required query IDs. - RequiredQueries *[]openapi_types.UUID `json:"required_queries,omitempty"` + RequiredQueries *RequiredQueryIDs `json:"required_queries,omitempty"` // Type Specifies the type of the query. Type QueryType `json:"type"` } -// QueryTestRequest defines model for QueryTestRequest. -type QueryTestRequest struct { - // DocumentId ID of the document to test against. - DocumentId openapi_types.UUID `json:"document_id"` +// QueryID The query id. +type QueryID = openapi_types.UUID - // QueryVersion Version of the query to use for testing. - QueryVersion int32 `json:"query_version"` +// QueryTestRequest The properties for a query test request. +type QueryTestRequest struct { + // DocumentId The document id. + DocumentId DocumentID `json:"document_id"` + + // QueryVersion The desired version. + QueryVersion Version `json:"query_version"` } -// QueryTestResponse defines model for QueryTestResponse. +// QueryTestResponse The response from a query test. type QueryTestResponse struct { // Value Result of the query test. Value string `json:"value"` @@ -256,18 +298,24 @@ type QueryTestResponse struct { // QueryType Specifies the type of the query. type QueryType string -// QueryUpdate defines model for QueryUpdate. +// QueryUpdate The properties that may be updated for a query. type QueryUpdate struct { - // ActiveVersion Updated active version. - ActiveVersion *int32 `json:"active_version,omitempty"` + // ActiveVersion The desired version. + ActiveVersion *Version `json:"active_version,omitempty"` - // Config Updated configuration for the query. - Config *string `json:"config,omitempty"` + // Config Configuration for the query. + Config *QueryConfig `json:"config,omitempty"` - // RequiredQueries Updated list of required query IDs. - RequiredQueries *[]openapi_types.UUID `json:"required_queries,omitempty"` + // RequiredQueries List of required query IDs. + RequiredQueries *RequiredQueryIDs `json:"required_queries,omitempty"` } +// RequiredQueryIDs List of required query IDs. +type RequiredQueryIDs = []QueryID + +// Version The desired version. +type Version = int32 + // CreateClientJSONRequestBody defines body for CreateClient for application/json ContentType. type CreateClientJSONRequestBody = ClientCreate @@ -368,34 +416,34 @@ type ClientInterface interface { CreateClient(ctx context.Context, body CreateClientJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) // GetClient request - GetClient(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) + GetClient(ctx context.Context, id ClientID, reqEditors ...RequestEditorFn) (*http.Response, error) // UpdateClientWithBody request with any body - UpdateClientWithBody(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + UpdateClientWithBody(ctx context.Context, id ClientID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - UpdateClient(ctx context.Context, id openapi_types.UUID, body UpdateClientJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + UpdateClient(ctx context.Context, id ClientID, body UpdateClientJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) // GetCollectorByClientId request - GetCollectorByClientId(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) + GetCollectorByClientId(ctx context.Context, id ClientID, reqEditors ...RequestEditorFn) (*http.Response, error) // SetCollectorByClientIdWithBody request with any body - SetCollectorByClientIdWithBody(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + SetCollectorByClientIdWithBody(ctx context.Context, id ClientID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - SetCollectorByClientId(ctx context.Context, id openapi_types.UUID, body SetCollectorByClientIdJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + SetCollectorByClientId(ctx context.Context, id ClientID, body SetCollectorByClientIdJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) // ListDocumentsByClientId request - ListDocumentsByClientId(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) - - // ExportState request - ExportState(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) + ListDocumentsByClientId(ctx context.Context, id ClientID, reqEditors ...RequestEditorFn) (*http.Response, error) // TriggerExportWithBody request with any body - TriggerExportWithBody(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + TriggerExportWithBody(ctx context.Context, id ClientID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - TriggerExport(ctx context.Context, id openapi_types.UUID, body TriggerExportJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + TriggerExport(ctx context.Context, id ClientID, body TriggerExportJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) // GetStatusByClientId request - GetStatusByClientId(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) + GetStatusByClientId(ctx context.Context, id ClientID, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ExportState request + ExportState(ctx context.Context, id ExportID, reqEditors ...RequestEditorFn) (*http.Response, error) // ListQueries request ListQueries(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -406,17 +454,17 @@ type ClientInterface interface { CreateQuery(ctx context.Context, body CreateQueryJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) // GetQuery request - GetQuery(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) + GetQuery(ctx context.Context, id QueryID, reqEditors ...RequestEditorFn) (*http.Response, error) // UpdateQueryWithBody request with any body - UpdateQueryWithBody(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + UpdateQueryWithBody(ctx context.Context, id QueryID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - UpdateQuery(ctx context.Context, id openapi_types.UUID, body UpdateQueryJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + UpdateQuery(ctx context.Context, id QueryID, body UpdateQueryJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) // TestQueryWithBody request with any body - TestQueryWithBody(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + TestQueryWithBody(ctx context.Context, id QueryID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - TestQuery(ctx context.Context, id openapi_types.UUID, body TestQueryJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + TestQuery(ctx context.Context, id QueryID, body TestQueryJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) } func (c *Client) CreateClientWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { @@ -443,7 +491,7 @@ func (c *Client) CreateClient(ctx context.Context, body CreateClientJSONRequestB return c.Client.Do(req) } -func (c *Client) GetClient(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { +func (c *Client) GetClient(ctx context.Context, id ClientID, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetClientRequest(c.Server, id) if err != nil { return nil, err @@ -455,7 +503,7 @@ func (c *Client) GetClient(ctx context.Context, id openapi_types.UUID, reqEditor return c.Client.Do(req) } -func (c *Client) UpdateClientWithBody(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { +func (c *Client) UpdateClientWithBody(ctx context.Context, id ClientID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewUpdateClientRequestWithBody(c.Server, id, contentType, body) if err != nil { return nil, err @@ -467,7 +515,7 @@ func (c *Client) UpdateClientWithBody(ctx context.Context, id openapi_types.UUID return c.Client.Do(req) } -func (c *Client) UpdateClient(ctx context.Context, id openapi_types.UUID, body UpdateClientJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { +func (c *Client) UpdateClient(ctx context.Context, id ClientID, body UpdateClientJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewUpdateClientRequest(c.Server, id, body) if err != nil { return nil, err @@ -479,7 +527,7 @@ func (c *Client) UpdateClient(ctx context.Context, id openapi_types.UUID, body U return c.Client.Do(req) } -func (c *Client) GetCollectorByClientId(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { +func (c *Client) GetCollectorByClientId(ctx context.Context, id ClientID, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetCollectorByClientIdRequest(c.Server, id) if err != nil { return nil, err @@ -491,7 +539,7 @@ func (c *Client) GetCollectorByClientId(ctx context.Context, id openapi_types.UU return c.Client.Do(req) } -func (c *Client) SetCollectorByClientIdWithBody(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { +func (c *Client) SetCollectorByClientIdWithBody(ctx context.Context, id ClientID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewSetCollectorByClientIdRequestWithBody(c.Server, id, contentType, body) if err != nil { return nil, err @@ -503,7 +551,7 @@ func (c *Client) SetCollectorByClientIdWithBody(ctx context.Context, id openapi_ return c.Client.Do(req) } -func (c *Client) SetCollectorByClientId(ctx context.Context, id openapi_types.UUID, body SetCollectorByClientIdJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { +func (c *Client) SetCollectorByClientId(ctx context.Context, id ClientID, body SetCollectorByClientIdJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewSetCollectorByClientIdRequest(c.Server, id, body) if err != nil { return nil, err @@ -515,7 +563,7 @@ func (c *Client) SetCollectorByClientId(ctx context.Context, id openapi_types.UU return c.Client.Do(req) } -func (c *Client) ListDocumentsByClientId(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { +func (c *Client) ListDocumentsByClientId(ctx context.Context, id ClientID, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewListDocumentsByClientIdRequest(c.Server, id) if err != nil { return nil, err @@ -527,19 +575,7 @@ func (c *Client) ListDocumentsByClientId(ctx context.Context, id openapi_types.U return c.Client.Do(req) } -func (c *Client) ExportState(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewExportStateRequest(c.Server, id) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - -func (c *Client) TriggerExportWithBody(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { +func (c *Client) TriggerExportWithBody(ctx context.Context, id ClientID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewTriggerExportRequestWithBody(c.Server, id, contentType, body) if err != nil { return nil, err @@ -551,7 +587,7 @@ func (c *Client) TriggerExportWithBody(ctx context.Context, id openapi_types.UUI return c.Client.Do(req) } -func (c *Client) TriggerExport(ctx context.Context, id openapi_types.UUID, body TriggerExportJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { +func (c *Client) TriggerExport(ctx context.Context, id ClientID, body TriggerExportJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewTriggerExportRequest(c.Server, id, body) if err != nil { return nil, err @@ -563,7 +599,7 @@ func (c *Client) TriggerExport(ctx context.Context, id openapi_types.UUID, body return c.Client.Do(req) } -func (c *Client) GetStatusByClientId(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { +func (c *Client) GetStatusByClientId(ctx context.Context, id ClientID, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetStatusByClientIdRequest(c.Server, id) if err != nil { return nil, err @@ -575,6 +611,18 @@ func (c *Client) GetStatusByClientId(ctx context.Context, id openapi_types.UUID, return c.Client.Do(req) } +func (c *Client) ExportState(ctx context.Context, id ExportID, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewExportStateRequest(c.Server, id) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) ListQueries(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewListQueriesRequest(c.Server) if err != nil { @@ -611,7 +659,7 @@ func (c *Client) CreateQuery(ctx context.Context, body CreateQueryJSONRequestBod return c.Client.Do(req) } -func (c *Client) GetQuery(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { +func (c *Client) GetQuery(ctx context.Context, id QueryID, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetQueryRequest(c.Server, id) if err != nil { return nil, err @@ -623,7 +671,7 @@ func (c *Client) GetQuery(ctx context.Context, id openapi_types.UUID, reqEditors return c.Client.Do(req) } -func (c *Client) UpdateQueryWithBody(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { +func (c *Client) UpdateQueryWithBody(ctx context.Context, id QueryID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewUpdateQueryRequestWithBody(c.Server, id, contentType, body) if err != nil { return nil, err @@ -635,7 +683,7 @@ func (c *Client) UpdateQueryWithBody(ctx context.Context, id openapi_types.UUID, return c.Client.Do(req) } -func (c *Client) UpdateQuery(ctx context.Context, id openapi_types.UUID, body UpdateQueryJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { +func (c *Client) UpdateQuery(ctx context.Context, id QueryID, body UpdateQueryJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewUpdateQueryRequest(c.Server, id, body) if err != nil { return nil, err @@ -647,7 +695,7 @@ func (c *Client) UpdateQuery(ctx context.Context, id openapi_types.UUID, body Up return c.Client.Do(req) } -func (c *Client) TestQueryWithBody(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { +func (c *Client) TestQueryWithBody(ctx context.Context, id QueryID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewTestQueryRequestWithBody(c.Server, id, contentType, body) if err != nil { return nil, err @@ -659,7 +707,7 @@ func (c *Client) TestQueryWithBody(ctx context.Context, id openapi_types.UUID, c return c.Client.Do(req) } -func (c *Client) TestQuery(ctx context.Context, id openapi_types.UUID, body TestQueryJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { +func (c *Client) TestQuery(ctx context.Context, id QueryID, body TestQueryJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewTestQueryRequest(c.Server, id, body) if err != nil { return nil, err @@ -712,7 +760,7 @@ func NewCreateClientRequestWithBody(server string, contentType string, body io.R } // NewGetClientRequest generates requests for GetClient -func NewGetClientRequest(server string, id openapi_types.UUID) (*http.Request, error) { +func NewGetClientRequest(server string, id ClientID) (*http.Request, error) { var err error var pathParam0 string @@ -746,7 +794,7 @@ func NewGetClientRequest(server string, id openapi_types.UUID) (*http.Request, e } // NewUpdateClientRequest calls the generic UpdateClient builder with application/json body -func NewUpdateClientRequest(server string, id openapi_types.UUID, body UpdateClientJSONRequestBody) (*http.Request, error) { +func NewUpdateClientRequest(server string, id ClientID, body UpdateClientJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader buf, err := json.Marshal(body) if err != nil { @@ -757,7 +805,7 @@ func NewUpdateClientRequest(server string, id openapi_types.UUID, body UpdateCli } // NewUpdateClientRequestWithBody generates requests for UpdateClient with any type of body -func NewUpdateClientRequestWithBody(server string, id openapi_types.UUID, contentType string, body io.Reader) (*http.Request, error) { +func NewUpdateClientRequestWithBody(server string, id ClientID, contentType string, body io.Reader) (*http.Request, error) { var err error var pathParam0 string @@ -793,7 +841,7 @@ func NewUpdateClientRequestWithBody(server string, id openapi_types.UUID, conten } // NewGetCollectorByClientIdRequest generates requests for GetCollectorByClientId -func NewGetCollectorByClientIdRequest(server string, id openapi_types.UUID) (*http.Request, error) { +func NewGetCollectorByClientIdRequest(server string, id ClientID) (*http.Request, error) { var err error var pathParam0 string @@ -827,7 +875,7 @@ func NewGetCollectorByClientIdRequest(server string, id openapi_types.UUID) (*ht } // NewSetCollectorByClientIdRequest calls the generic SetCollectorByClientId builder with application/json body -func NewSetCollectorByClientIdRequest(server string, id openapi_types.UUID, body SetCollectorByClientIdJSONRequestBody) (*http.Request, error) { +func NewSetCollectorByClientIdRequest(server string, id ClientID, body SetCollectorByClientIdJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader buf, err := json.Marshal(body) if err != nil { @@ -838,7 +886,7 @@ func NewSetCollectorByClientIdRequest(server string, id openapi_types.UUID, body } // NewSetCollectorByClientIdRequestWithBody generates requests for SetCollectorByClientId with any type of body -func NewSetCollectorByClientIdRequestWithBody(server string, id openapi_types.UUID, contentType string, body io.Reader) (*http.Request, error) { +func NewSetCollectorByClientIdRequestWithBody(server string, id ClientID, contentType string, body io.Reader) (*http.Request, error) { var err error var pathParam0 string @@ -874,7 +922,7 @@ func NewSetCollectorByClientIdRequestWithBody(server string, id openapi_types.UU } // NewListDocumentsByClientIdRequest generates requests for ListDocumentsByClientId -func NewListDocumentsByClientIdRequest(server string, id openapi_types.UUID) (*http.Request, error) { +func NewListDocumentsByClientIdRequest(server string, id ClientID) (*http.Request, error) { var err error var pathParam0 string @@ -907,42 +955,8 @@ func NewListDocumentsByClientIdRequest(server string, id openapi_types.UUID) (*h return req, nil } -// NewExportStateRequest generates requests for ExportState -func NewExportStateRequest(server string, id openapi_types.UUID) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/client/%s/export", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - return req, nil -} - // NewTriggerExportRequest calls the generic TriggerExport builder with application/json body -func NewTriggerExportRequest(server string, id openapi_types.UUID, body TriggerExportJSONRequestBody) (*http.Request, error) { +func NewTriggerExportRequest(server string, id ClientID, body TriggerExportJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader buf, err := json.Marshal(body) if err != nil { @@ -953,7 +967,7 @@ func NewTriggerExportRequest(server string, id openapi_types.UUID, body TriggerE } // NewTriggerExportRequestWithBody generates requests for TriggerExport with any type of body -func NewTriggerExportRequestWithBody(server string, id openapi_types.UUID, contentType string, body io.Reader) (*http.Request, error) { +func NewTriggerExportRequestWithBody(server string, id ClientID, contentType string, body io.Reader) (*http.Request, error) { var err error var pathParam0 string @@ -989,7 +1003,7 @@ func NewTriggerExportRequestWithBody(server string, id openapi_types.UUID, conte } // NewGetStatusByClientIdRequest generates requests for GetStatusByClientId -func NewGetStatusByClientIdRequest(server string, id openapi_types.UUID) (*http.Request, error) { +func NewGetStatusByClientIdRequest(server string, id ClientID) (*http.Request, error) { var err error var pathParam0 string @@ -1022,6 +1036,40 @@ func NewGetStatusByClientIdRequest(server string, id openapi_types.UUID) (*http. return req, nil } +// NewExportStateRequest generates requests for ExportState +func NewExportStateRequest(server string, id ExportID) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/export/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + // NewListQueriesRequest generates requests for ListQueries func NewListQueriesRequest(server string) (*http.Request, error) { var err error @@ -1090,7 +1138,7 @@ func NewCreateQueryRequestWithBody(server string, contentType string, body io.Re } // NewGetQueryRequest generates requests for GetQuery -func NewGetQueryRequest(server string, id openapi_types.UUID) (*http.Request, error) { +func NewGetQueryRequest(server string, id QueryID) (*http.Request, error) { var err error var pathParam0 string @@ -1124,7 +1172,7 @@ func NewGetQueryRequest(server string, id openapi_types.UUID) (*http.Request, er } // NewUpdateQueryRequest calls the generic UpdateQuery builder with application/json body -func NewUpdateQueryRequest(server string, id openapi_types.UUID, body UpdateQueryJSONRequestBody) (*http.Request, error) { +func NewUpdateQueryRequest(server string, id QueryID, body UpdateQueryJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader buf, err := json.Marshal(body) if err != nil { @@ -1135,7 +1183,7 @@ func NewUpdateQueryRequest(server string, id openapi_types.UUID, body UpdateQuer } // NewUpdateQueryRequestWithBody generates requests for UpdateQuery with any type of body -func NewUpdateQueryRequestWithBody(server string, id openapi_types.UUID, contentType string, body io.Reader) (*http.Request, error) { +func NewUpdateQueryRequestWithBody(server string, id QueryID, contentType string, body io.Reader) (*http.Request, error) { var err error var pathParam0 string @@ -1171,7 +1219,7 @@ func NewUpdateQueryRequestWithBody(server string, id openapi_types.UUID, content } // NewTestQueryRequest calls the generic TestQuery builder with application/json body -func NewTestQueryRequest(server string, id openapi_types.UUID, body TestQueryJSONRequestBody) (*http.Request, error) { +func NewTestQueryRequest(server string, id QueryID, body TestQueryJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader buf, err := json.Marshal(body) if err != nil { @@ -1182,7 +1230,7 @@ func NewTestQueryRequest(server string, id openapi_types.UUID, body TestQueryJSO } // NewTestQueryRequestWithBody generates requests for TestQuery with any type of body -func NewTestQueryRequestWithBody(server string, id openapi_types.UUID, contentType string, body io.Reader) (*http.Request, error) { +func NewTestQueryRequestWithBody(server string, id QueryID, contentType string, body io.Reader) (*http.Request, error) { var err error var pathParam0 string @@ -1266,34 +1314,34 @@ type ClientWithResponsesInterface interface { CreateClientWithResponse(ctx context.Context, body CreateClientJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateClientResponse, error) // GetClientWithResponse request - GetClientWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetClientResponse, error) + GetClientWithResponse(ctx context.Context, id ClientID, reqEditors ...RequestEditorFn) (*GetClientResponse, error) // UpdateClientWithBodyWithResponse request with any body - UpdateClientWithBodyWithResponse(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateClientResponse, error) + UpdateClientWithBodyWithResponse(ctx context.Context, id ClientID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateClientResponse, error) - UpdateClientWithResponse(ctx context.Context, id openapi_types.UUID, body UpdateClientJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateClientResponse, error) + UpdateClientWithResponse(ctx context.Context, id ClientID, body UpdateClientJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateClientResponse, error) // GetCollectorByClientIdWithResponse request - GetCollectorByClientIdWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetCollectorByClientIdResponse, error) + GetCollectorByClientIdWithResponse(ctx context.Context, id ClientID, reqEditors ...RequestEditorFn) (*GetCollectorByClientIdResponse, error) // SetCollectorByClientIdWithBodyWithResponse request with any body - SetCollectorByClientIdWithBodyWithResponse(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetCollectorByClientIdResponse, error) + SetCollectorByClientIdWithBodyWithResponse(ctx context.Context, id ClientID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetCollectorByClientIdResponse, error) - SetCollectorByClientIdWithResponse(ctx context.Context, id openapi_types.UUID, body SetCollectorByClientIdJSONRequestBody, reqEditors ...RequestEditorFn) (*SetCollectorByClientIdResponse, error) + SetCollectorByClientIdWithResponse(ctx context.Context, id ClientID, body SetCollectorByClientIdJSONRequestBody, reqEditors ...RequestEditorFn) (*SetCollectorByClientIdResponse, error) // ListDocumentsByClientIdWithResponse request - ListDocumentsByClientIdWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*ListDocumentsByClientIdResponse, error) - - // ExportStateWithResponse request - ExportStateWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*ExportStateResponse, error) + ListDocumentsByClientIdWithResponse(ctx context.Context, id ClientID, reqEditors ...RequestEditorFn) (*ListDocumentsByClientIdResponse, error) // TriggerExportWithBodyWithResponse request with any body - TriggerExportWithBodyWithResponse(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TriggerExportResponse, error) + TriggerExportWithBodyWithResponse(ctx context.Context, id ClientID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TriggerExportResponse, error) - TriggerExportWithResponse(ctx context.Context, id openapi_types.UUID, body TriggerExportJSONRequestBody, reqEditors ...RequestEditorFn) (*TriggerExportResponse, error) + TriggerExportWithResponse(ctx context.Context, id ClientID, body TriggerExportJSONRequestBody, reqEditors ...RequestEditorFn) (*TriggerExportResponse, error) // GetStatusByClientIdWithResponse request - GetStatusByClientIdWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetStatusByClientIdResponse, error) + GetStatusByClientIdWithResponse(ctx context.Context, id ClientID, reqEditors ...RequestEditorFn) (*GetStatusByClientIdResponse, error) + + // ExportStateWithResponse request + ExportStateWithResponse(ctx context.Context, id ExportID, reqEditors ...RequestEditorFn) (*ExportStateResponse, error) // ListQueriesWithResponse request ListQueriesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListQueriesResponse, error) @@ -1304,23 +1352,23 @@ type ClientWithResponsesInterface interface { CreateQueryWithResponse(ctx context.Context, body CreateQueryJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateQueryResponse, error) // GetQueryWithResponse request - GetQueryWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetQueryResponse, error) + GetQueryWithResponse(ctx context.Context, id QueryID, reqEditors ...RequestEditorFn) (*GetQueryResponse, error) // UpdateQueryWithBodyWithResponse request with any body - UpdateQueryWithBodyWithResponse(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateQueryResponse, error) + UpdateQueryWithBodyWithResponse(ctx context.Context, id QueryID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateQueryResponse, error) - UpdateQueryWithResponse(ctx context.Context, id openapi_types.UUID, body UpdateQueryJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateQueryResponse, error) + UpdateQueryWithResponse(ctx context.Context, id QueryID, body UpdateQueryJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateQueryResponse, error) // TestQueryWithBodyWithResponse request with any body - TestQueryWithBodyWithResponse(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TestQueryResponse, error) + TestQueryWithBodyWithResponse(ctx context.Context, id QueryID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TestQueryResponse, error) - TestQueryWithResponse(ctx context.Context, id openapi_types.UUID, body TestQueryJSONRequestBody, reqEditors ...RequestEditorFn) (*TestQueryResponse, error) + TestQueryWithResponse(ctx context.Context, id QueryID, body TestQueryJSONRequestBody, reqEditors ...RequestEditorFn) (*TestQueryResponse, error) } type CreateClientResponse struct { Body []byte HTTPResponse *http.Response - JSON201 *IdMessage + JSON201 *ClientIDBody } // Status returns HTTPResponse.Status @@ -1447,28 +1495,6 @@ func (r ListDocumentsByClientIdResponse) StatusCode() int { return 0 } -type ExportStateResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *ExportDetails -} - -// Status returns HTTPResponse.Status -func (r ExportStateResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r ExportStateResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - type TriggerExportResponse struct { Body []byte HTTPResponse *http.Response @@ -1513,6 +1539,28 @@ func (r GetStatusByClientIdResponse) StatusCode() int { return 0 } +type ExportStateResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ExportDetails +} + +// Status returns HTTPResponse.Status +func (r ExportStateResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ExportStateResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type ListQueriesResponse struct { Body []byte HTTPResponse *http.Response @@ -1640,7 +1688,7 @@ func (c *ClientWithResponses) CreateClientWithResponse(ctx context.Context, body } // GetClientWithResponse request returning *GetClientResponse -func (c *ClientWithResponses) GetClientWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetClientResponse, error) { +func (c *ClientWithResponses) GetClientWithResponse(ctx context.Context, id ClientID, reqEditors ...RequestEditorFn) (*GetClientResponse, error) { rsp, err := c.GetClient(ctx, id, reqEditors...) if err != nil { return nil, err @@ -1649,7 +1697,7 @@ func (c *ClientWithResponses) GetClientWithResponse(ctx context.Context, id open } // UpdateClientWithBodyWithResponse request with arbitrary body returning *UpdateClientResponse -func (c *ClientWithResponses) UpdateClientWithBodyWithResponse(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateClientResponse, error) { +func (c *ClientWithResponses) UpdateClientWithBodyWithResponse(ctx context.Context, id ClientID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateClientResponse, error) { rsp, err := c.UpdateClientWithBody(ctx, id, contentType, body, reqEditors...) if err != nil { return nil, err @@ -1657,7 +1705,7 @@ func (c *ClientWithResponses) UpdateClientWithBodyWithResponse(ctx context.Conte return ParseUpdateClientResponse(rsp) } -func (c *ClientWithResponses) UpdateClientWithResponse(ctx context.Context, id openapi_types.UUID, body UpdateClientJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateClientResponse, error) { +func (c *ClientWithResponses) UpdateClientWithResponse(ctx context.Context, id ClientID, body UpdateClientJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateClientResponse, error) { rsp, err := c.UpdateClient(ctx, id, body, reqEditors...) if err != nil { return nil, err @@ -1666,7 +1714,7 @@ func (c *ClientWithResponses) UpdateClientWithResponse(ctx context.Context, id o } // GetCollectorByClientIdWithResponse request returning *GetCollectorByClientIdResponse -func (c *ClientWithResponses) GetCollectorByClientIdWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetCollectorByClientIdResponse, error) { +func (c *ClientWithResponses) GetCollectorByClientIdWithResponse(ctx context.Context, id ClientID, reqEditors ...RequestEditorFn) (*GetCollectorByClientIdResponse, error) { rsp, err := c.GetCollectorByClientId(ctx, id, reqEditors...) if err != nil { return nil, err @@ -1675,7 +1723,7 @@ func (c *ClientWithResponses) GetCollectorByClientIdWithResponse(ctx context.Con } // SetCollectorByClientIdWithBodyWithResponse request with arbitrary body returning *SetCollectorByClientIdResponse -func (c *ClientWithResponses) SetCollectorByClientIdWithBodyWithResponse(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetCollectorByClientIdResponse, error) { +func (c *ClientWithResponses) SetCollectorByClientIdWithBodyWithResponse(ctx context.Context, id ClientID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetCollectorByClientIdResponse, error) { rsp, err := c.SetCollectorByClientIdWithBody(ctx, id, contentType, body, reqEditors...) if err != nil { return nil, err @@ -1683,7 +1731,7 @@ func (c *ClientWithResponses) SetCollectorByClientIdWithBodyWithResponse(ctx con return ParseSetCollectorByClientIdResponse(rsp) } -func (c *ClientWithResponses) SetCollectorByClientIdWithResponse(ctx context.Context, id openapi_types.UUID, body SetCollectorByClientIdJSONRequestBody, reqEditors ...RequestEditorFn) (*SetCollectorByClientIdResponse, error) { +func (c *ClientWithResponses) SetCollectorByClientIdWithResponse(ctx context.Context, id ClientID, body SetCollectorByClientIdJSONRequestBody, reqEditors ...RequestEditorFn) (*SetCollectorByClientIdResponse, error) { rsp, err := c.SetCollectorByClientId(ctx, id, body, reqEditors...) if err != nil { return nil, err @@ -1692,7 +1740,7 @@ func (c *ClientWithResponses) SetCollectorByClientIdWithResponse(ctx context.Con } // ListDocumentsByClientIdWithResponse request returning *ListDocumentsByClientIdResponse -func (c *ClientWithResponses) ListDocumentsByClientIdWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*ListDocumentsByClientIdResponse, error) { +func (c *ClientWithResponses) ListDocumentsByClientIdWithResponse(ctx context.Context, id ClientID, reqEditors ...RequestEditorFn) (*ListDocumentsByClientIdResponse, error) { rsp, err := c.ListDocumentsByClientId(ctx, id, reqEditors...) if err != nil { return nil, err @@ -1700,17 +1748,8 @@ func (c *ClientWithResponses) ListDocumentsByClientIdWithResponse(ctx context.Co return ParseListDocumentsByClientIdResponse(rsp) } -// ExportStateWithResponse request returning *ExportStateResponse -func (c *ClientWithResponses) ExportStateWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*ExportStateResponse, error) { - rsp, err := c.ExportState(ctx, id, reqEditors...) - if err != nil { - return nil, err - } - return ParseExportStateResponse(rsp) -} - // TriggerExportWithBodyWithResponse request with arbitrary body returning *TriggerExportResponse -func (c *ClientWithResponses) TriggerExportWithBodyWithResponse(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TriggerExportResponse, error) { +func (c *ClientWithResponses) TriggerExportWithBodyWithResponse(ctx context.Context, id ClientID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TriggerExportResponse, error) { rsp, err := c.TriggerExportWithBody(ctx, id, contentType, body, reqEditors...) if err != nil { return nil, err @@ -1718,7 +1757,7 @@ func (c *ClientWithResponses) TriggerExportWithBodyWithResponse(ctx context.Cont return ParseTriggerExportResponse(rsp) } -func (c *ClientWithResponses) TriggerExportWithResponse(ctx context.Context, id openapi_types.UUID, body TriggerExportJSONRequestBody, reqEditors ...RequestEditorFn) (*TriggerExportResponse, error) { +func (c *ClientWithResponses) TriggerExportWithResponse(ctx context.Context, id ClientID, body TriggerExportJSONRequestBody, reqEditors ...RequestEditorFn) (*TriggerExportResponse, error) { rsp, err := c.TriggerExport(ctx, id, body, reqEditors...) if err != nil { return nil, err @@ -1727,7 +1766,7 @@ func (c *ClientWithResponses) TriggerExportWithResponse(ctx context.Context, id } // GetStatusByClientIdWithResponse request returning *GetStatusByClientIdResponse -func (c *ClientWithResponses) GetStatusByClientIdWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetStatusByClientIdResponse, error) { +func (c *ClientWithResponses) GetStatusByClientIdWithResponse(ctx context.Context, id ClientID, reqEditors ...RequestEditorFn) (*GetStatusByClientIdResponse, error) { rsp, err := c.GetStatusByClientId(ctx, id, reqEditors...) if err != nil { return nil, err @@ -1735,6 +1774,15 @@ func (c *ClientWithResponses) GetStatusByClientIdWithResponse(ctx context.Contex return ParseGetStatusByClientIdResponse(rsp) } +// ExportStateWithResponse request returning *ExportStateResponse +func (c *ClientWithResponses) ExportStateWithResponse(ctx context.Context, id ExportID, reqEditors ...RequestEditorFn) (*ExportStateResponse, error) { + rsp, err := c.ExportState(ctx, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseExportStateResponse(rsp) +} + // ListQueriesWithResponse request returning *ListQueriesResponse func (c *ClientWithResponses) ListQueriesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListQueriesResponse, error) { rsp, err := c.ListQueries(ctx, reqEditors...) @@ -1762,7 +1810,7 @@ func (c *ClientWithResponses) CreateQueryWithResponse(ctx context.Context, body } // GetQueryWithResponse request returning *GetQueryResponse -func (c *ClientWithResponses) GetQueryWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetQueryResponse, error) { +func (c *ClientWithResponses) GetQueryWithResponse(ctx context.Context, id QueryID, reqEditors ...RequestEditorFn) (*GetQueryResponse, error) { rsp, err := c.GetQuery(ctx, id, reqEditors...) if err != nil { return nil, err @@ -1771,7 +1819,7 @@ func (c *ClientWithResponses) GetQueryWithResponse(ctx context.Context, id opena } // UpdateQueryWithBodyWithResponse request with arbitrary body returning *UpdateQueryResponse -func (c *ClientWithResponses) UpdateQueryWithBodyWithResponse(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateQueryResponse, error) { +func (c *ClientWithResponses) UpdateQueryWithBodyWithResponse(ctx context.Context, id QueryID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateQueryResponse, error) { rsp, err := c.UpdateQueryWithBody(ctx, id, contentType, body, reqEditors...) if err != nil { return nil, err @@ -1779,7 +1827,7 @@ func (c *ClientWithResponses) UpdateQueryWithBodyWithResponse(ctx context.Contex return ParseUpdateQueryResponse(rsp) } -func (c *ClientWithResponses) UpdateQueryWithResponse(ctx context.Context, id openapi_types.UUID, body UpdateQueryJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateQueryResponse, error) { +func (c *ClientWithResponses) UpdateQueryWithResponse(ctx context.Context, id QueryID, body UpdateQueryJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateQueryResponse, error) { rsp, err := c.UpdateQuery(ctx, id, body, reqEditors...) if err != nil { return nil, err @@ -1788,7 +1836,7 @@ func (c *ClientWithResponses) UpdateQueryWithResponse(ctx context.Context, id op } // TestQueryWithBodyWithResponse request with arbitrary body returning *TestQueryResponse -func (c *ClientWithResponses) TestQueryWithBodyWithResponse(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TestQueryResponse, error) { +func (c *ClientWithResponses) TestQueryWithBodyWithResponse(ctx context.Context, id QueryID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TestQueryResponse, error) { rsp, err := c.TestQueryWithBody(ctx, id, contentType, body, reqEditors...) if err != nil { return nil, err @@ -1796,7 +1844,7 @@ func (c *ClientWithResponses) TestQueryWithBodyWithResponse(ctx context.Context, return ParseTestQueryResponse(rsp) } -func (c *ClientWithResponses) TestQueryWithResponse(ctx context.Context, id openapi_types.UUID, body TestQueryJSONRequestBody, reqEditors ...RequestEditorFn) (*TestQueryResponse, error) { +func (c *ClientWithResponses) TestQueryWithResponse(ctx context.Context, id QueryID, body TestQueryJSONRequestBody, reqEditors ...RequestEditorFn) (*TestQueryResponse, error) { rsp, err := c.TestQuery(ctx, id, body, reqEditors...) if err != nil { return nil, err @@ -1819,7 +1867,7 @@ func ParseCreateClientResponse(rsp *http.Response) (*CreateClientResponse, error switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest IdMessage + var dest ClientIDBody if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -1940,32 +1988,6 @@ func ParseListDocumentsByClientIdResponse(rsp *http.Response) (*ListDocumentsByC return response, nil } -// ParseExportStateResponse parses an HTTP response from a ExportStateWithResponse call -func ParseExportStateResponse(rsp *http.Response) (*ExportStateResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &ExportStateResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest ExportDetails - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - } - - return response, nil -} - // ParseTriggerExportResponse parses an HTTP response from a TriggerExportWithResponse call func ParseTriggerExportResponse(rsp *http.Response) (*TriggerExportResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) @@ -2018,6 +2040,32 @@ func ParseGetStatusByClientIdResponse(rsp *http.Response) (*GetStatusByClientIdR return response, nil } +// ParseExportStateResponse parses an HTTP response from a ExportStateWithResponse call +func ParseExportStateResponse(rsp *http.Response) (*ExportStateResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ExportStateResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ExportDetails + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + // ParseListQueriesResponse parses an HTTP response from a ListQueriesWithResponse call func ParseListQueriesResponse(rsp *http.Response) (*ListQueriesResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) diff --git a/scripts/Taskfile.yml b/scripts/Taskfile.yml index c18d32fe..6c04fc60 100644 --- a/scripts/Taskfile.yml +++ b/scripts/Taskfile.yml @@ -26,22 +26,19 @@ includes: tasks: fullsuite: - cmds: - - task: build - - task: lint - - task: test:unit - - task: test:endtoend + - task: build + - task: lint + - task: test:unit + - task: test:endtoend precommit: - cmds: - - task: lint:short + - task: lint:short deps:tidy: - go mod tidy - go mod vendor build: - cmds: - - task: deps:tidy - - task: generate - - task: docker:build + - task: deps:tidy + - task: generate + - task: docker:build generate:clean: run: once deps: @@ -78,17 +75,10 @@ tasks: - json:lint - docker:lint - openapi:lint - - db:lint - compose:lint:short - go:lint: - cmds: - - golangci-lint run --fix {{.CLI_ARGS}} - yaml:lint: - cmds: - - yamllint . -s {{.CLI_ARGS}} - json:lint: - cmds: - - jsonlint devbox.json -q -s -i {{.CLI_ARGS}} + go:lint: golangci-lint run --fix {{.CLI_ARGS}} + yaml:lint: yamllint . -s {{.CLI_ARGS}} + json:lint: jsonlint devbox.json -q -s -i {{.CLI_ARGS}} docs:generate: run: once cmds: diff --git a/scripts/local-deployments.yml b/scripts/local-deployments.yml index bcc0fe8c..b7452e81 100644 --- a/scripts/local-deployments.yml +++ b/scripts/local-deployments.yml @@ -71,7 +71,7 @@ tasks: --notification-configuration '{ "QueueConfigurations": [{ "QueueArn": "arn:aws:sqs:us-east-1:000000000000:document_init", - "Events": ["s3:ObjectCreated:*"] + "Events": ["s3:ObjectCreated:Put"] }] }' down:test: diff --git a/scripts/openapi-scripts.yml b/scripts/openapi-scripts.yml index b7385373..12ee4992 100644 --- a/scripts/openapi-scripts.yml +++ b/scripts/openapi-scripts.yml @@ -6,7 +6,9 @@ version: "3" tasks: lint: cmds: - - vacuum lint ./serviceAPIs/queryService.yaml -b -d -e --no-clip + - | + vacuum lint ./serviceAPIs/queryService.yaml -b -d -e --no-clip \ + {{.CLI_ARGS}} generate: - | generateGo() { diff --git a/serviceAPIs/queryService.yaml b/serviceAPIs/queryService.yaml index f5d2693b..0529e269 100644 --- a/serviceAPIs/queryService.yaml +++ b/serviceAPIs/queryService.yaml @@ -28,6 +28,7 @@ paths: summary: Create a new client description: Creates a new client with the provided details. requestBody: + description: The details required to create a client required: true content: application/json: @@ -39,19 +40,13 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/IdMessage" + $ref: "#/components/schemas/ClientIDBody" "400": - description: Invalid request body. + $ref: "#/components/responses/InvalidRequest" /client/{id}: parameters: - - in: path - name: id - required: true - schema: - type: string - format: uuid - description: The ID of the client to retrieve. + - $ref: "#/components/parameters/ClientID" get: operationId: getClient tags: @@ -66,7 +61,7 @@ paths: schema: $ref: "#/components/schemas/DocClient" "400": - description: Invalid request parameters. + $ref: "#/components/responses/InvalidRequest" patch: operationId: updateClient tags: @@ -74,6 +69,7 @@ paths: summary: Update a client description: Updates an existing client with new details. requestBody: + description: The details to update required: true content: application/json: @@ -83,7 +79,7 @@ paths: "200": description: Client updated successfully. "400": - description: Invalid request body. + $ref: "#/components/responses/InvalidRequest" /query: get: @@ -100,7 +96,7 @@ paths: schema: $ref: "#/components/schemas/ListQueries" "400": - description: Invalid request parameters. + $ref: "#/components/responses/InvalidRequest" post: operationId: createQuery tags: @@ -108,6 +104,7 @@ paths: summary: Create a new query description: Creates a new query with the provided details. requestBody: + description: The details required to create a query required: true content: application/json: @@ -121,17 +118,11 @@ paths: schema: $ref: "#/components/schemas/IdMessage" "400": - description: Invalid request body. + $ref: "#/components/responses/InvalidRequest" /query/{id}: parameters: - - in: path - name: id - required: true - schema: - type: string - format: uuid - description: The ID of the query. + - $ref: "#/components/parameters/QueryID" get: operationId: getQuery tags: @@ -146,7 +137,7 @@ paths: schema: $ref: "#/components/schemas/Query" "400": - description: Invalid request parameters. + $ref: "#/components/responses/InvalidRequest" patch: operationId: updateQuery tags: @@ -154,6 +145,7 @@ paths: summary: Update a query description: Updates an existing query with new details. requestBody: + description: The update values for the desired query. required: true content: application/json: @@ -163,17 +155,11 @@ paths: "200": description: Query updated successfully. "400": - description: Invalid request body. + $ref: "#/components/responses/InvalidRequest" /query/{id}/test: parameters: - - in: path - name: id - required: true - schema: - type: string - format: uuid - description: The ID of the query. + - $ref: "#/components/parameters/QueryID" post: operationId: testQuery tags: @@ -181,6 +167,7 @@ paths: summary: Test a query description: Executes a test run of a query with the provided parameters. requestBody: + description: The query test requirements. required: true content: application/json: @@ -194,17 +181,11 @@ paths: schema: $ref: "#/components/schemas/QueryTestResponse" "400": - description: Invalid request body. + $ref: "#/components/responses/InvalidRequest" /client/{id}/status: parameters: - - in: path - name: id - required: true - schema: - type: string - format: uuid - description: The client id. + - $ref: "#/components/parameters/ClientID" get: operationId: getStatusByClientId tags: @@ -219,17 +200,11 @@ paths: schema: $ref: "#/components/schemas/ClientStatusBody" "400": - description: Invalid request parameters. + $ref: "#/components/responses/InvalidRequest" /client/{id}/collector: parameters: - - in: path - name: id - required: true - schema: - type: string - format: uuid - description: The client ID for the collector. + - $ref: "#/components/parameters/ClientID" get: operationId: getCollectorByClientId tags: @@ -244,7 +219,7 @@ paths: schema: $ref: "#/components/schemas/Collector" "400": - description: Invalid body. + $ref: "#/components/responses/InvalidRequest" patch: operationId: setCollectorByClientId tags: @@ -252,6 +227,7 @@ paths: summary: Set a collector description: Set client collector with new details. requestBody: + description: The details to be set for the collector. required: true content: application/json: @@ -261,17 +237,11 @@ paths: "204": description: Collector set successfully. "400": - description: Invalid request body. + $ref: "#/components/responses/InvalidRequest" /client/{id}/documents: parameters: - - in: path - name: id - required: true - schema: - type: string - format: uuid - description: The client ID for the documents. + - $ref: "#/components/parameters/ClientID" get: operationId: listDocumentsByClientId tags: @@ -286,17 +256,37 @@ paths: schema: $ref: "#/components/schemas/ListDocuments" "400": - description: Invalid request body. + $ref: "#/components/responses/InvalidRequest" /client/{id}/export: parameters: - - in: path - name: id + - $ref: "#/components/parameters/ClientID" + post: + operationId: triggerExport + tags: + - ExportService + summary: Trigger an export + description: Initiates the export process. + requestBody: + description: The export requirements. required: true - schema: - type: string - format: uuid - description: The ID of the export. + content: + application/json: + schema: + $ref: "#/components/schemas/ExportTrigger" + responses: + "201": + description: Export triggered successfully. + content: + application/json: + schema: + $ref: "#/components/schemas/IdMessage" + "400": + $ref: "#/components/responses/InvalidRequest" + + /export/{id}: + parameters: + - $ref: "#/components/parameters/ExportID" get: operationId: exportState tags: @@ -311,31 +301,77 @@ paths: schema: $ref: "#/components/schemas/ExportDetails" "400": - description: Invalid body. - post: - operationId: triggerExport - tags: - - ExportService - summary: Trigger an export - description: Initiates the export process. - requestBody: - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/ExportTrigger" - responses: - "201": - description: Export triggered successfully. - content: - application/json: - schema: - $ref: "#/components/schemas/IdMessage" - "400": - description: Invalid request body. + $ref: "#/components/responses/InvalidRequest" components: + parameters: + ClientID: + in: path + name: id + required: true + schema: + $ref: "#/components/schemas/ClientID" + description: The client ID. + + ExportID: + in: path + name: id + required: true + schema: + $ref: "#/components/schemas/ExportID" + description: The export ID. + + QueryID: + in: path + name: id + required: true + schema: + $ref: "#/components/schemas/QueryID" + description: The ID of the query. + + responses: + InvalidRequest: + description: Invalid request body. + schemas: + ClientID: + type: string + description: The client external id + example: AAA + + ClientUID: + type: string + format: uuid + description: The client internal unique id + example: 0195853c-8fdd-77cd-b36c-255241bddd33 + + QueryID: + type: string + format: uuid + description: The query id. + example: 019580df-ef65-7676-8de9-94435a93337a + + DocumentID: + type: string + format: uuid + description: The document id. + example: 019580df-b3f8-7348-9ab1-1e55b3f18ed7 + + ExportID: + type: string + format: uuid + description: The export id. + example: 019580de-4d51-713c-98ee-464e83811f13 + + ClientName: + type: string + description: The client name + example: AArete + + ClientCanSync: + type: boolean + description: If the client is allowing active syncs + QueryType: type: string enum: @@ -343,32 +379,26 @@ components: - CONTEXT_FULL description: Specifies the type of the query. + QueryConfig: + type: string + description: Configuration for the query. + Query: + description: A logic unit of execution. type: object properties: id: - type: string - format: uuid - description: Unique identifier for the query. + $ref: "#/components/schemas/QueryID" type: $ref: "#/components/schemas/QueryType" active_version: - type: integer - format: int32 - description: The active version of the query. + $ref: "#/components/schemas/Version" latest_version: - type: integer - format: int32 - description: The latest version of the query. + $ref: "#/components/schemas/Version" config: - type: string - description: Configuration for the query. + $ref: "#/components/schemas/QueryConfig" required_queries: - type: array - items: - type: string - format: uuid - description: List of required query IDs. + $ref: "#/components/schemas/RequiredQueryIDs" required: - id - type @@ -376,6 +406,7 @@ components: - latest_version ListQueries: + description: A set of queries. type: object properties: queries: @@ -387,55 +418,49 @@ components: - queries QueryCreate: + description: The parameters required to create a query. type: object properties: type: $ref: "#/components/schemas/QueryType" config: - type: string - description: Configuration for the new query. + $ref: "#/components/schemas/QueryConfig" required_queries: - type: array - items: - type: string - format: uuid - description: List of required query IDs. + $ref: "#/components/schemas/RequiredQueryIDs" required: - type + RequiredQueryIDs: + type: array + items: + $ref: "#/components/schemas/QueryID" + description: List of required query IDs. + QueryUpdate: + description: The properties that may be updated for a query. type: object properties: config: - type: string - description: Updated configuration for the query. + $ref: "#/components/schemas/QueryConfig" active_version: - type: integer - format: int32 - description: Updated active version. + $ref: "#/components/schemas/Version" required_queries: - type: array - items: - type: string - format: uuid - description: Updated list of required query IDs. + $ref: "#/components/schemas/RequiredQueryIDs" QueryTestRequest: + description: The properties for a query test request. type: object properties: document_id: - type: string - format: uuid - description: ID of the document to test against. + $ref: "#/components/schemas/DocumentID" query_version: - type: integer - format: int32 - description: Version of the query to use for testing. + $ref: "#/components/schemas/Version" required: - document_id - query_version QueryTestResponse: + description: The response from a query test. type: object properties: value: @@ -445,20 +470,20 @@ components: - value DocClient: + description: The properties of a client. type: object properties: + uid: + $ref: "#/components/schemas/ClientUID" id: - type: string - format: uuid - description: The client id + $ref: "#/components/schemas/ClientID" name: - type: string - description: The client name + $ref: "#/components/schemas/ClientName" can_sync: - type: boolean - description: If the client is allowing active syncs + $ref: "#/components/schemas/ClientCanSync" required: - id + - uid - name - can_sync @@ -471,18 +496,23 @@ components: description: Specifies the status of a client. ClientStatusBody: + description: A client status information object. type: object properties: - client_id: - type: string - format: uuid - description: The client id status: $ref: "#/components/schemas/ClientStatus" required: - - client_id - status + ClientIDBody: + description: The client id. + type: object + properties: + id: + $ref: "#/components/schemas/ClientID" + required: + - id + ListDocuments: type: array description: The documents in the client. @@ -490,12 +520,11 @@ components: $ref: "#/components/schemas/Document" Document: + description: The document properties. type: object properties: id: - type: string - format: uuid - description: The document id + $ref: "#/components/schemas/DocumentID" bucket: type: string description: The bucket containing the document @@ -508,25 +537,28 @@ components: - key ClientCreate: + description: The properties for creation. type: object properties: + id: + $ref: "#/components/schemas/ClientID" name: - type: string - description: The client name + $ref: "#/components/schemas/ClientName" required: + - id - name ClientUpdate: + description: The properties that may be updated. type: object properties: name: - type: string - description: The client name + $ref: "#/components/schemas/ClientName" can_sync: - type: boolean - description: If the client is allowing active syncs + $ref: "#/components/schemas/ClientCanSync" IdMessage: + description: A single uuid. type: object properties: id: @@ -536,34 +568,31 @@ components: required: - id + CodeVersion: + type: integer + format: int32 + description: The desired code version. + + Version: + type: integer + format: int32 + description: The desired version. + Collector: type: object properties: client_id: - type: string - format: uuid - description: The ID of the associated client. + $ref: "#/components/schemas/ClientID" active_version: - type: integer - format: int32 - description: The active version of the collector. + $ref: "#/components/schemas/Version" latest_version: - type: integer - format: int32 - description: The latest version of the collector. + $ref: "#/components/schemas/Version" minimum_cleaner_version: - type: integer - format: int32 - description: The minimum version for the document cleaner. + $ref: "#/components/schemas/CodeVersion" minimum_text_version: - type: integer - format: int32 - description: The minimum version for the text parser. + $ref: "#/components/schemas/CodeVersion" fields: - type: array - description: The fields in the collector. - items: - $ref: "#/components/schemas/CollectorField" + $ref: "#/components/schemas/CollectorFields" description: Collector model. required: - client_id @@ -573,39 +602,37 @@ components: - latest_version - active_version + CollectorFields: + type: array + description: The fields in the collector. + items: + $ref: "#/components/schemas/CollectorField" + CollectorSet: type: object properties: minimum_cleaner_version: - type: integer - format: int32 - description: The minimum version for the document cleaner. + $ref: "#/components/schemas/CodeVersion" minimum_text_version: - type: integer - format: int32 - description: The minimum version for the text parser. + $ref: "#/components/schemas/CodeVersion" active_version: - type: integer - format: int32 - description: The active version of the collector. + $ref: "#/components/schemas/Version" fields: - type: array - description: The fields in the collector. - items: - $ref: "#/components/schemas/CollectorField" + $ref: "#/components/schemas/CollectorFields" description: Payload for updating a Collector. + CollectorFieldName: + type: string + description: The output field name. + CollectorField: type: object description: The field properties for the collector. properties: name: - type: string - description: The output field name. + $ref: "#/components/schemas/CollectorFieldName" query_id: - type: string - format: uuid - description: The query id that will populate the result. + $ref: "#/components/schemas/QueryID" required: - name - query_id @@ -634,8 +661,7 @@ components: type: object properties: field_name: - type: string - description: The name of the field in question. + $ref: "#/components/schemas/CollectorFieldName" condition: $ref: "#/components/schemas/FieldFilterCondition" values: @@ -674,9 +700,7 @@ components: type: object properties: client_id: - type: string - format: uuid - description: The client id relative to the export. + $ref: "#/components/schemas/ClientID" status: $ref: "#/components/schemas/ExportStatus" output_location: diff --git a/test/process_test.go b/test/process_test.go index e2ff0eca..c91b3b82 100644 --- a/test/process_test.go +++ b/test/process_test.go @@ -3,20 +3,16 @@ package endtoend_test import ( "context" "fmt" - "os" - "path" "strings" "testing" "time" "queryorchestration/internal/serviceconfig" "queryorchestration/internal/serviceconfig/objectstore" - documentcleanc "queryorchestration/internal/serviceconfig/queue/documentclean" "queryorchestration/internal/test" + queryservicetest "queryorchestration/internal/test/queryService" queryservice "queryorchestration/pkg/queryService" - "github.com/aws/aws-sdk-go-v2/service/s3" - awstypes "github.com/aws/aws-sdk-go-v2/service/s3/types" "github.com/oapi-codegen/runtime/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -24,7 +20,6 @@ import ( type ProcessConfig struct { serviceconfig.BaseConfig - documentcleanc.DocCleanConfig objectstore.ObjectStoreConfig } @@ -32,150 +27,26 @@ func TestProcess(t *testing.T) { ctx := context.Background() cfg := &ProcessConfig{} - test.SetCfgProvider(t, cfg) - cfg.SetBasePath(path.Join(os.Getenv("PWD"), "..")) + test.SetCfgProviderWithBasePath(t, cfg, "..") - network, ncleanup := test.CreateNetwork(t, ctx) - defer ncleanup() - - acfg, clean := test.CreateAWSContainer(t, ctx, &test.CreateAWSConfig{ - Cfg: cfg, - Network: network, - }) + net, clean := test.CreateFullNetwork(t, ctx, cfg) defer clean() - err := cfg.SetQueueClient(ctx) - require.NoError(t, err) - test.CreateStoreClient(t, ctx, cfg, acfg.ExternalEndpoint) + client := queryservicetest.CreateClientWithSync(t, ctx, net.Client) - dociniturl := test.CreateQueue(t, ctx, cfg, test.DocInitRunner) - docsyncurl := test.CreateQueue(t, ctx, cfg, test.DocSyncRunner) - doccleanurl := test.CreateQueue(t, ctx, cfg, test.DocCleanRunner) - doctexturl := test.CreateQueue(t, ctx, cfg, test.DocTextRunner) - querysyncurl := test.CreateQueue(t, ctx, cfg, test.QuerySyncRunner) - queryurl := test.CreateQueue(t, ctx, cfg, test.QueryRunner) - clientsyncurl := test.CreateQueue(t, ctx, cfg, test.ClientSyncRunner) - queryversionsyncurl := test.CreateQueue(t, ctx, cfg, test.QueryVersionSyncRunner) - - bucketName := "docinitbucket" - test.CreateBucket(t, ctx, cfg, bucketName) - arn := fmt.Sprintf("arn:aws:sqs:%s:000000000000:%s", cfg.AWSRegion, test.DocInitRunner) - _, err = cfg.StoreClient.PutBucketNotificationConfiguration(ctx, &s3.PutBucketNotificationConfigurationInput{ - Bucket: &bucketName, - NotificationConfiguration: &awstypes.NotificationConfiguration{ - QueueConfigurations: []awstypes.QueueConfiguration{ - { - QueueArn: &arn, - Events: []awstypes.Event{ - awstypes.EventS3ObjectCreated, - }, - }, - }, - }, - }) - require.NoError(t, err) - - net, cleanup := test.CreateRunnersAndServicesNetwork(t, ctx, &test.EcosystemNetworkConfig{ - Cfg: cfg, - Network: network, - AWSContainer: acfg, - Runners: []*test.RunnerNetworkConfig{ - { - Name: test.DocInitRunner, - QueueURL: &dociniturl, - Env: map[string]string{ - "DOCUMENT_SYNC_URL": docsyncurl, - }, - }, - { - Name: test.DocSyncRunner, - QueueURL: &docsyncurl, - Env: map[string]string{ - "DOCUMENT_CLEAN_URL": doccleanurl, - }, - }, - { - Name: test.DocCleanRunner, - QueueURL: &doccleanurl, - Env: map[string]string{ - "DOCUMENT_TEXT_URL": doctexturl, - }, - }, - { - Name: test.DocTextRunner, - QueueURL: &doctexturl, - Env: map[string]string{ - "QUERY_SYNC_URL": querysyncurl, - }, - }, - { - Name: test.QuerySyncRunner, - QueueURL: &querysyncurl, - Env: map[string]string{ - "QUERY_URL": queryurl, - }, - }, - { - Name: test.QueryRunner, - QueueURL: &queryurl, - Env: map[string]string{ - "QUERY_URL": queryurl, - }, - }, - { - Name: test.ClientSyncRunner, - QueueURL: &clientsyncurl, - Env: map[string]string{ - "DOCUMENT_SYNC_URL": docsyncurl, - }, - }, - { - Name: test.QueryVersionSyncRunner, - QueueURL: &queryversionsyncurl, - Env: map[string]string{ - "CLIENT_SYNC_URL": clientsyncurl, - }, - }, - }, - Services: []*test.ServiceNetworkConfig{ - { - Name: test.QueryService, - Env: map[string]string{ - "CLIENT_SYNC_URL": clientsyncurl, - "QUERY_VERSION_SYNC_URL": queryversionsyncurl, - }, - }, - }, - }) - defer cleanup() - - qService, err := queryservice.NewClientWithResponses(net.Services[test.QueryService].URI) - require.NoError(t, err) - - clientRes, err := qService.CreateClientWithResponse(ctx, queryservice.ClientCreate{ - Name: "example_name", - }) - assert.NoError(t, err) - - canSync := true - _, err = qService.UpdateClientWithResponse(ctx, clientRes.JSON201.Id, queryservice.ClientUpdate{ - CanSync: &canSync, - }) - assert.NoError(t, err) - - contextQueryRes, err := qService.CreateQueryWithResponse(ctx, queryservice.QueryCreate{ + contextQueryRes, err := net.Client.CreateQueryWithResponse(ctx, queryservice.QueryCreate{ Type: queryservice.CONTEXTFULL, }) - assert.NoError(t, err) + require.NoError(t, err) jcfg := `{"path":"keyone"}` - jsonQueryRes, err := qService.CreateQueryWithResponse(ctx, queryservice.QueryCreate{ + jsonQueryRes, err := net.Client.CreateQueryWithResponse(ctx, queryservice.QueryCreate{ Type: queryservice.JSONEXTRACTOR, Config: &jcfg, RequiredQueries: &[]types.UUID{contextQueryRes.JSON201.Id}, }) - assert.NoError(t, err) + require.NoError(t, err) newActiveVersion := int32(1) - _, err = qService.SetCollectorByClientIdWithResponse(ctx, clientRes.JSON201.Id, queryservice.CollectorSet{ + _, err = net.Client.SetCollectorByClientIdWithResponse(ctx, client.Id, queryservice.CollectorSet{ ActiveVersion: &newActiveVersion, Fields: &[]queryservice.CollectorField{ { @@ -184,30 +55,24 @@ func TestProcess(t *testing.T) { }, }, }) - assert.NoError(t, err) + require.NoError(t, err) - WaitForClientStatus(t, ctx, qService, clientRes.JSON201.Id, queryservice.INSYNC) + WaitForClientStatus(t, ctx, net.Client, client.Id, queryservice.INSYNC) - location := fmt.Sprintf("%s/%s", clientRes.JSON201.Id, "object_name") body := strings.NewReader(pdfHelloWorld) - _, err = cfg.StoreClient.PutObject(ctx, &s3.PutObjectInput{ - Bucket: &bucketName, - Key: &location, - Body: body, - }) - assert.NoError(t, err) + location := test.PutObject(t, ctx, cfg, client.Uid, net.Dependencies.BucketName, "object_name", body) - WaitForClientStatus(t, ctx, qService, clientRes.JSON201.Id, queryservice.NOTSYNCED) - WaitForClientStatus(t, ctx, qService, clientRes.JSON201.Id, queryservice.INSYNC) + WaitForClientStatus(t, ctx, net.Client, client.Id, queryservice.NOTSYNCED) + WaitForClientStatus(t, ctx, net.Client, client.Id, queryservice.INSYNC) - docs, err := qService.ListDocumentsByClientIdWithResponse(ctx, clientRes.JSON201.Id) + docs, err := net.Client.ListDocumentsByClientIdWithResponse(ctx, client.Id) assert.NoError(t, err) assert.Len(t, *docs.JSON200, 1) doc := (*docs.JSON200)[0] - assert.Equal(t, bucketName, doc.Bucket) + assert.Equal(t, net.Dependencies.BucketName, doc.Bucket) assert.Equal(t, location, doc.Key) - testRes, err := qService.TestQueryWithResponse(ctx, jsonQueryRes.JSON201.Id, queryservice.QueryTestRequest{ + testRes, err := net.Client.TestQueryWithResponse(ctx, jsonQueryRes.JSON201.Id, queryservice.QueryTestRequest{ QueryVersion: 1, DocumentId: doc.Id, }) @@ -216,17 +81,17 @@ func TestProcess(t *testing.T) { aV := int32(2) jcfg = `{"path":"keytwo"}` - res, err := qService.UpdateQueryWithResponse(ctx, jsonQueryRes.JSON201.Id, queryservice.QueryUpdate{ + res, err := net.Client.UpdateQueryWithResponse(ctx, jsonQueryRes.JSON201.Id, queryservice.QueryUpdate{ ActiveVersion: &aV, Config: &jcfg, }) assert.NoError(t, err) assert.NotNil(t, res) - WaitForClientStatus(t, ctx, qService, clientRes.JSON201.Id, queryservice.NOTSYNCED) - WaitForClientStatus(t, ctx, qService, clientRes.JSON201.Id, queryservice.INSYNC) + WaitForClientStatus(t, ctx, net.Client, client.Id, queryservice.NOTSYNCED) + WaitForClientStatus(t, ctx, net.Client, client.Id, queryservice.INSYNC) - testRes, err = qService.TestQueryWithResponse(ctx, jsonQueryRes.JSON201.Id, queryservice.QueryTestRequest{ + testRes, err = net.Client.TestQueryWithResponse(ctx, jsonQueryRes.JSON201.Id, queryservice.QueryTestRequest{ QueryVersion: 2, DocumentId: doc.Id, }) @@ -234,7 +99,7 @@ func TestProcess(t *testing.T) { assert.Equal(t, "valuetwo", testRes.JSON200.Value) } -func WaitForClientStatus(t testing.TB, ctx context.Context, service *queryservice.ClientWithResponses, id types.UUID, status queryservice.ClientStatus) { +func WaitForClientStatus(t testing.TB, ctx context.Context, service *queryservice.ClientWithResponses, id string, status queryservice.ClientStatus) { t.Helper() timeout := time.After(30 * time.Second) diff --git a/test/queryService/client_test.go b/test/queryService/client_test.go index 7c51bb05..e6d37f81 100644 --- a/test/queryService/client_test.go +++ b/test/queryService/client_test.go @@ -27,6 +27,7 @@ func TestClient(t *testing.T) { idRes, err := client.CreateClientWithResponse(ctx, queryservice.ClientCreate{ Name: "example_name", + Id: "EXA", }) assert.NoError(t, err) assert.NotNil(t, idRes) diff --git a/test/queryService/collectorservice_test.go b/test/queryService/collectorservice_test.go index f664d433..96d49e41 100644 --- a/test/queryService/collectorservice_test.go +++ b/test/queryService/collectorservice_test.go @@ -73,6 +73,7 @@ func TestCollectorService(t *testing.T) { clientRes, err := client.CreateClientWithResponse(ctx, queryservice.ClientCreate{ Name: "example_name", + Id: "ID", }) assert.NoError(t, err) id := clientRes.JSON201.Id diff --git a/test/queryService/exportservice_test.go b/test/queryService/exportservice_test.go index a4b45a65..a425cb57 100644 --- a/test/queryService/exportservice_test.go +++ b/test/queryService/exportservice_test.go @@ -7,7 +7,6 @@ import ( "queryorchestration/internal/test" queryservice "queryorchestration/pkg/queryService" - "github.com/google/uuid" "github.com/stretchr/testify/assert" ) @@ -26,9 +25,7 @@ func TestExportService(t *testing.T) { client, err := queryservice.NewClientWithResponses(c.URI) assert.NoError(t, err) - id := uuid.New() - - idRes, err := client.TriggerExportWithResponse(ctx, id, queryservice.ExportTrigger{}) + idRes, err := client.TriggerExportWithResponse(ctx, "CLIENT_ID", queryservice.ExportTrigger{}) assert.NoError(t, err) assert.NotNil(t, idRes) }