googleapis / googleapis/google-cloud-python

create_database documentation improvements

Đang mở
#15,392 1 bình luận 0 reaction 1 người được giao Được @daniel-sanche nhận Xem trên GitHub
api: firestore type: docs type: feature request
Ngôn ngữ chính
Python
Star
5.4k
Fork
1.8k
Merge trung bình
3 ngày 4 giờ
Pull request đã merge (30 ngày)
122

Mô tả

The [sample code for create_database](https://github.com/googleapis/python-firestore/blob/b8cbf1d32414933f82174a4778d641324c8f1de9/google/cloud/firestore_admin_v1/services/firestore_admin/client.py#L1651) is not correct.

- The documentation says firestore_admin_v1.CreateDatabaseRequest, but it's supposed to be firestore_admin_v1.types.firestore_admin.CreateDatabaseRequest

- The documentation doesn't show using a database param being used, which is required.

- The Database Type is named with an underscore (type_), which is probably generated that way because type is a reserved keyword in Python, perhaps this could be renamed to 'database_type'.

Some example code that I got working is here:

```
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
from google.cloud import firestore
from google.cloud import firestore_admin_v1
from google.cloud.firestore_admin_v1.types import database
from google.cloud.firestore_admin_v1.types import firestore_admin

PROJECT_ID = 'projects/****'

def main(argv):
cred = credentials.ApplicationDefault()
firebase_admin.initialize_app(cred)
admin_client = firestore_admin_v1.FirestoreAdminClient()

db_type = database.Database.DatabaseType.FIRESTORE_NATIVE
db = database.Database(location_id='nam5', type_=db_type)
create_database_request = firestore_admin.CreateDatabaseRequest(
parent=PROJECT_ID, database_id='second-database', database=db
)

create_database_operation = admin_client.create_database(
request=create_database_request
)
print(create_database_operation)
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.