All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.fallwizard.rabbitmq.mgmt.PermissionOperations Maven / Gradle / Ivy

The newest version!
package io.github.fallwizard.rabbitmq.mgmt;

import com.google.common.base.Optional;
import io.github.fallwizard.rabbitmq.mgmt.model.Permission;

import java.util.Collection;


public class PermissionOperations extends BaseFluent {

	public PermissionOperations(HttpContext httpContext, RabbitMgmtService mgmtService) {
		super(httpContext, mgmtService);
	}

	public Collection all(){
		
		return HTTP.GET("/permissions", PERMISSION_COLLECTION).get();
	}
	
	public Optional get(String user){
		
		return get("/", user);
	}
	
	public Optional get(String vhost, String user){
		
		return HTTP.GET(String.format("/permissions/%s/%s", encodeSlashes(vhost), user),  PERMISSION);
	}
	
	public PermissionOperations set(Permission permission){
		
		HTTP.PUT(String.format("/permissions/%s/%s", 
			encodeSlashes(permission.getVhost()), permission.getUser()), permission);
		
		return this;
	}
	
	public PermissionOperations remove(String user){
		
		return remove(user);
	}
	
	public PermissionOperations remove(String vhost, String user){
		
		String url = String.format("/permissions/%s/%s", encodeSlashes(vhost), user);
		
		HTTP.DELETE(url);
		
		return this;
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy