|
| 1 | +# Azure DevCenter client library for Java |
| 2 | + |
| 3 | +This package contains Microsoft Azure DevCenter client library. |
| 4 | + |
| 5 | +## Documentation |
| 6 | + |
| 7 | +Various documentation is available to help you get started |
| 8 | + |
| 9 | +- [Product documentation: Azure Deployment Environments][environments_documentation] |
| 10 | +- [Product documentation: Microsoft Dev Box][devbox_documentation] |
| 11 | + |
| 12 | +## Getting started |
| 13 | + |
| 14 | +### Prerequisites |
| 15 | + |
| 16 | +- [Java Development Kit (JDK)][jdk] with version 8 or above |
| 17 | +- [Azure Subscription][azure_subscription] |
| 18 | +- The minimum requirements to create Dev Box resources using this SDK are to create DevCenter, Project, and Pool resources. |
| 19 | +- The minimum requirements to create Environment resources using this SDK are to create DevCenter, Project, EnvironmentType, and CatalogItem resources. |
| 20 | + |
| 21 | +### Adding the package to your product |
| 22 | + |
| 23 | +[//]: # ({x-version-update-start;com.azure:azure-developer-devcenter;current}) |
| 24 | +```xml |
| 25 | +<dependency> |
| 26 | + <groupId>com.azure</groupId> |
| 27 | + <artifactId>azure-developer-devcenter</artifactId> |
| 28 | + <version>1.0.0-beta.1</version> |
| 29 | +</dependency> |
| 30 | +``` |
| 31 | +[//]: # ({x-version-update-end}) |
| 32 | + |
| 33 | +### Authentication |
| 34 | + |
| 35 | +[Azure Identity][azure_identity] package provides the default implementation for authenticating the client. |
| 36 | + |
| 37 | +## Key concepts |
| 38 | + |
| 39 | +## Examples |
| 40 | +### Dev Box Scenarios |
| 41 | +```java com.azure.developer.devcenter.readme.devboxes |
| 42 | +String tenantId = Configuration.getGlobalConfiguration().get("AZURE_TENANT_ID"); |
| 43 | +String devCenterName = Configuration.getGlobalConfiguration().get("DEVCENTER_NAME"); |
| 44 | + |
| 45 | +// Build our clients |
| 46 | +DevCenterClient devCenterClient = |
| 47 | + new DevCenterClientBuilder() |
| 48 | + .devCenter(devCenterName) |
| 49 | + .tenantId(tenantId) |
| 50 | + .credential(new DefaultAzureCredentialBuilder().build()) |
| 51 | + .buildClient(); |
| 52 | + |
| 53 | +DevBoxesClient devBoxClient = |
| 54 | + new DevBoxesClientBuilder() |
| 55 | + .devCenter(devCenterName) |
| 56 | + .tenantId(tenantId) |
| 57 | + .credential(new DefaultAzureCredentialBuilder().build()) |
| 58 | + .buildClient(); |
| 59 | + |
| 60 | +// Find available Projects and Pools |
| 61 | +PagedIterable<BinaryData> projectListResponse = devCenterClient.listProjects(null); |
| 62 | +for (BinaryData p: projectListResponse) { |
| 63 | + System.out.println(p); |
| 64 | +} |
| 65 | + |
| 66 | +PagedIterable<BinaryData> poolListResponse = devBoxClient.listPools("myProject", null); |
| 67 | +for (BinaryData p: poolListResponse) { |
| 68 | + System.out.println(p); |
| 69 | +} |
| 70 | + |
| 71 | +// Provision a Dev Box |
| 72 | +BinaryData devBoxBody = BinaryData.fromString("{\"poolName\":\"MyPool\"}"); |
| 73 | +SyncPoller<BinaryData, BinaryData> devBoxCreateResponse = |
| 74 | + devBoxClient.beginCreateDevBox("myProject", "me", "MyDevBox", devBoxBody, null); |
| 75 | +devBoxCreateResponse.waitForCompletion(); |
| 76 | + |
| 77 | + |
| 78 | +Response<BinaryData> remoteConnectionResponse = |
| 79 | + devBoxClient.getRemoteConnectionWithResponse("myProject", "me", "MyDevBox", null); |
| 80 | +System.out.println(remoteConnectionResponse.getValue()); |
| 81 | + |
| 82 | +// Tear down the Dev Box when we're finished: |
| 83 | +SyncPoller<BinaryData, BinaryData> devBoxDeleteResponse = |
| 84 | + devBoxClient.beginDeleteDevBox("myProject", "me", "MyDevBox", null); |
| 85 | +devBoxDeleteResponse.waitForCompletion(); |
| 86 | +``` |
| 87 | + |
| 88 | +### Environments Scenarios |
| 89 | +```java com.azure.developer.devcenter.readme.environments |
| 90 | +EnvironmentsClient environmentsClient = |
| 91 | + new EnvironmentsClientBuilder() |
| 92 | + .devCenter(devCenterName) |
| 93 | + .tenantId(tenantId) |
| 94 | + .credential(new DefaultAzureCredentialBuilder().build()) |
| 95 | + .buildClient(); |
| 96 | + |
| 97 | +// Fetch available catalog items and environment types |
| 98 | +PagedIterable<BinaryData> catalogItemListResponse = environmentsClient.listCatalogItems("myProject", null); |
| 99 | +for (BinaryData p: catalogItemListResponse) { |
| 100 | + System.out.println(p); |
| 101 | +} |
| 102 | + |
| 103 | +PagedIterable<BinaryData> environmentTypesListResponse = environmentsClient.listEnvironmentTypes("myProject", null); |
| 104 | +for (BinaryData p: environmentTypesListResponse) { |
| 105 | + System.out.println(p); |
| 106 | +} |
| 107 | + |
| 108 | +// Create an environment |
| 109 | +BinaryData environmentBody = BinaryData.fromString("{\"catalogItemName\":\"MyCatalogItem\", \"environmentType\":\"MyEnvironmentType\"}"); |
| 110 | +SyncPoller<BinaryData, BinaryData> environmentCreateResponse = |
| 111 | + environmentsClient.beginCreateOrUpdateEnvironment("myProject", "me", "TestEnvironment", environmentBody, null); |
| 112 | +environmentCreateResponse.waitForCompletion(); |
| 113 | + |
| 114 | + |
| 115 | +// Fetch the deployment artifacts: |
| 116 | +PagedIterable<BinaryData> artifactListResponse = environmentsClient.listArtifactsByEnvironment("myProject", "me", "TestEnvironment", null); |
| 117 | +for (BinaryData p: artifactListResponse) { |
| 118 | + System.out.println(p); |
| 119 | +} |
| 120 | + |
| 121 | + |
| 122 | +// Delete the environment when we're finished: |
| 123 | +SyncPoller<BinaryData, BinaryData> environmentDeleteResponse = |
| 124 | + environmentsClient.beginDeleteEnvironment("myProject", "me", "TestEnvironment", null); |
| 125 | +environmentDeleteResponse.waitForCompletion(); |
| 126 | +``` |
| 127 | + |
| 128 | +## Troubleshooting |
| 129 | + |
| 130 | +## Next steps |
| 131 | + |
| 132 | +## Contributing |
| 133 | + |
| 134 | +For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md). |
| 135 | + |
| 136 | +1. Fork it |
| 137 | +1. Create your feature branch (`git checkout -b my-new-feature`) |
| 138 | +1. Commit your changes (`git commit -am 'Add some feature'`) |
| 139 | +1. Push to the branch (`git push origin my-new-feature`) |
| 140 | +1. Create new Pull Request |
| 141 | + |
| 142 | +<!-- LINKS --> |
| 143 | +[environments_documentation]: https://learn.microsoft.com/azure/deployment-environments/ |
| 144 | +[devbox_documentation]: https://learn.microsoft.com/azure/dev-box/ |
| 145 | +[docs]: https://azure.github.io/azure-sdk-for-java/ |
| 146 | +[jdk]: https://docs.microsoft.com/java/azure/jdk/ |
| 147 | +[azure_subscription]: https://azure.microsoft.com/free/ |
| 148 | +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity |
0 commit comments