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

export interface PortRangeArgs extends core.SchemaArgs {
  fromPort?: number | core.NumberOut;

  toPort?: number | core.NumberOut;
}

export class PortRange extends core.Schema<PortRangeArgs> {
  @core.attr(Number)
  public fromPort?: number | core.NumberOut;

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

export interface ListenerArgs extends core.ResourceArgs {
  acceleratorArn: string | core.StringOut;

  clientAffinity?: string | core.StringOut;

  portRange: core.Array<PortRange> | core.ArrayOut<PortRange>;

  protocol: string | core.StringOut;
}

export class Listener extends core.Resource<ListenerArgs> {
  @core.attr(String)
  public acceleratorArn!: string | core.StringOut;

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

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

  @core.attr(PortRange, { kind: "array" })
  public portRange!: core.Array<PortRange> | core.ArrayOut<PortRange>;

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

  constructor(name: string, args?: ListenerArgs) {
    super(name, "aws_globalaccelerator_listener", args);
  }

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