...
- Available with the Syndeia Cloud download. Check with your admin.
- Available with the tutorials in all three Syndeia clients - MagicDraw plugin, Rhapsody plugin, and Syndeia Standalone.
# CloudApiDemo #
This project is a Java example, that shows how to call various endpoints exposed by the Syndeia Cloud API.
### Code organization ###
This is a Maven project with a `pom.xml` file that mentions all the dependencies on the external Java packages.
The source code is organized in three packages -
* **com.intercax.syndeia.domain** - contains various domain model classes (like `Repository, Container, Artifact, Relation` etc.)
* **com.intercax.syndeia.services** - contains various classes like `CloudService, CoreCloudService, CloudServiceUrlHelper, GenericrestClient and ReponseTypesForGson` classes
* **com.intercax.syndeia.utils** - contains `Either` and `TriFunction` utility classes
A few of the subpackages of the `com.intercax.syndeia.domain` package, are as under -
* **com.intercax.syndeia.domain.forms** - contains classes that are to used to call POST / PUT APIs to sign-up and sign-in a
user
* **com.intercax.syndeia.domain.responses** - contains classes that are used to deserialize the string response of Syndeia
Cloud API endpoints
### How do I get set up? ###
* You can open this project in IntelliJ IDEA or Eclipse, or any other suitable editor like Visual Studio Code.
* For Eclipse, use Import -> Maven -> Existing Maven Projects (by pointing to the pom.xml file) or Import -> General -> Existing projects into Workspace
(by pointing to the .project file)
* Before running this code, you need to make sure that the Syndeia Cloud API is running
* You can run the tests in `com.intercax.syndeia.services.CloudServiceTests` to see how a particular Syndeia Cloud API endpoint is called
* Alternatively, you can run the `main` method of the `com.intercax.syndeia.CloudApiDemo` project to see examples of invoking a few of the
Syndeia Cloud API endpoints
* Both the main method and the tests assume some values (like the IP address, port, username and password) for where the Syndeia Cloud API is running.
**So before running either the tests or the main method, please get the required credentials from Syndeia Cloud administrator and use the relevant values.**
### How to extend this code (for trying out other Syndeia Cloud API endpoints) ###
* You need to figure out the URL of the particular Syndeia Cloud API endpoint, whether that endpoint is exposed over HTTP
Get, Post, Put, Delete (verbs) methods, and if it accepts any parameters
* Typically, the Post and Put methods expect some payload (data in JSON format) for the resource that has to be created
/ updated on the server
* The Get methods might also need some values for parameters that are part of the URL
* Most likely, there will be a method in the `com.intercax.syndeia.services.CloudServiceUrlHelper` class that will be
returning a correct URL by accepting (a few) parameters - if such a method is missing, you may add one accordingly
* Finally, you'll need to add a new method to the `com.intercax.syndeia.services.CloudService` class and use the URL
returned by one of the methods in `CloudServiceUrlHelper` and then passing this URL and the type of response expected
to one of the (`get, getAll`) methods in `CoreCloudService` class
* Typically, the methods in the `com.intercax.syndeia.services.CloudService` class return `Either<ErrorResponse, *Response<T>>` where -
* *Response is one of `ObjResponse` (for single values), `SeqResponse` (for a list of values) or `CreatedResponse` (if
something got created on the server)
* T is one of the domain objects from the **com.intercax.syndeia.domain** package
### Typical API calling pattern ###
```
// A method in the CloudService class
public Either<ErrorResponse, SeqResponse<Domain>> getAllDomainObjects() {
return coreCloudService.getAll(cloudServiceUrlHelper.getXyzApiEndpointUrl(), typeOfSeqResponseOfDomain);
}
```
### Who do I talk to? ###
* Please get in touch with the [Intercax team](info@intercax.com) for more details.