github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/schemas/schema.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 schemas
     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  // Provides an EventBridge Schema resource.
    16  //
    17  // > **Note:** EventBridge was formerly known as CloudWatch Events. The functionality is identical.
    18  //
    19  // ## Example Usage
    20  //
    21  // <!--Start PulumiCodeChooser -->
    22  // ```go
    23  // package main
    24  //
    25  // import (
    26  //
    27  //	"encoding/json"
    28  //
    29  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/schemas"
    30  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    31  //
    32  // )
    33  //
    34  //	func main() {
    35  //		pulumi.Run(func(ctx *pulumi.Context) error {
    36  //			test, err := schemas.NewRegistry(ctx, "test", &schemas.RegistryArgs{
    37  //				Name: pulumi.String("my_own_registry"),
    38  //			})
    39  //			if err != nil {
    40  //				return err
    41  //			}
    42  //			tmpJSON0, err := json.Marshal(map[string]interface{}{
    43  //				"openapi": "3.0.0",
    44  //				"info": map[string]interface{}{
    45  //					"version": "1.0.0",
    46  //					"title":   "Event",
    47  //				},
    48  //				"paths": nil,
    49  //				"components": map[string]interface{}{
    50  //					"schemas": map[string]interface{}{
    51  //						"Event": map[string]interface{}{
    52  //							"type": "object",
    53  //							"properties": map[string]interface{}{
    54  //								"name": map[string]interface{}{
    55  //									"type": "string",
    56  //								},
    57  //							},
    58  //						},
    59  //					},
    60  //				},
    61  //			})
    62  //			if err != nil {
    63  //				return err
    64  //			}
    65  //			json0 := string(tmpJSON0)
    66  //			_, err = schemas.NewSchema(ctx, "test", &schemas.SchemaArgs{
    67  //				Name:         pulumi.String("my_schema"),
    68  //				RegistryName: test.Name,
    69  //				Type:         pulumi.String("OpenApi3"),
    70  //				Description:  pulumi.String("The schema definition for my event"),
    71  //				Content:      pulumi.String(json0),
    72  //			})
    73  //			if err != nil {
    74  //				return err
    75  //			}
    76  //			return nil
    77  //		})
    78  //	}
    79  //
    80  // ```
    81  // <!--End PulumiCodeChooser -->
    82  //
    83  // ## Import
    84  //
    85  // Using `pulumi import`, import EventBridge schema using the `name` and `registry_name`. For example:
    86  //
    87  // ```sh
    88  // $ pulumi import aws:schemas/schema:Schema test name/registry
    89  // ```
    90  type Schema struct {
    91  	pulumi.CustomResourceState
    92  
    93  	// The Amazon Resource Name (ARN) of the discoverer.
    94  	Arn pulumi.StringOutput `pulumi:"arn"`
    95  	// The schema specification. Must be a valid Open API 3.0 spec.
    96  	Content pulumi.StringOutput `pulumi:"content"`
    97  	// The description of the schema. Maximum of 256 characters.
    98  	Description pulumi.StringPtrOutput `pulumi:"description"`
    99  	// The last modified date of the schema.
   100  	LastModified pulumi.StringOutput `pulumi:"lastModified"`
   101  	// The name of the schema. Maximum of 385 characters consisting of lower case letters, upper case letters, ., -, _, @.
   102  	Name pulumi.StringOutput `pulumi:"name"`
   103  	// The name of the registry in which this schema belongs.
   104  	RegistryName pulumi.StringOutput `pulumi:"registryName"`
   105  	// A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   106  	Tags pulumi.StringMapOutput `pulumi:"tags"`
   107  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   108  	//
   109  	// Deprecated: Please use `tags` instead.
   110  	TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
   111  	// The type of the schema. Valid values: `OpenApi3` or `JSONSchemaDraft4`.
   112  	Type pulumi.StringOutput `pulumi:"type"`
   113  	// The version of the schema.
   114  	Version pulumi.StringOutput `pulumi:"version"`
   115  	// The created date of the version of the schema.
   116  	VersionCreatedDate pulumi.StringOutput `pulumi:"versionCreatedDate"`
   117  }
   118  
   119  // NewSchema registers a new resource with the given unique name, arguments, and options.
   120  func NewSchema(ctx *pulumi.Context,
   121  	name string, args *SchemaArgs, opts ...pulumi.ResourceOption) (*Schema, error) {
   122  	if args == nil {
   123  		return nil, errors.New("missing one or more required arguments")
   124  	}
   125  
   126  	if args.Content == nil {
   127  		return nil, errors.New("invalid value for required argument 'Content'")
   128  	}
   129  	if args.RegistryName == nil {
   130  		return nil, errors.New("invalid value for required argument 'RegistryName'")
   131  	}
   132  	if args.Type == nil {
   133  		return nil, errors.New("invalid value for required argument 'Type'")
   134  	}
   135  	opts = internal.PkgResourceDefaultOpts(opts)
   136  	var resource Schema
   137  	err := ctx.RegisterResource("aws:schemas/schema:Schema", name, args, &resource, opts...)
   138  	if err != nil {
   139  		return nil, err
   140  	}
   141  	return &resource, nil
   142  }
   143  
   144  // GetSchema gets an existing Schema resource's state with the given name, ID, and optional
   145  // state properties that are used to uniquely qualify the lookup (nil if not required).
   146  func GetSchema(ctx *pulumi.Context,
   147  	name string, id pulumi.IDInput, state *SchemaState, opts ...pulumi.ResourceOption) (*Schema, error) {
   148  	var resource Schema
   149  	err := ctx.ReadResource("aws:schemas/schema:Schema", name, id, state, &resource, opts...)
   150  	if err != nil {
   151  		return nil, err
   152  	}
   153  	return &resource, nil
   154  }
   155  
   156  // Input properties used for looking up and filtering Schema resources.
   157  type schemaState struct {
   158  	// The Amazon Resource Name (ARN) of the discoverer.
   159  	Arn *string `pulumi:"arn"`
   160  	// The schema specification. Must be a valid Open API 3.0 spec.
   161  	Content *string `pulumi:"content"`
   162  	// The description of the schema. Maximum of 256 characters.
   163  	Description *string `pulumi:"description"`
   164  	// The last modified date of the schema.
   165  	LastModified *string `pulumi:"lastModified"`
   166  	// The name of the schema. Maximum of 385 characters consisting of lower case letters, upper case letters, ., -, _, @.
   167  	Name *string `pulumi:"name"`
   168  	// The name of the registry in which this schema belongs.
   169  	RegistryName *string `pulumi:"registryName"`
   170  	// A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   171  	Tags map[string]string `pulumi:"tags"`
   172  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   173  	//
   174  	// Deprecated: Please use `tags` instead.
   175  	TagsAll map[string]string `pulumi:"tagsAll"`
   176  	// The type of the schema. Valid values: `OpenApi3` or `JSONSchemaDraft4`.
   177  	Type *string `pulumi:"type"`
   178  	// The version of the schema.
   179  	Version *string `pulumi:"version"`
   180  	// The created date of the version of the schema.
   181  	VersionCreatedDate *string `pulumi:"versionCreatedDate"`
   182  }
   183  
   184  type SchemaState struct {
   185  	// The Amazon Resource Name (ARN) of the discoverer.
   186  	Arn pulumi.StringPtrInput
   187  	// The schema specification. Must be a valid Open API 3.0 spec.
   188  	Content pulumi.StringPtrInput
   189  	// The description of the schema. Maximum of 256 characters.
   190  	Description pulumi.StringPtrInput
   191  	// The last modified date of the schema.
   192  	LastModified pulumi.StringPtrInput
   193  	// The name of the schema. Maximum of 385 characters consisting of lower case letters, upper case letters, ., -, _, @.
   194  	Name pulumi.StringPtrInput
   195  	// The name of the registry in which this schema belongs.
   196  	RegistryName pulumi.StringPtrInput
   197  	// A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   198  	Tags pulumi.StringMapInput
   199  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   200  	//
   201  	// Deprecated: Please use `tags` instead.
   202  	TagsAll pulumi.StringMapInput
   203  	// The type of the schema. Valid values: `OpenApi3` or `JSONSchemaDraft4`.
   204  	Type pulumi.StringPtrInput
   205  	// The version of the schema.
   206  	Version pulumi.StringPtrInput
   207  	// The created date of the version of the schema.
   208  	VersionCreatedDate pulumi.StringPtrInput
   209  }
   210  
   211  func (SchemaState) ElementType() reflect.Type {
   212  	return reflect.TypeOf((*schemaState)(nil)).Elem()
   213  }
   214  
   215  type schemaArgs struct {
   216  	// The schema specification. Must be a valid Open API 3.0 spec.
   217  	Content string `pulumi:"content"`
   218  	// The description of the schema. Maximum of 256 characters.
   219  	Description *string `pulumi:"description"`
   220  	// The name of the schema. Maximum of 385 characters consisting of lower case letters, upper case letters, ., -, _, @.
   221  	Name *string `pulumi:"name"`
   222  	// The name of the registry in which this schema belongs.
   223  	RegistryName string `pulumi:"registryName"`
   224  	// A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   225  	Tags map[string]string `pulumi:"tags"`
   226  	// The type of the schema. Valid values: `OpenApi3` or `JSONSchemaDraft4`.
   227  	Type string `pulumi:"type"`
   228  }
   229  
   230  // The set of arguments for constructing a Schema resource.
   231  type SchemaArgs struct {
   232  	// The schema specification. Must be a valid Open API 3.0 spec.
   233  	Content pulumi.StringInput
   234  	// The description of the schema. Maximum of 256 characters.
   235  	Description pulumi.StringPtrInput
   236  	// The name of the schema. Maximum of 385 characters consisting of lower case letters, upper case letters, ., -, _, @.
   237  	Name pulumi.StringPtrInput
   238  	// The name of the registry in which this schema belongs.
   239  	RegistryName pulumi.StringInput
   240  	// A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   241  	Tags pulumi.StringMapInput
   242  	// The type of the schema. Valid values: `OpenApi3` or `JSONSchemaDraft4`.
   243  	Type pulumi.StringInput
   244  }
   245  
   246  func (SchemaArgs) ElementType() reflect.Type {
   247  	return reflect.TypeOf((*schemaArgs)(nil)).Elem()
   248  }
   249  
   250  type SchemaInput interface {
   251  	pulumi.Input
   252  
   253  	ToSchemaOutput() SchemaOutput
   254  	ToSchemaOutputWithContext(ctx context.Context) SchemaOutput
   255  }
   256  
   257  func (*Schema) ElementType() reflect.Type {
   258  	return reflect.TypeOf((**Schema)(nil)).Elem()
   259  }
   260  
   261  func (i *Schema) ToSchemaOutput() SchemaOutput {
   262  	return i.ToSchemaOutputWithContext(context.Background())
   263  }
   264  
   265  func (i *Schema) ToSchemaOutputWithContext(ctx context.Context) SchemaOutput {
   266  	return pulumi.ToOutputWithContext(ctx, i).(SchemaOutput)
   267  }
   268  
   269  // SchemaArrayInput is an input type that accepts SchemaArray and SchemaArrayOutput values.
   270  // You can construct a concrete instance of `SchemaArrayInput` via:
   271  //
   272  //	SchemaArray{ SchemaArgs{...} }
   273  type SchemaArrayInput interface {
   274  	pulumi.Input
   275  
   276  	ToSchemaArrayOutput() SchemaArrayOutput
   277  	ToSchemaArrayOutputWithContext(context.Context) SchemaArrayOutput
   278  }
   279  
   280  type SchemaArray []SchemaInput
   281  
   282  func (SchemaArray) ElementType() reflect.Type {
   283  	return reflect.TypeOf((*[]*Schema)(nil)).Elem()
   284  }
   285  
   286  func (i SchemaArray) ToSchemaArrayOutput() SchemaArrayOutput {
   287  	return i.ToSchemaArrayOutputWithContext(context.Background())
   288  }
   289  
   290  func (i SchemaArray) ToSchemaArrayOutputWithContext(ctx context.Context) SchemaArrayOutput {
   291  	return pulumi.ToOutputWithContext(ctx, i).(SchemaArrayOutput)
   292  }
   293  
   294  // SchemaMapInput is an input type that accepts SchemaMap and SchemaMapOutput values.
   295  // You can construct a concrete instance of `SchemaMapInput` via:
   296  //
   297  //	SchemaMap{ "key": SchemaArgs{...} }
   298  type SchemaMapInput interface {
   299  	pulumi.Input
   300  
   301  	ToSchemaMapOutput() SchemaMapOutput
   302  	ToSchemaMapOutputWithContext(context.Context) SchemaMapOutput
   303  }
   304  
   305  type SchemaMap map[string]SchemaInput
   306  
   307  func (SchemaMap) ElementType() reflect.Type {
   308  	return reflect.TypeOf((*map[string]*Schema)(nil)).Elem()
   309  }
   310  
   311  func (i SchemaMap) ToSchemaMapOutput() SchemaMapOutput {
   312  	return i.ToSchemaMapOutputWithContext(context.Background())
   313  }
   314  
   315  func (i SchemaMap) ToSchemaMapOutputWithContext(ctx context.Context) SchemaMapOutput {
   316  	return pulumi.ToOutputWithContext(ctx, i).(SchemaMapOutput)
   317  }
   318  
   319  type SchemaOutput struct{ *pulumi.OutputState }
   320  
   321  func (SchemaOutput) ElementType() reflect.Type {
   322  	return reflect.TypeOf((**Schema)(nil)).Elem()
   323  }
   324  
   325  func (o SchemaOutput) ToSchemaOutput() SchemaOutput {
   326  	return o
   327  }
   328  
   329  func (o SchemaOutput) ToSchemaOutputWithContext(ctx context.Context) SchemaOutput {
   330  	return o
   331  }
   332  
   333  // The Amazon Resource Name (ARN) of the discoverer.
   334  func (o SchemaOutput) Arn() pulumi.StringOutput {
   335  	return o.ApplyT(func(v *Schema) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
   336  }
   337  
   338  // The schema specification. Must be a valid Open API 3.0 spec.
   339  func (o SchemaOutput) Content() pulumi.StringOutput {
   340  	return o.ApplyT(func(v *Schema) pulumi.StringOutput { return v.Content }).(pulumi.StringOutput)
   341  }
   342  
   343  // The description of the schema. Maximum of 256 characters.
   344  func (o SchemaOutput) Description() pulumi.StringPtrOutput {
   345  	return o.ApplyT(func(v *Schema) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput)
   346  }
   347  
   348  // The last modified date of the schema.
   349  func (o SchemaOutput) LastModified() pulumi.StringOutput {
   350  	return o.ApplyT(func(v *Schema) pulumi.StringOutput { return v.LastModified }).(pulumi.StringOutput)
   351  }
   352  
   353  // The name of the schema. Maximum of 385 characters consisting of lower case letters, upper case letters, ., -, _, @.
   354  func (o SchemaOutput) Name() pulumi.StringOutput {
   355  	return o.ApplyT(func(v *Schema) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   356  }
   357  
   358  // The name of the registry in which this schema belongs.
   359  func (o SchemaOutput) RegistryName() pulumi.StringOutput {
   360  	return o.ApplyT(func(v *Schema) pulumi.StringOutput { return v.RegistryName }).(pulumi.StringOutput)
   361  }
   362  
   363  // A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   364  func (o SchemaOutput) Tags() pulumi.StringMapOutput {
   365  	return o.ApplyT(func(v *Schema) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)
   366  }
   367  
   368  // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   369  //
   370  // Deprecated: Please use `tags` instead.
   371  func (o SchemaOutput) TagsAll() pulumi.StringMapOutput {
   372  	return o.ApplyT(func(v *Schema) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput)
   373  }
   374  
   375  // The type of the schema. Valid values: `OpenApi3` or `JSONSchemaDraft4`.
   376  func (o SchemaOutput) Type() pulumi.StringOutput {
   377  	return o.ApplyT(func(v *Schema) pulumi.StringOutput { return v.Type }).(pulumi.StringOutput)
   378  }
   379  
   380  // The version of the schema.
   381  func (o SchemaOutput) Version() pulumi.StringOutput {
   382  	return o.ApplyT(func(v *Schema) pulumi.StringOutput { return v.Version }).(pulumi.StringOutput)
   383  }
   384  
   385  // The created date of the version of the schema.
   386  func (o SchemaOutput) VersionCreatedDate() pulumi.StringOutput {
   387  	return o.ApplyT(func(v *Schema) pulumi.StringOutput { return v.VersionCreatedDate }).(pulumi.StringOutput)
   388  }
   389  
   390  type SchemaArrayOutput struct{ *pulumi.OutputState }
   391  
   392  func (SchemaArrayOutput) ElementType() reflect.Type {
   393  	return reflect.TypeOf((*[]*Schema)(nil)).Elem()
   394  }
   395  
   396  func (o SchemaArrayOutput) ToSchemaArrayOutput() SchemaArrayOutput {
   397  	return o
   398  }
   399  
   400  func (o SchemaArrayOutput) ToSchemaArrayOutputWithContext(ctx context.Context) SchemaArrayOutput {
   401  	return o
   402  }
   403  
   404  func (o SchemaArrayOutput) Index(i pulumi.IntInput) SchemaOutput {
   405  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Schema {
   406  		return vs[0].([]*Schema)[vs[1].(int)]
   407  	}).(SchemaOutput)
   408  }
   409  
   410  type SchemaMapOutput struct{ *pulumi.OutputState }
   411  
   412  func (SchemaMapOutput) ElementType() reflect.Type {
   413  	return reflect.TypeOf((*map[string]*Schema)(nil)).Elem()
   414  }
   415  
   416  func (o SchemaMapOutput) ToSchemaMapOutput() SchemaMapOutput {
   417  	return o
   418  }
   419  
   420  func (o SchemaMapOutput) ToSchemaMapOutputWithContext(ctx context.Context) SchemaMapOutput {
   421  	return o
   422  }
   423  
   424  func (o SchemaMapOutput) MapIndex(k pulumi.StringInput) SchemaOutput {
   425  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Schema {
   426  		return vs[0].(map[string]*Schema)[vs[1].(string)]
   427  	}).(SchemaOutput)
   428  }
   429  
   430  func init() {
   431  	pulumi.RegisterInputType(reflect.TypeOf((*SchemaInput)(nil)).Elem(), &Schema{})
   432  	pulumi.RegisterInputType(reflect.TypeOf((*SchemaArrayInput)(nil)).Elem(), SchemaArray{})
   433  	pulumi.RegisterInputType(reflect.TypeOf((*SchemaMapInput)(nil)).Elem(), SchemaMap{})
   434  	pulumi.RegisterOutputType(SchemaOutput{})
   435  	pulumi.RegisterOutputType(SchemaArrayOutput{})
   436  	pulumi.RegisterOutputType(SchemaMapOutput{})
   437  }