twonote / radosgw-admin4j Goto Github PK
View Code? Open in Web Editor NEWA Ceph Object Storage Admin SDK / Client Library for Java ✨🍰✨
Home Page: https://twonote.github.io/radosgw-admin4j
License: Apache License 2.0
A Ceph Object Storage Admin SDK / Client Library for Java ✨🍰✨
Home Page: https://twonote.github.io/radosgw-admin4j
License: Apache License 2.0
http://docs.ceph.com/docs/mimic/radosgw/adminops/#set-quota-for-an-individual-bucket
I need this, set quota for an individual (or one by one) bucket, Can you give me some advise? Thanks you very much.
@Override
public void setIndividualBucketQuota(String userId, String bucket, long maxObjects, long maxSizeKB) {
setIndividualQuota(userId, bucket, "bucket", maxObjects, maxSizeKB);
}
//SET QUOTA FOR AN INDIVIDUAL BUCKET
public void setIndividualQuota(String userId, String bucket, String quotaType, long maxObjects, long maxSizeKB) {
HttpUrl.Builder urlBuilder =
HttpUrl.parse(endpoint).newBuilder()
.addPathSegment("user")
.query("quota")
.addQueryParameter("uid", userId)
.addQueryParameter("bucket", bucket)
.addQueryParameter("quota-type", quotaType);
String body = gson.toJson(ImmutableMap.of(
"max_objects", String.valueOf(maxObjects),
"max_size_kb", String.valueOf(maxSizeKB),
"enabled", "true"));
Request request = new Request.Builder().put(RequestBody.create(null, body)).url(urlBuilder.build()).build();
safeCall(request);
}
Not yet tested currently
There is not a set method for me to build a S3Credential. When modify a user's aK/sK, I want to maintain only one pair of aK/sK, so I need to delete a S3Credential in the list or just build a new S3Credential. But I cannot build a S3Credential via setAk and setSk
Currently, we can set options by, for example, rgwAdmin.setUserQuota(java.lang.String userId, long maxObjects, long maxSizeKB)
Add an overloaded method such as rgwAdmin.setUserQuota(Quota quota)
, so that user can :
Quota quota = rgwAdm.getUserQuota(userId)
quota.setMaxObjects = 5566
rgwAdm.setUserQuota(quota)
All "set" methods listed in https://www.javadoc.io/static/io.github.twonote/radosgw-admin4j/2.0.2/org/twonote/rgwadmin4j/RgwAdmin.html are needed to be overloaded.
Fri, 08 Jan 2021 08:01:40 GMT Tests in error:
Fri, 08 Jan 2021 08:01:40 GMT linkBucket(org.twonote.rgwadmin4j.impl.RgwAdminImplTest): InvalidArgument
Fri, 08 Jan 2021 08:01:40 GMT createUser(org.twonote.rgwadmin4j.impl.RgwAdminImplTest): UserAlreadyExists
For the 12.2.4 luminous version,the header for rgw-admin api nead a addtional header of "x-amz-content-sha256:UNSIGNED-PAYLOAD" pair? If not,with you api I alway get a "sigurnature not match" error with the correct access-secret pair.
Good afternoon, I'm trying to create a user through the client:
RgwAdmin rgwAdmin = new RgwAdminBuilder()
.accessKey(accessKey)
.secretKey(secretKey)
.endpoint(endpoint)
.build();
rgwAdmin.createUser("testuser");
As a result, this method returns null, I looked inside this method:
public User createUser(String userId, Map<String, String> options) {
HttpUrl.Builder urlBuilder = HttpUrl.parse(this.endpoint).newBuilder().addPathSegment("user").addQueryParameter("uid", userId).addQueryParameter("display-name", userId);
appendParameters(options, urlBuilder);
Request request = (new Request.Builder()).put(emptyBody).url(urlBuilder.build()).build();
String resp = this.safeCall(request);
return (User)gson.fromJson(resp, User.class);
Inside this method, the response (resp) field returns an empty string, what could be the reason for this, please tell me?
Hi , I am running radosgw-admin4j on Ceph 10.2.7 . What confused me is as blow.
List <User> users = admin.listUserInfo();
// [{"userId":null,"displayName":null,"email":null,"suspended":null,"maxBuckets":null,"subusers":null,"s3Credentials":null,"swiftCredentials":null,"caps":null},...]
List <String> names = admin.listUser();
// ["registry","hr-dev","test","es","s3-dev"]
I can get usernames but cannot get user info . Why it happened?
I am very concerned about the following method
private String safeCall(Request request) {
try (Response response = client.newCall(request).execute()) {
if (response.code() == 404) {
return null;
}
if (!response.isSuccessful()) {
throw ErrorUtils.parseError(response);
}
ResponseBody body = response.body();
if (body != null) {
return response.body().string();
} else {
return null;
}
} catch (IOException e) {
throw new RgwAdminException(500, "IOException", e);
}
}
This does not distinguish between a 404 situation and a null body, since in these two cases null is returned, which overwrites the cause. I want to draw attention to the fact that all other errors are thrown, for example, 403. This is important for future examples.
What causes the problem with all methods to grow.
@Override
public Optional<User> getUserInfo(String userId) {
HttpUrl.Builder urlBuilder =
HttpUrl.parse(endpoint)
.newBuilder()
.addPathSegment("user")
.addQueryParameter("uid", userId);
Request request = new Request.Builder().get().url(urlBuilder.build()).build();
String resp = safeCall(request);
return Optional.ofNullable(gson.fromJson(resp, User.class));
}
How will I use this method then:
RgwAdminImpl admin = new RgwAdminImpl("access", "secret", "endpoint");
try {
User user =
admin.getUserInfo("id")
.orElseThrow(() -> new NoSuchElementException("not found (404)"));
} catch (RgwAdminException | NoSuchElementException e) {
System.err.println("error logic: " + e.getMessage());
}
I still need a try catch to handle errors, and write orElseThrow
for some reason. But it's actually confusing. Optional<User>
when empty, it does not mean that this is normal behavior, it is just a ignored error
But the worst thing happens in the following example. It is simply impossible to write code here, either to throw an exception, or no policy has really been set.
try {
admin.getBucketPolicy("bucet_name")
.orElseThrow(() -> new NoSuchElementException("not found (404), or incorrect bucket name?"));
} catch (RgwAdminException | NoSuchElementException e) {
System.err.println("error logic: " + e.getMessage());
}
I really want to fix this, but I absolutely do not know for which methods Optional.empty
is normal behavior, and for which it is a ignored error
just find to get bucket info ,no create bucket api by using RGW_ADMIN.
In ceph docs , I found nothing about this.
but because the radosgw-admin's rest api use /admin/ , so I can't create a bucket named admin in the blank tenant.
Guava is not backward compatible and if an including project also uses Guava this results in conflicts. By shading Guava this is not an issue anymore.
java -p radosgw-admin4j-0.X.X.jar -m com.my.Application
for example), so I can declare radsogw-admin4j as named application modules in my module-info.java
hello, I have a problem, my code like this:
Quota bucketQuota = bucketInfo.getBucketQuota();
bucketQuota.setMaxSizeKb(quotaSize);
bucketQuota.setEnabled(true);
bucketInfo.setBucketQuota(bucketQuota);
But it does not come into force, what can I do ? Thanks...
Travis CI stop working on open source projects.
Migrate the CI server from Travis CI to GitHub Actions, or circles CI alternatively.
List<SubUser> list = rgwAdmin.setSubUserPermission("test", "subtest", Permission.READ_WRITE);
POST /admin/user?subuser&uid=test&subuser=subtest&access=read_write
not read_write but readwrite
Official Docker image has not yet released, Just wait.
https://github.com/ceph/ceph-container
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.