Class Node

  • All Implemented Interfaces:
    software.amazon.jsii.JsiiSerializable

    @Generated(value="jsii-pacmak/1.65.0 (build 7a02b7f)",
               date="2022-08-25T00:22:52.339Z")
    @Stability(Stable)
    public class Node
    extends software.amazon.jsii.JsiiObject
    Represents the construct node in the scope tree.
    • Field Detail

      • PATH_SEP

        @Stability(Stable)
        public static final String PATH_SEP
        Separator used to delimit construct path components.
    • Constructor Detail

      • Node

        protected Node​(software.amazon.jsii.JsiiObjectRef objRef)
      • Node

        protected Node​(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
      • Node

        @Stability(Stable)
        public Node​(@NotNull
                    Construct host,
                    @NotNull
                    IConstruct scope,
                    @NotNull
                    String id)
        Parameters:
        host - This parameter is required.
        scope - This parameter is required.
        id - This parameter is required.
    • Method Detail

      • of

        @Stability(Stable)
        @NotNull
        public static Node of​(@NotNull
                              IConstruct construct)
        Returns the node associated with a construct.

        Parameters:
        construct - the construct. This parameter is required.
      • addDependency

        @Stability(Stable)
        public void addDependency​(@NotNull
                                  @NotNull IConstruct... dependencies)
        Add an ordering dependency on another Construct.

        All constructs in the dependency's scope will be deployed before any construct in this construct's scope.

        Parameters:
        dependencies - This parameter is required.
      • addError

        @Stability(Stable)
        public void addError​(@NotNull
                             String message)
        Adds an { "error": } metadata entry to this construct.

        The toolkit will fail synthesis when errors are reported.

        Parameters:
        message - The error message. This parameter is required.
      • addInfo

        @Stability(Stable)
        public void addInfo​(@NotNull
                            String message)
        Adds a { "info": } metadata entry to this construct.

        The toolkit will display the info message when apps are synthesized.

        Parameters:
        message - The info message. This parameter is required.
      • addMetadata

        @Stability(Stable)
        public void addMetadata​(@NotNull
                                String type,
                                @NotNull
                                Object data,
                                @Nullable
                                Object fromFunction)
        Adds a metadata entry to this construct.

        Entries are arbitrary values and will also include a stack trace to allow tracing back to the code location for when the entry was added. It can be used, for example, to include source mapping in CloudFormation templates to improve diagnostics.

        Parameters:
        type - a string denoting the type of metadata. This parameter is required.
        data - the value of the metadata (can be a Token). This parameter is required.
        fromFunction - a function under which to restrict the metadata entry's stack trace (defaults to this.addMetadata).
      • addMetadata

        @Stability(Stable)
        public void addMetadata​(@NotNull
                                String type,
                                @NotNull
                                Object data)
        Adds a metadata entry to this construct.

        Entries are arbitrary values and will also include a stack trace to allow tracing back to the code location for when the entry was added. It can be used, for example, to include source mapping in CloudFormation templates to improve diagnostics.

        Parameters:
        type - a string denoting the type of metadata. This parameter is required.
        data - the value of the metadata (can be a Token). This parameter is required.
      • addValidation

        @Stability(Stable)
        public void addValidation​(@NotNull
                                  IValidation validation)
        Adds a validation to this construct.

        When node.validate() is called, the validate() method will be called on all validations and all errors will be returned.

        Parameters:
        validation - This parameter is required.
      • addWarning

        @Stability(Stable)
        public void addWarning​(@NotNull
                               String message)
        Adds a { "warning": } metadata entry to this construct.

        The toolkit will display the warning when an app is synthesized, or fail if run in --strict mode.

        Parameters:
        message - The warning message. This parameter is required.
      • applyAspect

        @Stability(Stable)
        public void applyAspect​(@NotNull
                                IAspect aspect)
        Applies the aspect to this Constructs node.

        Parameters:
        aspect - This parameter is required.
      • findAll

        @Stability(Stable)
        @NotNull
        public List<IConstruct> findAll​(@Nullable
                                        ConstructOrder order)
        Return this construct and all of its children in the given order.

        Parameters:
        order -
      • findAll

        @Stability(Stable)
        @NotNull
        public List<IConstruct> findAll()
        Return this construct and all of its children in the given order.
      • findChild

        @Stability(Stable)
        @NotNull
        public IConstruct findChild​(@NotNull
                                    String id)
        Return a direct child by id.

        Throws an error if the child is not found.

        Parameters:
        id - Identifier of direct child. This parameter is required.
        Returns:
        Child with the given id.
      • prepare

        @Stability(Stable)
        public void prepare()
        Invokes "prepare" on all constructs (depth-first, post-order) in the tree under `node`.
      • setContext

        @Stability(Stable)
        public void setContext​(@NotNull
                               String key,
                               @NotNull
                               Object value)
        This can be used to set contextual values.

        Context must be set before any children are added, since children may consult context info during construction. If the key already exists, it will be overridden.

        Parameters:
        key - The context key. This parameter is required.
        value - The context value. This parameter is required.
      • synthesize

        @Stability(Stable)
        public void synthesize​(@NotNull
                               SynthesisOptions options)
        Synthesizes a CloudAssembly from a construct tree.

        Parameters:
        options - Synthesis options. This parameter is required.
      • tryFindChild

        @Stability(Stable)
        @Nullable
        public IConstruct tryFindChild​(@NotNull
                                       String id)
        Return a direct child by id, or undefined.

        Parameters:
        id - Identifier of direct child. This parameter is required.
        Returns:
        the child if found, or undefined
      • tryGetContext

        @Stability(Stable)
        @NotNull
        public Object tryGetContext​(@NotNull
                                    String key)
        Retrieves a value from tree context.

        Context is usually initialized at the root, but can be overridden at any point in the tree.

        Parameters:
        key - The context key. This parameter is required.
        Returns:
        The context value or `undefined` if there is no context value for thie key.
      • tryRemoveChild

        @Stability(Experimental)
        @NotNull
        public Boolean tryRemoveChild​(@NotNull
                                      String childName)
        (experimental) Remove the child with the given name, if present.

        Parameters:
        childName - This parameter is required.
        Returns:
        Whether a child with the given name was deleted.
      • validate

        @Stability(Stable)
        @NotNull
        public List<ValidationError> validate()
        Validates tree (depth-first, pre-order) and returns the list of all errors.

        An empty list indicates that there are no errors.

      • getAddr

        @Stability(Stable)
        @NotNull
        public String getAddr()
        Returns an opaque tree-unique address for this construct.

        Addresses are 42 characters hexadecimal strings. They begin with "c8" followed by 40 lowercase hexadecimal characters (0-9a-f).

        Addresses are calculated using a SHA-1 of the components of the construct path.

        To enable refactorings of construct trees, constructs with the ID Default will be excluded from the calculation. In those cases constructs in the same tree may have the same addreess.

        Example:

         c83a2846e506bcc5f10682b564084bca2d275709ee
         
      • getChildren

        @Stability(Stable)
        @NotNull
        public List<IConstruct> getChildren()
        All direct children of this construct.
      • getDependencies

        @Stability(Stable)
        @NotNull
        public List<Dependency> getDependencies()
        Return all dependencies registered on this node or any of its children.
      • getId

        @Stability(Stable)
        @NotNull
        public String getId()
        The id of this construct within the current scope.

        This is a a scope-unique id. To obtain an app-unique id for this construct, use uniqueId.

      • getLocked

        @Stability(Stable)
        @NotNull
        public Boolean getLocked()
        Returns true if this construct or the scopes in which it is defined are locked.
      • getMetadata

        @Stability(Stable)
        @NotNull
        public List<MetadataEntry> getMetadata()
        An immutable array of metadata objects associated with this construct.

        This can be used, for example, to implement support for deprecation notices, source mapping, etc.

      • getPath

        @Stability(Stable)
        @NotNull
        public String getPath()
        The full, absolute path of this construct in the tree.

        Components are separated by '/'.

      • getRoot

        @Stability(Stable)
        @NotNull
        public IConstruct getRoot()
        Returns the root of the construct tree.

        Returns:
        The root of the construct tree.
      • getScopes

        @Stability(Stable)
        @NotNull
        public List<IConstruct> getScopes()
        All parent scopes of this construct.

        Returns:
        a list of parent scopes. The last element in the list will always be the current construct and the first element will be the root of the tree.
      • getUniqueId

        @Stability(Deprecated)
        @Deprecated
        @NotNull
        public String getUniqueId()
        Deprecated.
        please avoid using this property and use `addr` to form unique names. This algorithm uses MD5, which is not FIPS-complient and also excludes the identity of the root construct from the calculation.
        (deprecated) A tree-global unique alphanumeric identifier for this construct.

        Includes all components of the tree.

      • getScope

        @Stability(Stable)
        @Nullable
        public IConstruct getScope()
        Returns the scope in which this construct is defined.

        The value is undefined at the root of the construct scope tree.

      • getDefaultChild

        @Stability(Stable)
        @Nullable
        public IConstruct getDefaultChild()
        Returns the child construct that has the id `Default` or `Resource"`.

        This is usually the construct that provides the bulk of the underlying functionality. Useful for modifications of the underlying construct that are not available at the higher levels. Override the defaultChild property.

        This should only be used in the cases where the correct default child is not named 'Resource' or 'Default' as it should be.

        If you set this to undefined, the default behavior of finding the child named 'Resource' or 'Default' will be used.

        Returns:
        a construct or undefined if there is no default child
      • setDefaultChild

        @Stability(Stable)
        public void setDefaultChild​(@Nullable
                                    IConstruct value)
        Returns the child construct that has the id `Default` or `Resource"`.

        This is usually the construct that provides the bulk of the underlying functionality. Useful for modifications of the underlying construct that are not available at the higher levels. Override the defaultChild property.

        This should only be used in the cases where the correct default child is not named 'Resource' or 'Default' as it should be.

        If you set this to undefined, the default behavior of finding the child named 'Resource' or 'Default' will be used.