// Code generated by crd2pulumi DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***

package v1alpha1

import (
	"context"
	"reflect"

	"antoine-roux.tk/projects/go/pulumi-library/crds/kubernetes/internal"
	v1 "github.com/pulumi/pulumi-kubernetes/sdk/v4/go/kubernetes/meta/v1"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumix"
)

// Middleware is the CRD implementation of a Traefik Middleware.
// More info: https://doc.traefik.io/traefik/v3.0/middlewares/http/overview/
type Middleware struct {
	pulumi.CustomResourceState

	ApiVersion pulumi.StringPtrOutput `pulumi:"apiVersion"`
	Kind       pulumi.StringPtrOutput `pulumi:"kind"`
	Metadata   v1.ObjectMetaOutput    `pulumi:"metadata"`
	// MiddlewareSpec defines the desired state of a Middleware.
	Spec MiddlewareSpecOutput `pulumi:"spec"`
}

// NewMiddleware registers a new resource with the given unique name, arguments, and options.
func NewMiddleware(ctx *pulumi.Context,
	name string, args *MiddlewareArgs, opts ...pulumi.ResourceOption) (*Middleware, error) {
	if args == nil {
		args = &MiddlewareArgs{}
	}

	args.ApiVersion = pulumi.StringPtr("traefik.io/v1alpha1")
	args.Kind = pulumi.StringPtr("Middleware")
	opts = internal.PkgResourceDefaultOpts(opts)
	var resource Middleware
	err := ctx.RegisterResource("kubernetes:traefik.io/v1alpha1:Middleware", name, args, &resource, opts...)
	if err != nil {
		return nil, err
	}
	return &resource, nil
}

// GetMiddleware gets an existing Middleware resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetMiddleware(ctx *pulumi.Context,
	name string, id pulumi.IDInput, state *MiddlewareState, opts ...pulumi.ResourceOption) (*Middleware, error) {
	var resource Middleware
	err := ctx.ReadResource("kubernetes:traefik.io/v1alpha1:Middleware", name, id, state, &resource, opts...)
	if err != nil {
		return nil, err
	}
	return &resource, nil
}

// Input properties used for looking up and filtering Middleware resources.
type middlewareState struct {
}

type MiddlewareState struct {
}

func (MiddlewareState) ElementType() reflect.Type {
	return reflect.TypeOf((*middlewareState)(nil)).Elem()
}

type middlewareArgs struct {
	ApiVersion *string        `pulumi:"apiVersion"`
	Kind       *string        `pulumi:"kind"`
	Metadata   *v1.ObjectMeta `pulumi:"metadata"`
	// MiddlewareSpec defines the desired state of a Middleware.
	Spec *MiddlewareSpec `pulumi:"spec"`
}

// The set of arguments for constructing a Middleware resource.
type MiddlewareArgs struct {
	ApiVersion pulumi.StringPtrInput
	Kind       pulumi.StringPtrInput
	Metadata   v1.ObjectMetaPtrInput
	// MiddlewareSpec defines the desired state of a Middleware.
	Spec MiddlewareSpecPtrInput
}

func (MiddlewareArgs) ElementType() reflect.Type {
	return reflect.TypeOf((*middlewareArgs)(nil)).Elem()
}

type MiddlewareInput interface {
	pulumi.Input

	ToMiddlewareOutput() MiddlewareOutput
	ToMiddlewareOutputWithContext(ctx context.Context) MiddlewareOutput
}

func (*Middleware) ElementType() reflect.Type {
	return reflect.TypeOf((**Middleware)(nil)).Elem()
}

func (i *Middleware) ToMiddlewareOutput() MiddlewareOutput {
	return i.ToMiddlewareOutputWithContext(context.Background())
}

func (i *Middleware) ToMiddlewareOutputWithContext(ctx context.Context) MiddlewareOutput {
	return pulumi.ToOutputWithContext(ctx, i).(MiddlewareOutput)
}

func (i *Middleware) ToOutput(ctx context.Context) pulumix.Output[*Middleware] {
	return pulumix.Output[*Middleware]{
		OutputState: i.ToMiddlewareOutputWithContext(ctx).OutputState,
	}
}

type MiddlewareOutput struct{ *pulumi.OutputState }

func (MiddlewareOutput) ElementType() reflect.Type {
	return reflect.TypeOf((**Middleware)(nil)).Elem()
}

func (o MiddlewareOutput) ToMiddlewareOutput() MiddlewareOutput {
	return o
}

func (o MiddlewareOutput) ToMiddlewareOutputWithContext(ctx context.Context) MiddlewareOutput {
	return o
}

func (o MiddlewareOutput) ToOutput(ctx context.Context) pulumix.Output[*Middleware] {
	return pulumix.Output[*Middleware]{
		OutputState: o.OutputState,
	}
}

func (o MiddlewareOutput) ApiVersion() pulumi.StringPtrOutput {
	return o.ApplyT(func(v *Middleware) pulumi.StringPtrOutput { return v.ApiVersion }).(pulumi.StringPtrOutput)
}

func (o MiddlewareOutput) Kind() pulumi.StringPtrOutput {
	return o.ApplyT(func(v *Middleware) pulumi.StringPtrOutput { return v.Kind }).(pulumi.StringPtrOutput)
}

func (o MiddlewareOutput) Metadata() v1.ObjectMetaOutput {
	return o.ApplyT(func(v *Middleware) v1.ObjectMetaOutput { return v.Metadata }).(v1.ObjectMetaOutput)
}

// MiddlewareSpec defines the desired state of a Middleware.
func (o MiddlewareOutput) Spec() MiddlewareSpecOutput {
	return o.ApplyT(func(v *Middleware) MiddlewareSpecOutput { return v.Spec }).(MiddlewareSpecOutput)
}

func init() {
	pulumi.RegisterInputType(reflect.TypeOf((*MiddlewareInput)(nil)).Elem(), &Middleware{})
	pulumi.RegisterOutputType(MiddlewareOutput{})
}
