本文为您提供了服务端 Java SDK 的点播 CDN 模块的接口调用示例。
接口请求参数和返回参数说明详见创建域名。
package com.volcengine.example.vod.cdn; import com.volcengine.service.vod.IVodService; import com.volcengine.service.vod.impl.VodServiceImpl; public class VodCreateDomainDemo { public static void main(String[] args) throws Exception { // Create a VOD instance in the specified region. // IVodService vodService = VodServiceImpl.getInstance("cn-north-1"); IVodService vodService = VodServiceImpl.getInstance(); // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65641. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // vodService.setAccessKey("your ak"); // vodService.setSecretKey("your sk"); try { com.volcengine.service.vod.model.request.VodCreateDomainV2Request.Builder reqBuilder = com.volcengine.service.vod.model.request.VodCreateDomainV2Request.newBuilder(); reqBuilder.setSpaceName("your SpaceName"); reqBuilder.setDomainType("your DomainType"); reqBuilder.setDomain("your Domain"); reqBuilder.setSourceStationType(0); reqBuilder.setSourceStationAddressType(0); reqBuilder.setOrigins("your Origins"); reqBuilder.setArea("your Area"); com.volcengine.service.vod.model.response.VodCreateDomainV2Response resp = vodService.createDomain(reqBuilder.build()); if (resp.getResponseMetadata().hasError()) { System.out.println(resp.getResponseMetadata().getError()); System.exit(-1); } System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
接口请求参数和返回参数说明详见启用域名。
package com.volcengine.example.vod.cdn; import com.volcengine.service.vod.IVodService; import com.volcengine.service.vod.impl.VodServiceImpl; public class VodStartDomainDemo { public static void main(String[] args) throws Exception { // Create a VOD instance in the specified region. // IVodService vodService = VodServiceImpl.getInstance("cn-north-1"); IVodService vodService = VodServiceImpl.getInstance(); // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65641. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // vodService.setAccessKey("your ak"); // vodService.setSecretKey("your sk"); try { com.volcengine.service.vod.model.request.VodStartDomainRequest.Builder reqBuilder = com.volcengine.service.vod.model.request.VodStartDomainRequest.newBuilder(); reqBuilder.setSpaceName("your SpaceName"); reqBuilder.setDomainType("your DomainType"); reqBuilder.setDomain("your Domain"); reqBuilder.setSourceStationType(0); com.volcengine.service.vod.model.response.VodStartDomainResponse resp = vodService.startDomain(reqBuilder.build()); if (resp.getResponseMetadata().hasError()) { System.out.println(resp.getResponseMetadata().getError()); System.exit(-1); } System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
接口请求参数和返回参数说明详见停用域名。
package com.volcengine.example.vod.cdn; import com.volcengine.service.vod.IVodService; import com.volcengine.service.vod.impl.VodServiceImpl; public class VodStopDomainDemo { public static void main(String[] args) throws Exception { // Create a VOD instance in the specified region. // IVodService vodService = VodServiceImpl.getInstance("cn-north-1"); IVodService vodService = VodServiceImpl.getInstance(); // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65641. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // vodService.setAccessKey("your ak"); // vodService.setSecretKey("your sk"); try { com.volcengine.service.vod.model.request.VodStopDomainRequest.Builder reqBuilder = com.volcengine.service.vod.model.request.VodStopDomainRequest.newBuilder(); reqBuilder.setSpaceName("your SpaceName"); reqBuilder.setDomainType("your DomainType"); reqBuilder.setDomain("your Domain"); reqBuilder.setSourceStationType(0); com.volcengine.service.vod.model.response.VodStopDomainResponse resp = vodService.stopDomain(reqBuilder.build()); if (resp.getResponseMetadata().hasError()) { System.out.println(resp.getResponseMetadata().getError()); System.exit(-1); } System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
接口请求参数和返回参数说明详见删除域名。
package com.volcengine.example.vod.cdn; import com.volcengine.service.vod.IVodService; import com.volcengine.service.vod.impl.VodServiceImpl; public class VodDeleteDomainDemo { public static void main(String[] args) throws Exception { // Create a VOD instance in the specified region. // IVodService vodService = VodServiceImpl.getInstance("cn-north-1"); IVodService vodService = VodServiceImpl.getInstance(); // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65641. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // vodService.setAccessKey("your ak"); // vodService.setSecretKey("your sk"); try { com.volcengine.service.vod.model.request.VodDeleteDomainRequest.Builder reqBuilder = com.volcengine.service.vod.model.request.VodDeleteDomainRequest.newBuilder(); reqBuilder.setSpaceName("your SpaceName"); reqBuilder.setDomainType("your DomainType"); reqBuilder.setDomain("your Domain"); com.volcengine.service.vod.model.response.VodDeleteDomainResponse resp = vodService.deleteDomain(reqBuilder.build()); if (resp.getResponseMetadata().hasError()) { System.out.println(resp.getResponseMetadata().getError()); System.exit(-1); } System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
接口请求参数和返回参数说明详见获取空间域名列表。
package com.volcengine.example.vod.cdn; import com.volcengine.service.vod.IVodService; import com.volcengine.service.vod.impl.VodServiceImpl; public class VodListDomainDemo { public static void main(String[] args) throws Exception { // Create a VOD instance in the specified region. // IVodService vodService = VodServiceImpl.getInstance("cn-north-1"); IVodService vodService = VodServiceImpl.getInstance(); // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65641. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // vodService.setAccessKey("your ak"); // vodService.setSecretKey("your sk"); try { com.volcengine.service.vod.model.request.VodListDomainRequest.Builder reqBuilder = com.volcengine.service.vod.model.request.VodListDomainRequest.newBuilder(); reqBuilder.setSpaceName("your SpaceName"); reqBuilder.setDomainType("your DomainType"); reqBuilder.setSourceStationType(0); reqBuilder.setOffset(0); reqBuilder.setLimit(0); com.volcengine.service.vod.model.response.VodListDomainResponse resp = vodService.listDomain(reqBuilder.build()); if (resp.getResponseMetadata().hasError()) { System.out.println(resp.getResponseMetadata().getError()); System.exit(-1); } System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
接口请求参数和返回参数说明详见将域名添加至点播调度。
package com.volcengine.example.vod.cdn; import com.volcengine.service.vod.IVodService; import com.volcengine.service.vod.impl.VodServiceImpl; public class VodAddDomainToSchedulerDemo { public static void main(String[] args) throws Exception { // Create a VOD instance in the specified region. // IVodService vodService = VodServiceImpl.getInstance("cn-north-1"); IVodService vodService = VodServiceImpl.getInstance(); // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65641. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // vodService.setAccessKey("your ak"); // vodService.setSecretKey("your sk"); try { com.volcengine.service.vod.model.request.VodAddDomainToSchedulerRequest.Builder reqBuilder = com.volcengine.service.vod.model.request.VodAddDomainToSchedulerRequest.newBuilder(); reqBuilder.setSpaceName("your SpaceName"); reqBuilder.setDomainType("your DomainType"); reqBuilder.setDomain("your Domain"); reqBuilder.setSourceStationType(0); com.volcengine.service.vod.model.response.VodAddDomainToSchedulerResponse resp = vodService.addDomainToScheduler(reqBuilder.build()); if (resp.getResponseMetadata().hasError()) { System.out.println(resp.getResponseMetadata().getError()); System.exit(-1); } System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
接口请求参数和返回参数说明详见将域名移除点播调度。
package com.volcengine.example.vod.cdn; import com.volcengine.service.vod.IVodService; import com.volcengine.service.vod.impl.VodServiceImpl; public class VodRemoveDomainFromSchedulerDemo { public static void main(String[] args) throws Exception { // Create a VOD instance in the specified region. // IVodService vodService = VodServiceImpl.getInstance("cn-north-1"); IVodService vodService = VodServiceImpl.getInstance(); // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65641. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // vodService.setAccessKey("your ak"); // vodService.setSecretKey("your sk"); try { com.volcengine.service.vod.model.request.VodRemoveDomainFromSchedulerRequest.Builder reqBuilder = com.volcengine.service.vod.model.request.VodRemoveDomainFromSchedulerRequest.newBuilder(); reqBuilder.setSpaceName("your SpaceName"); reqBuilder.setDomainType("your DomainType"); reqBuilder.setDomain("your Domain"); reqBuilder.setSourceStationType(0); com.volcengine.service.vod.model.response.VodRemoveDomainFromSchedulerResponse resp = vodService.removeDomainFromScheduler(reqBuilder.build()); if (resp.getResponseMetadata().hasError()) { System.out.println(resp.getResponseMetadata().getError()); System.exit(-1); } System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
接口请求参数和返回参数说明详见设置域名分发规则。
package com.volcengine.example.vod.cdn; import com.volcengine.service.vod.IVodService; import com.volcengine.service.vod.impl.VodServiceImpl; public class VodUpdateDomainPlayRuleDemo { public static void main(String[] args) throws Exception { // Create a VOD instance in the specified region. // IVodService vodService = VodServiceImpl.getInstance("cn-north-1"); IVodService vodService = VodServiceImpl.getInstance(); // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65641. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // vodService.setAccessKey("your ak"); // vodService.setSecretKey("your sk"); try { com.volcengine.service.vod.model.request.VodUpdateDomainPlayRuleRequest.Builder reqBuilder = com.volcengine.service.vod.model.request.VodUpdateDomainPlayRuleRequest.newBuilder(); reqBuilder.setSpaceName("your SpaceName"); reqBuilder.setDefaultDomain("your DefaultDomain"); reqBuilder.setPlayRule("your PlayRule"); com.volcengine.service.vod.model.response.VodUpdateDomainPlayRuleResponse resp = vodService.updateDomainPlayRule(reqBuilder.build()); if (resp.getResponseMetadata().hasError()) { System.out.println(resp.getResponseMetadata().getError()); System.exit(-1); } System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
接口请求参数和返回参数说明详见修改域名时间戳防盗链。
package com.volcengine.example.vod.cdn; import com.volcengine.service.vod.IVodService; import com.volcengine.service.vod.impl.VodServiceImpl; public class VodUpdateDomainExpireDemo { public static void main(String[] args) throws Exception { // Create a VOD instance in the specified region. // IVodService vodService = VodServiceImpl.getInstance("cn-north-1"); IVodService vodService = VodServiceImpl.getInstance(); // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65641. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // vodService.setAccessKey("your ak"); // vodService.setSecretKey("your sk"); try { com.volcengine.service.vod.model.request.VodUpdateDomainExpireV2Request.Builder reqBuilder = com.volcengine.service.vod.model.request.VodUpdateDomainExpireV2Request.newBuilder(); reqBuilder.setSpaceName("your SpaceName"); reqBuilder.setDomainType("your DomainType"); reqBuilder.setDomain("your Domain"); reqBuilder.setExpire(0); com.volcengine.service.vod.model.response.VodUpdateDomainExpireV2Response resp = vodService.updateDomainExpire(reqBuilder.build()); if (resp.getResponseMetadata().hasError()) { System.out.println(resp.getResponseMetadata().getError()); System.exit(-1); } System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
接口请求参数和返回参数说明详见修改域名 URL 鉴权配置。
package com.volcengine.example.vod.cdn; import com.volcengine.service.vod.IVodService; import com.volcengine.service.vod.impl.VodServiceImpl; public class VodUpdateDomainUrlAuthConfigDemo { public static void main(String[] args) throws Exception { // Create a VOD instance in the specified region. // IVodService vodService = VodServiceImpl.getInstance("cn-north-1"); IVodService vodService = VodServiceImpl.getInstance(); // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65641. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // vodService.setAccessKey("your ak"); // vodService.setSecretKey("your sk"); try { com.volcengine.service.vod.model.request.VodUpdateDomainUrlAuthConfigV2Request.Builder reqBuilder = com.volcengine.service.vod.model.request.VodUpdateDomainUrlAuthConfigV2Request.newBuilder(); reqBuilder.setSpaceName("your SpaceName"); reqBuilder.setDomainType("your DomainType"); reqBuilder.setDomain("your Domain"); reqBuilder.setMainKey("your MainKey"); reqBuilder.setBackupKey("your BackupKey"); reqBuilder.setStatus("your Status"); com.volcengine.service.vod.model.response.VodUpdateDomainUrlAuthConfigV2Response resp = vodService.updateDomainUrlAuthConfig(reqBuilder.build()); if (resp.getResponseMetadata().hasError()) { System.out.println(resp.getResponseMetadata().getError()); System.exit(-1); } System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
接口请求参数和返回参数说明详见刷新缓存。
package com.volcengine.example.vod.cdn; import com.volcengine.service.vod.IVodService; import com.volcengine.service.vod.impl.VodServiceImpl; public class VodCreateCdnRefreshTaskDemo { public static void main(String[] args) throws Exception { // Create a VOD instance in the specified region. // IVodService vodService = VodServiceImpl.getInstance("cn-north-1"); IVodService vodService = VodServiceImpl.getInstance(); // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65641. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // vodService.setAccessKey("your ak"); // vodService.setSecretKey("your sk"); try { com.volcengine.service.vod.model.request.VodCreateCdnRefreshTaskRequest.Builder reqBuilder = com.volcengine.service.vod.model.request.VodCreateCdnRefreshTaskRequest.newBuilder(); reqBuilder.setSpaceName("your SpaceName"); reqBuilder.setUrls("your Urls"); reqBuilder.setType("your Type"); com.volcengine.service.vod.model.response.VodCreateCdnRefreshTaskResponse resp = vodService.createCdnRefreshTask(reqBuilder.build()); if (resp.getResponseMetadata().hasError()) { System.out.println(resp.getResponseMetadata().getError()); System.exit(-1); } System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
接口请求参数和返回参数说明详见预热缓存。
package com.volcengine.example.vod.cdn; import com.volcengine.service.vod.IVodService; import com.volcengine.service.vod.impl.VodServiceImpl; public class VodCreateCdnPreloadTaskDemo { public static void main(String[] args) throws Exception { // Create a VOD instance in the specified region. // IVodService vodService = VodServiceImpl.getInstance("cn-north-1"); IVodService vodService = VodServiceImpl.getInstance(); // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65641. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // vodService.setAccessKey("your ak"); // vodService.setSecretKey("your sk"); try { com.volcengine.service.vod.model.request.VodCreateCdnPreloadTaskRequest.Builder reqBuilder = com.volcengine.service.vod.model.request.VodCreateCdnPreloadTaskRequest.newBuilder(); reqBuilder.setSpaceName("your SpaceName"); reqBuilder.setUrls("your Urls"); com.volcengine.service.vod.model.response.VodCreateCdnPreloadTaskResponse resp = vodService.createCdnPreloadTask(reqBuilder.build()); if (resp.getResponseMetadata().hasError()) { System.out.println(resp.getResponseMetadata().getError()); System.exit(-1); } System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
接口请求参数和返回参数说明详见获取刷新预热任务列表。
package com.volcengine.example.vod.cdn; import com.volcengine.service.vod.IVodService; import com.volcengine.service.vod.impl.VodServiceImpl; public class VodListCdnTasksDemo { public static void main(String[] args) throws Exception { // Create a VOD instance in the specified region. // IVodService vodService = VodServiceImpl.getInstance("cn-north-1"); IVodService vodService = VodServiceImpl.getInstance(); // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65641. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // vodService.setAccessKey("your ak"); // vodService.setSecretKey("your sk"); try { com.volcengine.service.vod.model.request.VodListCdnTasksRequest.Builder reqBuilder = com.volcengine.service.vod.model.request.VodListCdnTasksRequest.newBuilder(); reqBuilder.setSpaceName("your SpaceName"); reqBuilder.setTaskId("your TaskId"); reqBuilder.setDomainName("your DomainName"); reqBuilder.setTaskType("your TaskType"); reqBuilder.setStatus("your Status"); reqBuilder.setStartTimestamp(0); reqBuilder.setEndTimestamp(0); reqBuilder.setPageNum(0); reqBuilder.setPageSize(0); com.volcengine.service.vod.model.response.VodListCdnTasksResponse resp = vodService.listCdnTasks(reqBuilder.build()); if (resp.getResponseMetadata().hasError()) { System.out.println(resp.getResponseMetadata().getError()); System.exit(-1); } System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }
接口请求参数和返回参数说明详见获取日志文件下载地址。
package com.volcengine.example.vod.cdn; import com.volcengine.service.vod.IVodService; import com.volcengine.service.vod.impl.VodServiceImpl; public class VodListCdnAccessLogDemo { public static void main(String[] args) throws Exception { // Create a VOD instance in the specified region. // IVodService vodService = VodServiceImpl.getInstance("cn-north-1"); IVodService vodService = VodServiceImpl.getInstance(); // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65641. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // vodService.setAccessKey("your ak"); // vodService.setSecretKey("your sk"); try { com.volcengine.service.vod.model.request.VodListCdnAccessLogRequest.Builder reqBuilder = com.volcengine.service.vod.model.request.VodListCdnAccessLogRequest.newBuilder(); reqBuilder.setDomains("your Domains"); reqBuilder.setStartTimestamp(0); reqBuilder.setEndTimestamp(0); reqBuilder.setSpaceName("your SpaceName"); com.volcengine.service.vod.model.response.VodListCdnAccessLogResponse resp = vodService.listCdnAccessLog(reqBuilder.build()); if (resp.getResponseMetadata().hasError()) { System.out.println(resp.getResponseMetadata().getError()); System.exit(-1); } System.out.println(resp); } catch (Exception e) { e.printStackTrace(); } } }