/**
 *
 */
import Util;
import OpenApi;

import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'regional';
  
  checkConfig(config);
  @endpoint = getEndpoint('composer', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model CloneFlowRequest {
  flowId?: string(name='FlowId'),
  versionId?: string(name='VersionId'),
}

model CloneFlowResponseBody = {
  requestId?: string(name='RequestId'),
  flowId?: string(name='FlowId'),
}

model CloneFlowResponse = {
  headers: map[string]string(name='headers'),
  body: CloneFlowResponseBody(name='body'),
}

async function cloneFlowWithOptions(request: CloneFlowRequest, runtime: Util.RuntimeOptions): CloneFlowResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('CloneFlow', '2018-12-12', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function cloneFlow(request: CloneFlowRequest): CloneFlowResponse {
  var runtime = new Util.RuntimeOptions{};
  return cloneFlowWithOptions(request, runtime);
}

model CreateFlowRequest {
  flowName?: string(name='FlowName'),
  flowDescription?: string(name='FlowDescription'),
  definition?: string(name='Definition'),
  templateId?: string(name='TemplateId'),
  flowSource?: string(name='FlowSource'),
}

model CreateFlowResponseBody = {
  requestId?: string(name='RequestId'),
  flowId?: string(name='FlowId'),
}

model CreateFlowResponse = {
  headers: map[string]string(name='headers'),
  body: CreateFlowResponseBody(name='body'),
}

async function createFlowWithOptions(request: CreateFlowRequest, runtime: Util.RuntimeOptions): CreateFlowResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('CreateFlow', '2018-12-12', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function createFlow(request: CreateFlowRequest): CreateFlowResponse {
  var runtime = new Util.RuntimeOptions{};
  return createFlowWithOptions(request, runtime);
}

model DeleteFlowRequest {
  flowId?: string(name='FlowId'),
}

model DeleteFlowResponseBody = {
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model DeleteFlowResponse = {
  headers: map[string]string(name='headers'),
  body: DeleteFlowResponseBody(name='body'),
}

async function deleteFlowWithOptions(request: DeleteFlowRequest, runtime: Util.RuntimeOptions): DeleteFlowResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('DeleteFlow', '2018-12-12', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function deleteFlow(request: DeleteFlowRequest): DeleteFlowResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteFlowWithOptions(request, runtime);
}

model DisableFlowRequest {
  flowId?: string(name='FlowId'),
}

model DisableFlowResponseBody = {
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
  flowStatus?: string(name='FlowStatus'),
}

model DisableFlowResponse = {
  headers: map[string]string(name='headers'),
  body: DisableFlowResponseBody(name='body'),
}

async function disableFlowWithOptions(request: DisableFlowRequest, runtime: Util.RuntimeOptions): DisableFlowResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('DisableFlow', '2018-12-12', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function disableFlow(request: DisableFlowRequest): DisableFlowResponse {
  var runtime = new Util.RuntimeOptions{};
  return disableFlowWithOptions(request, runtime);
}

model EnableFlowRequest {
  flowId?: string(name='FlowId'),
}

model EnableFlowResponseBody = {
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
  flowStatus?: string(name='FlowStatus'),
}

model EnableFlowResponse = {
  headers: map[string]string(name='headers'),
  body: EnableFlowResponseBody(name='body'),
}

async function enableFlowWithOptions(request: EnableFlowRequest, runtime: Util.RuntimeOptions): EnableFlowResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('EnableFlow', '2018-12-12', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function enableFlow(request: EnableFlowRequest): EnableFlowResponse {
  var runtime = new Util.RuntimeOptions{};
  return enableFlowWithOptions(request, runtime);
}

model GetFlowRequest {
  flowId?: string(name='FlowId'),
}

model GetFlowResponseBody = {
  requestId?: string(name='RequestId'),
  flowId?: string(name='FlowId'),
  regionId?: string(name='RegionId'),
  flowName?: string(name='FlowName'),
  flowDescription?: string(name='FlowDescription'),
  createTime?: string(name='CreateTime'),
  updateTime?: string(name='UpdateTime'),
  currentVersionId?: int32(name='CurrentVersionId'),
  flowStatus?: string(name='FlowStatus'),
  definition?: string(name='Definition'),
  templateId?: string(name='TemplateId'),
  flowSource?: string(name='FlowSource'),
  flowEditMode?: string(name='FlowEditMode'),
}

model GetFlowResponse = {
  headers: map[string]string(name='headers'),
  body: GetFlowResponseBody(name='body'),
}

async function getFlowWithOptions(request: GetFlowRequest, runtime: Util.RuntimeOptions): GetFlowResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('GetFlow', '2018-12-12', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function getFlow(request: GetFlowRequest): GetFlowResponse {
  var runtime = new Util.RuntimeOptions{};
  return getFlowWithOptions(request, runtime);
}

model GetTemplateRequest {
  templateId?: string(name='TemplateId'),
}

model GetTemplateResponseBody = {
  requestId?: string(name='RequestId'),
  regionId?: string(name='RegionId'),
  templateId?: string(name='TemplateId'),
  templateName?: string(name='TemplateName'),
  templateDescription?: string(name='TemplateDescription'),
  templateTag?: string(name='TemplateTag'),
  definition?: string(name='Definition'),
  createTime?: string(name='CreateTime'),
  updateTime?: string(name='UpdateTime'),
  templateConnector?: string(name='TemplateConnector'),
  templateSummary?: string(name='TemplateSummary'),
  templateSummaryEn?: string(name='TemplateSummaryEn'),
  templateLocale?: string(name='TemplateLocale'),
  templateVersion?: int32(name='TemplateVersion'),
  templateOverview?: string(name='TemplateOverview'),
  templateCreator?: string(name='TemplateCreator'),
}

model GetTemplateResponse = {
  headers: map[string]string(name='headers'),
  body: GetTemplateResponseBody(name='body'),
}

async function getTemplateWithOptions(request: GetTemplateRequest, runtime: Util.RuntimeOptions): GetTemplateResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('GetTemplate', '2018-12-12', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function getTemplate(request: GetTemplateRequest): GetTemplateResponse {
  var runtime = new Util.RuntimeOptions{};
  return getTemplateWithOptions(request, runtime);
}

model GetVersionRequest {
  flowId?: string(name='FlowId', description='工作流 ID'),
  versionId?: string(name='VersionId', description='工作流版本 ID'),
}

model GetVersionResponseBody = {
  createTime?: string(name='CreateTime', description='创建时间'),
  definition?: string(name='Definition', description='工作流定义'),
  flowId?: string(name='FlowId', description='工作流 ID'),
  regionId?: string(name='RegionId', description='地域 ID'),
  requestId?: string(name='RequestId', description='请求 ID'),
  updateTime?: string(name='UpdateTime', description='更新时间'),
  versionDescription?: string(name='VersionDescription', description='版本描述'),
  versionId?: string(name='VersionId', description='版本 ID'),
  versionName?: string(name='VersionName', description='版本名称'),
  versionStatus?: string(name='VersionStatus', description='版本状态'),
}

model GetVersionResponse = {
  headers: map[string]string(name='headers'),
  body: GetVersionResponseBody(name='body'),
}

async function getVersionWithOptions(request: GetVersionRequest, runtime: Util.RuntimeOptions): GetVersionResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('GetVersion', '2018-12-12', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function getVersion(request: GetVersionRequest): GetVersionResponse {
  var runtime = new Util.RuntimeOptions{};
  return getVersionWithOptions(request, runtime);
}

model GroupInvokeFlowRequest {
  flowId?: string(name='FlowId', description='FlowId'),
  groupKey?: string(name='GroupKey', description='GroupKey'),
  data?: string(name='Data', description='Data'),
  clientToken?: string(name='ClientToken', description='ClientToken'),
  totalCount?: int32(name='TotalCount', description='TotalCount'),
  tags?: string(name='Tags', description='Tags'),
}

model GroupInvokeFlowResponseBody = {
  currentCount?: int32(name='CurrentCount', description='当前批次'),
  groupInvocationId?: string(name='GroupInvocationId', description='执行 ID'),
  requestId?: string(name='RequestId', description='请求 ID'),
  status?: string(name='Status', description='状态'),
  success?: boolean(name='Success', description='调用是否成功'),
}

model GroupInvokeFlowResponse = {
  headers: map[string]string(name='headers'),
  body: GroupInvokeFlowResponseBody(name='body'),
}

async function groupInvokeFlowWithOptions(request: GroupInvokeFlowRequest, runtime: Util.RuntimeOptions): GroupInvokeFlowResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('GroupInvokeFlow', '2018-12-12', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function groupInvokeFlow(request: GroupInvokeFlowRequest): GroupInvokeFlowResponse {
  var runtime = new Util.RuntimeOptions{};
  return groupInvokeFlowWithOptions(request, runtime);
}

model InvokeFlowRequest {
  flowId?: string(name='FlowId'),
  parameters?: string(name='Parameters'),
  data?: string(name='Data'),
  clientToken?: string(name='ClientToken'),
}

model InvokeFlowResponseBody = {
  requestId?: string(name='RequestId'),
  invocationId?: string(name='InvocationId'),
  success?: boolean(name='Success'),
}

model InvokeFlowResponse = {
  headers: map[string]string(name='headers'),
  body: InvokeFlowResponseBody(name='body'),
}

async function invokeFlowWithOptions(request: InvokeFlowRequest, runtime: Util.RuntimeOptions): InvokeFlowResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('InvokeFlow', '2018-12-12', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function invokeFlow(request: InvokeFlowRequest): InvokeFlowResponse {
  var runtime = new Util.RuntimeOptions{};
  return invokeFlowWithOptions(request, runtime);
}

model ListFlowsRequest {
  pageSize?: int32(name='PageSize'),
  pageNumber?: int32(name='PageNumber'),
  flowName?: string(name='FlowName'),
  filter?: string(name='Filter'),
}

model ListFlowsResponseBody = {
  requestId?: string(name='RequestId'),
  totalCount?: int32(name='TotalCount'),
  flows?: [ 
    {
      flowId?: string(name='FlowId'),
      regionId?: string(name='RegionId'),
      flowName?: string(name='FlowName'),
      flowDescription?: string(name='FlowDescription'),
      versionId?: int32(name='VersionId'),
      createTime?: string(name='CreateTime'),
      updateTime?: string(name='UpdateTime'),
      flowStatus?: string(name='FlowStatus'),
      templateId?: string(name='TemplateId'),
      flowSource?: string(name='FlowSource'),
      flowEditMode?: string(name='FlowEditMode'),
    }
  ](name='Flows'),
}

model ListFlowsResponse = {
  headers: map[string]string(name='headers'),
  body: ListFlowsResponseBody(name='body'),
}

async function listFlowsWithOptions(request: ListFlowsRequest, runtime: Util.RuntimeOptions): ListFlowsResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('ListFlows', '2018-12-12', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function listFlows(request: ListFlowsRequest): ListFlowsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listFlowsWithOptions(request, runtime);
}

model ListTagResourcesRequest {
  resourceType?: string(name='ResourceType'),
  resourceId?: [ string ](name='ResourceId'),
  tag?: [ 
    {
      key?: string(name='Key'),
      value?: string(name='Value'),
    }
  ](name='Tag'),
  nextToken?: string(name='NextToken'),
  maxResults?: int32(name='MaxResults'),
}

model ListTagResourcesResponseBody = {
  requestId?: string(name='RequestId'),
  nextToken?: string(name='NextToken'),
  totalCount?: int32(name='TotalCount'),
  tagResources?: [ 
    {
      tagKey?: string(name='TagKey'),
      tagValue?: string(name='TagValue'),
      resourceId?: string(name='ResourceId'),
      resourceType?: string(name='ResourceType'),
    }
  ](name='TagResources'),
}

model ListTagResourcesResponse = {
  headers: map[string]string(name='headers'),
  body: ListTagResourcesResponseBody(name='body'),
}

async function listTagResourcesWithOptions(request: ListTagResourcesRequest, runtime: Util.RuntimeOptions): ListTagResourcesResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('ListTagResources', '2018-12-12', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function listTagResources(request: ListTagResourcesRequest): ListTagResourcesResponse {
  var runtime = new Util.RuntimeOptions{};
  return listTagResourcesWithOptions(request, runtime);
}

model ListTemplatesRequest {
  pageNumber?: int32(name='PageNumber'),
  pageSize?: int32(name='PageSize'),
  name?: string(name='Name'),
  tag?: string(name='Tag'),
  lang?: string(name='Lang'),
}

model ListTemplatesResponseBody = {
  requestId?: string(name='RequestId'),
  totalCount?: int32(name='TotalCount'),
  templates?: [ 
    {
      templateId?: string(name='TemplateId'),
      templateName?: string(name='TemplateName'),
      templateDescription?: string(name='TemplateDescription'),
      templateTag?: string(name='TemplateTag'),
      createTime?: string(name='CreateTime'),
      updateTime?: string(name='UpdateTime'),
      templateConnector?: string(name='TemplateConnector'),
      templateSummary?: string(name='TemplateSummary'),
      templateSummaryEn?: string(name='TemplateSummaryEn'),
      templateLocale?: string(name='TemplateLocale'),
      templateVersion?: int32(name='TemplateVersion'),
      templateCreator?: string(name='TemplateCreator'),
      templateOverview?: string(name='TemplateOverview'),
    }
  ](name='Templates'),
}

model ListTemplatesResponse = {
  headers: map[string]string(name='headers'),
  body: ListTemplatesResponseBody(name='body'),
}

async function listTemplatesWithOptions(request: ListTemplatesRequest, runtime: Util.RuntimeOptions): ListTemplatesResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('ListTemplates', '2018-12-12', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function listTemplates(request: ListTemplatesRequest): ListTemplatesResponse {
  var runtime = new Util.RuntimeOptions{};
  return listTemplatesWithOptions(request, runtime);
}

model ListVersionsRequest {
  flowId?: string(name='FlowId'),
  pageNumber?: int32(name='PageNumber'),
  pageSize?: int32(name='PageSize'),
}

model ListVersionsResponseBody = {
  requestId?: string(name='RequestId'),
  totalCount?: int32(name='TotalCount'),
  versions?: [ 
    {
      versionId?: string(name='VersionId'),
      flowId?: string(name='FlowId'),
      versionName?: int32(name='VersionName'),
      versionStatus?: int32(name='VersionStatus'),
      createTime?: string(name='CreateTime'),
      updateTime?: string(name='UpdateTime'),
    }
  ](name='Versions'),
}

model ListVersionsResponse = {
  headers: map[string]string(name='headers'),
  body: ListVersionsResponseBody(name='body'),
}

async function listVersionsWithOptions(request: ListVersionsRequest, runtime: Util.RuntimeOptions): ListVersionsResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('ListVersions', '2018-12-12', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function listVersions(request: ListVersionsRequest): ListVersionsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listVersionsWithOptions(request, runtime);
}

model TagResourcesRequest {
  resourceType?: string(name='ResourceType'),
  resourceId?: [ string ](name='ResourceId'),
  tag?: [ 
    {
      key?: string(name='Key'),
      value?: string(name='Value'),
    }
  ](name='Tag'),
}

model TagResourcesResponseBody = {
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model TagResourcesResponse = {
  headers: map[string]string(name='headers'),
  body: TagResourcesResponseBody(name='body'),
}

async function tagResourcesWithOptions(request: TagResourcesRequest, runtime: Util.RuntimeOptions): TagResourcesResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('TagResources', '2018-12-12', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function tagResources(request: TagResourcesRequest): TagResourcesResponse {
  var runtime = new Util.RuntimeOptions{};
  return tagResourcesWithOptions(request, runtime);
}

model UntagResourcesRequest {
  resourceType?: string(name='ResourceType'),
  resourceId?: [ string ](name='ResourceId'),
  tagKey?: [ string ](name='TagKey'),
  all?: boolean(name='All'),
}

model UntagResourcesResponseBody = {
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model UntagResourcesResponse = {
  headers: map[string]string(name='headers'),
  body: UntagResourcesResponseBody(name='body'),
}

async function untagResourcesWithOptions(request: UntagResourcesRequest, runtime: Util.RuntimeOptions): UntagResourcesResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('UntagResources', '2018-12-12', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function untagResources(request: UntagResourcesRequest): UntagResourcesResponse {
  var runtime = new Util.RuntimeOptions{};
  return untagResourcesWithOptions(request, runtime);
}

model UpdateFlowRequest {
  flowId?: string(name='FlowId'),
  flowName?: string(name='FlowName'),
  flowDescription?: string(name='FlowDescription'),
  definition?: string(name='Definition'),
}

model UpdateFlowResponseBody = {
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
  currentVersionId?: int32(name='CurrentVersionId'),
}

model UpdateFlowResponse = {
  headers: map[string]string(name='headers'),
  body: UpdateFlowResponseBody(name='body'),
}

async function updateFlowWithOptions(request: UpdateFlowRequest, runtime: Util.RuntimeOptions): UpdateFlowResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('UpdateFlow', '2018-12-12', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function updateFlow(request: UpdateFlowRequest): UpdateFlowResponse {
  var runtime = new Util.RuntimeOptions{};
  return updateFlowWithOptions(request, runtime);
}

