// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

package aiven

import (
	"context"
	"reflect"

	"github.com/pkg/errors"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

// ## # Opensearch ACL Rule Resource
//
// The Opensearch ACL Rule resource models a single ACL Rule for an Aiven Opensearch service.
type OpenSearchAclRule struct {
	pulumi.CustomResourceState

	// Elasticsearch index pattern
	Index pulumi.StringOutput `pulumi:"index"`
	// is the Opensearch permission, list of supported permissions:
	// `deny`, `admin`, `read`, `readwrite`, `write`.
	Permission pulumi.StringOutput `pulumi:"permission"`
	// and `serviceName` - (Required) define the project and service the ACL belongs to.
	Project pulumi.StringOutput `pulumi:"project"`
	// Service to link the Opensearch ACLs to
	ServiceName pulumi.StringOutput `pulumi:"serviceName"`
	// and `index` - (Required) define the username and index the ACL rule should apply to.
	Username pulumi.StringOutput `pulumi:"username"`
}

// NewOpenSearchAclRule registers a new resource with the given unique name, arguments, and options.
func NewOpenSearchAclRule(ctx *pulumi.Context,
	name string, args *OpenSearchAclRuleArgs, opts ...pulumi.ResourceOption) (*OpenSearchAclRule, error) {
	if args == nil {
		return nil, errors.New("missing one or more required arguments")
	}

	if args.Index == nil {
		return nil, errors.New("invalid value for required argument 'Index'")
	}
	if args.Permission == nil {
		return nil, errors.New("invalid value for required argument 'Permission'")
	}
	if args.Project == nil {
		return nil, errors.New("invalid value for required argument 'Project'")
	}
	if args.ServiceName == nil {
		return nil, errors.New("invalid value for required argument 'ServiceName'")
	}
	if args.Username == nil {
		return nil, errors.New("invalid value for required argument 'Username'")
	}
	var resource OpenSearchAclRule
	err := ctx.RegisterResource("aiven:index/openSearchAclRule:OpenSearchAclRule", name, args, &resource, opts...)
	if err != nil {
		return nil, err
	}
	return &resource, nil
}

// GetOpenSearchAclRule gets an existing OpenSearchAclRule 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 GetOpenSearchAclRule(ctx *pulumi.Context,
	name string, id pulumi.IDInput, state *OpenSearchAclRuleState, opts ...pulumi.ResourceOption) (*OpenSearchAclRule, error) {
	var resource OpenSearchAclRule
	err := ctx.ReadResource("aiven:index/openSearchAclRule:OpenSearchAclRule", name, id, state, &resource, opts...)
	if err != nil {
		return nil, err
	}
	return &resource, nil
}

// Input properties used for looking up and filtering OpenSearchAclRule resources.
type openSearchAclRuleState struct {
	// Elasticsearch index pattern
	Index *string `pulumi:"index"`
	// is the Opensearch permission, list of supported permissions:
	// `deny`, `admin`, `read`, `readwrite`, `write`.
	Permission *string `pulumi:"permission"`
	// and `serviceName` - (Required) define the project and service the ACL belongs to.
	Project *string `pulumi:"project"`
	// Service to link the Opensearch ACLs to
	ServiceName *string `pulumi:"serviceName"`
	// and `index` - (Required) define the username and index the ACL rule should apply to.
	Username *string `pulumi:"username"`
}

type OpenSearchAclRuleState struct {
	// Elasticsearch index pattern
	Index pulumi.StringPtrInput
	// is the Opensearch permission, list of supported permissions:
	// `deny`, `admin`, `read`, `readwrite`, `write`.
	Permission pulumi.StringPtrInput
	// and `serviceName` - (Required) define the project and service the ACL belongs to.
	Project pulumi.StringPtrInput
	// Service to link the Opensearch ACLs to
	ServiceName pulumi.StringPtrInput
	// and `index` - (Required) define the username and index the ACL rule should apply to.
	Username pulumi.StringPtrInput
}

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

type openSearchAclRuleArgs struct {
	// Elasticsearch index pattern
	Index string `pulumi:"index"`
	// is the Opensearch permission, list of supported permissions:
	// `deny`, `admin`, `read`, `readwrite`, `write`.
	Permission string `pulumi:"permission"`
	// and `serviceName` - (Required) define the project and service the ACL belongs to.
	Project string `pulumi:"project"`
	// Service to link the Opensearch ACLs to
	ServiceName string `pulumi:"serviceName"`
	// and `index` - (Required) define the username and index the ACL rule should apply to.
	Username string `pulumi:"username"`
}

