# TreeInspector

Inspector that maintains an attribute bag.

Used as argument in: [IInspectable.inspect](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IInspectable.html#inspect)

- Source: [`core/lib/tree.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/core/lib/tree.ts#L4)

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
const treeInspector = new cdk.TreeInspector();
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk

tree_inspector = cdk.TreeInspector()
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;

TreeInspector treeInspector = new TreeInspector();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;

var treeInspector = new TreeInspector();
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import cdk "github.com/aws/aws-cdk-go/awscdk"

treeInspector := cdk.NewTreeInspector()
```

## Initializer

TypeScript:

```ts
new TreeInspector()
```

Python:

```python
TreeInspector()
```

Java:

```java
new TreeInspector()
```

C# / .NET:

```csharp
new TreeInspector()
```

Golang:

```go
NewTreeInspector()
```

## Properties

- `attributes`: { [key: string]: any } — Represents the bag of attributes as key-value pairs.

## Methods

- `addAttribute(key: string, value: any): void` — Adds attribute to bag.

  Keys should be added by convention to prevent conflicts
  i.e. L1 constructs will contain attributes with keys prefixed with aws:cdk:cloudformation

  **Parameters**

  - `key` — - key for metadata.
  - `value` — - value of metadata.
