Operate Channel

Start or stop a read channel or write channel.

Prerequisites

A read channel or write channel already exists.

Request Format

POST https://{apigw-address}/data-federation/v2.0/channels/{channelId}

Request Parameters (URI)

Name

Location (Path/Query)

Mandatory/Optional

Data Type

Description

orgId

Query

Mandatory

String

The organization ID. How to get the orgId>>

channelId

Path

Mandatory

String

Channel ID.

action

Query

Mandatory

String

Operation to the channel (start: starting the channel; stop: stopping the channel)

Request Parameters (Body)

Name

Mandatory/Optional

Data Type

Description

resource

Optional

List<JSONObject>

When starting a channle, specify the resource configuration for running the channel. For details, see Resource Struct

Resource

Name

Mandatory/Optional

Data Type

Description

resourceId

Mandatory

String

Specify ID of the Federation Resource that is requested through the EnOS Resource Management page.

resourceConfig

Mandatory

Integer

Specify the amount of resource that is required for running the channel (by CU).

ifMultiResourceAnalysis

Mandatory

Boolean

Specify whether to enable cross-source analysis for the channel (true: enable; false: disable).

Samples

Request Sample

url: https://{apigw-address}/data-federation/v2.0/channels/{channelId}?orgId={}&action=start

method: POST

request body:

{
  "resource": {
    "resourceId": "federation_3n6nb7",
    "resourceConfig": "2",
    "ifMultiResourceAnalysis": "false"
  }
}

Return Sample

{
  "msg": "OK",
  "code": 0
}

Java SDK Sample

import com.alibaba.fastjson.JSONObject;
import com.envision.apim.poseidon.config.PConfig;
import com.envision.apim.poseidon.core.Poseidon;
import com.envision.apim.poseidon.request.PoseidonRequest;
import com.google.common.net.HttpHeaders;
import org.apache.commons.codec.binary.Hex;
import org.junit.Test;

import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;

public class Sample {

    private static String accessKey = "AccessKey of your APP";
    private static String secretKey = "SecretKey of your APP";
    private static String orgId = "yourOrgId";
    private static String chId = "yourChannelId";
    private static String action = "start";
    private static String url = "https://{domain_url}";

    private static class Request extends PoseidonRequest {

        public void setQueryParam(String key, Object value) {
            queryEncodeParams().put(key, value);
        }

        public void setMethod(String method) {
            this.method = method;
        }

        public void setBodyParams(String key, Object value) {
            bodyParams().put(key, value);
        }

        private String method;

        @Override
        public String baseUri() {
            return "";
        }

        @Override
        public String method() {
            return method;
        }
    }

    @Test
    public void operateChannel() {
        Request request = new Request();
        request.setQueryParam("orgId", orgId);
        request.setQueryParam("action", action);
        Map<String, Object> resource = new HashMap<>();
        resource.put("resourceId", "federation_2n6nb7");
        resource.put("resourceConfig", "2");
        resource.put("ifMultiResourceAnalysis", false);
        request.setQueryParam("resource", resource);
        request.setMethod("POST");
        try {
            JSONObject response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey))
                    .url(url + "/data-federation/v2.0/channels/" + chId)
                    .getResponse(request, JSONObject.class);
            System.out.println(response);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}