
## Manage announcements

URL: https://docs.atlan.com/product/capabilities/build-apps/sdks/python/how-tos/manage-announcements

> Add and remove announcements from assets programmatically using the Atlan Python SDK (pyatlan).

# Manage announcements

## Add to existing asset

To add an announcement to an existing [asset](https://docs.atlan.com/llms/platform/python/build-your-first-metadata-workflow/llms.txt):

### dbt

```yaml showLineNumbers title="Add announcement to existing assets"
models:
 - name: TOP_BEVERAGE_USERS # (1)
 meta:
 atlan:
 attributes: # (2)
 announcementType: warning # (3)
 announcementTitle: "Caution!" # (4)
 announcementMessage: >- # (5)
 This table was changed.
```

1. You must of course give the name of the object.
2. The details for the announcement must be nested within the `meta`.`atlan`.`attributes` structure.
3. You must provide a valid status for the announcement (`information`, `warning` or `issue`).
4. (Optional) You can also provide a title for the announcement.
5. (Optional) You can also provide a message to include in the announcement.

### Java

```java showLineNumbers title="Add announcement to existing assets"
Table result = Table.updateAnnouncement( // (1)
 client, // (2)
 "default/snowflake/1657037873/SAMPLE_DB/FOOD_BEV/TOP_BEVERAGE_USERS", // (3)
 AtlanAnnouncementType.WARNING, // (4)
 "Caution!", // (5)
 "This table was changed."); // (6)
```

1. Use the `updateAnnouncement()` helper method, which for most objects requires a minimal set of information. This helper method will construct the necessary request, call the necessary APIs, and return with the result of the update operation all-in-one.
2. Because this operation will directly change the asset in Atlan, you must [provide it an `AtlanClient`](https://docs.atlan.com/llms/platform/python/set-up-sdk/llms.txt) through which to connect to the tenant.
3. The `qualifiedName` of the object.
4. The type of the announcement (the `AtlanAnnouncementType` enumeration gives the valid values).
5. A title for the announcement.
6. A message to include in the announcement.

### Python

```python showLineNumbers title="Add announcement to existing assets"
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import Table
from pyatlan.model.core import Announcement
from pyatlan.model.enums import AnnouncementType

client = AtlanClient()
announcement = Announcement( # (1)
 announcement_title="Caution",
 announcement_message="This table was changed.",
 announcement_type=AnnouncementType.WARNING, # (2)
)
table = client.asset.update_announcement( # (3)
 asset_type=Table, # (4)
 qualified_name="default/snowflake/1657037873/SAMPLE_DB/FOOD_BEV/TOP_BEVERAGE_USERS",
 name="TOP_BEVERAGE_USERS",
 announcement=announcement,
)
```

1. Create the announcement.
2. The type of the announcement (the `AnnouncementType` enum gives the valid values).
3. Use the `update_announcment()` method, which for most objects requires a minimal set of information. This helper method will construct the necessary request, call the necessary APIs, and return with the result of the update operation all-in-one.
4. Specify the type of asset to be updated.

### Kotlin

```kotlin showLineNumbers title="Add announcement to existing assets"
val result = Table.updateAnnouncement( // (1)
 client, // (2)
 "default/snowflake/1657037873/SAMPLE_DB/FOOD_BEV/TOP_BEVERAGE_USERS", // (3)
 AtlanAnnouncementType.WARNING, // (4)
 "Caution!", // (5)
 "This table was changed.") // (6)
```

1. Use the `updateAnnouncement()` helper method, which for most objects requires a minimal set of information. This helper method will construct the necessary request, call the necessary APIs, and return with the result of the update operation all-in-one.
2. Because this operation will directly change the asset in Atlan, you must [provide it an `AtlanClient`](https://docs.atlan.com/llms/platform/python/set-up-sdk/llms.txt) through which to connect to the tenant.
3. The `qualifiedName` of the object.
4. The type of the announcement (the `AtlanAnnouncementType` enumeration gives the valid values).
5. A title for the announcement.
6. A message to include in the announcement.

### Raw REST API

```json showLineNumbers title="POST /api/meta/entity/bulk"
{
 "entities": [ // (1)
 }
 ]
}
```

1. All assets must be wrapped in an `entities` array.
2. You must provide the exact type name for the asset (case-sensitive).
3. You must provide the exact name of the asset (case-sensitive).
4. You must provide the exact `qualifiedName` of the asset (case-sensitive).
5. You must provide a valid type for the announcement.
6. (Optional) You can also provide a title and message for the announcement.

## Remove from existing asset

To remove an announcement from an existing asset:

### dbt

It's currently not possible to _remove_ an announcement from an asset via dbt.

### Java

```java showLineNumbers title="Remove announcement from existing asset"
Column column = Column.removeAnnouncement( // (1)
 client, // (2)
 "default/snowflake/1657037873/SAMPLE_DB/FOOD_BEV/TOP_BEVERAGE_USERS/USER_ID", // (3)
 "USER_ID"); // (4)
```

1. Use the `removeAnnouncement()` helper method, which for most objects requires a minimal set of information. This helper method will construct the necessary request, call the necessary APIs, and return with the result of the removal operation all-in-one.
2. Because this operation will directly change the asset in Atlan, you must [provide it an `AtlanClient`](https://docs.atlan.com/llms/platform/python/set-up-sdk/llms.txt) through which to connect to the tenant.
3. The `qualifiedName` of the column (this is generally needed on all assets).
4. The name of the column (this varies by asset, but most assets need the name specified).

### Python

```python showLineNumbers title="Remove announcement from existing asset"
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import Table

client = AtlanClient()
table = client.asset.remove_announcement( # (1)
 asset_type=Table, # (2)
 qualified_name="default/snowflake/1657037873/SAMPLE_DB/FOOD_BEV/TOP_BEVERAGE_USERS/USER_ID",
 name="USER_ID",
)
```

1. Use the `asset.remove_announcement()` helper method, which for most objects requires a minimal set of information. This helper method will construct the necessary request, call the necessary APIs, and return with the result of the removal operation all-in-one.
2. Specify the type of asset from which to remove the announcement.

### Kotlin

```kotlin showLineNumbers title="Remove announcement from existing asset"
val column = Column.removeAnnouncement( // (1)
 client, // (2)
 "default/snowflake/1657037873/SAMPLE_DB/FOOD_BEV/TOP_BEVERAGE_USERS/USER_ID", // (3)
 "USER_ID") // (4)
```

1. Use the `removeAnnouncement()` helper method, which for most objects requires a minimal set of information. This helper method will construct the necessary request, call the necessary APIs, and return with the result of the removal operation all-in-one.
2. Because this operation will directly change the asset in Atlan, you must [provide it an `AtlanClient`](https://docs.atlan.com/llms/platform/python/set-up-sdk/llms.txt) through which to connect to the tenant.
3. The `qualifiedName` of the column (this is generally needed on all assets).
4. The name of the column (this varies by asset, but most assets need the name specified).

### Raw REST API

```json showLineNumbers title="POST /api/meta/entity/bulk"
{
 "entities": [ // (1)
 }
 ]
}
```

1. All assets must be wrapped in an `entities` array.
2. You must provide the exact type name for the asset (case-sensitive).
3. You must provide the exact name of the asset (case-sensitive).
4. You must provide the exact `qualifiedName` of the asset (case-sensitive).
5. You must provide the value `null` for the type of the announcement, its title, and its message.

## When creating asset

To add an announcement when creating an asset:

### dbt

```yaml showLineNumbers title="Add announcement when creating asset"
models:
 - name: TOP_BEVERAGE_USERS # (1)
 meta:
 atlan:
 attributes: # (2)
 announcementType: information # (3)
 announcementTitle: "New!" # (4)
 announcementMessage: >- # (5)
 This table is newly created.
```

1. You must of course give the name of the object.
2. The details for the announcement must be nested within the `meta`.`atlan`.`attributes` structure.
3. You must provide a valid status for the announcement (`information`, `warning` or `issue`).
4. (Optional) You can also provide a title for the announcement.
5. (Optional) You can also provide a message to include in the announcement.

### Java

```java showLineNumbers title="Add announcement when creating asset"
Table table = Table
 .creator("TOP_BEVERAGE_USERS", // (1)
 "default/snowflake/1657037873/SAMPLE_DB/FOOD_BEV")
 .announcementType(AtlanAnnouncementType.INFORMATION) // (2)
 .announcementTitle("New!") // (3)
 .announcementMessage("This table is newly created.") // (4)
 .build(); // (5)
AssetMutationResponse response = table.save(client); // (6)
assert response.getCreatedAssets().size() == 1 // (7)
```

1. Use the `creator()` method to initialize the object with all [necessary attributes for creating it](https://docs.atlan.com/llms/platform/python/create-asset/llms.txt).
2. Set the announcement that should be added (in this example, we're using `INFORMATION`).
3. Add a title for the announcement.
4. Add a message for the announcement.
5. Call the `build()` method to build the enriched object.
6. Call the `save()` method to actually create the asset with this announcement. Because this operation will persist the asset in Atlan, you must [provide it an `AtlanClient`](https://docs.atlan.com/llms/platform/python/set-up-sdk/llms.txt) through which to connect to the tenant.
7. The response will include that single asset that was created.

### Python

```python showLineNumbers title="Add announcement when creating asset"
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.assets import Table
from pyatlan.model.core import Announcement
from pyatlan.model.enums import AnnouncementType
from pyatlan.model.response import AssetMutationResponse

client = AtlanClient()
table = Table.creator( # (1)
 name="TOP_BEVERAGE_USERS",
 schema_qualified_name="default/snowflake/1657037873/SAMPLE_DB/FOOD_BEV",
)
announcement = Announcement( # (2)
 announcement_title="New!",
 announcement_message="This table is newly created.",
 announcement_type=AnnouncementType.INFORMATION,
)
table.set_announcement(announcement=announcement)
response = client.asset.save(table) # (3)
assert response.assets_created(Table) # (4)
table = response.assets_created(Table)[0] # (5)
```

1. Use the `create()` method to initialize the object with all [necessary attributes for creating it.
2. Create the `Announcement` to be used.
3. Invoke the `save()` method with asset. This method will return an AssetMutationResponse object that encapsulates the results.
4. Since a save can add, update, delete or partially update multiple assets the `assets_created()` method can be used to return a list of the assets of the specified type that were added. The assert statement is present to make sure a `Table` asset was created.
5. Since only one `Table` should have been created we use an index of 0 to retrieve the newly created table.

### Kotlin

```kotlin showLineNumbers title="Add announcement when creating asset"
val table = Table
 .creator("TOP_BEVERAGE_USERS", // (1)
 "default/snowflake/1657037873/SAMPLE_DB/FOOD_BEV")
 .announcementType(AtlanAnnouncementType.INFORMATION) // (2)
 .announcementTitle("New!") // (3)
 .announcementMessage("This table is newly created.") // (4)
 .build() // (5)
val response = table.save(client) // (6)
assert(response.createdAssets.size == 1) // (7)
```

1. Use the `creator()` method to initialize the object with all [necessary attributes for creating it](https://docs.atlan.com/llms/platform/python/create-asset/llms.txt).
2. Set the announcement that should be added (in this example, we're using `INFORMATION`).
3. Add a title for the announcement.
4. Add a message for the announcement.
5. Call the `build()` method to build the enriched object.
6. Call the `save()` method to actually create the asset with this announcement. Because this operation will persist the asset in Atlan, you must [provide it an `AtlanClient`](https://docs.atlan.com/llms/platform/python/set-up-sdk/llms.txt) through which to connect to the tenant.
7. The response will include that single asset that was created.

### Raw REST API

```json showLineNumbers title="POST /api/meta/entity/bulk"
{
 "entities": [ // (1)
 },
 "announcementType": "information", // (6)
 "announcementTitle": "New!", // (7)
 "announcementMessage": "This table is newly created."
 }
 }
 ]
}
```

1. All assets must be wrapped in an `entities` array.
2. You must provide the exact type name for the asset (case-sensitive).
3. You must provide a name for the asset.
4. In the case of a table, the `qualifiedName` must be the concatenation of the parent schema's qualifiedName and the name of the table.
5. When creating a table, you must specify the schema to create it within. This is defined by the `atlanSchema` attribute. You must specify both the type (must be `Schema`) and qualifiedName of the schema within the `atlanSchema` attribute—and the schema must already exist.
6. You must provide a valid status for the announcement.
7. (Optional) You can also provide a title and message for the announcement.

---
