org.openstack4j.openstack.gbp.internal.PolicyActionServiceImpl Maven / Gradle / Ivy
The newest version!
package org.openstack4j.openstack.gbp.internal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.List;
import java.util.Map;
import org.openstack4j.api.gbp.PolicyActionService;
import org.openstack4j.model.common.ActionResponse;
import org.openstack4j.model.gbp.PolicyAction;
import org.openstack4j.model.gbp.PolicyActionUpdate;
import org.openstack4j.openstack.gbp.domain.GbpPolicyAction;
import org.openstack4j.openstack.gbp.domain.GbpPolicyAction.PolicyActions;
import org.openstack4j.openstack.networking.internal.BaseNetworkingServices;
/**
* Policy Action API Implementation
*
* @author vinod borole
*/
public class PolicyActionServiceImpl extends BaseNetworkingServices implements PolicyActionService {
/**
* {@inheritDoc}
*/
@Override
public List extends PolicyAction> list() {
return get(PolicyActions.class, uri("/grouppolicy/policy_actions")).execute().getList();
}
/**
* {@inheritDoc}
*/
@Override
public List extends PolicyAction> list(Map filteringParams) {
Invocation policyactionInvocation = buildInvocation(filteringParams);
return policyactionInvocation.execute().getList();
}
private Invocation buildInvocation(Map filteringParams) {
Invocation policyactionInvocation = get(PolicyActions.class, "/grouppolicy/policy_actions");
if (filteringParams == null) {
return policyactionInvocation;
}
if (filteringParams != null) {
for (Map.Entry entry : filteringParams.entrySet()) {
policyactionInvocation = policyactionInvocation.param(entry.getKey(), entry.getValue());
}
}
return policyactionInvocation;
}
/**
* {@inheritDoc}
*/
@Override
public PolicyAction get(String id) {
checkNotNull(id);
return get(GbpPolicyAction.class, uri("/grouppolicy/policy_actions/%s", id)).execute();
}
/**
* {@inheritDoc}
*/
@Override
public ActionResponse delete(String id) {
checkNotNull(id);
return deleteWithResponse(uri("/grouppolicy/policy_actions/%s", id)).execute();
}
/**
* {@inheritDoc}
*/
@Override
public PolicyAction create(PolicyAction policyAction) {
return post(GbpPolicyAction.class, uri("/grouppolicy/policy_actions")).entity(policyAction).execute();
}
/**
* {@inheritDoc}
*/
@Override
public PolicyAction update(String policyActionId, PolicyActionUpdate policyAction) {
checkNotNull(policyActionId);
checkNotNull(policyAction);
return put(GbpPolicyAction.class, uri("/grouppolicy/policy_actions/%s", policyActionId)).entity(policyAction).execute();
}
}