/**
 *
 */
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 ApidasRequest {
  x?: int32(name='x'),
  y?: int32(name='y'),
}

model ApidasResponseBody = {
  sum?: int32(name='sum'),
}

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

async function apidasWithOptions(request: ApidasRequest, runtime: Util.RuntimeOptions): ApidasResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('Apidas', '2021-07-01_11-49-52-485', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function apidas(request: ApidasRequest): ApidasResponse {
  var runtime = new Util.RuntimeOptions{};
  return apidasWithOptions(request, runtime);
}

model TestAOpenResponseBody = {
  requestId?: string(name='RequestId', description='Id of the request'),
}

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

async function testAOpenWithOptions(runtime: Util.RuntimeOptions): TestAOpenResponse {
  var req = new OpenApi.OpenApiRequest{};
  return doRPCRequest('TestAOpen', '2021-07-01_11-49-52-485', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function testAOpen(): TestAOpenResponse {
  var runtime = new Util.RuntimeOptions{};
  return testAOpenWithOptions(runtime);
}

model TestOneRequest {
  x?: int32(name='x'),
  y?: int32(name='y'),
}

model TestOneResponseBody = {
  sum?: int32(name='sum'),
}

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

async function testOneWithOptions(request: TestOneRequest, runtime: Util.RuntimeOptions): TestOneResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('TestOne', '2021-07-01_11-49-52-485', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function testOne(request: TestOneRequest): TestOneResponse {
  var runtime = new Util.RuntimeOptions{};
  return testOneWithOptions(request, runtime);
}

model TestTwoRequest {
  x?: int32(name='x'),
  y?: int32(name='y'),
}

model TestTwoResponseBody = {
  sum?: int32(name='sum'),
}

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

async function testTwoWithOptions(request: TestTwoRequest, runtime: Util.RuntimeOptions): TestTwoResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('TestTwo', '2021-07-01_11-49-52-485', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function testTwo(request: TestTwoRequest): TestTwoResponse {
  var runtime = new Util.RuntimeOptions{};
  return testTwoWithOptions(request, runtime);
}

model ReleaseStatusTestRequest {
  x?: int32(name='x'),
  y?: int32(name='y'),
}

model ReleaseStatusTestResponseBody = {
  sum?: int32(name='sum'),
}

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

async function releaseStatusTestWithOptions(request: ReleaseStatusTestRequest, runtime: Util.RuntimeOptions): ReleaseStatusTestResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('ReleaseStatusTest', '2021-07-01_11-49-52-485', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function releaseStatusTest(request: ReleaseStatusTestRequest): ReleaseStatusTestResponse {
  var runtime = new Util.RuntimeOptions{};
  return releaseStatusTestWithOptions(request, runtime);
}

