package com.fs.core.config;

import com.hc.openapi.tool.fastjson.JSON;
import com.volcengine.model.request.AssumeRoleRequest;
import com.volcengine.model.response.AssumeRoleResponse;
import com.volcengine.service.sts.ISTSService;
import com.volcengine.service.sts.impl.STSServiceImpl;
import com.volcengine.service.vod.IVodService;
import com.volcengine.service.vod.impl.VodServiceImpl;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class VolcEngineConfiguration {
    @Value("${hsy.access_key:''}")
    private String access_key;

    @Value("${hsy.secret_key:''}")
    private String secret_key;
    @Value("${hsy.region:''}")
    private String region;
    @Bean
    public IVodService vodService() throws Exception {
        // 根据区域获取火山云点播服务实例
        IVodService vodService = VodServiceImpl.getInstance(region);

        // 设置 AccessKey 和 SecretKey
        vodService.setAccessKey(access_key);
        vodService.setSecretKey(secret_key);

        return vodService;
    }



    public static void main(String[] args) throws Exception {
        ISTSService stsService = STSServiceImpl.getInstance();

        stsService.setAccessKey("AKLTNmMwNjJkNDFhYTVjNDIzYzhhNzEyZmZmZTlmYzBhNGM");
        stsService.setSecretKey("T0RaaFl6UmhZV1V4WXpKbU5EWTBNMkZpT0RNNU9UY3daak0wTjJFd09XUQ==");

        AssumeRoleRequest request = new AssumeRoleRequest();
        request.setRoleSessionName("just_for_test");
        request.setDurationSeconds(900);
        request.setRoleTrn("trn:iam::2114522511:role/hylj");

        AssumeRoleResponse resp = stsService.assumeRole(request);
        System.out.println(JSON.toJSONString(resp));

    }
}

