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

com.huaweicloud.sdk.frs.v2.model.AddFacesByFileRequestBody Maven / Gradle / Ivy

There is a newer version: 3.1.114
Show newest version
package com.huaweicloud.sdk.frs.v2.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.huaweicloud.sdk.core.http.FormDataFilePart;
import com.huaweicloud.sdk.core.http.FormDataPart;
import com.huaweicloud.sdk.core.http.SdkFormDataBody;

import java.io.InputStream;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;

/**
 * AddFacesByFileRequestBody
 */
public class AddFacesByFileRequestBody implements SdkFormDataBody {

    @JsonProperty(value = "image_file", access = JsonProperty.Access.WRITE_ONLY)

    private FormDataFilePart imageFile;

    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty(value = "external_image_id")

    private String externalImageId;

    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty(value = "external_fields")

    private String externalFields;

    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty(value = "single")

    private Boolean single;

    public AddFacesByFileRequestBody withImageFile(FormDataFilePart imageFile) {
        this.imageFile = imageFile;
        return this;
    }

    /**
     * 本地图片文件,图片不能超过8MB,建议小于1MB。上传文件时,请求格式为multipart。
     * @return imageFile
     */
    public FormDataFilePart getImageFile() {
        return imageFile;
    }

    public void setImageFile(FormDataFilePart imageFile) {
        this.imageFile = imageFile;
    }

    public AddFacesByFileRequestBody withExternalImageId(String externalImageId) {
        this.externalImageId = externalImageId;
        return this;
    }

    /**
     * 用户指定的图片外部ID,与当前图像绑定。用户没提供,系统会生成一个。 该ID长度范围为1~36位,可以包含字母、数字、中划线或者下划线,不包含其他的特殊字符。
     * @return externalImageId
     */
    public String getExternalImageId() {
        return externalImageId;
    }

    public void setExternalImageId(String externalImageId) {
        this.externalImageId = externalImageId;
    }

    public AddFacesByFileRequestBody withExternalFields(String externalFields) {
        this.externalFields = externalFields;
        return this;
    }

    /**
     * [根据用户自定义数据类型,填入相应的数值。创建faceset时定义该字段,Json字符串不校验重复性,参考[自定义字段](https://support.huaweicloud.com/api-face/face_02_0012.html)。](tag:hc) [根据用户自定义数据类型,填入相应的数值。创建faceset时定义该字段,Json字符串不校验重复性,参考[自定义字段](https://support.huaweicloud.com/intl/zh-cn/api-face/face_02_0012.html)。](tag:hk)
     * @return externalFields
     */
    public String getExternalFields() {
        return externalFields;
    }

    public void setExternalFields(String externalFields) {
        this.externalFields = externalFields;
    }

    public AddFacesByFileRequestBody withSingle(Boolean single) {
        this.single = single;
        return this;
    }

    /**
     * 是否将图片中的最大人脸添加至人脸库。可选值包括: • true: 传入的单张图片中如果包含多张人脸,则只将最大人脸添加到人脸库中。 • false: 默认为false。传入的单张图片中如果包含多张人脸,则将所有人脸添加至人脸库中。
     * @return single
     */
    public Boolean getSingle() {
        return single;
    }

    public void setSingle(Boolean single) {
        this.single = single;
    }

    public AddFacesByFileRequestBody withImageFile(InputStream inputStream, String fileName, String contentType) {
        this.imageFile = new FormDataFilePart(inputStream, fileName).withContentType(contentType);
        return this;
    }

    public AddFacesByFileRequestBody withImageFile(InputStream inputStream, String fileName) {
        this.imageFile = new FormDataFilePart(inputStream, fileName);
        return this;
    }

    public AddFacesByFileRequestBody withImageFile(InputStream inputStream, String fileName,
        Map headers) {
        this.imageFile = new FormDataFilePart(inputStream, fileName).withHeaders(headers);
        return this;
    }

    @Override
    public Map> buildFormData() {
        return new LinkedHashMap>() {

            private static final long serialVersionUID = 1L;
            {
                put("image_file", imageFile);
                if (externalImageId != null) {
                    put("external_image_id", new FormDataPart<>(externalImageId));
                }
                if (externalFields != null) {
                    put("external_fields", new FormDataPart<>(externalFields));
                }
                if (single != null) {
                    put("single", new FormDataPart<>(single));
                }
            }
        };
    }

    @Override
    public boolean equals(java.lang.Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        AddFacesByFileRequestBody that = (AddFacesByFileRequestBody) obj;
        return Objects.equals(this.imageFile, that.imageFile)
            && Objects.equals(this.externalImageId, that.externalImageId)
            && Objects.equals(this.externalFields, that.externalFields) && Objects.equals(this.single, that.single);
    }

    @Override
    public int hashCode() {
        return Objects.hash(imageFile, externalImageId, externalFields, single);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("class AddFacesByFileRequestBody {\n");
        sb.append("    imageFile: ").append(toIndentedString("[resource:will-not-print]")).append("\n");
        sb.append("    externalImageId: ").append(toIndentedString(externalImageId)).append("\n");
        sb.append("    externalFields: ").append(toIndentedString(externalFields)).append("\n");
        sb.append("    single: ").append(toIndentedString(single)).append("\n");
        sb.append("}");
        return sb.toString();
    }

    /**
     * Convert the given object to string with each line indented by 4 spaces
     * (except the first line).
     */
    private String toIndentedString(java.lang.Object o) {
        if (o == null) {
            return "null";
        }
        return o.toString().replace("\n", "\n    ");
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy