package com.heyu.api.alibaba.handle.imageseg;


import com.aliyun.imageseg20191230.models.SegmentHeadRequest;
import com.aliyun.imageseg20191230.models.SegmentHeadResponse;
import com.aliyun.teautil.models.RuntimeOptions;
import com.heyu.api.data.annotation.CustomPath;
import com.heyu.api.alibaba.AlibabaBaseHandle;
import com.heyu.api.alibaba.request.imageseg.ASegmentHeadRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * https://next.api.aliyun.com/api/imageseg/2019-12-30/SegmentHDSky?tab=DOC
 * <p>
 * <p>
 * 天空高清分割 SegmentHDSky
 */

@Component
@Slf4j
@CustomPath("segmentHead")
public class ASegmentHeadHandle extends AlibabaBaseHandle<ASegmentHeadRequest, SegmentHeadResponse> {

    @Autowired
    private com.aliyun.imageseg20191230.Client client;

    @Override
    public String check(ASegmentHeadRequest aSegmentHeadRequest) {
        return checkUrlBase64(aSegmentHeadRequest);
    }



    @Override
    public SegmentHeadResponse run(ASegmentHeadRequest aSegmentHeadRequest, RuntimeOptions runtime) throws Exception {

        SegmentHeadRequest segmentHeadRequest = new SegmentHeadRequest();
        segmentHeadRequest.setImageURL(aSegmentHeadRequest.getImageUrl());
        segmentHeadRequest.setReturnForm(aSegmentHeadRequest.getReturnType());

        // 复制代码运行请自行打印 API 的返回值
        return client.segmentHeadWithOptions(segmentHeadRequest, runtime);
    }
}
