Skip to content
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: GraphQL connector template #202

Merged
merged 20 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d437444
feat: GraphQL connector template
markfarkas-camunda Jan 11, 2023
856f06e
fix(graphql): update license headers
markfarkas-camunda Jan 11, 2023
4c4a942
feat(graphql): implement GraphQL GET method without variables
markfarkas-camunda Jan 23, 2023
949d43e
feat(graphql): implement POST method and variable handling
markfarkas-camunda Jan 23, 2023
d9afadf
fix(graphql): additional character escape, and cleanup
markfarkas-camunda Jan 25, 2023
3400db7
feat(graphql): modify application.properties, code restructure
markfarkas-camunda Jan 26, 2023
6a111bd
fix(graphql): make input variable names graphql specific
markfarkas-camunda Jan 27, 2023
1ce9f74
fix(graphql): swap url and method in the element template
markfarkas-camunda Jan 27, 2023
7a6ea75
chore(graphql): add connectors-common-library to unify http behavior
markfarkas-camunda Jan 31, 2023
2cb7f8e
chore(graphql): set post as default value for method
markfarkas-camunda Feb 3, 2023
e6545ca
Merge branch 'main' into 153-create-template-for-graphql-deploy
markfarkas-camunda Feb 3, 2023
59a6015
feat(graphql): use connectors-common-library in http-json connector, …
markfarkas-camunda Feb 8, 2023
706618b
feat(graphql): add proxy behavior
markfarkas-camunda Feb 9, 2023
cf5d61a
chore(graphql): bundle pom cleanup
markfarkas-camunda Feb 9, 2023
8768ae5
chore(graphql): add README
markfarkas-camunda Feb 9, 2023
ae158c9
chore(graphql): fix README format
markfarkas-camunda Feb 9, 2023
7a853aa
Merge branch 'main' into 153-create-template-for-graphql-deploy
markfarkas-camunda Feb 9, 2023
5b8dbab
chore(graphql): update links to point to internal documentation
markfarkas-camunda Feb 9, 2023
32238f2
fix(graphql): common library licensing, null safety
markfarkas-camunda Feb 10, 2023
518a5ba
fix(graphql): fix code style
markfarkas-camunda Feb 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bundle/mvn/default-bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
<groupId>io.camunda.connector</groupId>
<artifactId>connector-microsoft-teams</artifactId>
</dependency>
<dependency>
<groupId>io.camunda.connector</groupId>
<artifactId>connector-graphql</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
5 changes: 5 additions & 0 deletions bundle/mvn/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@
<artifactId>connector-slack</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.camunda.connector</groupId>
<artifactId>connector-graphql</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</parent>

<name>${artifactId}</name>
<description>${connectorName} cnnector for Camunda 8</description>
<description>${connectorName} connector for Camunda 8</description>
<artifactId>${artifactId}</artifactId>
<packaging>jar</packaging>

Expand Down
67 changes: 67 additions & 0 deletions connectors/connectors-common-library/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.camunda.connector</groupId>
<artifactId>connector-function-parent</artifactId>
<version>0.16.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<name>connectors-common-library</name>
<description>Common library for connectors</description>
<artifactId>connectors-common-library</artifactId>
<packaging>jar</packaging>

<properties>
<license.inlineheader>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.</license.inlineheader>
</properties>
Comment on lines +18 to +33
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, should be this one

Suggested change
<properties>
<license.inlineheader>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.</license.inlineheader>
</properties>
<licenses>
<license>
<name>Camunda Platform Self-Managed Free Edition license</name>
<url>https://camunda.com/legal/terms/cloud-terms-and-conditions/camunda-cloud-self-managed-free-edition-terms/</url>
</license>
<license>
<name>Camunda Platform Self-Managed Enterprise Edition license</name>
</license>
</licenses>
<properties>
<license.inlineheader>Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
under one or more contributor license agreements. Licensed under a proprietary license.
See the License.txt file for more information. You may not use this file
except in compliance with the proprietary license.</license.inlineheader>
</properties>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, disregard this comment. I think, it's okay to keep it as Apache 2.0 since it's a common lib.


<dependencies>
<dependency>
<groupId>org.danilopianini</groupId>
<artifactId>gson-extras</artifactId>
</dependency>

<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-gson</artifactId>
</dependency>

<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-apache-v2</artifactId>
</dependency>

<dependency>
<groupId>com.google.auth</groupId>
<artifactId>google-auth-library-oauth2-http</artifactId>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.camunda.connector.http.auth;
package io.camunda.connector.common.auth;

import com.google.api.client.http.HttpHeaders;
import com.google.common.base.Objects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.camunda.connector.http.auth;
package io.camunda.connector.common.auth;

import com.google.api.client.http.HttpHeaders;
import com.google.common.base.Objects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.camunda.connector.http.auth;
package io.camunda.connector.common.auth;

import com.google.api.client.http.HttpHeaders;
import com.google.common.base.Objects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.camunda.connector.http.auth;
package io.camunda.connector.common.auth;

import com.google.api.client.http.HttpHeaders;
import io.camunda.connector.api.annotation.Secret;
import io.camunda.connector.http.model.HttpJsonRequest;
import io.camunda.connector.common.model.CommonRequest;
import java.util.Map;
import java.util.Objects;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

