Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: openapi query namespace support not fill item #83

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
*/
public interface NamespaceOpenApiService {

OpenNamespaceDTO getNamespace(String appId, String env, String clusterName, String namespaceName);
OpenNamespaceDTO getNamespace(String appId, String env, String clusterName, String namespaceName, boolean fillItemDetail);

List<OpenNamespaceDTO> getNamespaces(String appId, String env, String clusterName);
List<OpenNamespaceDTO> getNamespaces(String appId, String env, String clusterName, boolean fillItemDetail);

OpenAppNamespaceDTO createAppNamespace(OpenAppNamespaceDTO appNamespaceDTO);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,18 @@ public List<OpenAppDTO> getAppsByIds(List<String> appIds) {
}

/**
* Get the namespaces
* @deprecated use {@link ApolloOpenApiClient#getNamespaces(String, String, String, boolean)} instead
*/
public List<OpenNamespaceDTO> getNamespaces(String appId, String env, String clusterName) {
return namespaceService.getNamespaces(appId, env, clusterName);
return namespaceService.getNamespaces(appId, env, clusterName, true);
}

/**
* Get the namespaces
* @since 2.4.0
*/
public List<OpenNamespaceDTO> getNamespaces(String appId, String env, String clusterName, boolean fillItemDetail) {
return namespaceService.getNamespaces(appId, env, clusterName, fillItemDetail);
}

/**
Expand All @@ -125,10 +133,18 @@ public OpenClusterDTO createCluster(String env, OpenClusterDTO openClusterDTO) {
}

/**
* Get the namespace
* @deprecated use {@link ApolloOpenApiClient#getNamespace(String, String, String, String, boolean)} instead
*/
public OpenNamespaceDTO getNamespace(String appId, String env, String clusterName, String namespaceName) {
return namespaceService.getNamespace(appId, env, clusterName, namespaceName);
return namespaceService.getNamespace(appId, env, clusterName, namespaceName, true);
}

/**
* Get the namespace
* @since 2.4.0
*/
public OpenNamespaceDTO getNamespace(String appId, String env, String clusterName, String namespaceName, boolean fillItemDetail) {
return namespaceService.getNamespace(appId, env, clusterName, namespaceName, fillItemDetail);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public NamespaceOpenApiService(CloseableHttpClient client, String baseUrl, Gson
}

@Override
public OpenNamespaceDTO getNamespace(String appId, String env, String clusterName, String namespaceName) {
public OpenNamespaceDTO getNamespace(String appId, String env, String clusterName, String namespaceName, boolean fillItemDetail) {
if (Strings.isNullOrEmpty(clusterName)) {
clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT;
}
Expand All @@ -58,6 +58,8 @@ public OpenNamespaceDTO getNamespace(String appId, String env, String clusterNam
.clustersPathVal(clusterName)
.namespacesPathVal(namespaceName);

pathBuilder.addParam("fillItemDetail", fillItemDetail);

try (CloseableHttpResponse response = get(pathBuilder)) {
return gson.fromJson(EntityUtils.toString(response.getEntity()), OpenNamespaceDTO.class);
} catch (Throwable ex) {
Expand All @@ -68,7 +70,7 @@ public OpenNamespaceDTO getNamespace(String appId, String env, String clusterNam
}

@Override
public List<OpenNamespaceDTO> getNamespaces(String appId, String env, String clusterName) {
public List<OpenNamespaceDTO> getNamespaces(String appId, String env, String clusterName, boolean fillItemDetail) {
if (Strings.isNullOrEmpty(clusterName)) {
clusterName = ConfigConsts.CLUSTER_NAME_DEFAULT;
}
Expand All @@ -82,6 +84,8 @@ public List<OpenNamespaceDTO> getNamespaces(String appId, String env, String clu
.clustersPathVal(clusterName)
.customResource("namespaces");

pathBuilder.addParam("fillItemDetail", fillItemDetail);

try (CloseableHttpResponse response = get(pathBuilder)) {
return gson.fromJson(EntityUtils.toString(response.getEntity()), OPEN_NAMESPACE_DTO_LIST_TYPE);
} catch (Throwable ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void setUp() throws Exception {
public void testGetNamespace() throws Exception {
final ArgumentCaptor<HttpGet> request = ArgumentCaptor.forClass(HttpGet.class);

namespaceOpenApiService.getNamespace(someAppId, someEnv, someCluster, someNamespace);
namespaceOpenApiService.getNamespace(someAppId, someEnv, someCluster, someNamespace, true);

verify(httpClient, times(1)).execute(request.capture());

Expand All @@ -73,7 +73,7 @@ public void testGetNamespace() throws Exception {
public void testGetNamespaceWithError() throws Exception {
when(statusLine.getStatusCode()).thenReturn(404);

namespaceOpenApiService.getNamespace(someAppId, someEnv, someCluster, someNamespace);
namespaceOpenApiService.getNamespace(someAppId, someEnv, someCluster, someNamespace, true);
}

@Test
Expand All @@ -83,7 +83,7 @@ public void testGetNamespaces() throws Exception {

final ArgumentCaptor<HttpGet> request = ArgumentCaptor.forClass(HttpGet.class);

namespaceOpenApiService.getNamespaces(someAppId, someEnv, someCluster);
namespaceOpenApiService.getNamespaces(someAppId, someEnv, someCluster, true);

verify(httpClient, times(1)).execute(request.capture());

Expand All @@ -98,7 +98,7 @@ public void testGetNamespaces() throws Exception {
public void testGetNamespacesWithError() throws Exception {
when(statusLine.getStatusCode()).thenReturn(404);

namespaceOpenApiService.getNamespaces(someAppId, someEnv, someCluster);
namespaceOpenApiService.getNamespaces(someAppId, someEnv, someCluster, true);
}

@Test
Expand Down
Loading