-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(rest): Add support for storing GraphQL/REST Connector's response as a document #3746
base: main
Are you sure you want to change the base?
Changes from all commits
2ac7605
691ba10
af4a47f
653e33b
0a51b6a
7e5e975
110c6b0
371f420
a8c2e84
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,6 +103,10 @@ public void clear() { | |
documents.clear(); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. found it helpful for test purposes, and this is the InMemory store not a production one, I guess it's ok |
||
public Map<String, byte[]> getDocuments() { | ||
return documents; | ||
} | ||
|
||
public void logWarning() { | ||
LOGGER.warning( | ||
"In-memory document store is used. This store is not suitable for production use."); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH | ||
* under one or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information regarding copyright | ||
* ownership. Camunda licenses this file to you under the Apache License, | ||
* Version 2.0; you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.camunda.connector.http.base; | ||
|
||
import io.camunda.connector.api.outbound.OutboundConnectorContext; | ||
|
||
public sealed interface ExecutionEnvironment | ||
permits ExecutionEnvironment.SaaSCallerSideEnvironment, | ||
ExecutionEnvironment.SaaSCloudFunctionSideEnvironment, | ||
ExecutionEnvironment.SelfManagedEnvironment { | ||
|
||
/** | ||
* Indicates whether the option to store the response as a document was selected in the Element | ||
* Template. | ||
*/ | ||
boolean storeResponseSelected(); | ||
|
||
/** | ||
* The connector is executed in the context of the cloud function. This is where the | ||
* HttpCommonRequest will be executed. | ||
*/ | ||
record SaaSCloudFunctionSideEnvironment(boolean storeResponseSelected) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe the |
||
implements ExecutionEnvironment {} | ||
|
||
/** | ||
* The connector is executed in the context of the caller, i.e. in the C8 Cluster. When executed | ||
* here, the initial HttpCommonRequest will be serialized as JSON and passed to the Cloud | ||
* Function. | ||
*/ | ||
record SaaSCallerSideEnvironment(boolean storeResponseSelected, OutboundConnectorContext context) | ||
implements ExecutionEnvironment, StoresDocument {} | ||
|
||
record SelfManagedEnvironment(boolean storeResponseSelected, OutboundConnectorContext context) | ||
implements ExecutionEnvironment, StoresDocument {} | ||
|
||
/** | ||
* Factory method to create an ExecutionEnvironment based on the given parameters. | ||
* | ||
* @param cloudFunctionEnabled whether the connector is executed in the context of a cloud | ||
* @param isRunningInCloudFunction whether the connector is executed in the cloud function | ||
* @param storeResponseSelected whether the response should be stored as a Document (this property | ||
* comes from the Element Template) | ||
*/ | ||
static ExecutionEnvironment from( | ||
boolean cloudFunctionEnabled, | ||
boolean isRunningInCloudFunction, | ||
boolean storeResponseSelected, | ||
OutboundConnectorContext context) { | ||
if (cloudFunctionEnabled) { | ||
return new SaaSCallerSideEnvironment(storeResponseSelected, context); | ||
} | ||
if (isRunningInCloudFunction) { | ||
return new SaaSCloudFunctionSideEnvironment(storeResponseSelected); | ||
} | ||
return new SelfManagedEnvironment(storeResponseSelected, context); | ||
} | ||
|
||
interface StoresDocument { | ||
OutboundConnectorContext context(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets let the client decide on the filename and not do it here.