Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

Commit 36a7825

Browse filesBrowse files
peter-zheng-ggguuss
authored andcommitted
[Asset] Add requirements.txt [(#1834)](GoogleCloudPlatform/python-docs-samples#1834)
Adds asset quickstart
1 parent db37cd6 commit 36a7825
Copy full SHA for 36a7825

File tree

Expand file treeCollapse file tree

3 files changed

+16
-11
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+16
-11
lines changed

‎samples/snippets/quickstart_exportassets.py

Copy file name to clipboardExpand all lines: samples/snippets/quickstart_exportassets.py
+7-6Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ def export_assets(project_id, dump_file_path):
2323
from google.cloud import asset_v1beta1
2424
from google.cloud.asset_v1beta1.proto import asset_service_pb2
2525

26-
# TODO project_id = "Your Google Cloud Project ID"
27-
# TODO dump_file_path = "Your asset dump file path"
26+
# TODO project_id = 'Your Google Cloud Project ID'
27+
# TODO dump_file_path = 'Your asset dump file path'
2828

2929
client = asset_v1beta1.AssetServiceClient()
3030
parent = client.project_path(project_id)
3131
output_config = asset_service_pb2.OutputConfig()
3232
output_config.gcs_destination.uri = dump_file_path
3333
response = client.export_assets(parent, output_config)
34-
print(response.result)
34+
print(response.result())
3535
# [END asset_quickstart_exportassets]
3636

3737

@@ -42,9 +42,10 @@ def export_assets(project_id, dump_file_path):
4242
formatter_class=argparse.RawDescriptionHelpFormatter
4343
)
4444
parser.add_argument('project_id', help='Your Google Cloud project ID')
45-
parser.add_argument('dump_file_path',
46-
help='The file ExportAssets API will dump assets to, '
47-
'e.g.: gs://<bucket-name>/asset_dump_file')
45+
parser.add_argument(
46+
'dump_file_path',
47+
help='The file ExportAssets API will dump assets to, '
48+
'e.g.: gs://<bucket-name>/asset_dump_file')
4849

4950
args = parser.parse_args()
5051

‎samples/snippets/quickstart_exportassets_test.py

Copy file name to clipboardExpand all lines: samples/snippets/quickstart_exportassets_test.py
+7-5Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
# limitations under the License.
1616

1717
import os
18+
import time
1819

1920
from google.cloud import storage
2021
import pytest
2122

2223
import quickstart_exportassets
2324

2425
PROJECT = os.environ['GCLOUD_PROJECT']
25-
BUCKET = 'bucket-for-assets'
26+
BUCKET = 'assets-{}'.format(int(time.time()))
2627

2728

2829
@pytest.fixture(scope='module')
@@ -36,15 +37,16 @@ def asset_bucket(storage_client):
3637

3738
try:
3839
storage_client.delete_bucket(BUCKET)
39-
except Exception:
40-
pass
40+
except Exception as e:
41+
print('Failed to delete bucket{}'.format(BUCKET))
42+
raise e
4143

4244
yield BUCKET
4345

4446

4547
def test_export_assets(asset_bucket, capsys):
46-
dump_file_path = "gs://", asset_bucket, "/assets-dump.txt"
48+
dump_file_path = 'gs://{}/assets-dump.txt'.format(asset_bucket)
4749
quickstart_exportassets.export_assets(PROJECT, dump_file_path)
4850
out, _ = capsys.readouterr()
4951

50-
assert "uri: \"gs://cai-prober-prod-for-assets/phython-test.txt\"" in out
52+
assert dump_file_path in out

‎samples/snippets/requirements.txt

Copy file name to clipboard
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
google-cloud-storage==1.13.0
2+
google-cloud-asset==0.1.1

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.