Hi 

   I'm new to graylog and trying to implement PluginRestResource as a 
plugin. I can see the server start logs my plugin is loaded but i can't see 
the same in api-browser. How do i know if my service is deployed properly.

   Any example on PluginRestResource will really help. I have checked the 
documentation for AlarumCallBack

Thanks
-Gangadhar

-- 
You received this message because you are subscribed to the Google Groups 
"Graylog Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/graylog2/e613056f-4e26-4df3-8b4a-ae9cfeb789e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: org.graylog2.plugin.Plugin
Description: Binary data

package com.cisco.clip.rules;

import java.text.MessageFormat;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.graylog2.plugin.rest.PluginRestResource;
import org.graylog2.shared.rest.resources.RestResource;

import com.codahale.metrics.annotation.Timed;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;

/**
 * This is the plugin. Your class should implement one of the existing plugin
 * interfaces. (i.e. AlarmCallback, MessageInput, MessageOutput)
 */
@RequiresAuthentication
@Path("/clip/test")
@Produces("application/json")
@Consumes("application/json")
@Api(value = "Clip/Test", description = "Manage clip Rules")
public class RulesPluginResource extends RestResource implements PluginRestResource{
	@GET
    @Timed
    @Path("/{name}")
    @ApiOperation("Get the existing clip rule")
	public String greet(@ApiParam(name = "name", required = true)
    						@PathParam("name") String name){
		return MessageFormat.format("Welcome, {0} !!!", name  ); 
	}
	
	
}
package com.cisco.clip.rules;

import org.graylog2.plugin.PluginMetaData;
import org.graylog2.plugin.ServerStatus;
import org.graylog2.plugin.Version;

import java.net.URI;
import java.util.Collections;
import java.util.Set;

/**
 * Implement the PluginMetaData interface here.
 */
public class RulesPluginResourceMetaData implements PluginMetaData {
    @Override
    public String getUniqueId() {
        return "com.cisco.clip.rules.RulesPluginResourcePlugin";
    }

    @Override
    public String getName() {
        return "RulesPluginResource";
    }

    @Override
    public String getAuthor() {
        return "[email protected]";
    }

    @Override
    public URI getURL() {
        return URI.create("http://wikicentral.cisco.com/display/PROJECT/CLIP+-+Features";);
    }

    @Override
    public Version getVersion() {
        return new Version(0, 0, 0);
    }

    @Override
    public String getDescription() {
        return "Plugin for Clip Rules";
    }

    @Override
    public Version getRequiredVersion() {
        return new Version(0, 0, 0);
    }

    @Override
    public Set<ServerStatus.Capability> getRequiredCapabilities() {
        return Collections.emptySet();
    }
}
package com.cisco.clip.rules;

import org.graylog2.plugin.PluginConfigBean;
import org.graylog2.plugin.PluginModule;

import java.util.Collections;
import java.util.Set;

/**
 * Extend the PluginModule abstract class here to add you plugin to the system.
 */
public class RulesPluginResourceModule extends PluginModule {
    /**
     * Returns all configuration beans required by this plugin.
     *
     * Implementing this method is optional. The default method returns an empty {@link Set}.
     */
    @Override
    public Set<? extends PluginConfigBean> getConfigBeans() {
        return Collections.emptySet();
    }

    @Override
    protected void configure() {
        /*
         * Register your plugin types here.
         *
         * Examples:
         *
         * addMessageInput(Class<? extends MessageInput>);
         * addMessageFilter(Class<? extends MessageFilter>);
         * addMessageOutput(Class<? extends MessageOutput>);
         * addPeriodical(Class<? extends Periodical>);
         * addAlarmCallback(Class<? extends AlarmCallback>);
         * addInitializer(Class<? extends Service>);
         * addRestResource(Class<? extends PluginRestResource>);
         *
         *
         * Add all configuration beans returned by getConfigBeans():
         *
         * addConfigBeans();
         */
    	
    	addRestResource(RulesPluginResource.class);
    }
}
package com.cisco.clip.rules;

import org.graylog2.plugin.Plugin;
import org.graylog2.plugin.PluginMetaData;
import org.graylog2.plugin.PluginModule;

import java.util.Arrays;
import java.util.Collection;

/**
 * Implement the Plugin interface here.
 */
public class RulesPluginResourcePlugin implements Plugin {
    @Override
    public PluginMetaData metadata() {
        return new RulesPluginResourceMetaData();
    }

    @Override
    public Collection<PluginModule> modules () {
        return Arrays.<PluginModule>asList(new RulesPluginResourceModule());
    }
}

Reply via email to