# Google Cloud Storage (Legacy)

## Overview

The **Google Cloud Storage Book** integrates with Google Cloud Storage, allowing you to manage and store files effortlessly within your automations.

## Prerequisites

1. **Google Cloud Account**: You need to have an active Google Cloud account. If you do not have one, you can sign up for a Google Cloud trial account to get started.
2. **Google Cloud Storage Bucket**: Ensure that a Google Cloud Storage bucket has been created. This bucket will be used to store your files and data.
3. **Service Account with Storage Admin Role**: Create a service account in Google Cloud and assign it the Storage Admin role. Kognitos will use this service account to interact with Google Cloud Storage.
4. **Service Account Key**: Download the JSON key file for your service account. This key file will be used to authenticate Kognitos with Google Cloud Storage.

### Learning the Google Cloud Storage Book

1. Navigate to **Books → All Books**
2. Search for **Google Cloud** and click on it.
3. Click **Add Connection** and provide the authentication details. You will need the following credentials:
   1. **Service Account Key File**: The JSON key file for your Google Cloud service account. This file contains the credentials required to authenticate with Google Cloud Storage.

Once you have successfully added the book, you are ready to use the book's procedures. You can now dump files, purge files, and enrich questions with additional information.

## Procedures

### Dumping Files to Google Cloud Storage

To dump a file to Google Cloud Storage, you need to specify the file and the Google Cloud Storage path. For example:

```
get the file
the gs path is "gs://my_bucket/path/to/file"
dump the file to google cloud storage
```

### Purging Files from Google Cloud Storage

To purge a file from Google Cloud Storage, you need to specify the file path. For example:

```
the file path is "gs://my-bucket/path/to/my-file.txt"
purge the file from google cloud storage
```

This purges the specified file from Google Cloud Storage.

### Dumping CSVs to Google Cloud Storage

To dump a CSV to Google Cloud Storage, you need to specify the CSV path and optionally the bucket prefix and folder.

**Example 1:**

```
get the csv
the csv path is "data_exports/my_export.csv"
dump the csv to google cloud storage
```

This dumps the specified CSV to the given Google Cloud Storage path.

**Example 2:**

```
get the csv
the csv path is "data_exports/my_export.csv"
the bucket prefix is "my_bucket"
the folder is "2023/exports"
dump the csv to google cloud storage
```

This dumps the specified CSV to the given Google Cloud Storage path with the specified bucket prefix and folder.

### Purging CSVs from Google Cloud Storage

To purge a CSV from Google Cloud Storage, you need to specify the CSV path and the Google Cloud Storage path.

**Example 1:**

```
purge the csv from google cloud storage with
  the gs path is "gs://my-bucket/folder1"
  the csv path is "in-folder-path/to/your/csvfile.csv"
```

This purges the specified CSV from the given Google Cloud Storage path.

**Example 2:**

```
the csv path is "datasets/2023/march/sales_data.csv"
the gs path is "gs://my-bucket/folder2"
purge the csv from google cloud storage
```

This purges the specified CSV from the given Google Cloud Storage path.

### Enriching Questions

To enrich a question with additional information, you need to specify the details to be enriched. For example:

```
enrich the question with
  the foo is "example"
  the bar is "detailed example"
  the baz is "further information"

the foo is "example"
the bar is "detailed example"
the baz is "further information"
enrich the question
```

This enriches the question with the specified details.
