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

export interface WeightedTargetArgs extends core.SchemaArgs {
  virtualNode: string | core.StringOut;

  weight: number | core.NumberOut;
}

export class WeightedTarget extends core.Schema<WeightedTargetArgs> {
  @core.attr(String)
  public virtualNode!: string | core.StringOut;

  @core.attr(Number)
  public weight!: number | core.NumberOut;
}

export interface ActionArgs extends core.SchemaArgs {
  weightedTarget: core.Array<WeightedTarget> | core.ArrayOut<WeightedTarget>;
}

export class Action extends core.Schema<ActionArgs> {
  @core.attr(WeightedTarget, { kind: "array" })
  public weightedTarget!:
    | core.Array<WeightedTarget>
    | core.ArrayOut<WeightedTarget>;
}

export interface RangeArgs extends core.SchemaArgs {
  end: number | core.NumberOut;

  start: number | core.NumberOut;
}

export class Range extends core.Schema<RangeArgs> {
  @core.attr(Number)
  public end!: number | core.NumberOut;

  @core.attr(Number)
  public start!: number | core.NumberOut;
}

export interface MetadataMatchArgs extends core.SchemaArgs {
  exact?: string | core.StringOut;

  prefix?: string | core.StringOut;

  range?: Range;

  regex?: string | core.StringOut;

  suffix?: string | core.StringOut;
}

export class MetadataMatch extends core.Schema<MetadataMatchArgs> {
  @core.attr(String)
  public exact?: string | core.StringOut;

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

  @core.attr(Range)
  public range?: Range;

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

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

export interface MetadataArgs extends core.SchemaArgs {
  invert?: boolean | core.BooleanOut;

  match?: MetadataMatch;

  name: string | core.StringOut;
}

export class Metadata extends core.Schema<MetadataArgs> {
  @core.attr(Boolean)
  public invert?: boolean | core.BooleanOut;

  @core.attr(MetadataMatch)
  public match?: MetadataMatch;

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

export interface GrpcRouteMatchArgs extends core.SchemaArgs {
  metadata?: core.Array<Metadata> | core.ArrayOut<Metadata>;

  methodName?: string | core.StringOut;

  prefix?: string | core.StringOut;

  serviceName?: string | core.StringOut;
}

export class GrpcRouteMatch extends core.Schema<GrpcRouteMatchArgs> {
  @core.attr(Metadata, { kind: "array" })
  public metadata?: core.Array<Metadata> | core.ArrayOut<Metadata>;

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

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

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

export interface PerRetryTimeoutArgs extends core.SchemaArgs {
  unit: string | core.StringOut;

  value: number | core.NumberOut;
}

export class PerRetryTimeout extends core.Schema<PerRetryTimeoutArgs> {
  @core.attr(String)
  public unit!: string | core.StringOut;

  @core.attr(Number)
  public value!: number | core.NumberOut;
}

export interface GrpcRouteRetryPolicyArgs extends core.SchemaArgs {
  grpcRetryEvents?: core.Array<string> | core.ArrayOut<core.StringOut>;

  httpRetryEvents?: core.Array<string> | core.ArrayOut<core.StringOut>;

  maxRetries: number | core.NumberOut;

  perRetryTimeout: PerRetryTimeout;

  tcpRetryEvents?: core.Array<string> | core.ArrayOut<core.StringOut>;
}

export class GrpcRouteRetryPolicy extends core.Schema<GrpcRouteRetryPolicyArgs> {
  @core.attr(String, { kind: "array" })
  public grpcRetryEvents?: core.Array<string> | core.ArrayOut<core.StringOut>;

  @core.attr(String, { kind: "array" })
  public httpRetryEvents?: core.Array<string> | core.ArrayOut<core.StringOut>;

  @core.attr(Number)
  public maxRetries!: number | core.NumberOut;

  @core.attr(PerRetryTimeout)
  public perRetryTimeout!: PerRetryTimeout;

  @core.attr(String, { kind: "array" })
  public tcpRetryEvents?: core.Array<string> | core.ArrayOut<core.StringOut>;
}

export interface IdleArgs extends core.SchemaArgs {
  unit: string | core.StringOut;

  value: number | core.NumberOut;
}

export class Idle extends core.Schema<IdleArgs> {
  @core.attr(String)
  public unit!: string | core.StringOut;

  @core.attr(Number)
  public value!: number | core.NumberOut;
}

export interface PerRequestArgs extends core.SchemaArgs {
  unit: string | core.StringOut;

  value: number | core.NumberOut;
}

export class PerRequest extends core.Schema<PerRequestArgs> {
  @core.attr(String)
  public unit!: string | core.StringOut;

  @core.attr(Number)
  public value!: number | core.NumberOut;
}

export interface GrpcRouteTimeoutArgs extends core.SchemaArgs {
  idle?: Idle;

  perRequest?: PerRequest;
}

export class GrpcRouteTimeout extends core.Schema<GrpcRouteTimeoutArgs> {
  @core.attr(Idle)
  public idle?: Idle;

  @core.attr(PerRequest)
  public perRequest?: PerRequest;
}

export interface GrpcRouteArgs extends core.SchemaArgs {
  action: Action;

  match?: GrpcRouteMatch;

  retryPolicy?: GrpcRouteRetryPolicy;

  timeout?: GrpcRouteTimeout;
}

export class GrpcRoute extends core.Schema<GrpcRouteArgs> {
  @core.attr(Action)
  public action!: Action;

  @core.attr(GrpcRouteMatch)
  public match?: GrpcRouteMatch;

