Metadata-Version: 2.4
Name: google-cloud-helper
Version: 0.1.8
Summary: Add your description here
Project-URL: Homepage, https://github.com/SWRdata/google-cloud-helper.git
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: google-cloud-bigquery>=3.35.0
Requires-Dist: google-cloud-secret-manager>=2.24.0
Requires-Dist: google-cloud-storage>=3.2.0
Requires-Dist: pandas>=2.3.1
Requires-Dist: pandas-gbq>=0.29.2
Requires-Dist: pre-commit>=4.2.0
Requires-Dist: pytest>=8.4.1

# google-cloud-helper

This repository contains common functions for easy access to Google Cloud Infrastructure, such as Big Query or Google buckets.


## Example Usage

```python
from google_cloud_helper.BigQueryHelper import BigQueryHelper
from google_cloud_helper.GoogleBucketHelper import GoogleBucketHelper
from google_cloud_helper.SecretManagerHelper import SecretManagerHelper

# BigQuery
bq_helper = BigQueryHelper("your-gcp-project-id")
exists = bq_helper.exists_table("your-gcp-project-id.dataset.table")
print(f"Table exists: {exists}")

# Google Cloud Storage
bucket_helper = GoogleBucketHelper("your-gcp-project-id")
bucket_exists = bucket_helper.exists_bucket("your-bucket-name")
print(f"Bucket exists: {bucket_exists}")

# Secret Manager
secret_helper = SecretManagerHelper()
my_secret = secret_helper.get_secret("your-gcp-project-id", "your-secret-id")
print("Successfully retrieved secret!")
```

## Available Functions

### BigQueryHelper

<!-- BIGQUERYHELPER START -->
- `create_dataset(self, dataset_id, location)`
- `create_table_from_df(self, table_id, df, partitioning, clustering, labels, specific_types)`
- `create_table_labels(self, cost_category, triggered_by, caller)`
- `delete_dataset(self, dataset_id)`
- `delete_table(self, table_id)`
- `exists_table(self, table_id)`
- `generate_bigquery_schema_from_df(self, df, specific_types)`
- `incremental_insert_with_deduplication(self, table_id, df, id_cols)`
- `read_table_as_df(self, table_id)`
- `sql2df(self, query)`
- `update_table(self, table_id, df, id_cols)`
- `upload_df_to_table(self, table_id, df)`

<!-- BIGQUERYHELPER END -->


### GoogleBucketHelper

<!-- GOOGLEBUCKETHELPER START -->
- `download_as_text(self, bucket_name, path)`
- `exists_bucket(self, bucket_name)`
- `list_all_files_in_bucket(self, bucket_name, folder_name, suffix)`
- `upload_content(self, content, bucket_name, filename, content_type)`

<!-- GOOGLEBUCKETHELPER END -->

### SecretManagerHelper

<!-- SECRETMANAGERHELPER START -->
- `get_secret(self, project_id, secret_id)`

<!-- SECRETMANAGERHELPER END -->

## Development

When new functions are added run `uv run update_readme.py` to update the README.md file.

## Testing

To run the tests, execute the following command:

```
uv run pytest
```

## Build and Publish

To build and publish the package to PyPI, execute the following command:

```
uv build
uv publish --token <pypi-token>
```
