Skip to content

Site Recovery Manager and vSphere Replication REST API was released in 8.6 and 8.7 of the product. We would like to create a codespace in VMware github to provide examples of the main use cases which our customers have difficulties with. These examples will be code snippets (or the whole request) of working REST API requests.

License

Notifications You must be signed in to change notification settings

vmware-samples/site-recovery-manager-rest-api-examples

site-recovery-manager-rest-api-examples

Examples (code snippets) of working REST API requests.

1. Prerequisites

REST API gateway Open API spec file in one of the formats - .json or .yaml

REST API client generator.

Online option - https://editor.swagger.io/

Maven option:

swagger-codegen-maven-plugin

<plugin>
   <groupId>io.swagger.codegen.v3</groupId>
   <artifactId>swagger-codegen-maven-plugin</artifactId>
   <version>3.0.32</version>
   <dependencies>
      <dependency>
         <groupId>com.github.jknack</groupId>
         <artifactId>handlebars</artifactId>
         <version>4.3.0</version>
      </dependency>
   </dependencies>
   <executions>
      <execution>
         <phase>generate-sources</phase>
         <goals>
            <goal>generate</goal>
         </goals>
         <configuration>
            <inputSpec>${swagger.definitions.url}</inputSpec>
            <language>java</language>
            <output>${swagger.output.dir}</output>
            <generateSupportingFiles>true</generateSupportingFiles>
            <generateApiTests>false</generateApiTests>
            <generateApiDocumentation>false</generateApiDocumentation>
            <generateModelTests>false</generateModelTests>
            <generateModelDocumentation>false</generateModelDocumentation>
            <environmentVariables>
               <io.swagger.v3.parser.util.RemoteUrl.trustAll>true</io.swagger.v3.parser.util.RemoteUrl.trustAll>
            </environmentVariables>
            <configOptions>
               <dateLibrary>legacy</dateLibrary>
               <useRuntimeException>true</useRuntimeException>
               <hideGenerationTimestamp>true</hideGenerationTimestamp>
            </configOptions>
         </configuration>
      </execution>
   </executions>
</plugin>

Other options are also available.

Project build tools - Maven, Gradle, etc.

2. Project Setup Steps

Generate REST API gateway client.

Build REST API gateway generated client.

Create your project and introduce dependency on REST API gateway client built in the previous step.

Write your code to start calling REST API gateway endpoints.

First start with login request in order to obtain REST API gateway session token. This needs Basic Authentication with user and password credentials for the local SRM/HMS site. Add the obtained session token to the header, with key "x-dr-session", of every future REST API request.

Call get all pairings request. This is a preliminary step before calling remote login request.

Call remote login request in order to authenticate to the SRM/HMS remote site. This needs Basic Authentication with user and password credentials for the remote SRM/HMS site.

Now logged in at the local and remote site, any request of your interest can be made.

With project build tool of your choice build your project.

Contributing

The site-recovery-manager-rest-api-examples project team welcomes contributions from the community. Before you start working with site-recovery-manager-rest-api-examples, please read our Developer Certificate of Origin. All contributions to this repository must be signed as described on that page. Your signature certifies that you wrote the patch or have the right to pass it on as an open-source patch. For more detailed information, refer to CONTRIBUTING_DCO.md.

License

BSD-2

About

Site Recovery Manager and vSphere Replication REST API was released in 8.6 and 8.7 of the product. We would like to create a codespace in VMware github to provide examples of the main use cases which our customers have difficulties with. These examples will be code snippets (or the whole request) of working REST API requests.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published