github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/apigateway/methodSettings.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  // Manages API Gateway Stage Method Settings. For example, CloudWatch logging and metrics.
    16  //
    17  // > **NOTE:** We recommend using this resource in conjunction with the `apigateway.Stage` resource instead of a stage managed by the `apigateway.Deployment` resource optional `stageName` argument. Stages managed by the `apigateway.Deployment` resource are recreated on redeployment and this resource will require a second apply to recreate the method settings.
    18  //
    19  // ## Example Usage
    20  //
    21  // ### End-to-end
    22  //
    23  // ### Off
    24  //
    25  // <!--Start PulumiCodeChooser -->
    26  // ```go
    27  // package main
    28  //
    29  // import (
    30  //
    31  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/apigateway"
    32  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    33  //
    34  // )
    35  //
    36  //	func main() {
    37  //		pulumi.Run(func(ctx *pulumi.Context) error {
    38  //			_, err := apigateway.NewMethodSettings(ctx, "path_specific", &apigateway.MethodSettingsArgs{
    39  //				RestApi:    pulumi.Any(example.Id),
    40  //				StageName:  pulumi.Any(exampleAwsApiGatewayStage.StageName),
    41  //				MethodPath: pulumi.String("path1/GET"),
    42  //				Settings: &apigateway.MethodSettingsSettingsArgs{
    43  //					LoggingLevel: pulumi.String("OFF"),
    44  //				},
    45  //			})
    46  //			if err != nil {
    47  //				return err
    48  //			}
    49  //			return nil
    50  //		})
    51  //	}
    52  //
    53  // ```
    54  // <!--End PulumiCodeChooser -->
    55  //
    56  // ### Errors Only
    57  //
    58  // <!--Start PulumiCodeChooser -->
    59  // ```go
    60  // package main
    61  //
    62  // import (
    63  //
    64  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/apigateway"
    65  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    66  //
    67  // )
    68  //
    69  //	func main() {
    70  //		pulumi.Run(func(ctx *pulumi.Context) error {
    71  //			_, err := apigateway.NewMethodSettings(ctx, "path_specific", &apigateway.MethodSettingsArgs{
    72  //				RestApi:    pulumi.Any(example.Id),
    73  //				StageName:  pulumi.Any(exampleAwsApiGatewayStage.StageName),
    74  //				MethodPath: pulumi.String("path1/GET"),
    75  //				Settings: &apigateway.MethodSettingsSettingsArgs{
    76  //					LoggingLevel:     pulumi.String("ERROR"),
    77  //					MetricsEnabled:   pulumi.Bool(true),
    78  //					DataTraceEnabled: pulumi.Bool(false),
    79  //				},
    80  //			})
    81  //			if err != nil {
    82  //				return err
    83  //			}
    84  //			return nil
    85  //		})
    86  //	}
    87  //
    88  // ```
    89  // <!--End PulumiCodeChooser -->
    90  //
    91  // ### Errors and Info Logs
    92  //
    93  // <!--Start PulumiCodeChooser -->
    94  // ```go
    95  // package main
    96  //
    97  // import (
    98  //
    99  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/apigateway"
   100  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
   101  //
   102  // )
   103  //
   104  //	func main() {
   105  //		pulumi.Run(func(ctx *pulumi.Context) error {
   106  //			_, err := apigateway.NewMethodSettings(ctx, "path_specific", &apigateway.MethodSettingsArgs{
   107  //				RestApi:    pulumi.Any(example.Id),
   108  //				StageName:  pulumi.Any(exampleAwsApiGatewayStage.StageName),
   109  //				MethodPath: pulumi.String("path1/GET"),
   110  //				Settings: &apigateway.MethodSettingsSettingsArgs{
   111  //					LoggingLevel:     pulumi.String("INFO"),
   112  //					MetricsEnabled:   pulumi.Bool(true),
   113  //					DataTraceEnabled: pulumi.Bool(false),
   114  //				},
   115  //			})
   116  //			if err != nil {
   117  //				return err
   118  //			}
   119  //			return nil
   120  //		})
   121  //	}
   122  //
   123  // ```
   124  // <!--End PulumiCodeChooser -->
   125  //
   126  // ### Full Request and Response Logs
   127  //
   128  // <!--Start PulumiCodeChooser -->
   129  // ```go
   130  // package main
   131  //
   132  // import (
   133  //
   134  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/apigateway"
   135  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
   136  //
   137  // )
   138  //
   139  //	func main() {
   140  //		pulumi.Run(func(ctx *pulumi.Context) error {
   141  //			_, err := apigateway.NewMethodSettings(ctx, "path_specific", &apigateway.MethodSettingsArgs{
   142  //				RestApi:    pulumi.Any(example.Id),
   143  //				StageName:  pulumi.Any(exampleAwsApiGatewayStage.StageName),
   144  //				MethodPath: pulumi.String("path1/GET"),
   145  //				Settings: &apigateway.MethodSettingsSettingsArgs{
   146  //					LoggingLevel:     pulumi.String("INFO"),
   147  //					MetricsEnabled:   pulumi.Bool(true),
   148  //					DataTraceEnabled: pulumi.Bool(true),
   149  //				},
   150  //			})
   151  //			if err != nil {
   152  //				return err
   153  //			}
   154  //			return nil
   155  //		})
   156  //	}
   157  //
   158  // ```
   159  // <!--End PulumiCodeChooser -->
   160  //
   161  // ## Import
   162  //
   163  // Using `pulumi import`, import `aws_api_gateway_method_settings` using `REST-API-ID/STAGE-NAME/METHOD-PATH`. For example:
   164  //
   165  // ```sh
   166  // $ pulumi import aws:apigateway/methodSettings:MethodSettings example 12345abcde/example/test/GET
   167  // ```
   168  type MethodSettings struct {
   169  	pulumi.CustomResourceState
   170  
   171  	// Method path defined as `{resource_path}/{http_method}` for an individual method override, or `*/*` for overriding all methods in the stage. Ensure to trim any leading forward slashes in the path (e.g., `trimprefix(aws_api_gateway_resource.example.path, "/")`).
   172  	MethodPath pulumi.StringOutput `pulumi:"methodPath"`
   173  	// ID of the REST API
   174  	RestApi pulumi.StringOutput `pulumi:"restApi"`
   175  	// Settings block, see below.
   176  	Settings MethodSettingsSettingsOutput `pulumi:"settings"`
   177  	// Name of the stage
   178  	StageName pulumi.StringOutput `pulumi:"stageName"`
   179  }
   180  
   181  // NewMethodSettings registers a new resource with the given unique name, arguments, and options.
   182  func NewMethodSettings(ctx *pulumi.Context,
   183  	name string, args *MethodSettingsArgs, opts ...pulumi.ResourceOption) (*MethodSettings, error) {
   184  	if args == nil {
   185  		return nil, errors.New("missing one or more required arguments")
   186  	}
   187  
   188  	if args.MethodPath == nil {
   189  		return nil, errors.New("invalid value for required argument 'MethodPath'")
   190  	}
   191  	if args.RestApi == nil {
   192  		return nil, errors.New("invalid value for required argument 'RestApi'")
   193  	}
   194  	if args.Settings == nil {
   195  		return nil, errors.New("invalid value for required argument 'Settings'")
   196  	}
   197  	if args.StageName == nil {
   198  		return nil, errors.New("invalid value for required argument 'StageName'")
   199  	}
   200  	opts = internal.PkgResourceDefaultOpts(opts)
   201  	var resource MethodSettings
   202  	err := ctx.RegisterResource("aws:apigateway/methodSettings:MethodSettings", name, args, &resource, opts...)
   203  	if err != nil {
   204  		return nil, err
   205  	}
   206  	return &resource, nil
   207  }
   208  
   209  // GetMethodSettings gets an existing MethodSettings resource's state with the given name, ID, and optional
   210  // state properties that are used to uniquely qualify the lookup (nil if not required).
   211  func GetMethodSettings(ctx *pulumi.Context,
   212  	name string, id pulumi.IDInput, state *MethodSettingsState, opts ...pulumi.ResourceOption) (*MethodSettings, error) {
   213  	var resource MethodSettings
   214  	err := ctx.ReadResource("aws:apigateway/methodSettings:MethodSettings", name, id, state, &resource, opts...)
   215  	if err != nil {
   216  		return nil, err
   217  	}
   218  	return &resource, nil
   219  }
   220  
   221  // Input properties used for looking up and filtering MethodSettings resources.
   222  type methodSettingsState struct {
   223  	// Method path defined as `{resource_path}/{http_method}` for an individual method override, or `*/*` for overriding all methods in the stage. Ensure to trim any leading forward slashes in the path (e.g., `trimprefix(aws_api_gateway_resource.example.path, "/")`).
   224  	MethodPath *string `pulumi:"methodPath"`
   225  	// ID of the REST API
   226  	RestApi interface{} `pulumi:"restApi"`
   227  	// Settings block, see below.
   228  	Settings *MethodSettingsSettings `pulumi:"settings"`
   229  	// Name of the stage
   230  	StageName *string `pulumi:"stageName"`
   231  }
   232  
   233  type MethodSettingsState struct {
   234  	// Method path defined as `{resource_path}/{http_method}` for an individual method override, or `*/*` for overriding all methods in the stage. Ensure to trim any leading forward slashes in the path (e.g., `trimprefix(aws_api_gateway_resource.example.path, "/")`).
   235  	MethodPath pulumi.StringPtrInput
   236  	// ID of the REST API
   237  	RestApi pulumi.Input
   238  	// Settings block, see below.
   239  	Settings MethodSettingsSettingsPtrInput
   240  	// Name of the stage
   241  	StageName pulumi.StringPtrInput
   242  }
   243  
   244  func (MethodSettingsState) ElementType() reflect.Type {
   245  	return reflect.TypeOf((*methodSettingsState)(nil)).Elem()
   246  }
   247  
   248  type methodSettingsArgs struct {
   249  	// Method path defined as `{resource_path}/{http_method}` for an individual method override, or `*/*` for overriding all methods in the stage. Ensure to trim any leading forward slashes in the path (e.g., `trimprefix(aws_api_gateway_resource.example.path, "/")`).
   250  	MethodPath string `pulumi:"methodPath"`
   251  	// ID of the REST API
   252  	RestApi interface{} `pulumi:"restApi"`
   253  	// Settings block, see below.
   254  	Settings MethodSettingsSettings `pulumi:"settings"`
   255  	// Name of the stage
   256  	StageName string `pulumi:"stageName"`
   257  }
   258  
   259  // The set of arguments for constructing a MethodSettings resource.
   260  type MethodSettingsArgs struct {
   261  	// Method path defined as `{resource_path}/{http_method}` for an individual method override, or `*/*` for overriding all methods in the stage. Ensure to trim any leading forward slashes in the path (e.g., `trimprefix(aws_api_gateway_resource.example.path, "/")`).
   262  	MethodPath pulumi.StringInput
   263  	// ID of the REST API
   264  	RestApi pulumi.Input
   265  	// Settings block, see below.
   266  	Settings MethodSettingsSettingsInput
   267  	// Name of the stage
   268  	StageName pulumi.StringInput
   269  }
   270  
   271  func (MethodSettingsArgs) ElementType() reflect.Type {
   272  	return reflect.TypeOf((*methodSettingsArgs)(nil)).Elem()
   273  }
   274  
   275  type MethodSettingsInput interface {
   276  	pulumi.Input
   277  
   278  	ToMethodSettingsOutput() MethodSettingsOutput
   279  	ToMethodSettingsOutputWithContext(ctx context.Context) MethodSettingsOutput
   280  }
   281  
   282  func (*MethodSettings) ElementType() reflect.Type {
   283  	return reflect.TypeOf((**MethodSettings)(nil)).Elem()
   284  }
   285  
   286  func (i *MethodSettings) ToMethodSettingsOutput() MethodSettingsOutput {
   287  	return i.ToMethodSettingsOutputWithContext(context.Background())
   288  }
   289  
   290  func (i *MethodSettings) ToMethodSettingsOutputWithContext(ctx context.Context) MethodSettingsOutput {
   291  	return pulumi.ToOutputWithContext(ctx, i).(MethodSettingsOutput)
   292  }
   293  
   294  // MethodSettingsArrayInput is an input type that accepts MethodSettingsArray and MethodSettingsArrayOutput values.
   295  // You can construct a concrete instance of `MethodSettingsArrayInput` via:
   296  //
   297  //	MethodSettingsArray{ MethodSettingsArgs{...} }
   298  type MethodSettingsArrayInput interface {
   299  	pulumi.Input
   300  
   301  	ToMethodSettingsArrayOutput() MethodSettingsArrayOutput
   302  	ToMethodSettingsArrayOutputWithContext(context.Context) MethodSettingsArrayOutput
   303  }
   304  
   305  type MethodSettingsArray []MethodSettingsInput
   306  
   307  func (MethodSettingsArray) ElementType() reflect.Type {
   308  	return reflect.TypeOf((*[]*MethodSettings)(nil)).Elem()
   309  }
   310  
   311  func (i MethodSettingsArray) ToMethodSettingsArrayOutput() MethodSettingsArrayOutput {
   312  	return i.ToMethodSettingsArrayOutputWithContext(context.Background())
   313  }
   314  
   315  func (i MethodSettingsArray) ToMethodSettingsArrayOutputWithContext(ctx context.Context) MethodSettingsArrayOutput {
   316  	return pulumi.ToOutputWithContext(ctx, i).(MethodSettingsArrayOutput)
   317  }
   318  
   319  // MethodSettingsMapInput is an input type that accepts MethodSettingsMap and MethodSettingsMapOutput values.
   320  // You can construct a concrete instance of `MethodSettingsMapInput` via:
   321  //
   322  //	MethodSettingsMap{ "key": MethodSettingsArgs{...} }
   323  type MethodSettingsMapInput interface {
   324  	pulumi.Input
   325  
   326  	ToMethodSettingsMapOutput() MethodSettingsMapOutput
   327  	ToMethodSettingsMapOutputWithContext(context.Context) MethodSettingsMapOutput
   328  }
   329  
   330  type MethodSettingsMap map[string]MethodSettingsInput
   331  
   332  func (MethodSettingsMap) ElementType() reflect.Type {
   333  	return reflect.TypeOf((*map[string]*MethodSettings)(nil)).Elem()
   334  }
   335  
   336  func (i MethodSettingsMap) ToMethodSettingsMapOutput() MethodSettingsMapOutput {
   337  	return i.ToMethodSettingsMapOutputWithContext(context.Background())
   338  }
   339  
   340  func (i MethodSettingsMap) ToMethodSettingsMapOutputWithContext(ctx context.Context) MethodSettingsMapOutput {
   341  	return pulumi.ToOutputWithContext(ctx, i).(MethodSettingsMapOutput)
   342  }
   343  
   344  type MethodSettingsOutput struct{ *pulumi.OutputState }
   345  
   346  func (MethodSettingsOutput) ElementType() reflect.Type {
   347  	return reflect.TypeOf((**MethodSettings)(nil)).Elem()
   348  }
   349  
   350  func (o MethodSettingsOutput) ToMethodSettingsOutput() MethodSettingsOutput {
   351  	return o
   352  }
   353  
   354  func (o MethodSettingsOutput) ToMethodSettingsOutputWithContext(ctx context.Context) MethodSettingsOutput {
   355  	return o
   356  }
   357  
   358  // Method path defined as `{resource_path}/{http_method}` for an individual method override, or `*/*` for overriding all methods in the stage. Ensure to trim any leading forward slashes in the path (e.g., `trimprefix(aws_api_gateway_resource.example.path, "/")`).
   359  func (o MethodSettingsOutput) MethodPath() pulumi.StringOutput {
   360  	return o.ApplyT(func(v *MethodSettings) pulumi.StringOutput { return v.MethodPath }).(pulumi.StringOutput)
   361  }
   362  
   363  // ID of the REST API
   364  func (o MethodSettingsOutput) RestApi() pulumi.StringOutput {
   365  	return o.ApplyT(func(v *MethodSettings) pulumi.StringOutput { return v.RestApi }).(pulumi.StringOutput)
   366  }
   367  
   368  // Settings block, see below.
   369  func (o MethodSettingsOutput) Settings() MethodSettingsSettingsOutput {
   370  	return o.ApplyT(func(v *MethodSettings) MethodSettingsSettingsOutput { return v.Settings }).(MethodSettingsSettingsOutput)
   371  }
   372  
   373  // Name of the stage
   374  func (o MethodSettingsOutput) StageName() pulumi.StringOutput {
   375  	return o.ApplyT(func(v *MethodSettings) pulumi.StringOutput { return v.StageName }).(pulumi.StringOutput)
   376  }
   377  
   378  type MethodSettingsArrayOutput struct{ *pulumi.OutputState }
   379  
   380  func (MethodSettingsArrayOutput) ElementType() reflect.Type {
   381  	return reflect.TypeOf((*[]*MethodSettings)(nil)).Elem()
   382  }
   383  
   384  func (o MethodSettingsArrayOutput) ToMethodSettingsArrayOutput() MethodSettingsArrayOutput {
   385  	return o
   386  }
   387  
   388  func (o MethodSettingsArrayOutput) ToMethodSettingsArrayOutputWithContext(ctx context.Context) MethodSettingsArrayOutput {
   389  	return o
   390  }
   391  
   392  func (o MethodSettingsArrayOutput) Index(i pulumi.IntInput) MethodSettingsOutput {
   393  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *MethodSettings {
   394  		return vs[0].([]*MethodSettings)[vs[1].(int)]
   395  	}).(MethodSettingsOutput)
   396  }
   397  
   398  type MethodSettingsMapOutput struct{ *pulumi.OutputState }
   399  
   400  func (MethodSettingsMapOutput) ElementType() reflect.Type {
   401  	return reflect.TypeOf((*map[string]*MethodSettings)(nil)).Elem()
   402  }
   403  
   404  func (o MethodSettingsMapOutput) ToMethodSettingsMapOutput() MethodSettingsMapOutput {
   405  	return o
   406  }
   407  
   408  func (o MethodSettingsMapOutput) ToMethodSettingsMapOutputWithContext(ctx context.Context) MethodSettingsMapOutput {
   409  	return o
   410  }
   411  
   412  func (o MethodSettingsMapOutput) MapIndex(k pulumi.StringInput) MethodSettingsOutput {
   413  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *MethodSettings {
   414  		return vs[0].(map[string]*MethodSettings)[vs[1].(string)]
   415  	}).(MethodSettingsOutput)
   416  }
   417  
   418  func init() {
   419  	pulumi.RegisterInputType(reflect.TypeOf((*MethodSettingsInput)(nil)).Elem(), &MethodSettings{})
   420  	pulumi.RegisterInputType(reflect.TypeOf((*MethodSettingsArrayInput)(nil)).Elem(), MethodSettingsArray{})
   421  	pulumi.RegisterInputType(reflect.TypeOf((*MethodSettingsMapInput)(nil)).Elem(), MethodSettingsMap{})
   422  	pulumi.RegisterOutputType(MethodSettingsOutput{})
   423  	pulumi.RegisterOutputType(MethodSettingsArrayOutput{})
   424  	pulumi.RegisterOutputType(MethodSettingsMapOutput{})
   425  }