public class CustomAuthentication extends Authentication {

@NotNull @Valid private HttpJsonRequest request;
@NotNull @Valid private CommonRequest request;

@Secret private Map<String, String> outputBody;

Expand All @@ -35,11 +35,11 @@ public class CustomAuthentication extends Authentication {
@Override
public void setHeaders(final HttpHeaders headers) {}

public HttpJsonRequest getRequest() {
public CommonRequest getRequest() {
return request;
}

public void setRequest(final HttpJsonRequest request) {
public void setRequest(final CommonRequest request) {
this.request = request;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.camunda.connector.http.auth;
package io.camunda.connector.common.auth;

import com.google.api.client.http.HttpHeaders;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.camunda.connector.http.auth;
package io.camunda.connector.common.auth;

import com.google.api.client.http.HttpHeaders;
import io.camunda.connector.api.annotation.Secret;
import io.camunda.connector.http.constants.Constants;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import javax.validation.constraints.NotEmpty;

Expand All @@ -31,20 +28,8 @@ public class OAuthAuthentication extends Authentication {
@NotEmpty @Secret private String clientSecret;
@Secret private String audience;
@NotEmpty private String clientAuthentication;
private String scopes;

public Map<String, String> getDataForAuthRequestBody() {
Map<String, String> data = new HashMap<>();
data.put(Constants.GRANT_TYPE, grantType);
data.put(Constants.AUDIENCE, audience);
data.put(Constants.SCOPE, scopes);

if (clientAuthentication.equals(Constants.CREDENTIALS_BODY)) {
data.put(Constants.CLIENT_ID, clientId);
data.put(Constants.CLIENT_SECRET, clientSecret);
}
return data;
}
private String scopes;

public String getClientId() {
return clientId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.camunda.connector.http.constants;
package io.camunda.connector.common.constants;

public class Constants {
public static final String GRANT_TYPE = "grant_type";
Expand All @@ -23,7 +23,6 @@ public class Constants {
public static final String AUDIENCE = "audience";
public static final String SCOPE = "scope";
public static final String ACCESS_TOKEN = "access_token";
public static final String COMPUTE_METADATA = "computeMetadata";
public static final String BASIC_AUTH_HEADER = "basicAuthHeader";
public static final String CREDENTIALS_BODY = "credentialsBody";
public static final String PROXY_FUNCTION_URL_ENV_NAME = "CAMUNDA_CONNECTOR_HTTP_PROXY_URL";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
/*
* 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.common.model;

import io.camunda.connector.api.annotation.Secret;
import io.camunda.connector.common.auth.Authentication;
import java.util.Map;
import java.util.Objects;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

public class CommonRequest {

@NotBlank
@Pattern(regexp = "^(http://|https://|secrets).*$")
@Secret
private String url;

@NotBlank @Secret private String method;

@Valid @Secret private Authentication authentication;

@Pattern(regexp = "^([0-9]*$)|(secrets.*$)")
@Secret
private String connectionTimeoutInSeconds;

@Secret private Map<String, String> headers;

@Secret private Object body;

@Secret private Map<String, String> queryParameters;

public Object getBody() {
return body;
}

public void setBody(final Object body) {
this.body = body;
}

public boolean hasHeaders() {
return headers != null;
}

public boolean hasBody() {
return body != null;
}

public Map<String, String> getHeaders() {
return headers;
}

public void setHeaders(final Map<String, String> headers) {
this.headers = headers;
}

public boolean hasQueryParameters() {
return queryParameters != null;
}

public Map<String, String> getQueryParameters() {
return queryParameters;
}

public void setQueryParameters(Map<String, String> queryParameters) {
this.queryParameters = queryParameters;
}

public boolean hasAuthentication() {
return authentication != null;
}

public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}

public Authentication getAuthentication() {
return authentication;
}

public void setAuthentication(Authentication authentication) {
this.authentication = authentication;
}

public String getMethod() {
return method;
}

public void setMethod(String method) {
this.method = method;
}

public String getConnectionTimeoutInSeconds() {
return connectionTimeoutInSeconds;
}

public void setConnectionTimeoutInSeconds(String connectionTimeoutInSeconds) {
this.connectionTimeoutInSeconds = connectionTimeoutInSeconds;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CommonRequest that = (CommonRequest) o;
return url.equals(that.url)
&& method.equals(that.method)
&& Objects.equals(authentication, that.authentication)
&& Objects.equals(connectionTimeoutInSeconds, that.connectionTimeoutInSeconds)
&& Objects.equals(headers, that.headers)
&& Objects.equals(body, that.body)
&& Objects.equals(queryParameters, that.queryParameters);
}

@Override
public int hashCode() {
return Objects.hash(
url, method, authentication, connectionTimeoutInSeconds, headers, body, queryParameters);
}

@Override
public String toString() {
return "CommonRequest{"
+ "url='"
+ url
+ '\''
+ ", method='"
+ method
+ '\''
+ ", authentication="
+ authentication
+ ", connectionTimeoutInSeconds='"
+ connectionTimeoutInSeconds
+ '\''
+ ", headers="
+ headers
+ ", body="
+ body
+ ", queryParameters="
+ queryParameters
+ '}';
}
}
Loading