-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve SDK bindings examples (#377)
## Type of change ``` - [ ] Bug fix - [ ] New feature development - [x] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ``` ## Objective Updated all the samples to load access token, organization id and urls from env variables. This made it much easier to quickly test all the bindings. Also added one Java example.
- Loading branch information
1 parent
a8ebf5a
commit 7ec2183
Showing
6 changed files
with
56 additions
and
58 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
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
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import java.lang.System; | ||
import java.util.UUID; | ||
|
||
import com.bitwarden.sdk.*; | ||
import com.bitwarden.sdk.schema.*; | ||
|
||
class Example { | ||
public static void main(String[] args) { | ||
|
||
String accessToken = System.getenv("ACCESS_TOKEN"); | ||
UUID organizationId = UUID.fromString(System.getenv("ORGANIZATION_ID")); | ||
String apiUrl = System.getenv("API_URL"); | ||
String identityUrl = System.getenv("IDENTITY_URL"); | ||
|
||
// Configuring the URLS is optional, remove them to use the default values | ||
BitwardenSettings bitwardenSettings = new BitwardenSettings(); | ||
bitwardenSettings.setApiUrl(apiUrl); | ||
bitwardenSettings.setIdentityUrl(identityUrl); | ||
BitwardenClient client = new BitwardenClient(bitwardenSettings); | ||
client.accessTokenLogin(accessToken); | ||
|
||
|
||
ProjectResponse project = client.projects().create(organizationId, "Test Project"); | ||
ProjectsResponse list = client.projects().list(organizationId); | ||
|
||
SecretResponse secret = client.secrets().create("Secret Key", "Secret Value", "Secret Note", organizationId, new UUID[] { project.getID() }); | ||
|
||
System.out.println("Secret: " + secret.getValue()); | ||
|
||
client.secrets().delete(new UUID[] { secret.getID() }); | ||
client.projects().delete(new UUID[] { project.getID() }); | ||
} | ||
} |
42 changes: 0 additions & 42 deletions
42
languages/java/src/main/java/com/bitwarden/sdk/ExampleProgram.java
This file was deleted.
Oops, something went wrong.
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
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