diff --git a/README.md b/README.md index 6acdb6992eb..0e98c81e965 100644 --- a/README.md +++ b/README.md @@ -153,11 +153,15 @@ The API documentation can be accessed from here: [VMware Cloud on AWS APIs](https://vmware.github.io/vsphere-automation-sdk-java/vmc/index.html). -[VMware NSX-T APIs](https://vmware.github.io/vsphere-automation-sdk-java/nsx/nsx/index.html). +[VMware NSX-T Manager APIs (for on-prem customers)](https://vmware.github.io/vsphere-automation-sdk-java/nsx/nsx/index.html). -[VMware NSX-T Policy APIs](https://vmware.github.io/vsphere-automation-sdk-java/nsx/nsx-policy/index.html). +[VMware NSX-T Policy APIs (for on-prem customers)](https://vmware.github.io/vsphere-automation-sdk-java/nsx/nsx-policy/index.html). -[VMware NSX-T VMC app APIs](https://vmware.github.io/vsphere-automation-sdk-java/nsx/vmc-app/index.html). +[VMware NSX-T Policy APIs (for VMC customers)](https://vmware.github.io/vsphere-automation-sdk-java/nsx/nsx-vmc-policy/index.html). + +[VMware NSX-T VMC AWS Integration APIs (for VMC customers)](https://vmware.github.io/vsphere-automation-sdk-java/nsx/nsx-vmc-aws-integration/index.html). + +[VMware NSX-T VMC Common APIs (for VMC customers)](https://vmware.github.io/vsphere-automation-sdk-java/nsx/nsx-vmc-sdk-common/index.html). ## Submitting samples diff --git a/lib/nsx-java-sdk-2.3.0.0.2.11053635-javadoc.jar b/lib/nsx-java-sdk-2.3.0.0.3.13851140-javadoc.jar similarity index 70% rename from lib/nsx-java-sdk-2.3.0.0.2.11053635-javadoc.jar rename to lib/nsx-java-sdk-2.3.0.0.3.13851140-javadoc.jar index 72b25a5491b..a545a0fa9be 100644 Binary files a/lib/nsx-java-sdk-2.3.0.0.2.11053635-javadoc.jar and b/lib/nsx-java-sdk-2.3.0.0.3.13851140-javadoc.jar differ diff --git a/lib/nsx-java-sdk-2.3.0.0.2.11053635.jar b/lib/nsx-java-sdk-2.3.0.0.3.13851140.jar similarity index 72% rename from lib/nsx-java-sdk-2.3.0.0.2.11053635.jar rename to lib/nsx-java-sdk-2.3.0.0.3.13851140.jar index 7eadb89547b..780ab9a2b00 100644 Binary files a/lib/nsx-java-sdk-2.3.0.0.2.11053635.jar and b/lib/nsx-java-sdk-2.3.0.0.3.13851140.jar differ diff --git a/lib/nsx-policy-java-sdk-2.3.0.0.2.11053635-javadoc.jar b/lib/nsx-policy-java-sdk-2.3.0.0.3.13851140-javadoc.jar similarity index 69% rename from lib/nsx-policy-java-sdk-2.3.0.0.2.11053635-javadoc.jar rename to lib/nsx-policy-java-sdk-2.3.0.0.3.13851140-javadoc.jar index 98db76f2d40..af7b57afb20 100644 Binary files a/lib/nsx-policy-java-sdk-2.3.0.0.2.11053635-javadoc.jar and b/lib/nsx-policy-java-sdk-2.3.0.0.3.13851140-javadoc.jar differ diff --git a/lib/nsx-policy-java-sdk-2.3.0.0.2.11053635.jar b/lib/nsx-policy-java-sdk-2.3.0.0.3.13851140.jar similarity index 58% rename from lib/nsx-policy-java-sdk-2.3.0.0.2.11053635.jar rename to lib/nsx-policy-java-sdk-2.3.0.0.3.13851140.jar index 5912da2b541..68cf76fcb8c 100644 Binary files a/lib/nsx-policy-java-sdk-2.3.0.0.2.11053635.jar and b/lib/nsx-policy-java-sdk-2.3.0.0.3.13851140.jar differ diff --git a/lib/nsx-vmc-aws-integration-java-sdk-2.3.0.0.3.13851140-javadoc.jar b/lib/nsx-vmc-aws-integration-java-sdk-2.3.0.0.3.13851140-javadoc.jar new file mode 100644 index 00000000000..ecfbf778e94 Binary files /dev/null and b/lib/nsx-vmc-aws-integration-java-sdk-2.3.0.0.3.13851140-javadoc.jar differ diff --git a/lib/nsx-vmc-aws-integration-java-sdk-2.3.0.0.3.13851140.jar b/lib/nsx-vmc-aws-integration-java-sdk-2.3.0.0.3.13851140.jar new file mode 100644 index 00000000000..74a99ccffa0 Binary files /dev/null and b/lib/nsx-vmc-aws-integration-java-sdk-2.3.0.0.3.13851140.jar differ diff --git a/lib/nsx-vmc-policy-java-sdk-2.3.0.0.3.13851140-javadoc.jar b/lib/nsx-vmc-policy-java-sdk-2.3.0.0.3.13851140-javadoc.jar new file mode 100644 index 00000000000..d6ef855cee3 Binary files /dev/null and b/lib/nsx-vmc-policy-java-sdk-2.3.0.0.3.13851140-javadoc.jar differ diff --git a/lib/nsx-vmc-policy-java-sdk-2.3.0.0.3.13851140.jar b/lib/nsx-vmc-policy-java-sdk-2.3.0.0.3.13851140.jar new file mode 100644 index 00000000000..74ff46f4867 Binary files /dev/null and b/lib/nsx-vmc-policy-java-sdk-2.3.0.0.3.13851140.jar differ diff --git a/lib/nsx-vmc-sdk-common-2.3.0.0.2.11053635-javadoc.jar b/lib/nsx-vmc-sdk-common-2.3.0.0.2.11053635-javadoc.jar deleted file mode 100644 index 796d21d3f8a..00000000000 Binary files a/lib/nsx-vmc-sdk-common-2.3.0.0.2.11053635-javadoc.jar and /dev/null differ diff --git a/lib/nsx-vmc-sdk-common-2.3.0.0.3.13851140-javadoc.jar b/lib/nsx-vmc-sdk-common-2.3.0.0.3.13851140-javadoc.jar new file mode 100644 index 00000000000..66eefdeeac4 Binary files /dev/null and b/lib/nsx-vmc-sdk-common-2.3.0.0.3.13851140-javadoc.jar differ diff --git a/lib/nsx-vmc-sdk-common-2.3.0.0.2.11053635.jar b/lib/nsx-vmc-sdk-common-2.3.0.0.3.13851140.jar similarity index 65% rename from lib/nsx-vmc-sdk-common-2.3.0.0.2.11053635.jar rename to lib/nsx-vmc-sdk-common-2.3.0.0.3.13851140.jar index 1cae19b10ef..1dd2d4e8901 100644 Binary files a/lib/nsx-vmc-sdk-common-2.3.0.0.2.11053635.jar and b/lib/nsx-vmc-sdk-common-2.3.0.0.3.13851140.jar differ diff --git a/lib/vmc-app-java-sdk-2.3.0.0.2.11053635-javadoc.jar b/lib/vmc-app-java-sdk-2.3.0.0.2.11053635-javadoc.jar deleted file mode 100644 index f2754144d00..00000000000 Binary files a/lib/vmc-app-java-sdk-2.3.0.0.2.11053635-javadoc.jar and /dev/null differ diff --git a/lib/vmc-app-java-sdk-2.3.0.0.2.11053635.jar b/lib/vmc-app-java-sdk-2.3.0.0.2.11053635.jar deleted file mode 100644 index 32f466af904..00000000000 Binary files a/lib/vmc-app-java-sdk-2.3.0.0.2.11053635.jar and /dev/null differ diff --git a/pom.xml b/pom.xml index 4e4835aad3a..75078f63cbe 100644 --- a/pom.xml +++ b/pom.xml @@ -26,8 +26,9 @@ 6.7.2 1.4.0 3.0.0 - 2.3.0.0.2.11053635 - 2.3.0.0.2.11053635 + 2.3.0.0.3.13851140 + 2.3.0.0.3.13851140 + 2.3.0.0.3.13851140 @@ -190,7 +191,7 @@ - install-vmc-app-sdk + install-nsx-vmc-policy-sdk initialize install-file @@ -198,9 +199,37 @@ jar com.vmware.nsx - vmc-app-java-sdk - ${vmcappsdk.version} - ./lib/vmc-app-java-sdk-${vmcappsdk.version}.jar + nsx-vmc-policy-java-sdk + ${nsxpolicysdk.version} + ./lib/nsx-vmc-policy-java-sdk-${nsxpolicysdk.version}.jar + + + + install-nsx-vmc-aws-integration-sdk + initialize + + install-file + + + jar + com.vmware.nsx + nsx-vmc-aws-integration-sdk + ${nsxvmcawsint.version} + ./lib/nsx-vmc-aws-integration-java-sdk-${nsxvmcawsint.version}.jar + + + + install-nsx-vmc-sdk-common + initialize + + install-file + + + jar + com.vmware.nsx + nsx-vmc-sdk-common + ${nsxvmcsdkcommon.version} + ./lib/nsx-vmc-sdk-common-${nsxvmcsdkcommon.version}.jar @@ -284,13 +313,18 @@ com.vmware.nsx - nsx-policy-java-sdk + nsx-vmc-policy-java-sdk ${nsxpolicysdk.version} com.vmware.nsx - vmc-app-java-sdk - ${vmcappsdk.version} + nsx-vmc-aws-integration-sdk + ${nsxvmcawsint.version} + + + com.vmware.nsx + nsx-vmc-sdk-common + ${nsxvmcsdkcommon.version} com.vmware.vim25 diff --git a/src/main/java/vmware/samples/common/authentication/VmcNsxAuthenticationHelper.java b/src/main/java/vmware/samples/common/authentication/VmcNsxAuthenticationHelper.java new file mode 100644 index 00000000000..d2a4c276769 --- /dev/null +++ b/src/main/java/vmware/samples/common/authentication/VmcNsxAuthenticationHelper.java @@ -0,0 +1,46 @@ +/* + * ******************************************************* + * Copyright VMware, Inc. 2019. All Rights Reserved. + * SPDX-License-Identifier: MIT + * ******************************************************* + * + * DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN, + * EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED + * WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, + * NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. + */ +package vmware.samples.common.authentication; + +import com.vmware.nsx_vmc.client.VmcNsxClients; +import com.vmware.vapi.client.ApiClient; + +/** + * Helper class which provides methods for creating a new ApiClient + * for VMC APIs + */ +public class VmcNsxAuthenticationHelper { + public static final String CSP_AUTHORIZATION_URL = "/csp/gateway/am/api/auth/api-tokens/authorize"; + + /** + * Instantiates an ApiClient using a refresh token which can be used for + * creating stubs. + * + * @param refreshToken + * refresh token of the user + * @param verifyServerCertificate + * if true, verify the server's certificate + * @param verifyServerHostname + * if true, verify the server's hostname + * @return + */ + public ApiClient newVmcNsxPolicyClient(String organizationId, String sddcId, + String refreshToken, boolean verifyServerCertificate, + boolean verifyServerHostname) { + return VmcNsxClients.custom() + .setRefreshToken(refreshToken.toCharArray()) + .setOrganizationId(organizationId).setSddcId(sddcId) + .setVerifyServerCertificate(verifyServerCertificate) + .setVerifyServerHostname(verifyServerHostname).build(); + } +} diff --git a/src/main/java/vmware/samples/vmc/networks/NsxTAuth.java b/src/main/java/vmware/samples/vmc/networks/NsxTAuth.java new file mode 100644 index 00000000000..6749267516b --- /dev/null +++ b/src/main/java/vmware/samples/vmc/networks/NsxTAuth.java @@ -0,0 +1,127 @@ +/* + * ******************************************************* + * Copyright VMware, Inc. 2018. All Rights Reserved. + * SPDX-License-Identifier: MIT + * ******************************************************* + * + * DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN, + * EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED + * WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, + * NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +package vmware.samples.vmc.networks; + +import java.util.Arrays; +import java.util.List; + +import org.apache.commons.cli.Option; + +import com.vmware.nsx_policy.Infra; +import com.vmware.nsx_policy.infra.Domains; +import com.vmware.nsx_policy.model.DomainListResult; +import com.vmware.nsx_vmc_app.infra.LinkedVpcs; +import com.vmware.nsx_vmc_app.model.LinkedVpcsListResult; +import com.vmware.vapi.client.ApiClient; + +import vmware.samples.common.VmcSamplesAbstractBase; +import vmware.samples.common.authentication.VmcNsxAuthenticationHelper; + +/*- + * This example shows how to authenticate to the VMC (VMware Cloud on AWS) + * service, using a VMC refresh token to obtain an authentication token that + * can then be used to authenticate to the NSX-T instance in a Software + * Defined Data Center (SDDC). It also shows how to list several types + * of entities. + */ +public class NsxTAuth extends VmcSamplesAbstractBase { + + private String orgId; + private String sddcId; + private ApiClient apiClient; + private Infra infraService; + private Domains domainsService; + private LinkedVpcs lvpcService; + + public static String VMC_SERVER = "vmc.vmware.com"; + public static String CSP_SERVER = "console.cloud.vmware.com"; + + /** + * Define the options specific to this sample and configure the sample using + * command-line arguments or a config file + * + * @param args command line arguments passed to the sample + */ + @Override + protected void parseArgs(String[] args) { + Option orgOption = Option.builder() + .longOpt("org_id") + .desc("Specify the organization id") + .argName("ORGANIZATION ID") + .required(true) + .hasArg() + .build(); + Option sddcOption = Option.builder() + .longOpt("sddc_id") + .desc("Specify the SDDC id") + .argName("SDDC ID") + .required(true) + .hasArg() + .build(); + List