Giter Site home page Giter Site logo

twonote / radosgw-admin4j Goto Github PK

View Code? Open in Web Editor NEW
61.0 6.0 33.0 383 KB

A Ceph Object Storage Admin SDK / Client Library for Java ✨🍰✨

Home Page: https://twonote.github.io/radosgw-admin4j

License: Apache License 2.0

Java 100.00%
ceph radosgw rgw s3 aws-s3 radosgwadmin4j radosgw4j java radosgwadmin rgwadmin

radosgw-admin4j's People

Contributors

alexwangd avatar dependabot[bot] avatar faust64 avatar hrchu avatar swimfish09 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

radosgw-admin4j's Issues

individual bucket

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);
}

cannot delete aK/sK in s3Credentials

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

Add overload methods which accept models

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.

Fix test cases in Octopus

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

the 12,2 version error

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.

how to create User?

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?

Cannot get user info list

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?

Optional.empty and 404

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

Please shade Guava

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.

Modularization

  1. As a library (which depends on radsogw-admin4j) developer, I want to use radsogw-admin4j in the Java 9 modular way (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
  2. The build is compatible with Java 8 and provides module-info for Java 9

How to save the BucketInfo?

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...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.