// The set of arguments for constructing a OpenSearchAclRule resource.
type OpenSearchAclRuleArgs struct {
	// Elasticsearch index pattern
	Index pulumi.StringInput
	// is the Opensearch permission, list of supported permissions:
	// `deny`, `admin`, `read`, `readwrite`, `write`.
	Permission pulumi.StringInput
	// and `serviceName` - (Required) define the project and service the ACL belongs to.
	Project pulumi.StringInput
	// Service to link the Opensearch ACLs to
	ServiceName pulumi.StringInput
	// and `index` - (Required) define the username and index the ACL rule should apply to.
	Username pulumi.StringInput
}

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

type OpenSearchAclRuleInput interface {
	pulumi.Input

	ToOpenSearchAclRuleOutput() OpenSearchAclRuleOutput
	ToOpenSearchAclRuleOutputWithContext(ctx context.Context) OpenSearchAclRuleOutput
}

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

func (i *OpenSearchAclRule) ToOpenSearchAclRuleOutput() OpenSearchAclRuleOutput {
	return i.ToOpenSearchAclRuleOutputWithContext(context.Background())
}

func (i *OpenSearchAclRule) ToOpenSearchAclRuleOutputWithContext(ctx context.Context) OpenSearchAclRuleOutput {
	return pulumi.ToOutputWithContext(ctx, i).(OpenSearchAclRuleOutput)
}

func (i *OpenSearchAclRule) ToOpenSearchAclRulePtrOutput() OpenSearchAclRulePtrOutput {
	return i.ToOpenSearchAclRulePtrOutputWithContext(context.Background())
}

func (i *OpenSearchAclRule) ToOpenSearchAclRulePtrOutputWithContext(ctx context.Context) OpenSearchAclRulePtrOutput {
	return pulumi.ToOutputWithContext(ctx, i).(OpenSearchAclRulePtrOutput)
}

type OpenSearchAclRulePtrInput interface {
	pulumi.Input

	ToOpenSearchAclRulePtrOutput() OpenSearchAclRulePtrOutput
	ToOpenSearchAclRulePtrOutputWithContext(ctx context.Context) OpenSearchAclRulePtrOutput
}

type openSearchAclRulePtrType OpenSearchAclRuleArgs

func (*openSearchAclRulePtrType) ElementType() reflect.Type {
	return reflect.TypeOf((**OpenSearchAclRule)(nil))
}

func (i *openSearchAclRulePtrType) ToOpenSearchAclRulePtrOutput() OpenSearchAclRulePtrOutput {
	return i.ToOpenSearchAclRulePtrOutputWithContext(context.Background())
}

func (i *openSearchAclRulePtrType) ToOpenSearchAclRulePtrOutputWithContext(ctx context.Context) OpenSearchAclRulePtrOutput {
	return pulumi.ToOutputWithContext(ctx, i).(OpenSearchAclRulePtrOutput)
}

// OpenSearchAclRuleArrayInput is an input type that accepts OpenSearchAclRuleArray and OpenSearchAclRuleArrayOutput values.
// You can construct a concrete instance of `OpenSearchAclRuleArrayInput` via:
//
//          OpenSearchAclRuleArray{ OpenSearchAclRuleArgs{...} }
type OpenSearchAclRuleArrayInput interface {
	pulumi.Input

	ToOpenSearchAclRuleArrayOutput() OpenSearchAclRuleArrayOutput
	ToOpenSearchAclRuleArrayOutputWithContext(context.Context) OpenSearchAclRuleArrayOutput
}

type OpenSearchAclRuleArray []OpenSearchAclRuleInput

func (OpenSearchAclRuleArray) ElementType() reflect.Type {
	return reflect.TypeOf(([]*OpenSearchAclRule)(nil))
}

func (i OpenSearchAclRuleArray) ToOpenSearchAclRuleArrayOutput() OpenSearchAclRuleArrayOutput {
	return i.ToOpenSearchAclRuleArrayOutputWithContext(context.Background())
}

func (i OpenSearchAclRuleArray) ToOpenSearchAclRuleArrayOutputWithContext(ctx context.Context) OpenSearchAclRuleArrayOutput {
	return pulumi.ToOutputWithContext(ctx, i).(OpenSearchAclRuleArrayOutput)
}

// OpenSearchAclRuleMapInput is an input type that accepts OpenSearchAclRuleMap and OpenSearchAclRuleMapOutput values.
// You can construct a concrete instance of `OpenSearchAclRuleMapInput` via:
//
//          OpenSearchAclRuleMap{ "key": OpenSearchAclRuleArgs{...} }
type OpenSearchAclRuleMapInput interface {
	pulumi.Input

	ToOpenSearchAclRuleMapOutput() OpenSearchAclRuleMapOutput
	ToOpenSearchAclRuleMapOutputWithContext(context.Context) OpenSearchAclRuleMapOutput
}

