All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alibaba.dashscope.utils.EncryptionKey Maven / Gradle / Ivy

There is a newer version: 2.16.9
Show newest version
package com.alibaba.dashscope.utils;

import com.alibaba.dashscope.common.DashScopeResult;
import com.google.gson.JsonObject;
import com.google.gson.annotations.SerializedName;
import lombok.Data;

@Data
public class EncryptionKey {
  @SerializedName("request_id")
  private String requestId;

  /*
   * base64 encoded public key
   */
  @SerializedName("public_key")
  private String publicKey;

  @SerializedName("public_key_id")
  private String publicKeyId;

  private EncryptionKey() {}

  public static EncryptionKey fromDashScopeResult(DashScopeResult result) {
    JsonObject dashscopeResult = (JsonObject) result.getOutput();
    EncryptionKey encryptionKey =
        JsonUtils.fromJsonObject(dashscopeResult.get("data"), EncryptionKey.class);
    encryptionKey.setRequestId(dashscopeResult.get("request_id").getAsString());
    encryptionKey.setPublicKey(encryptionKey.getPublicKey());
    return encryptionKey;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy