-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed schema specific code for faster testing
- Loading branch information
1 parent
927be0d
commit ac41ee1
Showing
4 changed files
with
205 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 34 additions & 33 deletions
67
languages/java/src/main/java/com/infisical/sdk/CommandRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,46 @@ | ||
package com.infisical.sdk; | ||
// package com.infisical.sdk; | ||
|
||
import com.infisical.sdk.schema.Command; | ||
import com.infisical.sdk.schema.Converter; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.sun.jna.Pointer; | ||
// import com.infisical.sdk.schema.Command; | ||
// import com.infisical.sdk.schema.Converter; | ||
// import com.fasterxml.jackson.annotation.JsonInclude; | ||
// import com.fasterxml.jackson.databind.ObjectMapper; | ||
// import com.sun.jna.Pointer; | ||
|
||
import java.io.IOException; | ||
import java.util.function.Function; | ||
// import java.io.IOException; | ||
// import java.util.function.Function; | ||
|
||
class CommandRunner { | ||
// class CommandRunner { | ||
|
||
private final InfisicalLibrary library; | ||
// private final InfisicalLibrary library; | ||
|
||
private final Pointer client; | ||
// private final Pointer client; | ||
|
||
CommandRunner(InfisicalLibrary library, Pointer client) { | ||
this.library = library; | ||
this.client = client; | ||
} | ||
// CommandRunner(InfisicalLibrary library, Pointer client) { | ||
// this.library = library; | ||
// this.client = client; | ||
// } | ||
|
||
<T> T runCommand(Command command, Function<String, T> deserializer) { | ||
String response = null; | ||
// <T> T runCommand(Command command, Function<String, T> deserializer) { | ||
// String response = null; | ||
|
||
try { | ||
response = library.run_command(commandToString(command), client); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
// try { | ||
// response = library.run_command(commandToString(command), client); | ||
// } catch (IOException e) { | ||
// throw new RuntimeException(e); | ||
// } | ||
|
||
return deserializer.apply(response); | ||
} | ||
// return deserializer.apply(response); | ||
// } | ||
|
||
private String commandToString(Command command) throws IOException { | ||
// Removes null properties from the generated converter output to avoid command errors | ||
String inputJson = Converter.CommandToJsonString(command); | ||
// private String commandToString(Command command) throws IOException { | ||
// // Removes null properties from the generated converter output to avoid | ||
// command errors | ||
// String inputJson = Converter.CommandToJsonString(command); | ||
|
||
ObjectMapper mapper = new ObjectMapper(); | ||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); | ||
// ObjectMapper mapper = new ObjectMapper(); | ||
// mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); | ||
|
||
Object inputObject = mapper.readValue(inputJson, Object.class); | ||
return mapper.writeValueAsString(inputObject); | ||
} | ||
} | ||
// Object inputObject = mapper.readValue(inputJson, Object.class); | ||
// return mapper.writeValueAsString(inputObject); | ||
// } | ||
// } |
48 changes: 24 additions & 24 deletions
48
languages/java/src/main/java/com/infisical/sdk/Example.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
package com.infisical.sdk; | ||
// package com.infisical.sdk; | ||
|
||
import com.infisical.sdk.schema.AuthenticationOptions; | ||
import com.infisical.sdk.schema.ClientSettings; | ||
import com.infisical.sdk.schema.GetSecretOptions; | ||
import com.infisical.sdk.schema.GetSecretResponseSecret; | ||
// import com.infisical.sdk.schema.AuthenticationOptions; | ||
// import com.infisical.sdk.schema.ClientSettings; | ||
// import com.infisical.sdk.schema.GetSecretOptions; | ||
// import com.infisical.sdk.schema.GetSecretResponseSecret; | ||
|
||
public class Example { | ||
// public class Example { | ||
|
||
public static void Main(String[] args) { | ||
ClientSettings settings = new ClientSettings(); | ||
settings.setClientID("CLIENT_ID"); | ||
settings.setClientSecret("CLIENT_SECRET"); | ||
settings.setSiteURL("http://localhost:8080"); | ||
// public static void Main(String[] args) { | ||
// ClientSettings settings = new ClientSettings(); | ||
// settings.setClientID("CLIENT_ID"); | ||
// settings.setClientSecret("CLIENT_SECRET"); | ||
// settings.setSiteURL("http://localhost:8080"); | ||
|
||
AuthenticationOptions authOptions = new AuthenticationOptions(); | ||
authOptions.setAccessToken("TEST_ACCESS_TOKEN"); | ||
settings.setAuth(authOptions); | ||
// AuthenticationOptions authOptions = new AuthenticationOptions(); | ||
// authOptions.setAccessToken("TEST_ACCESS_TOKEN"); | ||
// settings.setAuth(authOptions); | ||
|
||
InfisicalClient client = new InfisicalClient(settings); | ||
// InfisicalClient client = new InfisicalClient(settings); | ||
|
||
GetSecretOptions options = new GetSecretOptions(); | ||
// GetSecretOptions options = new GetSecretOptions(); | ||
|
||
options.setSecretName("TEST"); | ||
options.setEnvironment("dev"); | ||
options.setProjectID("65670ae4f72abccd9f63d218"); | ||
// options.setSecretName("TEST"); | ||
// options.setEnvironment("dev"); | ||
// options.setProjectID("65670ae4f72abccd9f63d218"); | ||
|
||
GetSecretResponseSecret secret = client.getSecret(options); | ||
// GetSecretResponseSecret secret = client.getSecret(options); | ||
|
||
System.out.println(secret.getSecretValue()); | ||
// System.out.println(secret.getSecretValue()); | ||
|
||
client.close(); | ||
} | ||
} | ||
// client.close(); | ||
// } | ||
// } |
Oops, something went wrong.