type OpenSearchAclRuleMap map[string]OpenSearchAclRuleInput

func (OpenSearchAclRuleMap) ElementType() reflect.Type {
	return reflect.TypeOf((map[string]*OpenSearchAclRule)(nil))
}

func (i OpenSearchAclRuleMap) ToOpenSearchAclRuleMapOutput() OpenSearchAclRuleMapOutput {
	return i.ToOpenSearchAclRuleMapOutputWithContext(context.Background())
}

func (i OpenSearchAclRuleMap) ToOpenSearchAclRuleMapOutputWithContext(ctx context.Context) OpenSearchAclRuleMapOutput {
	return pulumi.ToOutputWithContext(ctx, i).(OpenSearchAclRuleMapOutput)
}

type OpenSearchAclRuleOutput struct {
	*pulumi.OutputState
}

func (OpenSearchAclRuleOutput) ElementType() reflect.Type {
	return reflect.TypeOf((*OpenSearchAclRule)(nil))
}

func (o OpenSearchAclRuleOutput) ToOpenSearchAclRuleOutput() OpenSearchAclRuleOutput {
	return o
}

func (o OpenSearchAclRuleOutput) ToOpenSearchAclRuleOutputWithContext(ctx context.Context) OpenSearchAclRuleOutput {
	return o
}

func (o OpenSearchAclRuleOutput) ToOpenSearchAclRulePtrOutput() OpenSearchAclRulePtrOutput {
	return o.ToOpenSearchAclRulePtrOutputWithContext(context.Background())
}

func (o OpenSearchAclRuleOutput) ToOpenSearchAclRulePtrOutputWithContext(ctx context.Context) OpenSearchAclRulePtrOutput {
	return o.ApplyT(func(v OpenSearchAclRule) *OpenSearchAclRule {
		return &v
	}).(OpenSearchAclRulePtrOutput)
}

type OpenSearchAclRulePtrOutput struct {
	*pulumi.OutputState
}

func (OpenSearchAclRulePtrOutput) ElementType() reflect.Type {
	return reflect.TypeOf((**OpenSearchAclRule)(nil))
}

func (o OpenSearchAclRulePtrOutput) ToOpenSearchAclRulePtrOutput() OpenSearchAclRulePtrOutput {
	return o
}

func (o OpenSearchAclRulePtrOutput) ToOpenSearchAclRulePtrOutputWithContext(ctx context.Context) OpenSearchAclRulePtrOutput {
	return o
}

type OpenSearchAclRuleArrayOutput struct{ *pulumi.OutputState }

func (OpenSearchAclRuleArrayOutput) ElementType() reflect.Type {
	return reflect.TypeOf((*[]OpenSearchAclRule)(nil))
}

func (o OpenSearchAclRuleArrayOutput) ToOpenSearchAclRuleArrayOutput() OpenSearchAclRuleArrayOutput {
	return o
}

func (o OpenSearchAclRuleArrayOutput) ToOpenSearchAclRuleArrayOutputWithContext(ctx context.Context) OpenSearchAclRuleArrayOutput {
	return o
}

func (o OpenSearchAclRuleArrayOutput) Index(i pulumi.IntInput) OpenSearchAclRuleOutput {
	return pulumi.All(o, i).ApplyT(func(vs []interface{}) OpenSearchAclRule {
		return vs[0].([]OpenSearchAclRule)[vs[1].(int)]
	}).(OpenSearchAclRuleOutput)
}

type OpenSearchAclRuleMapOutput struct{ *pulumi.OutputState }

func (OpenSearchAclRuleMapOutput) ElementType() reflect.Type {
	return reflect.TypeOf((*map[string]OpenSearchAclRule)(nil))
}

func (o OpenSearchAclRuleMapOutput) ToOpenSearchAclRuleMapOutput() OpenSearchAclRuleMapOutput {
	return o
}

func (o OpenSearchAclRuleMapOutput) ToOpenSearchAclRuleMapOutputWithContext(ctx context.Context) OpenSearchAclRuleMapOutput {
	return o
}

func (o OpenSearchAclRuleMapOutput) MapIndex(k pulumi.StringInput) OpenSearchAclRuleOutput {
	return pulumi.All(o, k).ApplyT(func(vs []interface{}) OpenSearchAclRule {
		return vs[0].(map[string]OpenSearchAclRule)[vs[1].(string)]
	}).(OpenSearchAclRuleOutput)
}

func init() {
	pulumi.RegisterOutputType(OpenSearchAclRuleOutput{})
	pulumi.RegisterOutputType(OpenSearchAclRulePtrOutput{})
	pulumi.RegisterOutputType(OpenSearchAclRuleArrayOutput{})
	pulumi.RegisterOutputType(OpenSearchAclRuleMapOutput{})
}
