github.com/myhau/pulumi/pkg/v3@v3.70.2-0.20221116134521-f2775972e587/codegen/testing/test/testdata/plain-and-default/nodejs/moduleResource.ts (about)

     1  // *** WARNING: this file was generated by test. ***
     2  // *** Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  import * as pulumi from "@pulumi/pulumi";
     5  import * as inputs from "./types/input";
     6  import * as outputs from "./types/output";
     7  import * as enums from "./types/enums";
     8  import * as utilities from "./utilities";
     9  
    10  export class ModuleResource extends pulumi.CustomResource {
    11      /**
    12       * Get an existing ModuleResource resource's state with the given name, ID, and optional extra
    13       * properties used to qualify the lookup.
    14       *
    15       * @param name The _unique_ name of the resulting resource.
    16       * @param id The _unique_ provider ID of the resource to lookup.
    17       * @param opts Optional settings to control the behavior of the CustomResource.
    18       */
    19      public static get(name: string, id: pulumi.Input<pulumi.ID>, opts?: pulumi.CustomResourceOptions): ModuleResource {
    20          return new ModuleResource(name, undefined as any, { ...opts, id: id });
    21      }
    22  
    23      /** @internal */
    24      public static readonly __pulumiType = 'foobar::ModuleResource';
    25  
    26      /**
    27       * Returns true if the given object is an instance of ModuleResource.  This is designed to work even
    28       * when multiple copies of the Pulumi SDK have been loaded into the same process.
    29       */
    30      public static isInstance(obj: any): obj is ModuleResource {
    31          if (obj === undefined || obj === null) {
    32              return false;
    33          }
    34          return obj['__pulumiType'] === ModuleResource.__pulumiType;
    35      }
    36  
    37  
    38      /**
    39       * Create a ModuleResource resource with the given unique name, arguments, and options.
    40       *
    41       * @param name The _unique_ name of the resource.
    42       * @param args The arguments to use to populate this resource's properties.
    43       * @param opts A bag of options that control this resource's behavior.
    44       */
    45      constructor(name: string, args: ModuleResourceArgs, opts?: pulumi.CustomResourceOptions) {
    46          let resourceInputs: pulumi.Inputs = {};
    47          opts = opts || {};
    48          if (!opts.id) {
    49              if ((!args || args.plain_required_bool === undefined) && !opts.urn) {
    50                  throw new Error("Missing required property 'plain_required_bool'");
    51              }
    52              if ((!args || args.plain_required_const === undefined) && !opts.urn) {
    53                  throw new Error("Missing required property 'plain_required_const'");
    54              }
    55              if ((!args || args.plain_required_number === undefined) && !opts.urn) {
    56                  throw new Error("Missing required property 'plain_required_number'");
    57              }
    58              if ((!args || args.plain_required_string === undefined) && !opts.urn) {
    59                  throw new Error("Missing required property 'plain_required_string'");
    60              }
    61              if ((!args || args.required_bool === undefined) && !opts.urn) {
    62                  throw new Error("Missing required property 'required_bool'");
    63              }
    64              if ((!args || args.required_enum === undefined) && !opts.urn) {
    65                  throw new Error("Missing required property 'required_enum'");
    66              }
    67              if ((!args || args.required_number === undefined) && !opts.urn) {
    68                  throw new Error("Missing required property 'required_number'");
    69              }
    70              if ((!args || args.required_string === undefined) && !opts.urn) {
    71                  throw new Error("Missing required property 'required_string'");
    72              }
    73              resourceInputs["optional_bool"] = (args ? args.optional_bool : undefined) ?? true;
    74              resourceInputs["optional_const"] = "val";
    75              resourceInputs["optional_enum"] = (args ? args.optional_enum : undefined) ?? 8;
    76              resourceInputs["optional_number"] = (args ? args.optional_number : undefined) ?? 42;
    77              resourceInputs["optional_string"] = (args ? args.optional_string : undefined) ?? "buzzer";
    78              resourceInputs["plain_optional_bool"] = (args ? args.plain_optional_bool : undefined) ?? true;
    79              resourceInputs["plain_optional_const"] = "val";
    80              resourceInputs["plain_optional_number"] = (args ? args.plain_optional_number : undefined) ?? 42;
    81              resourceInputs["plain_optional_string"] = (args ? args.plain_optional_string : undefined) ?? "buzzer";
    82              resourceInputs["plain_required_bool"] = (args ? args.plain_required_bool : undefined) ?? true;
    83              resourceInputs["plain_required_const"] = "val";
    84              resourceInputs["plain_required_number"] = (args ? args.plain_required_number : undefined) ?? 42;
    85              resourceInputs["plain_required_string"] = (args ? args.plain_required_string : undefined) ?? "buzzer";
    86              resourceInputs["required_bool"] = (args ? args.required_bool : undefined) ?? true;
    87              resourceInputs["required_enum"] = (args ? args.required_enum : undefined) ?? 4;
    88              resourceInputs["required_number"] = (args ? args.required_number : undefined) ?? 42;
    89              resourceInputs["required_string"] = (args ? args.required_string : undefined) ?? "buzzer";
    90          } else {
    91          }
    92          opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
    93          super(ModuleResource.__pulumiType, name, resourceInputs, opts);
    94      }
    95  }
    96  
    97  /**
    98   * The set of arguments for constructing a ModuleResource resource.
    99   */
   100  export interface ModuleResourceArgs {
   101      optional_bool?: pulumi.Input<boolean>;
   102      optional_const?: pulumi.Input<"val">;
   103      optional_enum?: pulumi.Input<enums.EnumThing>;
   104      optional_number?: pulumi.Input<number>;
   105      optional_string?: pulumi.Input<string>;
   106      plain_optional_bool?: boolean;
   107      plain_optional_const?: "val";
   108      plain_optional_number?: number;
   109      plain_optional_string?: string;
   110      plain_required_bool: boolean;
   111      plain_required_const: "val";
   112      plain_required_number: number;
   113      plain_required_string: string;
   114      required_bool: pulumi.Input<boolean>;
   115      required_enum: pulumi.Input<enums.EnumThing>;
   116      required_number: pulumi.Input<number>;
   117      required_string: pulumi.Input<string>;
   118  }