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

import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('nbf', @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 YxTestSingleApiRequest {
  x?: int32(name='x'),
  y?: int32(name='y'),
}

model YxTestSingleApiResponseBody = {
  sum?: string(name='sum'),
}

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

async function yxTestSingleApiWithOptions(request: YxTestSingleApiRequest, runtime: Util.RuntimeOptions): YxTestSingleApiResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('YxTestSingleApi', '2021-07-15_10-37-40-905', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function yxTestSingleApi(request: YxTestSingleApiRequest): YxTestSingleApiResponse {
  var runtime = new Util.RuntimeOptions{};
  return yxTestSingleApiWithOptions(request, runtime);
}

model YxTestDynamicSpiRequest {
  method?: string(name='method'),
  x?: int32(name='x'),
  y?: int32(name='y'),
}

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

async function yxTestDynamicSpiWithOptions(request: YxTestDynamicSpiRequest, runtime: Util.RuntimeOptions): YxTestDynamicSpiResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('YxTestDynamicSpi', '2021-07-15_10-37-40-905', 'HTTPS', 'POST', 'AK', 'int32', req, runtime);
}

async function yxTestDynamicSpi(request: YxTestDynamicSpiRequest): YxTestDynamicSpiResponse {
  var runtime = new Util.RuntimeOptions{};
  return yxTestDynamicSpiWithOptions(request, runtime);
}

