Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
tutkat committed Jul 26, 2024
1 parent 5d6c161 commit aeda5a9
Showing 1 changed file with 22 additions and 28 deletions.
50 changes: 22 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,37 +44,31 @@ mvn clean package
Create a sample file with the following code:
```java
// Import classes:
import com.equinix.openapi.fabric.ApiClient;
import com.equinix.openapi.fabric.ApiException;
import com.equinix.openapi.fabric.Configuration;
import com.equinix.openapi.fabric.auth.*;
import com.equinix.openapi.fabric.v4.model.*;
import com.equinix.openapi.fabric.v4.api.PortsApi;
import java.util.UUID;

public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.equinix.com");
public class RouteFiltersApiTest {

private RouteFiltersApi api;

@Before
public void createApi() {
api = ApiClient.api(ApiClient.Config.apiConfig().reqSpecSupplier(
() -> new RequestSpecBuilder()
.addHeader("Authorization", "<<TOKEN>>")
.setConfig(config().objectMapperConfig(objectMapperConfig().defaultObjectMapper(jackson())))
.addFilter(new ErrorLoggingFilter())
.setBaseUri("https://api.equinix.com"))).routeFilters();
}

// Configure HTTP bearer authorization: BearerAuth
HttpBearerAuth BearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("BearerAuth");
BearerAuth.setBearerToken("<GetBearerTokenFromDeveloperPortal>");

PortsApi apiInstance = new PortsApi(defaultClient);
try {
Port result = apiInstance.getPortByUuid(UUID.fromString("<RetrievePortUUIDFromFabricPortal>"));
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ConnectionsApi#createConnection");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
@Test
public void shouldSee202AfterAttachConnectionRouteFilter() {
String routeFilterId = null;
String connectionId = null;
ConnectionRouteFiltersBase connectionRouteFiltersBase = null;
api.attachConnectionRouteFilter()
.routeFilterIdPath(routeFilterId)
.connectionIdPath(connectionId)
.body(connectionRouteFiltersBase).execute(r -> r.prettyPeek());
}
}
}
```

Sample can be run by consuming local jars produced after building generated fabric-java client
(Notice that the version numbers in the jar path will change over time, input correct path into
Expand Down

0 comments on commit aeda5a9

Please sign in to comment.