Skip to content
This repository was archived by the owner on Dec 23, 2017. It is now read-only.

Commit cc359ad

Browse files
committed
Add resource to return the plugin configuration
1 parent 2ee23c2 commit cc359ad

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Copyright (C) 2015 Graylog, Inc. ([email protected])
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.graylog.plugins.usagestatistics;
18+
19+
import com.fasterxml.jackson.annotation.JsonAutoDetect;
20+
import com.fasterxml.jackson.annotation.JsonProperty;
21+
import com.google.auto.value.AutoValue;
22+
23+
@JsonAutoDetect
24+
@AutoValue
25+
public abstract class UsageStatsConfigurationResponse {
26+
@JsonProperty("enabled")
27+
public abstract boolean isEnabled();
28+
29+
public static UsageStatsConfigurationResponse create(@JsonProperty("enabled") boolean isEnabled) {
30+
return new AutoValue_UsageStatsConfigurationResponse(isEnabled);
31+
}
32+
}

src/main/java/org/graylog/plugins/usagestatistics/UsageStatsResource.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,24 @@
3838
public class UsageStatsResource extends RestResource implements PluginRestResource {
3939
private final UsageStatsNodeService usageStatsNodeService;
4040
private final UsageStatsClusterService usageStatsClusterService;
41+
private final UsageStatsConfiguration configuration;
4142

4243
@Inject
4344
public UsageStatsResource(UsageStatsNodeService usageStatsNodeService,
44-
UsageStatsClusterService usageStatsClusterService) {
45+
UsageStatsClusterService usageStatsClusterService,
46+
UsageStatsConfiguration configuration) {
4547
this.usageStatsNodeService = usageStatsNodeService;
4648
this.usageStatsClusterService = usageStatsClusterService;
49+
this.configuration = configuration;
50+
}
51+
52+
@GET
53+
@Path("config")
54+
@Timed
55+
@ApiOperation(value = "Show configuration for the anonymous usage statistics plugin")
56+
@Produces(MediaType.APPLICATION_JSON)
57+
public UsageStatsConfigurationResponse showConfig() {
58+
return UsageStatsConfigurationResponse.create(configuration.isEnabled());
4759
}
4860

4961
@GET

0 commit comments

Comments
 (0)