import * as core from "@terrascript/core";

export interface LambdaConflictHandlerConfigArgs extends core.SchemaArgs {
  lambdaConflictHandlerArn?: string | core.StringOut;
}

export class LambdaConflictHandlerConfig extends core.Schema<LambdaConflictHandlerConfigArgs> {
  @core.attr(String)
  public lambdaConflictHandlerArn?: string | core.StringOut;
}

export interface SyncConfigArgs extends core.SchemaArgs {
  conflictDetection?: string | core.StringOut;

  conflictHandler?: string | core.StringOut;

  lambdaConflictHandlerConfig?: LambdaConflictHandlerConfig;
}

export class SyncConfig extends core.Schema<SyncConfigArgs> {
  @core.attr(String)
  public conflictDetection?: string | core.StringOut;

  @core.attr(String)
  public conflictHandler?: string | core.StringOut;

  @core.attr(LambdaConflictHandlerConfig)
  public lambdaConflictHandlerConfig?: LambdaConflictHandlerConfig;
}

export interface FunctionArgs extends core.ResourceArgs {
  apiId: string | core.StringOut;

  dataSource: string | core.StringOut;

  description?: string | core.StringOut;

  functionVersion?: string | core.StringOut;

  maxBatchSize?: number | core.NumberOut;

  name: string | core.StringOut;

  requestMappingTemplate: string | core.StringOut;

  responseMappingTemplate: string | core.StringOut;

  syncConfig?: SyncConfig;
}

export class Function extends core.Resource<FunctionArgs> {
  @core.attr(String)
  public apiId!: string | core.StringOut;

  @core.attr(String, { computed: true })
  public arn!: string | core.StringOut;

  @core.attr(String)
  public dataSource!: string | core.StringOut;

  @core.attr(String)
  public description?: string | core.StringOut;

  @core.attr(String, { computed: true })
  public functionId!: string | core.StringOut;

  @core.attr(String)
  public functionVersion?: string | core.StringOut;

  @core.attr(String, { computed: true })
  public id!: string | core.StringOut;

  @core.attr(Number)
  public maxBatchSize?: number | core.NumberOut;

  @core.attr(String)
  public name!: string | core.StringOut;

  @core.attr(String)
  public requestMappingTemplate!: string | core.StringOut;

  @core.attr(String)
  public responseMappingTemplate!: string | core.StringOut;

  @core.attr(SyncConfig)
  public syncConfig?: SyncConfig;

  constructor(name: string, args?: FunctionArgs) {
    super(name, "aws_appsync_function", args);
  }

  public override getNamespace(): string {
    return "aws_appsync";
  }
}
