|
| 1 | +package hello; |
| 2 | + |
| 3 | +import org.joda.time.LocalTime; |
| 4 | +import org.permify.api.TenancyApi; |
| 5 | +import org.permify.model.TenantCreateRequest; |
| 6 | +import org.permify.model.TenantCreateResponse; |
| 7 | +import org.permify.ApiClient; |
| 8 | +import reactor.core.publisher.Mono; |
| 9 | + |
| 10 | +public class HelloWorld { |
| 11 | + public static void main(String[] args) { |
| 12 | + String baseUrl = "http://localhost:3476"; // Ensure this is the correct port |
| 13 | + String bearerToken = "secret"; // Replace with your actual bearer token |
| 14 | + |
| 15 | + ApiClient apiClient = new ApiClient(); |
| 16 | + apiClient.setBasePath(baseUrl); |
| 17 | + System.out.println("Created Api Client Endpoint: " + apiClient.getBasePath()); |
| 18 | + apiClient.addDefaultHeader("Authorization", "Bearer secret"); |
| 19 | + |
| 20 | + TenancyApi api = new TenancyApi(apiClient); |
| 21 | + |
| 22 | + try { |
| 23 | + System.out.println("Sending request to " + baseUrl + " with Authorization header Bearer " + bearerToken); |
| 24 | + TenantCreateRequest req = new TenantCreateRequest(); |
| 25 | + req.setId("template_tenant2"); |
| 26 | + req.setName("Template"); |
| 27 | + Mono<TenantCreateResponse> responseMono = api.tenantsCreate(req); |
| 28 | + TenantCreateResponse response = responseMono.block(); // Block to get the response synchronously |
| 29 | + System.out.println("Tenant create response: " + response); |
| 30 | + } catch (Exception e) { |
| 31 | + LocalTime time = new LocalTime(); |
| 32 | + System.out.println("Error occurred at " + time.toString() + ": " + e.getMessage()); |
| 33 | + } |
| 34 | + } |
| 35 | +} |
0 commit comments