/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'central';
  
@endpointMap = {
    cn-hangzhou = 'quickbi-public-share.aliyuncs.com',
    cn-hongkong = 'quickbi-public-share.aliyuncs.com',
    ap-southeast-1 = 'quickbi-public-share.aliyuncs.com',
    ap-southeast-3 = 'quickbi-public-share.aliyuncs.com',
    eu-central-1 = 'quickbi-public-share.aliyuncs.com',
  };

  checkConfig(config);
  @endpoint = getEndpoint('quickbi-public', @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 AddShareReportRequest {
  worksId?: string(name='WorksId'),
  shareToId?: string(name='ShareToId'),
  shareToType?: int32(name='ShareToType'),
  expireDate?: long(name='ExpireDate'),
  authPoint?: int32(name='AuthPoint'),
}

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

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

async function addShareReportWithOptions(request: AddShareReportRequest, runtime: Util.RuntimeOptions): AddShareReportResponse {
  Util.validateModel(request);
  var query = {};
  query["WorksId"] = request.worksId;
  query["ShareToId"] = request.shareToId;
  query["ShareToType"] = request.shareToType;
  query["ExpireDate"] = request.expireDate;
  query["AuthPoint"] = request.authPoint;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'AddShareReport',
    version = '2020-08-04',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function addShareReport(request: AddShareReportRequest): AddShareReportResponse {
  var runtime = new Util.RuntimeOptions{};
  return addShareReportWithOptions(request, runtime);
}

model CancelReportShareRequest {
  reportId?: string(name='ReportId'),
  shareToIds?: string(name='ShareToIds'),
  shareToType?: int32(name='ShareToType'),
}

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

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

async function cancelReportShareWithOptions(request: CancelReportShareRequest, runtime: Util.RuntimeOptions): CancelReportShareResponse {
  Util.validateModel(request);
  var query = {};
  query["ReportId"] = request.reportId;
  query["ShareToIds"] = request.shareToIds;
  query["ShareToType"] = request.shareToType;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'CancelReportShare',
    version = '2020-08-04',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function cancelReportShare(request: CancelReportShareRequest): CancelReportShareResponse {
  var runtime = new Util.RuntimeOptions{};
  return cancelReportShareWithOptions(request, runtime);
}

model QueryShareListRequest {
  reportId?: string(name='ReportId'),
}

model QueryShareListResponseBody = {
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
  result?: [ 
    {
      shareId?: string(name='ShareId'),
      shareToId?: string(name='ShareToId'),
      authPoint?: int32(name='AuthPoint'),
      expireDate?: long(name='ExpireDate'),
      shareToType?: int32(name='ShareToType'),
      reportId?: string(name='ReportId'),
      shareToName?: string(name='ShareToName'),
      shareType?: string(name='ShareType'),
    }
  ](name='Result'),
}

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

async function queryShareListWithOptions(request: QueryShareListRequest, runtime: Util.RuntimeOptions): QueryShareListResponse {
  Util.validateModel(request);
  var query = {};
  query["ReportId"] = request.reportId;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'QueryShareList',
    version = '2020-08-04',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryShareList(request: QueryShareListRequest): QueryShareListResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryShareListWithOptions(request, runtime);
}

model QuerySharesToUserListRequest {
  userId?: string(name='UserId'),
}

model QuerySharesToUserListResponseBody = {
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
  result?: [ 
    {
      thirdPartAuthFlag?: int32(name='ThirdPartAuthFlag'),
      status?: int32(name='Status'),
      worksId?: string(name='WorksId'),
      createTime?: string(name='CreateTime'),
      workType?: string(name='WorkType'),
      ownerName?: string(name='OwnerName'),
      workspaceName?: string(name='WorkspaceName'),
      ownerId?: string(name='OwnerId'),
      modifyName?: string(name='ModifyName'),
      workspaceId?: string(name='WorkspaceId'),
      securityLevel?: string(name='SecurityLevel'),
      description?: string(name='Description'),
      workName?: string(name='WorkName'),
      directory?: {
        pathName?: string(name='PathName'),
        pathId?: string(name='PathId'),
        name?: string(name='Name'),
        id?: string(name='Id'),
      }(name='Directory'),
      modifyTime?: string(name='ModifyTime'),
    }
  ](name='Result'),
}

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

async function querySharesToUserListWithOptions(request: QuerySharesToUserListRequest, runtime: Util.RuntimeOptions): QuerySharesToUserListResponse {
  Util.validateModel(request);
  var query = {};
  query["UserId"] = request.userId;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'QuerySharesToUserList',
    version = '2020-08-04',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function querySharesToUserList(request: QuerySharesToUserListRequest): QuerySharesToUserListResponse {
  var runtime = new Util.RuntimeOptions{};
  return querySharesToUserListWithOptions(request, runtime);
}

