github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/apigatewayv2/model.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 apigatewayv2
     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 Amazon API Gateway Version 2 [model](https://docs.aws.amazon.com/apigateway/latest/developerguide/models-mappings.html#models-mappings-models).
    16  //
    17  // ## Example Usage
    18  //
    19  // ### Basic
    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/apigatewayv2"
    30  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    31  //
    32  // )
    33  //
    34  //	func main() {
    35  //		pulumi.Run(func(ctx *pulumi.Context) error {
    36  //			tmpJSON0, err := json.Marshal(map[string]interface{}{
    37  //				"$schema": "http://json-schema.org/draft-04/schema#",
    38  //				"title":   "ExampleModel",
    39  //				"type":    "object",
    40  //				"properties": map[string]interface{}{
    41  //					"id": map[string]interface{}{
    42  //						"type": "string",
    43  //					},
    44  //				},
    45  //			})
    46  //			if err != nil {
    47  //				return err
    48  //			}
    49  //			json0 := string(tmpJSON0)
    50  //			_, err = apigatewayv2.NewModel(ctx, "example", &apigatewayv2.ModelArgs{
    51  //				ApiId:       pulumi.Any(exampleAwsApigatewayv2Api.Id),
    52  //				ContentType: pulumi.String("application/json"),
    53  //				Name:        pulumi.String("example"),
    54  //				Schema:      pulumi.String(json0),
    55  //			})
    56  //			if err != nil {
    57  //				return err
    58  //			}
    59  //			return nil
    60  //		})
    61  //	}
    62  //
    63  // ```
    64  // <!--End PulumiCodeChooser -->
    65  //
    66  // ## Import
    67  //
    68  // Using `pulumi import`, import `aws_apigatewayv2_model` using the API identifier and model identifier. For example:
    69  //
    70  // ```sh
    71  // $ pulumi import aws:apigatewayv2/model:Model example aabbccddee/1122334
    72  // ```
    73  type Model struct {
    74  	pulumi.CustomResourceState
    75  
    76  	// API identifier.
    77  	ApiId pulumi.StringOutput `pulumi:"apiId"`
    78  	// The content-type for the model, for example, `application/json`. Must be between 1 and 256 characters in length.
    79  	ContentType pulumi.StringOutput `pulumi:"contentType"`
    80  	// Description of the model. Must be between 1 and 128 characters in length.
    81  	Description pulumi.StringPtrOutput `pulumi:"description"`
    82  	// Name of the model. Must be alphanumeric. Must be between 1 and 128 characters in length.
    83  	Name pulumi.StringOutput `pulumi:"name"`
    84  	// Schema for the model. This should be a [JSON schema draft 4](https://tools.ietf.org/html/draft-zyp-json-schema-04) model. Must be less than or equal to 32768 characters in length.
    85  	Schema pulumi.StringOutput `pulumi:"schema"`
    86  }
    87  
    88  // NewModel registers a new resource with the given unique name, arguments, and options.
    89  func NewModel(ctx *pulumi.Context,
    90  	name string, args *ModelArgs, opts ...pulumi.ResourceOption) (*Model, error) {
    91  	if args == nil {
    92  		return nil, errors.New("missing one or more required arguments")
    93  	}
    94  
    95  	if args.ApiId == nil {
    96  		return nil, errors.New("invalid value for required argument 'ApiId'")
    97  	}
    98  	if args.ContentType == nil {
    99  		return nil, errors.New("invalid value for required argument 'ContentType'")
   100  	}
   101  	if args.Schema == nil {
   102  		return nil, errors.New("invalid value for required argument 'Schema'")
   103  	}
   104  	opts = internal.PkgResourceDefaultOpts(opts)
   105  	var resource Model
   106  	err := ctx.RegisterResource("aws:apigatewayv2/model:Model", name, args, &resource, opts...)
   107  	if err != nil {
   108  		return nil, err
   109  	}
   110  	return &resource, nil
   111  }
   112  
   113  // GetModel gets an existing Model resource's state with the given name, ID, and optional
   114  // state properties that are used to uniquely qualify the lookup (nil if not required).
   115  func GetModel(ctx *pulumi.Context,
   116  	name string, id pulumi.IDInput, state *ModelState, opts ...pulumi.ResourceOption) (*Model, error) {
   117  	var resource Model
   118  	err := ctx.ReadResource("aws:apigatewayv2/model:Model", name, id, state, &resource, opts...)
   119  	if err != nil {
   120  		return nil, err
   121  	}
   122  	return &resource, nil
   123  }
   124  
   125  // Input properties used for looking up and filtering Model resources.
   126  type modelState struct {
   127  	// API identifier.
   128  	ApiId *string `pulumi:"apiId"`
   129  	// The content-type for the model, for example, `application/json`. Must be between 1 and 256 characters in length.
   130  	ContentType *string `pulumi:"contentType"`
   131  	// Description of the model. Must be between 1 and 128 characters in length.
   132  	Description *string `pulumi:"description"`
   133  	// Name of the model. Must be alphanumeric. Must be between 1 and 128 characters in length.
   134  	Name *string `pulumi:"name"`
   135  	// Schema for the model. This should be a [JSON schema draft 4](https://tools.ietf.org/html/draft-zyp-json-schema-04) model. Must be less than or equal to 32768 characters in length.
   136  	Schema *string `pulumi:"schema"`
   137  }
   138  
   139  type ModelState struct {
   140  	// API identifier.
   141  	ApiId pulumi.StringPtrInput
   142  	// The content-type for the model, for example, `application/json`. Must be between 1 and 256 characters in length.
   143  	ContentType pulumi.StringPtrInput
   144  	// Description of the model. Must be between 1 and 128 characters in length.
   145  	Description pulumi.StringPtrInput
   146  	// Name of the model. Must be alphanumeric. Must be between 1 and 128 characters in length.
   147  	Name pulumi.StringPtrInput
   148  	// Schema for the model. This should be a [JSON schema draft 4](https://tools.ietf.org/html/draft-zyp-json-schema-04) model. Must be less than or equal to 32768 characters in length.
   149  	Schema pulumi.StringPtrInput
   150  }
   151  
   152  func (ModelState) ElementType() reflect.Type {
   153  	return reflect.TypeOf((*modelState)(nil)).Elem()
   154  }
   155  
   156  type modelArgs struct {
   157  	// API identifier.
   158  	ApiId string `pulumi:"apiId"`
   159  	// The content-type for the model, for example, `application/json`. Must be between 1 and 256 characters in length.
   160  	ContentType string `pulumi:"contentType"`
   161  	// Description of the model. Must be between 1 and 128 characters in length.
   162  	Description *string `pulumi:"description"`
   163  	// Name of the model. Must be alphanumeric. Must be between 1 and 128 characters in length.
   164  	Name *string `pulumi:"name"`
   165  	// Schema for the model. This should be a [JSON schema draft 4](https://tools.ietf.org/html/draft-zyp-json-schema-04) model. Must be less than or equal to 32768 characters in length.
   166  	Schema string `pulumi:"schema"`
   167  }
   168  
   169  // The set of arguments for constructing a Model resource.
   170  type ModelArgs struct {
   171  	// API identifier.
   172  	ApiId pulumi.StringInput
   173  	// The content-type for the model, for example, `application/json`. Must be between 1 and 256 characters in length.
   174  	ContentType pulumi.StringInput
   175  	// Description of the model. Must be between 1 and 128 characters in length.
   176  	Description pulumi.StringPtrInput
   177  	// Name of the model. Must be alphanumeric. Must be between 1 and 128 characters in length.
   178  	Name pulumi.StringPtrInput
   179  	// Schema for the model. This should be a [JSON schema draft 4](https://tools.ietf.org/html/draft-zyp-json-schema-04) model. Must be less than or equal to 32768 characters in length.
   180  	Schema pulumi.StringInput
   181  }
   182  
   183  func (ModelArgs) ElementType() reflect.Type {
   184  	return reflect.TypeOf((*modelArgs)(nil)).Elem()
   185  }
   186  
   187  type ModelInput interface {
   188  	pulumi.Input
   189  
   190  	ToModelOutput() ModelOutput
   191  	ToModelOutputWithContext(ctx context.Context) ModelOutput
   192  }
   193  
   194  func (*Model) ElementType() reflect.Type {
   195  	return reflect.TypeOf((**Model)(nil)).Elem()
   196  }
   197  
   198  func (i *Model) ToModelOutput() ModelOutput {
   199  	return i.ToModelOutputWithContext(context.Background())
   200  }
   201  
   202  func (i *Model) ToModelOutputWithContext(ctx context.Context) ModelOutput {
   203  	return pulumi.ToOutputWithContext(ctx, i).(ModelOutput)
   204  }
   205  
   206  // ModelArrayInput is an input type that accepts ModelArray and ModelArrayOutput values.
   207  // You can construct a concrete instance of `ModelArrayInput` via:
   208  //
   209  //	ModelArray{ ModelArgs{...} }
   210  type ModelArrayInput interface {
   211  	pulumi.Input
   212  
   213  	ToModelArrayOutput() ModelArrayOutput
   214  	ToModelArrayOutputWithContext(context.Context) ModelArrayOutput
   215  }
   216  
   217  type ModelArray []ModelInput
   218  
   219  func (ModelArray) ElementType() reflect.Type {
   220  	return reflect.TypeOf((*[]*Model)(nil)).Elem()
   221  }
   222  
   223  func (i ModelArray) ToModelArrayOutput() ModelArrayOutput {
   224  	return i.ToModelArrayOutputWithContext(context.Background())
   225  }
   226  
   227  func (i ModelArray) ToModelArrayOutputWithContext(ctx context.Context) ModelArrayOutput {
   228  	return pulumi.ToOutputWithContext(ctx, i).(ModelArrayOutput)
   229  }
   230  
   231  // ModelMapInput is an input type that accepts ModelMap and ModelMapOutput values.
   232  // You can construct a concrete instance of `ModelMapInput` via:
   233  //
   234  //	ModelMap{ "key": ModelArgs{...} }
   235  type ModelMapInput interface {
   236  	pulumi.Input
   237  
   238  	ToModelMapOutput() ModelMapOutput
   239  	ToModelMapOutputWithContext(context.Context) ModelMapOutput
   240  }
   241  
   242  type ModelMap map[string]ModelInput
   243  
   244  func (ModelMap) ElementType() reflect.Type {
   245  	return reflect.TypeOf((*map[string]*Model)(nil)).Elem()
   246  }
   247  
   248  func (i ModelMap) ToModelMapOutput() ModelMapOutput {
   249  	return i.ToModelMapOutputWithContext(context.Background())
   250  }
   251  
   252  func (i ModelMap) ToModelMapOutputWithContext(ctx context.Context) ModelMapOutput {
   253  	return pulumi.ToOutputWithContext(ctx, i).(ModelMapOutput)
   254  }
   255  
   256  type ModelOutput struct{ *pulumi.OutputState }
   257  
   258  func (ModelOutput) ElementType() reflect.Type {
   259  	return reflect.TypeOf((**Model)(nil)).Elem()
   260  }
   261  
   262  func (o ModelOutput) ToModelOutput() ModelOutput {
   263  	return o
   264  }
   265  
   266  func (o ModelOutput) ToModelOutputWithContext(ctx context.Context) ModelOutput {
   267  	return o
   268  }
   269  
   270  // API identifier.
   271  func (o ModelOutput) ApiId() pulumi.StringOutput {
   272  	return o.ApplyT(func(v *Model) pulumi.StringOutput { return v.ApiId }).(pulumi.StringOutput)
   273  }
   274  
   275  // The content-type for the model, for example, `application/json`. Must be between 1 and 256 characters in length.
   276  func (o ModelOutput) ContentType() pulumi.StringOutput {
   277  	return o.ApplyT(func(v *Model) pulumi.StringOutput { return v.ContentType }).(pulumi.StringOutput)
   278  }
   279  
   280  // Description of the model. Must be between 1 and 128 characters in length.
   281  func (o ModelOutput) Description() pulumi.StringPtrOutput {
   282  	return o.ApplyT(func(v *Model) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput)
   283  }
   284  
   285  // Name of the model. Must be alphanumeric. Must be between 1 and 128 characters in length.
   286  func (o ModelOutput) Name() pulumi.StringOutput {
   287  	return o.ApplyT(func(v *Model) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   288  }
   289  
   290  // Schema for the model. This should be a [JSON schema draft 4](https://tools.ietf.org/html/draft-zyp-json-schema-04) model. Must be less than or equal to 32768 characters in length.
   291  func (o ModelOutput) Schema() pulumi.StringOutput {
   292  	return o.ApplyT(func(v *Model) pulumi.StringOutput { return v.Schema }).(pulumi.StringOutput)
   293  }
   294  
   295  type ModelArrayOutput struct{ *pulumi.OutputState }
   296  
   297  func (ModelArrayOutput) ElementType() reflect.Type {
   298  	return reflect.TypeOf((*[]*Model)(nil)).Elem()
   299  }
   300  
   301  func (o ModelArrayOutput) ToModelArrayOutput() ModelArrayOutput {
   302  	return o
   303  }
   304  
   305  func (o ModelArrayOutput) ToModelArrayOutputWithContext(ctx context.Context) ModelArrayOutput {
   306  	return o
   307  }
   308  
   309  func (o ModelArrayOutput) Index(i pulumi.IntInput) ModelOutput {
   310  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Model {
   311  		return vs[0].([]*Model)[vs[1].(int)]
   312  	}).(ModelOutput)
   313  }
   314  
   315  type ModelMapOutput struct{ *pulumi.OutputState }
   316  
   317  func (ModelMapOutput) ElementType() reflect.Type {
   318  	return reflect.TypeOf((*map[string]*Model)(nil)).Elem()
   319  }
   320  
   321  func (o ModelMapOutput) ToModelMapOutput() ModelMapOutput {
   322  	return o
   323  }
   324  
   325  func (o ModelMapOutput) ToModelMapOutputWithContext(ctx context.Context) ModelMapOutput {
   326  	return o
   327  }
   328  
   329  func (o ModelMapOutput) MapIndex(k pulumi.StringInput) ModelOutput {
   330  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Model {
   331  		return vs[0].(map[string]*Model)[vs[1].(string)]
   332  	}).(ModelOutput)
   333  }
   334  
   335  func init() {
   336  	pulumi.RegisterInputType(reflect.TypeOf((*ModelInput)(nil)).Elem(), &Model{})
   337  	pulumi.RegisterInputType(reflect.TypeOf((*ModelArrayInput)(nil)).Elem(), ModelArray{})
   338  	pulumi.RegisterInputType(reflect.TypeOf((*ModelMapInput)(nil)).Elem(), ModelMap{})
   339  	pulumi.RegisterOutputType(ModelOutput{})
   340  	pulumi.RegisterOutputType(ModelArrayOutput{})
   341  	pulumi.RegisterOutputType(ModelMapOutput{})
   342  }