Skip to content

Commit

Permalink
feat(gemini): impl connector
Browse files Browse the repository at this point in the history
  • Loading branch information
DenovVasil committed Nov 25, 2024
1 parent 3db7761 commit f4eb1c6
Show file tree
Hide file tree
Showing 35 changed files with 2,823 additions and 13 deletions.
4 changes: 4 additions & 0 deletions bundle/default-bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@
<groupId>io.camunda.connector</groupId>
<artifactId>connector-aws-comprehend</artifactId>
</dependency>
<dependency>
<groupId>io.camunda.connector</groupId>
<artifactId>connector-google-gemini</artifactId>
</dependency>
</dependencies>

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ public void handle(final JobClient client, final ActivatedJob job) {
var context =
new JobHandlerContext(
job, getSecretProvider(), validationProvider, documentFactory, objectMapper);
var response = call.execute(context);
var response = call.
execute(context);
var responseVariables =
ConnectorHelper.createOutputVariables(
response,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,27 @@ public final class GoogleServiceSupplierUtil {
private GoogleServiceSupplierUtil() {}

public static HttpCredentialsAdapter getHttpHttpCredentialsAdapter(final Authentication auth) {
Credentials creds = null;
Credentials creds = getCredentials(auth);
if (auth.authType() == AuthenticationType.BEARER) {
AccessToken accessToken = new AccessToken(auth.bearerToken(), null);
creds = new GoogleCredentials(accessToken).createScoped(DriveScopes.DRIVE);
}

if (auth.authType() == AuthenticationType.REFRESH) {
creds =
UserCredentials.newBuilder()
.setClientId(auth.oauthClientId())
.setClientSecret(auth.oauthClientSecret())
.setRefreshToken(auth.oauthRefreshToken())
.build();
creds = ((GoogleCredentials) creds).createScoped(DriveScopes.DRIVE);
}

return new HttpCredentialsAdapter(creds);
}

public static Credentials getCredentials(Authentication auth) {
if (auth.authType() == AuthenticationType.BEARER) {
AccessToken accessToken = new AccessToken(auth.bearerToken(), null);
GoogleCredentials googleCredentials = new GoogleCredentials(accessToken);

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
GoogleCredentials.GoogleCredentials
should be avoided because it has been deprecated.
return googleCredentials;
}
return UserCredentials.newBuilder()
.setClientId(auth.oauthClientId())
.setClientSecret(auth.oauthClientSecret())
.setRefreshToken(auth.oauthRefreshToken())
.build();
}

public static NetHttpTransport getNetHttpTransport() {
try {
return GoogleNetHttpTransport.newTrustedTransport();
Expand Down
Loading

0 comments on commit f4eb1c6

Please sign in to comment.