diff options
Diffstat (limited to 'keystone-client/src/main/java/com/woorea/openstack/keystone/api')
6 files changed, 579 insertions, 0 deletions
diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/api/EndpointsResource.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/api/EndpointsResource.java new file mode 100644 index 0000000..acc128b --- /dev/null +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/api/EndpointsResource.java @@ -0,0 +1,71 @@ +package com.woorea.openstack.keystone.api; + + +import com.woorea.openstack.base.client.Entity; +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.keystone.model.Endpoint; +import com.woorea.openstack.keystone.model.Endpoints; + +public class EndpointsResource { + + private OpenStackClient client; + + public EndpointsResource(OpenStackClient client) { + this.client = client; + } + + public List list() { + return new List(); + } + + public Create create(Endpoint endpoint) { + return new Create(endpoint); + } + + public Show show(String id) { + return new Show(id); + } + + + public Delete delete(String id) { + return new Delete(id); + } + + public class List extends OpenStackRequest<Endpoints> { + + public List() { + super(client, HttpMethod.GET, "/endpoints", null, Endpoints.class); + } + + } + + public class Create extends OpenStackRequest<Endpoint> { + + private Endpoint endpoint; + + public Create(Endpoint endpoint) { + super(client, HttpMethod.POST, "/endpoints", Entity.json(endpoint), Endpoint.class); + this.endpoint = endpoint; + } + + } + + public class Show extends OpenStackRequest<Endpoint> { + + public Show(String id) { + super(client, HttpMethod.GET, new StringBuilder("/endpoints/").append(id).toString(), null, Endpoint.class); + } + + } + + public class Delete extends OpenStackRequest<Void> { + + public Delete(String id) { + super(client, HttpMethod.DELETE, new StringBuilder("/endpoints/").append(id).toString(), null, Void.class); + } + + } + +} diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/api/RolesResource.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/api/RolesResource.java new file mode 100644 index 0000000..d39dc77 --- /dev/null +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/api/RolesResource.java @@ -0,0 +1,58 @@ +package com.woorea.openstack.keystone.api; + + +import com.woorea.openstack.base.client.Entity; +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.keystone.model.Role; +import com.woorea.openstack.keystone.model.Roles; + +public class RolesResource { + + private OpenStackClient client; + + public RolesResource(OpenStackClient client) { + this.client = client; + } + + public List list() { + return new List(); + } + + public Create create(Role role) { + return new Create(role); + } + + public Delete delete(String id) { + return new Delete(id); + } + + public class List extends OpenStackRequest<Roles> { + + public List() { + super(client, HttpMethod.GET, "/OS-KSADM/roles", null, Roles.class); + } + + } + + public class Create extends OpenStackRequest<Role> { + + private Role role; + + public Create(Role role) { + super(client, HttpMethod.POST, "/OS-KSADM/roles", Entity.json(role), Role.class); + this.role = role; + } + + } + + public class Delete extends OpenStackRequest<Void> { + + public Delete(String id) { + super(client, HttpMethod.DELETE, new StringBuilder("/OS-KSADM/roles/").append(id).toString(), null, Void.class); + } + + } + +} diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/api/ServicesResource.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/api/ServicesResource.java new file mode 100644 index 0000000..5b18939 --- /dev/null +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/api/ServicesResource.java @@ -0,0 +1,70 @@ +package com.woorea.openstack.keystone.api; + + +import com.woorea.openstack.base.client.Entity; +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.keystone.model.Service; +import com.woorea.openstack.keystone.model.Services; + +public class ServicesResource { + + private OpenStackClient client; + + public ServicesResource(OpenStackClient client) { + this.client = client; + } + + public List list() { + return new List(); + } + + public Create create(Service service) { + return new Create(service); + } + + public Show show(String id) { + return new Show(id); + } + + public Delete delete(String id) { + return new Delete(id); + } + + public class List extends OpenStackRequest<Services> { + + public List() { + super(client, HttpMethod.GET, "/OS-KSADM/services", null, Services.class); + } + + } + + public class Create extends OpenStackRequest<Service> { + + private Service service; + + public Create(Service service) { + super(client, HttpMethod.POST, "/OS-KSADM/services", Entity.json(service), Service.class); + this.service = service; + } + + } + + public class Show extends OpenStackRequest<Service> { + + public Show(String id) { + super(client, HttpMethod.GET, new StringBuilder("/OS-KSADM/services/").append(id).toString(), null, Service.class); + } + + } + + public class Delete extends OpenStackRequest<Void> { + + public Delete(String id) { + super(client, HttpMethod.DELETE, new StringBuilder("/OS-KSADM/services/").append(id).toString(), null, Void.class); + } + + } + +} diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/api/TenantsResource.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/api/TenantsResource.java new file mode 100644 index 0000000..a073241 --- /dev/null +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/api/TenantsResource.java @@ -0,0 +1,212 @@ +package com.woorea.openstack.keystone.api; + +/* + * Modifications copyright (c) 2017 AT&T Intellectual Property + */ + +import com.woorea.openstack.base.client.Entity; +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.keystone.model.Roles; +import com.woorea.openstack.keystone.model.Tenant; +import com.woorea.openstack.keystone.model.Tenants; +import com.woorea.openstack.keystone.model.Users; +import com.woorea.openstack.keystone.model.Metadata; + +public class TenantsResource { + + private OpenStackClient client; + + public TenantsResource(OpenStackClient client) { + this.client = client; + } + + public List list() { + return new List(); + } + + public Create create(Tenant tenant) { + return new Create(tenant); + } + + public Show show(String id) { + return new Show(id); + } + + public Update update(String id, Tenant tenant) { + return new Update(id, tenant); + } + + public Delete delete(String id) { + return new Delete(id); + } + + public ListUsers listUsers(String tenantId) { + return new ListUsers(tenantId); + } + + public AddUser addUser(String tenantId, String userId, String roleId) { + return new AddUser(tenantId, userId, roleId); + } + + public RemoveUser removeUser(String tenantId, String userId, String roleId) { + return new RemoveUser(tenantId, userId, roleId); + } + + public ListUserRoles listUserRoles(String tenantId, String userId) { + return new ListUserRoles(tenantId, userId); + } + + public ShowMetadata showMetadata(String id) { + return new ShowMetadata(id); + } + + public CreateOrUpdateMetadata createOrUpdateMetadata(String id,Metadata metadata) { + return new CreateOrUpdateMetadata(id,metadata); + } + + public ReplaceMetadata replaceMetadata(String id,Metadata metadata) { + return new ReplaceMetadata(id,metadata); + } + + public ShowMetadataItem showMetadataItem(String id,String key) { + return new ShowMetadataItem(id,key); + } + + public CreateOrUpdateMetadataItem createOrUpdateMetadataItem(String id,String key,Metadata metadata) { + return new CreateOrUpdateMetadataItem(id,key,metadata); + } + + public DeleteMetadataItem deleteMetadataItem(String id, String key) { + return new DeleteMetadataItem(id,key); + } + + public class List extends OpenStackRequest<Tenants> { + + public List() { + super(client, HttpMethod.GET, "/tenants", null, Tenants.class); + } + + } + + public class Create extends OpenStackRequest<Tenant> { + + private Tenant tenant; + + public Create(Tenant tenant) { + super(client, HttpMethod.POST, "/tenants", Entity.json(tenant), Tenant.class); + this.tenant = tenant; + } + + } + + public class Show extends OpenStackRequest<Tenant> { + + public Show(String id) { + super(client, HttpMethod.GET, new StringBuilder("/tenants/").append(id).toString(), null, Tenant.class); + } + + } + + public class Update extends OpenStackRequest<Tenant> { + + private Tenant tenant; + + public Update(String id, Tenant tenant) { + super(client, HttpMethod.PUT, new StringBuilder("/tenants/").append(id).toString(), Entity.json(tenant), Tenant.class); + this.tenant = tenant; + } + + } + + public class Delete extends OpenStackRequest<Void> { + + public Delete(String id) { + super(client, HttpMethod.DELETE, new StringBuilder("/tenants/").append(id).toString(), null, Void.class); + } + + } + + public class ListUsers extends OpenStackRequest<Users> { + + public ListUsers(String tenantId) { + super(client, HttpMethod.GET, new StringBuilder("/tenants/").append(tenantId).append("/users").toString(), null, Users.class); + } + + } + + public class AddUser extends OpenStackRequest<Void> { + + public AddUser(String tenantId, String userId, String roleId) { + super(client, HttpMethod.PUT, new StringBuilder("/tenants/").append(tenantId).append("/users/").append(userId).append("/roles/OS-KSADM/").append(roleId).toString(), null, Void.class); + } + + } + + public class RemoveUser extends OpenStackRequest<Void> { + + public RemoveUser(String tenantId, String userId, String roleId) { + super(client, HttpMethod.DELETE, new StringBuilder("/tenants/").append(tenantId).append("/users/").append(userId).append("/roles/OS-KSADM/").append(roleId).toString(), null, Void.class); + } + + } + + public class ListUserRoles extends OpenStackRequest<Roles> { + + public ListUserRoles(String tenantId, String userId) { + super(client, HttpMethod.GET, new StringBuilder("/tenants/").append(tenantId).append("/users/").append(userId).append("/roles").toString(), null, Roles.class); + } + + } + + /** + * The following APIs support Tenant-level metadata. This is a feature supported + * by the DCP/LCP (i.e. AIC cloud), but not native Openstack. The full API as + * documented by AIC is implemented below. + */ + public class ShowMetadata extends OpenStackRequest<Metadata> { + + public ShowMetadata(String tenantId) { + super(client, HttpMethod.GET, new StringBuilder("/tenants/").append(tenantId).append("/metadata"), null, Metadata.class); + } + + } + + public class CreateOrUpdateMetadata extends OpenStackRequest<Metadata> { + + public CreateOrUpdateMetadata(String tenantId,Metadata metadata) { + super(client, HttpMethod.POST, new StringBuilder("/tenants/").append(tenantId).append("/metadata"), Entity.json(metadata), Metadata.class); + } + + } + public class ReplaceMetadata extends OpenStackRequest<Metadata> { + + public ReplaceMetadata(String tenantId,Metadata metadata) { + super(client, HttpMethod.PUT, new StringBuilder("/tenants/").append(tenantId).append("/metadata"), Entity.json(metadata), Metadata.class); + } + + } + + public class ShowMetadataItem extends OpenStackRequest<Metadata> { + + public ShowMetadataItem(String tenantId, String key) { + super(client, HttpMethod.GET, new StringBuilder("/tenants/").append(tenantId).append("/metadata").append(key), null, Metadata.class); + } + + } + public class CreateOrUpdateMetadataItem extends OpenStackRequest<Metadata> { + + public CreateOrUpdateMetadataItem(String tenantId,String key,Metadata metadata) { + super(client, HttpMethod.POST, new StringBuilder("/tenants/").append(tenantId).append("/metadata").append(key), Entity.json(metadata), Metadata.class); + } + + } + public class DeleteMetadataItem extends OpenStackRequest<Void> { + + public DeleteMetadataItem(String tenantId,String key) { + super(client, HttpMethod.DELETE, new StringBuilder("/tenants/").append(tenantId).append("/metadata/").append(key), null, Void.class); + } + + } + } diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/api/TokensResource.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/api/TokensResource.java new file mode 100644 index 0000000..4f30313 --- /dev/null +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/api/TokensResource.java @@ -0,0 +1,83 @@ +package com.woorea.openstack.keystone.api; + +/* + * Modifications copyright (c) 2017 AT&T Intellectual Property + */ + +import com.woorea.openstack.base.client.Entity; +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.keystone.model.Access; +import com.woorea.openstack.keystone.model.Authentication; +import com.woorea.openstack.keystone.model.authentication.AccessKey; +import com.woorea.openstack.keystone.model.authentication.RackspaceAuthentication; +import com.woorea.openstack.keystone.model.authentication.TokenAuthentication; +import com.woorea.openstack.keystone.model.authentication.UsernamePassword; + +public class TokensResource { + + private final OpenStackClient CLIENT; + + public TokensResource(OpenStackClient client) { + CLIENT = client; + } + + public Authenticate.Builder authenticate() { + return new Authenticate().new Builder(); + } + + public Authenticate authenticate(Authentication authentication) { + return new Authenticate(authentication); + } + + public class Authenticate extends OpenStackRequest<Access> { + + private Authentication authentication; + + public Authenticate() { + + } + + public Authenticate(Authentication authentication) { + super(CLIENT, HttpMethod.POST, "/tokens", Entity.json(authentication), Access.class); + this.authentication = authentication; + } + + public Authenticate withTenantId(String tenantId) { + authentication.setTenantId(tenantId); + return this; + } + + public Authenticate withTenantName(String tenantName) { + authentication.setTenantName(tenantName); + return this; + } + + public class Builder { + + public Authenticate withUsernamePassword(String username, String password) { + Authentication authentication = new UsernamePassword(username, password); + return new Authenticate(authentication); + } + + public Authenticate withToken(String token) { + Authentication authentication = new TokenAuthentication(token); + return new Authenticate(authentication); + } + + public Authenticate withRackspace(String username, String apiKey, String region) { + Authentication authentication = new RackspaceAuthentication(username, apiKey); + return new Authenticate(authentication); + } + + public Authenticate withAccessKey(String accessKey, String secretKey) { + Authentication authentication = new AccessKey(accessKey, secretKey); + return new Authenticate(authentication); + } + + } + + } + +} diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/api/UsersResource.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/api/UsersResource.java new file mode 100644 index 0000000..dbb897c --- /dev/null +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/api/UsersResource.java @@ -0,0 +1,85 @@ +package com.woorea.openstack.keystone.api; + + +import com.woorea.openstack.base.client.Entity; +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.keystone.model.User; +import com.woorea.openstack.keystone.model.Users; + +public class UsersResource { + + private OpenStackClient client; + + public UsersResource(OpenStackClient client) { + this.client = client; + } + + public List list() { + return new List(); + } + + public Create create(User user) { + return new Create(user); + } + + public Show show(String id) { + return new Show(id); + } + + public Update update(String id, User user) { + return new Update(id, user); + } + + public Delete delete(String id) { + return new Delete(id); + } + + public class List extends OpenStackRequest<Users> { + + public List() { + super(client, HttpMethod.GET, "/users", null, Users.class); + } + + } + + public class Create extends OpenStackRequest<User> { + + private User user; + + public Create(User user) { + super(client, HttpMethod.POST, "/users", Entity.json(user), User.class); + this.user = user; + } + + } + + public class Show extends OpenStackRequest<User> { + + public Show(String id) { + super(client, HttpMethod.GET, new StringBuilder("/users/").append(id).toString(), null, User.class); + } + + } + + public class Update extends OpenStackRequest<User> { + + private User user; + + public Update(String id, User user) { + super(client, HttpMethod.PUT, new StringBuilder("/users/").append(id).toString(), Entity.json(user), User.class); + this.user = user; + } + + } + + public class Delete extends OpenStackRequest<Void> { + + public Delete(String id) { + super(client, HttpMethod.DELETE, new StringBuilder("/users/").append(id).toString(), null, Void.class); + } + + } + +} |