com.shapestone.authorization.client.AuthorizationClient Maven / Gradle / Ivy
package com.shapestone.authorization.client;
import com.shapestone.rest.jersey.hystrix.rx.HystrixRxCommand;
import com.shapestone.rest.jersey.hystrix.rx.HystrixRxMethod;
import com.shapestone.authorization.*;
import com.shapestone.result.Result;
import rx.Observable;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.GenericType;
import java.util.List;
import static java.util.UUID.randomUUID;
import static javax.ws.rs.client.Entity.entity;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static org.glassfish.jersey.client.rx.rxjava.RxObservable.from;
/**
* Name: Michael Williams
* Date: 10/29/16.
*/
public class AuthorizationClient {
private AuthorizationClientData authorizationClientData;
private Client client;
public AuthorizationClient(AuthorizationClientData authorizationClientData, Client client) {
this.authorizationClientData = authorizationClientData;
this.client = client;
}
public Observable canCreateOnResourceName(String partyId, String customerPartyId, String resourceName) {
return this.canCreateOnResourceName(partyId, customerPartyId, resourceName, null);
}
public Observable canCreateOnResourceName(String partyId, String customerPartyId, String resourceName, String correlationId) {
return this.isAuthorizeOnResourceName(partyId, customerPartyId, resourceName, "CREATE", correlationId);
}
public Observable canCreateOnResourceName(List partyIds, String customerPartyId, String resourceName) {
return this.canCreateOnResourceName(partyIds, customerPartyId, resourceName, null);
}
public Observable canCreateOnResourceName(List partyIds, String customerPartyId, String resourceName, String correlationId) {
return this.isAuthorizeOnResourceName(partyIds, customerPartyId, resourceName, "CREATE", correlationId);
}
public Observable canCreateChildNodeOnResourceName(List partyIds, String customerPartyId, String resourceName) {
return this.canCreateChildNodeOnResourceName(partyIds, customerPartyId, resourceName, null);
}
public Observable canCreateChildNodeOnResourceName(List partyIds, String customerPartyId, String resourceName, String correlationId) {
return this.isAuthorizeOnResourceName(partyIds, customerPartyId, resourceName, "CREATE_CHILD_NODE", correlationId);
}
public Observable canCreateChildLeafOnResourceName(List partyIds, String customerPartyId, String resourceName) {
return this.canCreateChildLeafOnResourceName(partyIds, customerPartyId, resourceName, null);
}
public Observable canCreateChildLeafOnResourceName(List partyIds, String customerPartyId, String resourceName, String correlationId) {
return this.isAuthorizeOnResourceName(partyIds, customerPartyId, resourceName, "CREATE_CHILD_LEAF", correlationId);
}
public Observable canCreateOnResourceExternalId(String partyId, String customerPartyId, String resourceExternalId) {
return this.canCreateOnResourceExternalId(partyId, customerPartyId, resourceExternalId, null);
}
public Observable canCreateOnResourceExternalId(String partyId, String customerPartyId, String resourceExternalId, String correlationId) {
return this.isAuthorizeOnResourceExternalId(partyId, customerPartyId, resourceExternalId, "CREATE", correlationId);
}
public Observable canCreateOnResourceExternalId(List partyIds, String customerPartyId, String resourceExternalId) {
return this.canCreateOnResourceExternalId(partyIds, customerPartyId, resourceExternalId, null);
}
public Observable canCreateOnResourceExternalId(List partyIds, String customerPartyId, String resourceExternalId, String correlationId) {
return this.isAuthorizeOnResourceExternalId(partyIds, customerPartyId, resourceExternalId, "CREATE", correlationId);
}
public Observable canCreateChildNodeOnResourceExternalId(List partyIds, String customerPartyId, String resourceExternalId) {
return this.canCreateChildNodeOnResourceExternalId(partyIds, customerPartyId, resourceExternalId, null);
}
public Observable canCreateChildNodeOnResourceExternalId(List partyIds, String customerPartyId, String resourceExternalId, String correlationId) {
return this.isAuthorizeOnResourceExternalId(partyIds, customerPartyId, resourceExternalId, "CREATE_CHILD_NODE", correlationId);
}
public Observable canCreateChildLeafOnResourceExternalId(List partyIds, String customerPartyId, String resourceExternalId) {
return this.canCreateChildLeafOnResourceExternalId(partyIds, customerPartyId, resourceExternalId, null);
}
public Observable canCreateChildLeafOnResourceExternalId(List partyIds, String customerPartyId, String resourceExternalId, String correlationId) {
return this.isAuthorizeOnResourceExternalId(partyIds, customerPartyId, resourceExternalId, "CREATE_CHILD_LEAF", correlationId);
}
public Observable canReadOnResourceName(String partyId, String customerPartyId, String resourceName) {
return this.canCreateOnResourceName(partyId, customerPartyId, resourceName);
}
public Observable canReadOnResourceName(String partyId, String customerPartyId, String resourceName, String correlationId) {
return this.isAuthorizeOnResourceName(partyId, customerPartyId, resourceName, "READ", correlationId);
}
public Observable canReadOnResourceName(List partyIds, String customerPartyId, String resourceName) {
return this.canCreateOnResourceName(partyIds, customerPartyId, resourceName);
}
public Observable canReadOnResourceName(List partyIds, String customerPartyId, String resourceName, String correlationId) {
return this.isAuthorizeOnResourceName(partyIds, customerPartyId, resourceName, "READ", correlationId);
}
public Observable canReadOnResourceExternalId(String partyId, String customerPartyId, String resourceExternalId) {
return this.canCreateOnResourceExternalId(partyId, customerPartyId, resourceExternalId);
}
public Observable canReadOnResourceExternalId(String partyId, String customerPartyId, String resourceExternalId, String correlationId) {
return this.isAuthorizeOnResourceExternalId(partyId, customerPartyId, resourceExternalId, "READ", correlationId);
}
public Observable canReadOnResourceExternalId(List partyIds, String customerPartyId, String resourceExternalId) {
return this.canCreateOnResourceExternalId(partyIds, customerPartyId, resourceExternalId);
}
public Observable canReadOnResourceExternalId(List partyIds, String customerPartyId, String resourceExternalId, String correlationId) {
return this.isAuthorizeOnResourceExternalId(partyIds, customerPartyId, resourceExternalId, "READ", correlationId);
}
public Observable canUpdateOnResourceName(String partyId, String customerPartyId, String resourceName) {
return this.canCreateOnResourceName(partyId, customerPartyId, resourceName);
}
public Observable canUpdateOnResourceName(String partyId, String customerPartyId, String resourceName, String correlationId) {
return this.isAuthorizeOnResourceName(partyId, customerPartyId, resourceName, "UPDATE", correlationId);
}
public Observable canUpdateOnResourceName(List partyIds, String customerPartyId, String resourceName) {
return this.canCreateOnResourceName(partyIds, customerPartyId, resourceName);
}
public Observable canUpdateOnResourceName(List partyIds, String customerPartyId, String resourceName, String correlationId) {
return this.isAuthorizeOnResourceName(partyIds, customerPartyId, resourceName, "UPDATE", correlationId);
}
public Observable canUpdateOnResourceExternalId(String partyId, String customerPartyId, String resourceExternalId) {
return this.canCreateOnResourceExternalId(partyId, customerPartyId, resourceExternalId);
}
public Observable canUpdateOnResourceExternalId(String partyId, String customerPartyId, String resourceExternalId, String correlationId) {
return this.isAuthorizeOnResourceExternalId(partyId, customerPartyId, resourceExternalId, "UPDATE", correlationId);
}
public Observable canUpdateOnResourceExternalId(List partyIds, String customerPartyId, String resourceExternalId) {
return this.canCreateOnResourceExternalId(partyIds, customerPartyId, resourceExternalId);
}
public Observable canUpdateOnResourceExternalId(List partyIds, String customerPartyId, String resourceExternalId, String correlationId) {
return this.isAuthorizeOnResourceExternalId(partyIds, customerPartyId, resourceExternalId, "UPDATE", correlationId);
}
public Observable canDeleteOnResourceName(String partyId, String customerPartyId, String resourceName) {
return this.canCreateOnResourceName(partyId, customerPartyId, resourceName);
}
public Observable canDeleteOnResourceName(String partyId, String customerPartyId, String resourceName, String correlationId) {
return this.isAuthorizeOnResourceName(partyId, customerPartyId, resourceName, "DELETE", correlationId);
}
public Observable canDeleteOnResourceName(List partyIds, String customerPartyId, String resourceName) {
return this.canCreateOnResourceName(partyIds, customerPartyId, resourceName);
}
public Observable canDeleteOnResourceName(List partyIds, String customerPartyId, String resourceName, String correlationId) {
return this.isAuthorizeOnResourceName(partyIds, customerPartyId, resourceName, "DELETE", correlationId);
}
public Observable canDeleteOnResourceExternalId(String partyId, String customerPartyId, String resourceExternalId) {
return this.canCreateOnResourceName(partyId, customerPartyId, resourceExternalId);
}
public Observable canDeleteOnResourceExternalId(String partyId, String customerPartyId, String resourceExternalId, String correlationId) {
return this.isAuthorizeOnResourceName(partyId, customerPartyId, resourceExternalId, "DELETE", correlationId);
}
public Observable canDeleteOnResourceExternalId(List partyIds, String customerPartyId, String resourceExternalId) {
return this.canCreateOnResourceName(partyIds, customerPartyId, resourceExternalId);
}
public Observable canDeleteOnResourceExternalId(List partyIds, String customerPartyId, String resourceExternalId, String correlationId) {
return this.isAuthorizeOnResourceName(partyIds, customerPartyId, resourceExternalId, "DELETE", correlationId);
}
public Observable isAuthorizeOnResourceName(String partyId, String customerPartyId, String resourceName, String permissionName) {
return this.isAuthorizeOnResourceName(partyId, customerPartyId, resourceName, permissionName, null);
}
public Observable isAuthorizeOnResourceName(String partyId, String customerPartyId, String resourceName, String permissionName, String correlationId) {
final HystrixRxMethod> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/parties/{partyId}/is-authorize-on-resource-name")
.resolveTemplate("partyId", partyId)
.queryParam("resourceName", resourceName)
.queryParam("permissionName", permissionName)
.request()
.header("customerPartyId", customerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.post(entity("", APPLICATION_JSON_TYPE), Boolean.class);
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "authorizationClient.isAuthorizeOnResourceName").observe();
}
public Observable isAuthorizeOnResourceName(List partyIds, String customerPartyId, String resourceName, String permissionName) {
return this.isAuthorizeOnResourceName(partyIds, customerPartyId, resourceName, permissionName, null);
}
public Observable isAuthorizeOnResourceName(List partyIds, String customerPartyId, String resourceName, String permissionName, String correlationId) {
final HystrixRxMethod> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/parties/is-authorize-on-resource-name")
.queryParam("partyIds", partyIds.toArray())
.queryParam("resourceName", resourceName)
.queryParam("permissionName", permissionName)
.request()
.header("customerPartyId", customerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.post(Entity.entity(null, APPLICATION_JSON_TYPE), Boolean.class);
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "isAuthorizeOnResourceName").observe();
}
public Observable isAuthorizeOnResourceExternalId(String partyId, String customerPartyId, String resourceExternalId, String permissionName) {
return isAuthorizeOnResourceExternalId(partyId, customerPartyId, resourceExternalId, permissionName, null);
}
public Observable isAuthorizeOnResourceExternalId(String partyId, String customerPartyId, String resourceExternalId, String permissionName, String correlationId) {
final HystrixRxMethod> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/parties/{partyId}/is-authorize-on-resource-external-id")
.resolveTemplate("partyId", partyId)
.queryParam("resourceExternalId", resourceExternalId)
.queryParam("permissionName", permissionName)
.request()
.header("customerPartyId", customerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.post(Entity.entity(null, APPLICATION_JSON_TYPE), Boolean.class);
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "isAuthorizeOnResourceExternalId").observe();
}
public Observable isAuthorizeOnResourceExternalId(List partyIds, String customerPartyId, String resourceExternalId, String permissionName) {
return isAuthorizeOnResourceExternalId(partyIds, customerPartyId, resourceExternalId, permissionName, null);
}
public Observable isAuthorizeOnResourceExternalId(List partyIds, String customerPartyId, String resourceExternalId, String permissionName, String correlationId) {
final HystrixRxMethod> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/parties/is-authorize-on-resource-external-id")
.queryParam("partyIds", partyIds.toArray())
.queryParam("resourceExternalId", resourceExternalId)
.queryParam("permissionName", permissionName)
.request()
.header("customerPartyId", customerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.post(Entity.entity(null, APPLICATION_JSON_TYPE), Boolean.class);
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "isAuthorizeOnResourceExternalId").observe();
}
public Observable addPermission(Permission permission) {
return addPermission(permission, null);
}
public Observable addPermission(Permission permission, String correlationId) {
final HystrixRxMethod> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/permissions")
.request()
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.post(entity(permission, APPLICATION_JSON_TYPE), Permission.class);
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "addPermission").observe();
}
public Observable>> addPermissions(List permissions) {
return addPermissions(permissions, null);
}
public Observable>> addPermissions(List permissions, String correlationId) {
final HystrixRxMethod>>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/permissions/batch")
.request()
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.post(entity(permissions, APPLICATION_JSON_TYPE), new GenericType>>(){});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "addPermissions").observe();
}
public Observable getPermissionById(String permissionId) {
return getPermissionById(permissionId, null);
}
public Observable getPermissionById(String permissionId, String correlationId) {
final HystrixRxMethod> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/permissions/{permissionId}")
.resolveTemplate("permissionId", permissionId)
.request()
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(Permission.class);
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getPermissionById").observe();
}
public Observable> getPermissionsByIds(List permissionIds) {
return getPermissionsByIds(permissionIds, null);
}
public Observable> getPermissionsByIds(List permissionIds, String correlationId) {
final HystrixRxMethod>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/permissions")
.queryParam("permissionIds", permissionIds.toArray())
.request()
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(new GenericType>() {});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getPermissionsByIds").observe();
}
public Observable> getPermissionsByOwnerPartyId(String ownerPartyId, String correlationId) {
final HystrixRxMethod>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/permissions/parties/{ownerPartyId}")
.resolveTemplate("ownerPartyId", ownerPartyId)
.request()
.header("ownerPartyId", ownerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(new GenericType>() {});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getPermissionsByOwnerPartyId").observe();
}
public Observable getResourceById(String resourceId, String correlationId) {
final HystrixRxMethod> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resources/{resourceId}")
.resolveTemplate("resourceId", resourceId)
.request()
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(Resource.class);
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getResourceById").observe();
}
public Observable> getResourcesByIds(List resourcesIds, String correlationId) {
final HystrixRxMethod>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resources")
.queryParam("resourceIds", resourcesIds.toArray())
.request()
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(new GenericType>(){});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getResourcesByIds").observe();
}
public Observable> getResources(String correlationId) {
final HystrixRxMethod>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resources")
.queryParam("resourceIds", new Object[]{})
.request()
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(new GenericType>(){});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getResourcesByIds").observe();
}
public Observable> getResourcesByOwnerPartyId(String ownerPartyId, String correlationId) {
final HystrixRxMethod>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resources/parties/{ownerPartyId}")
.resolveTemplate("ownerPartyId", ownerPartyId)
.request()
.header("ownerPartyId", ownerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(new GenericType>(){});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getResourcesByOwnerPartyId").observe();
}
public Observable addResource(Resource resource) {
return addResource(resource, null);
}
public Observable addResource(Resource resource, String correlationId) {
final HystrixRxMethod> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resources")
.request()
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.post(entity(resource, APPLICATION_JSON_TYPE), Resource.class);
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "addResource").observe();
}
public Observable>> addResources(List resources) {
return addResources(resources, null);
}
public Observable>> addResources(List resources, String correlationId) {
final HystrixRxMethod>>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resources/batch")
.request()
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.post(entity(resources, APPLICATION_JSON_TYPE), new GenericType>>(){});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "addResources").observe();
}
public Observable> getResourcePermissionsByIds(List grantIds) {
return getResourcePermissionsByIds(grantIds, null);
}
public Observable> getResourcePermissionsByIds(List resourcePermissionIds, String correlationId) {
final HystrixRxMethod>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resource-permissions")
.queryParam("resourcePermissionIds", resourcePermissionIds.toArray())
.request()
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(new GenericType>() {});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getResourcePermissionsByIds").observe();
}
public Observable> getResourcePermissionsByOwnerPartyId(String ownerPartyId, String correlationId) {
final HystrixRxMethod>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resource-permissions/parties/{ownerPartyId}")
.resolveTemplate("ownerPartyId", ownerPartyId)
.request()
.header("ownerPartyId", ownerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(new GenericType>() {});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getResourcePermissionsByOwnerPartyId").observe();
}
public Observable getResourcePermission(String resourcePermissionId) {
return getResourcePermission(resourcePermissionId, null);
}
public Observable getResourcePermission(String resourcePermissionId, String correlationId) {
final HystrixRxMethod> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resource-permissions/{resourcePermissionId}")
.resolveTemplate("resourcePermissionId", resourcePermissionId)
.request()
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(ResourcePermission.class);
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getResourcePermission").observe();
}
public Observable addResourcePermission(ResourcePermission resourcePermission) {
return addResourcePermission(resourcePermission, null);
}
public Observable addResourcePermission(ResourcePermission resourcePermission, String correlationId) {
final HystrixRxMethod> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resource-permissions")
.request()
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.post(entity(resourcePermission, APPLICATION_JSON_TYPE), ResourcePermission.class);
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "addResourcePermission").observe();
}
public Observable>> addResourcePermissions(List resourcePermissions) {
return addResourcePermissions(resourcePermissions, null);
}
public Observable>> addResourcePermissions(List resourcePermissions, String correlationId) {
final HystrixRxMethod>>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resource-permissions/batch")
.request()
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.post(entity(resourcePermissions, APPLICATION_JSON_TYPE), new GenericType>>(){});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "addResourcePermissions").observe();
}
public Observable> getGrantsByIds(List grantIds) {
return getGrantsByIds(grantIds, null);
}
public Observable> getGrantsByIds(List grantIds, String correlationId) {
final HystrixRxMethod>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/grants")
.queryParam("grantIds", grantIds.toArray())
.request()
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(new GenericType>() {});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getGrantsByIds").observe();
}
public Observable> getGrantsByPartyIds(List partyIds, String ownerPartyId, String correlationId) {
final HystrixRxMethod>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/grants/parties")
.queryParam("partyIds", partyIds.toArray())
.request()
.header("ownerPartyId", ownerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(new GenericType>() {});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getGrantsByPartyIds").observe();
}
public Observable> getGrantsByOwnerPartyId(String ownerPartyId, String correlationId) {
final HystrixRxMethod>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/grants/{ownerPartyId}")
.queryParam("ownerPartyId", ownerPartyId)
.request()
.header("ownerPartyId", ownerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(new GenericType>() {});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getGrantsByIds").observe();
}
public Observable getGrant(String grantId) {
return getGrant(grantId, null);
}
public Observable getGrant(String grantId, String correlationId) {
final HystrixRxMethod> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/grants/{grantId}")
.resolveTemplate("grantId", grantId)
.request()
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(Grant.class);
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getGrant").observe();
}
public Observable addGrant(Grant grant) {
return addGrant(grant, null);
}
public Observable addGrant(Grant grant, String correlationId) {
final HystrixRxMethod> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/grants")
.request()
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.post(entity(grant, APPLICATION_JSON_TYPE), Grant.class);
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "addGrant").observe();
}
public Observable>> addGrants(List grants) {
return addGrants(grants, null);
}
public Observable>> addGrants(List grants, String correlationId) {
final HystrixRxMethod>>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/grants/batch")
.request()
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.post(entity(grants, APPLICATION_JSON_TYPE), new GenericType>>(){});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "addGrants").observe();
}
public Observable addResourcesCopyGrants(Resource resource, String resourceExternalId, String customerPartyId, String correlationId) {
final HystrixRxMethod> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resources/{fromResourceExternalId}")
.resolveTemplate("fromResourceExternalId", resourceExternalId)
.request()
.header("customerPartyId", customerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.post(entity(resource, APPLICATION_JSON_TYPE), ResourceGrantResult.class);
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "addResourcesCopyGrants").observe();
}
public Observable addResourcePermissionsGrants(ResourceTypeGrantRequest resourceTypeGrantRequest,
String customerPartyId, String correlationId) {
final HystrixRxMethod> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resources/permissions/grants/defaults")
.request()
.header("customerPartyId", customerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.post(entity(resourceTypeGrantRequest, APPLICATION_JSON_TYPE), ResourceGrantResult.class);
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "addResourcePermissionsGrants").observe();
}
public Observable deleteResourceGrants(String resourceExternalId, String customerPartyId, String correlationId) {
final HystrixRxMethod> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resources/{resourceExternalId}/grants")
.resolveTemplate("resourceExternalId", resourceExternalId)
.request()
.header("customerPartyId", customerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.delete(ResourceGrantResult.class);
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "deleteResourceGrants").observe();
}
public Observable addResourceType(ResourceType resourceType, String customerPartyId, String correlationId) {
final HystrixRxMethod> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resource-types")
.request()
.header("customerPartyId", customerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.post(entity(resourceType, APPLICATION_JSON_TYPE), ResourceType.class);
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "addResourceType").observe();
}
public Observable>> addResourceTypes(List resourceTypes, String customerPartyId, String correlationId) {
final HystrixRxMethod>>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resource-types/batch")
.request()
.header("customerPartyId", customerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.post(entity(resourceTypes, APPLICATION_JSON_TYPE), new GenericType>>(){});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "addResourceTypes").observe();
}
public Observable getResourceTypeById(String resourceTypeId, String customerPartyId, String correlationId) {
final HystrixRxMethod> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resource-types/{resourceTypeId}")
.resolveTemplate("resourceTypeId", resourceTypeId)
.request()
.header("customerPartyId", customerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(ResourceType.class);
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getResourceTypeById").observe();
}
public Observable getResourceByOwnerPartyId(String ownerPartyId, String correlationId) {
final HystrixRxMethod> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resource-types/parties/{ownerPartyId}")
.resolveTemplate("ownerPartyId", ownerPartyId)
.request()
.header("ownerPartyId", ownerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(ResourceType.class);
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getResourceByOwnerPartyId").observe();
}
public Observable getResourceTypeByName(String name, String customerPartyId, String correlationId) {
final HystrixRxMethod> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resource-types/{name}/find-by-name")
.resolveTemplate("name", name)
.request()
.header("customerPartyId", customerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(ResourceType.class);
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getResourceTypeByName").observe();
}
public Observable> getResourceTypesByIds(List resourceTypeIds, String customerPartyId, String correlationId) {
final HystrixRxMethod>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resource-types")
.queryParam("resourceTypeIds", resourceTypeIds.toArray())
.request()
.header("customerPartyId", customerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(new GenericType>(){});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getResourceTypesByIds").observe();
}
public Observable> getResourceTypesByOwnerPartyId(String ownerPartyId, String correlationId) {
final HystrixRxMethod>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resource-types/parties/{ownerPartyId}")
.resolveTemplate("ownerPartyId", ownerPartyId)
.request()
.header("ownerPartyId", ownerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(new GenericType>(){});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getResourceTypesByIds").observe();
}
public Observable> deleteResourceTypesById(String resourceTypeId, String customerPartyId, String correlationId) {
final HystrixRxMethod>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resource-types")
.queryParam("resourceTypeId", resourceTypeId)
.request()
.header("customerPartyId", customerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(new GenericType>(){});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "deleteResourceTypesById").observe();
}
public Observable addResourceTypePermission(ResourceTypePermission resourceTypePermission, String customerPartyId, String correlationId) {
final HystrixRxMethod> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resource-type-permissions")
.request()
.header("customerPartyId", customerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.post(entity(resourceTypePermission, APPLICATION_JSON_TYPE), ResourceTypePermission.class);
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "addResourceTypePermission").observe();
}
public Observable>> addResourceTypePermissions(List resourceTypePermissions, String customerPartyId, String correlationId) {
final HystrixRxMethod>>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resource-type-permissions/batch")
.request()
.header("customerPartyId", customerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.post(entity(resourceTypePermissions, APPLICATION_JSON_TYPE), new GenericType>>(){});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "addResourceTypePermissions").observe();
}
public Observable getResourceTypePermissionById(String resourceTypePermissionId, String customerPartyId, String correlationId) {
final HystrixRxMethod> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resource-type-permissions/{resourceTypeId}")
.resolveTemplate("resourceTypeId", resourceTypePermissionId)
.request()
.header("customerPartyId", customerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(ResourceTypePermission.class);
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getResourceTypePermissionById").observe();
}
public Observable> getResourceTypePermissionByResourceTypeId(String resourceTypeId, String customerPartyId, String correlationId) {
final HystrixRxMethod>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resource-type-permissions/resource-types/{resourceTypeId}/find-resource-type-id")
.resolveTemplate("resourceTypeId", resourceTypeId)
.request()
.header("customerPartyId", customerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(new GenericType>(){});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getResourceTypePermissionByResourceTypeId").observe();
}
public Observable> getResourceTypePermissionByPermissionId(String resourceTypeId, String customerPartyId, String correlationId) {
final HystrixRxMethod>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resource-type-permissions/permissions/{permissionId}/find-by-permission-id")
.resolveTemplate("resourceTypeId", resourceTypeId)
.request()
.header("customerPartyId", customerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(new GenericType>(){});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getResourceTypePermissionByPermissionId").observe();
}
public Observable> getResourceTypePermissionsByIds(List resourceTypePermissionsByIds, String customerPartyId, String correlationId) {
final HystrixRxMethod>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resource-type-permissions")
.queryParam("resourceTypePermissionsByIds", resourceTypePermissionsByIds.toArray())
.request()
.header("customerPartyId", customerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(new GenericType>(){});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getResourceTypePermissionsByIds").observe();
}
public Observable> getResourceTypePermissionsByOwnerPartyId(String ownerPartyId, String correlationId) {
final HystrixRxMethod>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resource-type-permissions/parties/{ownerPartyId}")
.resolveTemplate("ownerPartyId", ownerPartyId)
.request()
.header("ownerPartyId", ownerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(new GenericType>(){});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getResourceTypePermissionsByOwnerPartyId").observe();
}
public Observable> deleteResourceTypePermissionsById(String resourceTypePermissionsById, String customerPartyId, String correlationId) {
final HystrixRxMethod>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resource-type-permissions/{resourceTypePermissionId}")
.queryParam("resourceTypePermissionsById", resourceTypePermissionsById)
.request()
.header("customerPartyId", customerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(new GenericType>(){});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "deleteResourceTypePermissionsById").observe();
}
public Observable getPartyResourcesPermissions(String partyId, String ownerPartyId, String correlationId) {
final HystrixRxMethod> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/parties/{partyId}/resources/permissions")
.queryParam("partyId", partyId)
.request()
.header("ownerPartyId", ownerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(new GenericType(){});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getPartyResourcesPermissions").observe();
}
public Observable> getResourcesPartiesPermissions(List partyIds, String ownerPartyId, String correlationId) {
final HystrixRxMethod>> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/resources/parties/permissions")
.queryParam("partyIds", partyIds.toArray())
.request()
.header("ownerPartyId", ownerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(new GenericType>(){});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getResourcesPartiesPermissions").observe();
}
public Observable getPartiesResourcesPermissions(List partyIds, String ownerPartyId, String correlationId) {
final HystrixRxMethod> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/parties/resources/permissions")
.queryParam("partyIds", partyIds.toArray())
.request()
.header("ownerPartyId", ownerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.get(new GenericType(){});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "getPartiesResourcesPermissions").observe();
}
public Observable addGranteeGrants(Grantee grantee, String ownerPartyId, String correlationId) {
final HystrixRxMethod> hystrixMethod = () ->
from(client.target(authorizationClientData.getUrl()))
.path("/authorization/grantees")
.request()
.header("ownerPartyId", ownerPartyId)
.header("correlationId", determineCorrelationId(correlationId))
.rx()
.post(entity(grantee, APPLICATION_JSON_TYPE), new GenericType(){});
return new HystrixRxCommand<>(authorizationClientData, hystrixMethod, "addGranteeGrants").observe();
}
private String determineCorrelationId(String correlationId) {
return correlationId != null ? correlationId : randomUUID().toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy