arrow_back

APIs Explorer: Cloud Storage

Partecipa Accedi
Test and share your knowledge with our community!
done
Get access to over 700 hands-on labs, skill badges, and courses

APIs Explorer: Cloud Storage

Lab 45 minuti universal_currency_alt 1 credito show_chart Introduttivi
Test and share your knowledge with our community!
done
Get access to over 700 hands-on labs, skill badges, and courses

GSP421

Google Cloud self-paced labs logo

Overview

The Google APIs Explorer is a tool that helps you explore various Google APIs interactively. With the APIs Explorer, you can:

  • Browse quickly through available APIs and versions.
  • See methods available for each API and what parameters they support along with inline documentation.
  • Execute requests for any method and see responses in real-time.
  • Make authenticated and authorized API calls.
  • Search across all services, methods, and your recent requests to quickly find what you are looking for.

Cloud Storage allows world-wide storage and retrieval of any amount of data at any time. You can use Cloud Storage for a range of scenarios including serving website content, storing data for archival and disaster recovery, or distributing large data objects to users via direct download.

In this lab, you will use the APIs Explorer to make Cloud Storage API requests that create and delete Cloud Storage buckets. You will also learn how to copy and delete files in Cloud Storage.

Objectives

In this lab, you will:

  • Create Cloud Storage buckets using the APIs Explorer.
  • Upload image files to your Cloud Storage bucket.
  • Copy an image file and add it to a Cloud Storage bucket using the APIs Explorer.
  • Delete image files from your Cloud Storage bucket using the APIs Explorer.
  • Delete a Cloud Storage bucket using the APIs Explorer.

Setup and requirements

Before you click the Start Lab button

Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources will be made available to you.

This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.

To complete this lab, you need:

  • Access to a standard internet browser (Chrome browser recommended).
Note: Use an Incognito or private browser window to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.
  • Time to complete the lab---remember, once you start, you cannot pause a lab.
Note: If you already have your own personal Google Cloud account or project, do not use it for this lab to avoid extra charges to your account.

How to start your lab and sign in to the Google Cloud console

  1. Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is the Lab Details panel with the following:

    • The Open Google Cloud console button
    • Time remaining
    • The temporary credentials that you must use for this lab
    • Other information, if needed, to step through this lab
  2. Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).

    The lab spins up resources, and then opens another tab that shows the Sign in page.

    Tip: Arrange the tabs in separate windows, side-by-side.

    Note: If you see the Choose an account dialog, click Use Another Account.
  3. If necessary, copy the Username below and paste it into the Sign in dialog.

    {{{user_0.username | "Username"}}}

    You can also find the Username in the Lab Details panel.

  4. Click Next.

  5. Copy the Password below and paste it into the Welcome dialog.

    {{{user_0.password | "Password"}}}

    You can also find the Password in the Lab Details panel.

  6. Click Next.

    Important: You must use the credentials the lab provides you. Do not use your Google Cloud account credentials. Note: Using your own Google Cloud account for this lab may incur extra charges.
  7. Click through the subsequent pages:

    • Accept the terms and conditions.
    • Do not add recovery options or two-factor authentication (because this is a temporary account).
    • Do not sign up for free trials.

After a few moments, the Google Cloud console opens in this tab.

Note: To view a menu with a list of Google Cloud products and services, click the Navigation menu at the top-left. Navigation menu icon

Task 1. Create Cloud Storage Buckets

  1. To access the Cloud Storage APIs Explorer tool, from the Navigation menu select APIs & Services > Library.

  2. In the search bar, type Cloud Storage.

  3. Click on the Google Cloud Storage JSON API from the results list.

  4. Make sure that API is enabled, if not click Enable.

  5. Open the Buckets: insert reference. This will open a new tab with the APIs Explorer page loaded.

You will now be on the APIs Explorer page.

Note: In the next section you are using the insert method from Cloud Storage JSON API. You can view all API versions and its method in the API reference.
  1. Now click on the request body from the right panel under Try this API and fill in the details for your storage bucket:
  • project: add your Project ID - .
  • Request body: click inside the quotes next to the name key-value pair and give your Cloud Storage bucket a unique name that follows the Cloud Storage bucket naming guidelines.

Your method should now resemble the following:

The method displaying in the Request body section of the Request parameters dialog box

Note: Make sure that there are no trailing spaces in the project ID field. Also, that Google OAuth 2.0 and API key checkboxes are selected under Credentials section.

The Google OAuth 2.0 and API key checkboxes selected in the Credentials section

Note: To view Credentials FAQs, click on the question mark icon next to Credentials title.
  1. Click the Execute button.

  2. Select the student account you started the lab with.

  3. On the next screen, click Allow to give APIs Explorer access.

Your response should resemble the following:

{ "kind": "storage#bucket", "id": "qwiklabs-bucket01", "selfLink": "https://www.googleapis.com/storage/v1/b/qwiklabs-bucket01", "projectNumber": "250399850182", "name": "qwiklabs-bucket01", "timeCreated": "2019-10-18T13:59:08.300Z", "updated": "2019-10-18T13:59:08.300Z", "metageneration": "1", "iamConfiguration": { "bucketPolicyOnly": { "enabled": false }, "uniformBucketLevelAccess": { "enabled": false } }, "location": "US", "locationType": "multi-region", "storageClass": "STANDARD", "etag": "CAE=" }

Click Check my progress to verify the objective. Create a Cloud Storage Bucket.

Task 2. Make a second Cloud Storage bucket

Now make another Cloud Storage bucket so you can get hands-on practice copying files between the two.

  1. Still, in the insert method, ensure that your Project ID is still in the project field.

  2. In the request body, for the name key-value pair, give your second bucket a unique name.

  3. Make sure that there are no trailing spaces in any of the fields.

  4. Click the Execute button. Your response should resemble the following:

{ "kind": "storage#bucket", "id": "qwiklabs-bucket02", "selfLink": "https://www.googleapis.com/storage/v1/b/qwiklabs-bucket02", "projectNumber": "250399850182", "name": "qwiklabs-bucket02", "timeCreated": "2019-10-18T13:59:08.300Z", "updated": "2019-10-18T13:59:08.300Z", "metageneration": "1", "iamConfiguration": { "bucketPolicyOnly": { "enabled": false }, "uniformBucketLevelAccess": { "enabled": false } }, "location": "US", "locationType": "multi-region", "storageClass": "STANDARD", "etag": "CAE=" }

You have successfully created two buckets with the insert method. Next you'll find them in the Cloud console.

Click Check my progress to verify the objective. Make a second Cloud Storage bucket.

View your Cloud Storage buckets in the Cloud console

  1. Return to the Cloud console and from the Navigation menu go to Cloud Storage to ensure that your Cloud Storage buckets were created.

  2. From the Navigation menu select Cloud Storage > Buckets. You should see your newly created buckets added.

Remain in the Cloud console for the following step. Keep the APIs Explorer tab open.

Task 3. Upload files to your Cloud Storage bucket

Upload some files to your Cloud Storage bucket so you can get hands-on practice with methods housed in the APIs explorer.

  1. Save the following image to your computer and name it demo-image1.png:

Dog

  1. Now save this public domain image of Ada Lovelace to your computer and name it demo-image2.png:

Ada Lovelace

  1. In the Cloud Storage browser select the first bucket from the list.

  2. Click Upload files and select demo-image1.png and demo-image2.png from your computer.

Your bucket should now have both image files added to it and should resemble the following:

demo-image1.png and demo-image2.png listed on the Objects tabbed page of qwiklabs-bucket01

Click Check my progress to verify the objective. Upload Files to Your Cloud Storage Bucket (demo-image1.png and demo-image2.png)

Next, you will copy one of the image files to your second Cloud Storage bucket.

Task 4. Copy files between Cloud Storage buckets

  1. From the left APIs & Reference section, navigate to JSON API > API reference > Objects > copy to copy method or, to copy files between storage buckets using API Explorer, use the Objects: copy reference.

  2. Update as follows:

  • sourceBucket: type in the name of the bucket that contains the demo image files.
  • sourceObject: enter in demo-image1.png.
  • destinationBucket: enter intype the name of your second (empty) bucket.
  • destinationObject: type in demo-image1-copy.png.

Your method should resemble the following:

The Request parameters dialog displaying the bulleted information in step 2

  1. Make sure that Google OAuth 2.0 and API key checkboxes are selected under Credentials section.
Note: To view Credentials FAQs, click on question mark icon next to Credentials title.
  1. Make sure that there are no trailing spaces in any of the fields.

  2. Now scroll down and click Execute.

You should receive a similar output:

{ "kind": "storage#object", "id": "qwiklabs-bucket02/demo-image1-copy.png/1571408245199237", "selfLink": "https://www.googleapis.com/storage/v1/b/qwiklabs-bucket02/o/demo-image1-copy.png", "name": "demo-image1-copy.png", "bucket": "qwiklabs-bucket02", "generation": "1571408245199237", "metageneration": "1", "contentType": "image/png", "timeCreated": "2019-10-18T14:17:25.198Z", "updated": "2019-10-18T14:17:25.198Z", "storageClass": "STANDARD", "timeStorageClassUpdated": "2019-10-18T14:17:25.198Z", "size": "401951", "md5Hash": "LbpHpwhnApQKQx9IEXjTsQ==", "mediaLink": "https://www.googleapis.com/download/storage/v1/b/qwiklabs-bucket02/o/demo-image1-copy.png?generation=1571408245199237&alt=media", "owner": { "entity": "user-gcpstaging93416_student@qwiklabs.net" }, "crc32c": "j5oPrg==", "etag": "CIWjgvL/peUCEAE=" }

You have successfully copied a file from one bucket to another using the objects.copy method.

Click Check my progress to verify the objective. Copy files between Cloud Storage buckets (demo-image1-copy.png)

View your updated bucket in the Cloud console

  1. Return to the Cloud console for this step. You should have left off on your Cloud Storage bucket details page.

  2. From the left-hand menu, click Buckets and select your second bucket. You should see the copy of demo-image1.png added.

Task 5. Delete files from a Cloud Storage bucket

  1. From the left APIs & Reference section navigate to JSON API > API reference > Objects > delete or, to delete files from a Cloud Storage bucket using API Explorer, use the Objects: delete reference.

  2. Now you'll delete an image file from a Cloud Storage bucket.

  • bucket: enter in the name of your bucket that contains both demo image files.
  • object: enter in demo-image1.png. Your method should resemble the following:

The method displayed in the Request parameters dialog box

  1. Make sure that Google OAuth 2.0 and API key checkboxes are selected under Credentials section.
Note: To view Credentials FAQs, click on question mark icon next to Credentials title.
  1. Make sure that there are no trailing spaces in any of the fields.

  2. Now scroll down and click Execute.

You should receive a similar output as below:

204 displayed on a green ribbon

  1. Now remove the second image from the Cloud Storage bucket. Still in the same method, for the object field, enter in demo-image2.png. Your bucket name will remain the same. Your method should resemble the following:

The request parameters dialog box displaying the method

  1. Now scroll down and click Execute. You should receive a similar output:

204 displayed on a green ribbon

You have successfully deleted files from a bucket using the objects.delete method. You will now view your removed file in the Cloud console.

View your updated bucket in the Cloud console

  1. Return to the Cloud console for this step. You should have left off on your Cloud Storage bucket details page.

  2. From the left-hand menu, click Buckets and select your first bucket. You should see that both images have been removed.

Task 6. Delete your Cloud Storage bucket

  1. From the left APIs & Reference section navigate to JSON API > API reference > Buckets > delete to buckets.delete method or, to delete a Cloud Storage bucket using API Explorer, use the Buckets: delete reference.

You will now delete your first (empty) Cloud Storage bucket.

  1. For the bucket field, enter in the name of your first bucket. Your method should resemble the following:

The Request parameters dialog box with the populated bucket field

  1. Make sure that Google OAuth 2.0 and API key checkboxes are selected under Credentials section.
Note: To view Credentials FAQs, click on question mark icon next to Credentials title.
  1. Make sure that there are no trailing spaces in any of the fields.

  2. Now scroll down and click Execute. You should receive a similar output:

204 displayed on a green ribbon

You have successfully deleted a bucket using the buckets.delete method.

View your updated bucket in the Cloud console

  1. Return to the Cloud console for this step. You should have left off on the Details page.

  2. From the left-hand menu, click Buckets. You should see that your first bucket has been removed.

You have successfully completed all steps of the lab. You can end your lab here, or experiment with some new methods in the remaining time.

Task 7. Test your understanding

Below are multiple-choice questions to reinforce your understanding of this lab's concepts. Answer them to the best of your abilities.

Congratulations!

In this lab you created Cloud Storage buckets with the APIs Explorer. You also copied and deleted image files with specific APIs Explorer methods. After deleting image files, you learned how to delete an entire bucket with the delete method. At this point, you have a solid understanding of Cloud Storage and how you can provision this service's methods through the APIs Explorer.

Finish your quest

This self-paced lab is part of the Exploring APIs quest. A quest is a series of related labs that form a learning path. Completing this quest earns you a badge to recognize your achievement. You can make your badge or badges public and link to them in your online resume or social media account. Enroll in this quest and get immediate completion credit. Refer to the Google Cloud Skills Boost catalog for all available quests.

Next steps / Learn more

For more practice with the APIs Explorer, try this lab:

APIs Explorer: Create and Update a Cluster

Google Cloud training and certification

...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.

Manual Last Updated May 1, 2023

Lab Last Tested February 8, 2023

Copyright 2024 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.