github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/opensearch/package.go (about)

     1  // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
     2  // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  package opensearch
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"errors"
    11  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    12  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    13  )
    14  
    15  // Manages an AWS Opensearch Package.
    16  //
    17  // ## Example Usage
    18  //
    19  // ### Basic Usage
    20  //
    21  // <!--Start PulumiCodeChooser -->
    22  // ```go
    23  // package main
    24  //
    25  // import (
    26  //
    27  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/opensearch"
    28  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
    29  //	"github.com/pulumi/pulumi-std/sdk/go/std"
    30  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    31  //
    32  // )
    33  //
    34  //	func main() {
    35  //		pulumi.Run(func(ctx *pulumi.Context) error {
    36  //			myOpensearchPackages, err := s3.NewBucketV2(ctx, "my_opensearch_packages", &s3.BucketV2Args{
    37  //				Bucket: pulumi.String("my-opensearch-packages"),
    38  //			})
    39  //			if err != nil {
    40  //				return err
    41  //			}
    42  //			invokeFilemd5, err := std.Filemd5(ctx, &std.Filemd5Args{
    43  //				Input: "./example.txt",
    44  //			}, nil)
    45  //			if err != nil {
    46  //				return err
    47  //			}
    48  //			example, err := s3.NewBucketObjectv2(ctx, "example", &s3.BucketObjectv2Args{
    49  //				Bucket: myOpensearchPackages.Bucket,
    50  //				Key:    pulumi.String("example.txt"),
    51  //				Source: pulumi.NewFileAsset("./example.txt"),
    52  //				Etag:   invokeFilemd5.Result,
    53  //			})
    54  //			if err != nil {
    55  //				return err
    56  //			}
    57  //			_, err = opensearch.NewPackage(ctx, "example", &opensearch.PackageArgs{
    58  //				PackageName: pulumi.String("example-txt"),
    59  //				PackageSource: &opensearch.PackagePackageSourceArgs{
    60  //					S3BucketName: myOpensearchPackages.Bucket,
    61  //					S3Key:        example.Key,
    62  //				},
    63  //				PackageType: pulumi.String("TXT-DICTIONARY"),
    64  //			})
    65  //			if err != nil {
    66  //				return err
    67  //			}
    68  //			return nil
    69  //		})
    70  //	}
    71  //
    72  // ```
    73  // <!--End PulumiCodeChooser -->
    74  //
    75  // ## Import
    76  //
    77  // Using `pulumi import`, import AWS Opensearch Packages using the Package ID. For example:
    78  //
    79  // ```sh
    80  // $ pulumi import aws:opensearch/package:Package example package-id
    81  // ```
    82  type Package struct {
    83  	pulumi.CustomResourceState
    84  
    85  	// The current version of the package.
    86  	AvailablePackageVersion pulumi.StringOutput `pulumi:"availablePackageVersion"`
    87  	// Description of the package.
    88  	PackageDescription pulumi.StringPtrOutput `pulumi:"packageDescription"`
    89  	PackageId          pulumi.StringOutput    `pulumi:"packageId"`
    90  	// Unique name for the package.
    91  	PackageName pulumi.StringOutput `pulumi:"packageName"`
    92  	// Configuration block for the package source options.
    93  	PackageSource PackagePackageSourceOutput `pulumi:"packageSource"`
    94  	// The type of package.
    95  	PackageType pulumi.StringOutput `pulumi:"packageType"`
    96  }
    97  
    98  // NewPackage registers a new resource with the given unique name, arguments, and options.
    99  func NewPackage(ctx *pulumi.Context,
   100  	name string, args *PackageArgs, opts ...pulumi.ResourceOption) (*Package, error) {
   101  	if args == nil {
   102  		return nil, errors.New("missing one or more required arguments")
   103  	}
   104  
   105  	if args.PackageName == nil {
   106  		return nil, errors.New("invalid value for required argument 'PackageName'")
   107  	}
   108  	if args.PackageSource == nil {
   109  		return nil, errors.New("invalid value for required argument 'PackageSource'")
   110  	}
   111  	if args.PackageType == nil {
   112  		return nil, errors.New("invalid value for required argument 'PackageType'")
   113  	}
   114  	opts = internal.PkgResourceDefaultOpts(opts)
   115  	var resource Package
   116  	err := ctx.RegisterResource("aws:opensearch/package:Package", name, args, &resource, opts...)
   117  	if err != nil {
   118  		return nil, err
   119  	}
   120  	return &resource, nil
   121  }
   122  
   123  // GetPackage gets an existing Package resource's state with the given name, ID, and optional
   124  // state properties that are used to uniquely qualify the lookup (nil if not required).
   125  func GetPackage(ctx *pulumi.Context,
   126  	name string, id pulumi.IDInput, state *PackageState, opts ...pulumi.ResourceOption) (*Package, error) {
   127  	var resource Package
   128  	err := ctx.ReadResource("aws:opensearch/package:Package", name, id, state, &resource, opts...)
   129  	if err != nil {
   130  		return nil, err
   131  	}
   132  	return &resource, nil
   133  }
   134  
   135  // Input properties used for looking up and filtering Package resources.
   136  type packageState struct {
   137  	// The current version of the package.
   138  	AvailablePackageVersion *string `pulumi:"availablePackageVersion"`
   139  	// Description of the package.
   140  	PackageDescription *string `pulumi:"packageDescription"`
   141  	PackageId          *string `pulumi:"packageId"`
   142  	// Unique name for the package.
   143  	PackageName *string `pulumi:"packageName"`
   144  	// Configuration block for the package source options.
   145  	PackageSource *PackagePackageSource `pulumi:"packageSource"`
   146  	// The type of package.
   147  	PackageType *string `pulumi:"packageType"`
   148  }
   149  
   150  type PackageState struct {
   151  	// The current version of the package.
   152  	AvailablePackageVersion pulumi.StringPtrInput
   153  	// Description of the package.
   154  	PackageDescription pulumi.StringPtrInput
   155  	PackageId          pulumi.StringPtrInput
   156  	// Unique name for the package.
   157  	PackageName pulumi.StringPtrInput
   158  	// Configuration block for the package source options.
   159  	PackageSource PackagePackageSourcePtrInput
   160  	// The type of package.
   161  	PackageType pulumi.StringPtrInput
   162  }
   163  
   164  func (PackageState) ElementType() reflect.Type {
   165  	return reflect.TypeOf((*packageState)(nil)).Elem()
   166  }
   167  
   168  type packageArgs struct {
   169  	// Description of the package.
   170  	PackageDescription *string `pulumi:"packageDescription"`
   171  	// Unique name for the package.
   172  	PackageName string `pulumi:"packageName"`
   173  	// Configuration block for the package source options.
   174  	PackageSource PackagePackageSource `pulumi:"packageSource"`
   175  	// The type of package.
   176  	PackageType string `pulumi:"packageType"`
   177  }
   178  
   179  // The set of arguments for constructing a Package resource.
   180  type PackageArgs struct {
   181  	// Description of the package.
   182  	PackageDescription pulumi.StringPtrInput
   183  	// Unique name for the package.
   184  	PackageName pulumi.StringInput
   185  	// Configuration block for the package source options.
   186  	PackageSource PackagePackageSourceInput
   187  	// The type of package.
   188  	PackageType pulumi.StringInput
   189  }
   190  
   191  func (PackageArgs) ElementType() reflect.Type {
   192  	return reflect.TypeOf((*packageArgs)(nil)).Elem()
   193  }
   194  
   195  type PackageInput interface {
   196  	pulumi.Input
   197  
   198  	ToPackageOutput() PackageOutput
   199  	ToPackageOutputWithContext(ctx context.Context) PackageOutput
   200  }
   201  
   202  func (*Package) ElementType() reflect.Type {
   203  	return reflect.TypeOf((**Package)(nil)).Elem()
   204  }
   205  
   206  func (i *Package) ToPackageOutput() PackageOutput {
   207  	return i.ToPackageOutputWithContext(context.Background())
   208  }
   209  
   210  func (i *Package) ToPackageOutputWithContext(ctx context.Context) PackageOutput {
   211  	return pulumi.ToOutputWithContext(ctx, i).(PackageOutput)
   212  }
   213  
   214  // PackageArrayInput is an input type that accepts PackageArray and PackageArrayOutput values.
   215  // You can construct a concrete instance of `PackageArrayInput` via:
   216  //
   217  //	PackageArray{ PackageArgs{...} }
   218  type PackageArrayInput interface {
   219  	pulumi.Input
   220  
   221  	ToPackageArrayOutput() PackageArrayOutput
   222  	ToPackageArrayOutputWithContext(context.Context) PackageArrayOutput
   223  }
   224  
   225  type PackageArray []PackageInput
   226  
   227  func (PackageArray) ElementType() reflect.Type {
   228  	return reflect.TypeOf((*[]*Package)(nil)).Elem()
   229  }
   230  
   231  func (i PackageArray) ToPackageArrayOutput() PackageArrayOutput {
   232  	return i.ToPackageArrayOutputWithContext(context.Background())
   233  }
   234  
   235  func (i PackageArray) ToPackageArrayOutputWithContext(ctx context.Context) PackageArrayOutput {
   236  	return pulumi.ToOutputWithContext(ctx, i).(PackageArrayOutput)
   237  }
   238  
   239  // PackageMapInput is an input type that accepts PackageMap and PackageMapOutput values.
   240  // You can construct a concrete instance of `PackageMapInput` via:
   241  //
   242  //	PackageMap{ "key": PackageArgs{...} }
   243  type PackageMapInput interface {
   244  	pulumi.Input
   245  
   246  	ToPackageMapOutput() PackageMapOutput
   247  	ToPackageMapOutputWithContext(context.Context) PackageMapOutput
   248  }
   249  
   250  type PackageMap map[string]PackageInput
   251  
   252  func (PackageMap) ElementType() reflect.Type {
   253  	return reflect.TypeOf((*map[string]*Package)(nil)).Elem()
   254  }
   255  
   256  func (i PackageMap) ToPackageMapOutput() PackageMapOutput {
   257  	return i.ToPackageMapOutputWithContext(context.Background())
   258  }
   259  
   260  func (i PackageMap) ToPackageMapOutputWithContext(ctx context.Context) PackageMapOutput {
   261  	return pulumi.ToOutputWithContext(ctx, i).(PackageMapOutput)
   262  }
   263  
   264  type PackageOutput struct{ *pulumi.OutputState }
   265  
   266  func (PackageOutput) ElementType() reflect.Type {
   267  	return reflect.TypeOf((**Package)(nil)).Elem()
   268  }
   269  
   270  func (o PackageOutput) ToPackageOutput() PackageOutput {
   271  	return o
   272  }
   273  
   274  func (o PackageOutput) ToPackageOutputWithContext(ctx context.Context) PackageOutput {
   275  	return o
   276  }
   277  
   278  // The current version of the package.
   279  func (o PackageOutput) AvailablePackageVersion() pulumi.StringOutput {
   280  	return o.ApplyT(func(v *Package) pulumi.StringOutput { return v.AvailablePackageVersion }).(pulumi.StringOutput)
   281  }
   282  
   283  // Description of the package.
   284  func (o PackageOutput) PackageDescription() pulumi.StringPtrOutput {
   285  	return o.ApplyT(func(v *Package) pulumi.StringPtrOutput { return v.PackageDescription }).(pulumi.StringPtrOutput)
   286  }
   287  
   288  func (o PackageOutput) PackageId() pulumi.StringOutput {
   289  	return o.ApplyT(func(v *Package) pulumi.StringOutput { return v.PackageId }).(pulumi.StringOutput)
   290  }
   291  
   292  // Unique name for the package.
   293  func (o PackageOutput) PackageName() pulumi.StringOutput {
   294  	return o.ApplyT(func(v *Package) pulumi.StringOutput { return v.PackageName }).(pulumi.StringOutput)
   295  }
   296  
   297  // Configuration block for the package source options.
   298  func (o PackageOutput) PackageSource() PackagePackageSourceOutput {
   299  	return o.ApplyT(func(v *Package) PackagePackageSourceOutput { return v.PackageSource }).(PackagePackageSourceOutput)
   300  }
   301  
   302  // The type of package.
   303  func (o PackageOutput) PackageType() pulumi.StringOutput {
   304  	return o.ApplyT(func(v *Package) pulumi.StringOutput { return v.PackageType }).(pulumi.StringOutput)
   305  }
   306  
   307  type PackageArrayOutput struct{ *pulumi.OutputState }
   308  
   309  func (PackageArrayOutput) ElementType() reflect.Type {
   310  	return reflect.TypeOf((*[]*Package)(nil)).Elem()
   311  }
   312  
   313  func (o PackageArrayOutput) ToPackageArrayOutput() PackageArrayOutput {
   314  	return o
   315  }
   316  
   317  func (o PackageArrayOutput) ToPackageArrayOutputWithContext(ctx context.Context) PackageArrayOutput {
   318  	return o
   319  }
   320  
   321  func (o PackageArrayOutput) Index(i pulumi.IntInput) PackageOutput {
   322  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Package {
   323  		return vs[0].([]*Package)[vs[1].(int)]
   324  	}).(PackageOutput)
   325  }
   326  
   327  type PackageMapOutput struct{ *pulumi.OutputState }
   328  
   329  func (PackageMapOutput) ElementType() reflect.Type {
   330  	return reflect.TypeOf((*map[string]*Package)(nil)).Elem()
   331  }
   332  
   333  func (o PackageMapOutput) ToPackageMapOutput() PackageMapOutput {
   334  	return o
   335  }
   336  
   337  func (o PackageMapOutput) ToPackageMapOutputWithContext(ctx context.Context) PackageMapOutput {
   338  	return o
   339  }
   340  
   341  func (o PackageMapOutput) MapIndex(k pulumi.StringInput) PackageOutput {
   342  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Package {
   343  		return vs[0].(map[string]*Package)[vs[1].(string)]
   344  	}).(PackageOutput)
   345  }
   346  
   347  func init() {
   348  	pulumi.RegisterInputType(reflect.TypeOf((*PackageInput)(nil)).Elem(), &Package{})
   349  	pulumi.RegisterInputType(reflect.TypeOf((*PackageArrayInput)(nil)).Elem(), PackageArray{})
   350  	pulumi.RegisterInputType(reflect.TypeOf((*PackageMapInput)(nil)).Elem(), PackageMap{})
   351  	pulumi.RegisterOutputType(PackageOutput{})
   352  	pulumi.RegisterOutputType(PackageArrayOutput{})
   353  	pulumi.RegisterOutputType(PackageMapOutput{})
   354  }