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