  @core.attr(GrpcRouteRetryPolicy)
  public retryPolicy?: GrpcRouteRetryPolicy;

  @core.attr(GrpcRouteTimeout)
  public timeout?: GrpcRouteTimeout;
}

export interface HeaderArgs extends core.SchemaArgs {
  invert?: boolean | core.BooleanOut;

  match?: MetadataMatch;

  name: string | core.StringOut;
}

export class Header extends core.Schema<HeaderArgs> {
  @core.attr(Boolean)
  public invert?: boolean | core.BooleanOut;

  @core.attr(MetadataMatch)
  public match?: MetadataMatch;

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

export interface Http2RouteMatchArgs extends core.SchemaArgs {
  header?: core.Array<Header> | core.ArrayOut<Header>;

  method?: string | core.StringOut;

  prefix: string | core.StringOut;

  scheme?: string | core.StringOut;
}

export class Http2RouteMatch extends core.Schema<Http2RouteMatchArgs> {
  @core.attr(Header, { kind: "array" })
  public header?: core.Array<Header> | core.ArrayOut<Header>;

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

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

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

export interface Http2RouteRetryPolicyArgs extends core.SchemaArgs {
  httpRetryEvents?: core.Array<string> | core.ArrayOut<core.StringOut>;

  maxRetries: number | core.NumberOut;

  perRetryTimeout: PerRetryTimeout;

  tcpRetryEvents?: core.Array<string> | core.ArrayOut<core.StringOut>;
}

export class Http2RouteRetryPolicy extends core.Schema<Http2RouteRetryPolicyArgs> {
  @core.attr(String, { kind: "array" })
  public httpRetryEvents?: core.Array<string> | core.ArrayOut<core.StringOut>;

  @core.attr(Number)
  public maxRetries!: number | core.NumberOut;

  @core.attr(PerRetryTimeout)
  public perRetryTimeout!: PerRetryTimeout;

  @core.attr(String, { kind: "array" })
  public tcpRetryEvents?: core.Array<string> | core.ArrayOut<core.StringOut>;
}

export interface Http2RouteArgs extends core.SchemaArgs {
  action: Action;

  match: Http2RouteMatch;

  retryPolicy?: Http2RouteRetryPolicy;

  timeout?: GrpcRouteTimeout;
}

export class Http2Route extends core.Schema<Http2RouteArgs> {
  @core.attr(Action)
  public action!: Action;

  @core.attr(Http2RouteMatch)
  public match!: Http2RouteMatch;

  @core.attr(Http2RouteRetryPolicy)
  public retryPolicy?: Http2RouteRetryPolicy;

  @core.attr(GrpcRouteTimeout)
  public timeout?: GrpcRouteTimeout;
}

export interface HttpRouteArgs extends core.SchemaArgs {
  action: Action;

  match: Http2RouteMatch;

  retryPolicy?: Http2RouteRetryPolicy;

  timeout?: GrpcRouteTimeout;
}

export class HttpRoute extends core.Schema<HttpRouteArgs> {
  @core.attr(Action)
  public action!: Action;

  @core.attr(Http2RouteMatch)
  public match!: Http2RouteMatch;

  @core.attr(Http2RouteRetryPolicy)
  public retryPolicy?: Http2RouteRetryPolicy;

  @core.attr(GrpcRouteTimeout)
  public timeout?: GrpcRouteTimeout;
}

export interface TcpRouteTimeoutArgs extends core.SchemaArgs {
  idle?: Idle;
}

export class TcpRouteTimeout extends core.Schema<TcpRouteTimeoutArgs> {
  @core.attr(Idle)
  public idle?: Idle;
}

export interface TcpRouteArgs extends core.SchemaArgs {
  action: Action;

  timeout?: TcpRouteTimeout;
}

export class TcpRoute extends core.Schema<TcpRouteArgs> {
  @core.attr(Action)
  public action!: Action;

  @core.attr(TcpRouteTimeout)
  public timeout?: TcpRouteTimeout;
}

export interface SpecArgs extends core.SchemaArgs {
  grpcRoute?: GrpcRoute;

  http2Route?: Http2Route;

  httpRoute?: HttpRoute;

  priority?: number | core.NumberOut;

  tcpRoute?: TcpRoute;
}

export class Spec extends core.Schema<SpecArgs> {
  @core.attr(GrpcRoute)
  public grpcRoute?: GrpcRoute;

  @core.attr(Http2Route)
  public http2Route?: Http2Route;

  @core.attr(HttpRoute)
  public httpRoute?: HttpRoute;

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

  @core.attr(TcpRoute)
  public tcpRoute?: TcpRoute;
}

export interface RouteArgs extends core.ResourceArgs {
  meshName: string | core.StringOut;

  meshOwner?: string | core.StringOut;

  name: string | core.StringOut;

  spec: Spec;

  tags?: core.Map<string, string> | core.MapOut<core.StringOut>;

  tagsAll?: core.Map<string, string> | core.MapOut<core.StringOut>;

  virtualRouterName: string | core.StringOut;
}

export class Route extends core.Resource<RouteArgs> {
  @core.attr(String, { computed: true })
  public arn!: string | core.StringOut;

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

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

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

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

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

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

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

  @core.attr(Spec)
  public spec!: Spec;

  @core.attr(String, { kind: "map" })
  public tags?: core.Map<string, string> | core.MapOut<core.StringOut>;

  @core.attr(String, { computed: true, kind: "map" })
  public tagsAll?: core.Map<string, string> | core.MapOut<core.StringOut>;

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

  constructor(name: string, args?: RouteArgs) {
    super(name, "aws_appmesh_route", args);
  }

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