Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Apollo 2.5.0
* [Feature: Provide a new open API to return the organization list](https://github.com/apolloconfig/apollo/pull/5365)
* [Refactor: Exception handler adds root cause information](https://github.com/apolloconfig/apollo/pull/5367)
* [Feature: Enhanced parameter verification for edit item](https://github.com/apolloconfig/apollo/pull/5376)
* [Feature: Added a new feature to get instance count by namespace.](https://github.com/apolloconfig/apollo/pull/5381)

------------------
All issues and pull requests are [here](https://github.com/apolloconfig/apollo/milestone/16?closed=1)
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2024 Apollo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.ctrip.framework.apollo.openapi.server.service;

import com.ctrip.framework.apollo.openapi.api.InstanceOpenApiService;
Comment thread
nobodyiam marked this conversation as resolved.
import com.ctrip.framework.apollo.portal.environment.Env;
import com.ctrip.framework.apollo.portal.service.InstanceService;
import org.springframework.stereotype.Service;

@Service
public class ServerInstanceOpenApiService implements InstanceOpenApiService {

private final InstanceService instanceService;

public ServerInstanceOpenApiService(InstanceService instanceService) {
this.instanceService = instanceService;
}

@Override
public int getInstanceCountByNamespace(String appId, String env, String clusterName, String namespaceName) {
return instanceService.getInstanceCountByNamespace(appId, Env.valueOf(env), clusterName, namespaceName);
}
Comment thread
nobodyiam marked this conversation as resolved.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2024 Apollo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.ctrip.framework.apollo.openapi.v1.controller;

import com.ctrip.framework.apollo.openapi.api.InstanceOpenApiService;
Comment thread
nobodyiam marked this conversation as resolved.
import org.springframework.web.bind.annotation.*;

@RestController("openapiInstanceController")
@RequestMapping("/openapi/v1/envs/{env}")
public class InstanceController {
private final InstanceOpenApiService instanceOpenApiService;

public InstanceController(InstanceOpenApiService instanceOpenApiService) {
this.instanceOpenApiService = instanceOpenApiService;
}

@GetMapping(value = "/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/instances")
public int getInstanceCountByNamespace(@PathVariable String appId, @PathVariable String env,
@PathVariable String clusterName, @PathVariable String namespaceName) {
return this.instanceOpenApiService.getInstanceCountByNamespace(appId, env, clusterName, namespaceName);
}
}
Comment thread
nobodyiam marked this conversation as resolved.