|
1 | 1 | package com.contentstack.sdk; |
2 | 2 |
|
| 3 | +import java.util.Map; |
3 | 4 | import java.util.Objects; |
4 | 5 |
|
5 | 6 | /** |
@@ -98,6 +99,60 @@ private static void validateCredentials(String stackApiKey, String deliveryToken |
98 | 99 | } |
99 | 100 | } |
100 | 101 |
|
| 102 | + /** |
| 103 | + * Returns the Contentstack API URL for the given region and service. |
| 104 | + * |
| 105 | + * <p>Delegates to {@link Endpoint#getContentstackEndpoint(String, String)} — provided as a |
| 106 | + * convenience so callers can reach endpoint resolution through the same top-level class they |
| 107 | + * use to create stacks. |
| 108 | + * |
| 109 | + * @param region region ID or alias (e.g. {@code "na"}, {@code "eu"}, {@code "azure-na"}) |
| 110 | + * @param service service key (e.g. {@code "contentDelivery"}, {@code "contentManagement"}) |
| 111 | + * @return full URL including {@code https://} scheme |
| 112 | + * @throws IllegalArgumentException if the region or service is not recognised |
| 113 | + */ |
| 114 | + public static String getContentstackEndpoint(String region, String service) { |
| 115 | + return Endpoint.getContentstackEndpoint(region, service); |
| 116 | + } |
| 117 | + |
| 118 | + /** |
| 119 | + * Returns the Contentstack API URL for the given region and service, optionally stripping |
| 120 | + * the {@code https://} scheme. |
| 121 | + * |
| 122 | + * @param region region ID or alias |
| 123 | + * @param service service key |
| 124 | + * @param omitHttps when {@code true}, returns the bare host without {@code https://} |
| 125 | + * @return URL or bare host |
| 126 | + * @throws IllegalArgumentException if the region or service is not recognised |
| 127 | + */ |
| 128 | + public static String getContentstackEndpoint(String region, String service, boolean omitHttps) { |
| 129 | + return Endpoint.getContentstackEndpoint(region, service, omitHttps); |
| 130 | + } |
| 131 | + |
| 132 | + /** |
| 133 | + * Returns all service endpoints for the given region as an ordered map of service key to URL. |
| 134 | + * |
| 135 | + * @param region region ID or alias |
| 136 | + * @return map of service key → full URL |
| 137 | + * @throws IllegalArgumentException if the region is not recognised |
| 138 | + */ |
| 139 | + public static Map<String, String> getContentstackEndpoints(String region) { |
| 140 | + return Endpoint.getAllEndpoints(region); |
| 141 | + } |
| 142 | + |
| 143 | + /** |
| 144 | + * Returns all service endpoints for the given region, optionally stripping the |
| 145 | + * {@code https://} scheme from every URL. |
| 146 | + * |
| 147 | + * @param region region ID or alias |
| 148 | + * @param omitHttps when {@code true}, returns bare hosts without {@code https://} |
| 149 | + * @return map of service key → URL or bare host |
| 150 | + * @throws IllegalArgumentException if the region is not recognised |
| 151 | + */ |
| 152 | + public static Map<String, String> getContentstackEndpoints(String region, boolean omitHttps) { |
| 153 | + return Endpoint.getAllEndpoints(region, omitHttps); |
| 154 | + } |
| 155 | + |
101 | 156 | private static Stack initializeStack(String stackApiKey, String deliveryToken, String environment, Config config) { |
102 | 157 | Stack stack = new Stack(stackApiKey.trim()); |
103 | 158 | stack.setHeader("api_key", stackApiKey); |
|
0 commit comments