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

com.alibaba.dashscope.common.Result Maven / Gradle / Ivy

There is a newer version: 2.16.9
Show newest version
// Copyright (c) Alibaba, Inc. and its affiliates.

package com.alibaba.dashscope.common;

import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.protocol.HalfDuplexRequest;
import com.alibaba.dashscope.protocol.NetworkResponse;
import com.alibaba.dashscope.protocol.Protocol;
import com.google.gson.JsonElement;
import java.util.Map;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

@Data
@SuperBuilder
@NoArgsConstructor
public abstract class Result {

  /** The request id. */
  private String requestId;

  /** The usage information */
  private JsonElement usage;

  /** The headers of response */
  private Map headers;

  /**
   * Load data from the server output.
   *
   * @param protocol The protocol, please check the `Protocol` enum.
   * @param response The response.
   * @param  Object extends `Result`
   * @return The result.
   * @throws ApiException Failed, possibly due to a data error.
   */
  protected abstract  T fromResponse(Protocol protocol, NetworkResponse response)
      throws ApiException;

  public abstract  T fromResponse(
      Protocol protocol, NetworkResponse response, boolean isFlattenResult) throws ApiException;

  public abstract  T fromResponse(
      Protocol protocol, NetworkResponse response, boolean isFlattenResult, HalfDuplexRequest req)
      throws ApiException;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy