func()

in datahub/implement.go [1201:1227]


func (datahub *DataHub) OpenSubscriptionSession(projectName, topicName, subId string, shardIds []string) (*OpenSubscriptionSessionResult, error) {
	if !util.CheckProjectName(projectName) {
		return nil, NewInvalidParameterErrorWithMessage(projectNameInvalid)
	}
	if !util.CheckTopicName(topicName) {
		return nil, NewInvalidParameterErrorWithMessage(topicNameInvalid)
	}
	for _, id := range shardIds {
		if !util.CheckShardId(id) {
			return nil, NewInvalidParameterErrorWithMessage(shardIdInvalid)
		}
	}

	path := fmt.Sprintf(offsetsPath, projectName, topicName, subId)
	reqPara := &RequestParameter{
		Header: map[string]string{httpHeaderContentType: httpJsonContent},
	}
	ossr := &OpenSubscriptionSessionRequest{
		Action:   "open",
		ShardIds: shardIds,
	}
	respBody, commonResp, err := datahub.Client.Post(path, ossr, reqPara)
	if err != nil {
		return nil, err
	}
	return NewOpenSubscriptionSessionResult(respBody, commonResp)
}