<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Cloud Storage client library
This tutorial shows how to get started with the Cloud Storage Python client library.
Create a storage bucket
Buckets are the basic containers that hold your data. Everything that you store in Cloud Storage must be contained in a bucket. You can use buckets to organize your data and control access to your data.
Start by importing the library
Step1:  The storage.Client object uses your default project. Alternatively, you can specify a project in the Client constructor. For more information about how the default project is determined, see the google-auth documentation.
Run the following to create a client with your default project
Step2:  To explicitly specify a project when constructing the client, set the project parameter
Step3:  Finally, create a bucket with a globally unique name.
For more information about naming buckets, see Bucket name requirements.
Step4:  List buckets in a project
Step5:  Get bucket metadata
The next cell shows how to get information on metadata of your Cloud Storage buckets.
To learn more about specific bucket properties, see Bucket locations and Storage classes.
Step6:  Upload a local file to a bucket
Objects are the individual pieces of data that you store in Cloud Storage. Objects are referred to as "blobs" in the Python client library. There is no limit on the number of objects that you can create in a bucket.
An object's name is treated as a piece of object metadata in Cloud Storage. Object names can contain any combination of Unicode characters (UTF-8 encoded) and must be less than 1024 bytes in length.
For more information, including how to rename an object, see the Object name requirements.
Step7:  List blobs in a bucket
Step8:  Get a blob and display metadata
See documentation for more information about object metadata.
Step9:  Download a blob to a local directory
Step10:  Cleaning up
Delete a blob
Step11:  Delete a bucket
Note that the bucket must be empty before it can be deleted.
<ASSISTANT_TASK:>
Python Code:
from google.cloud import storage
Explanation: Cloud Storage client library
This tutorial shows how to get started with the Cloud Storage Python client library.
Create a storage bucket
Buckets are the basic containers that hold your data. Everything that you store in Cloud Storage must be contained in a bucket. You can use buckets to organize your data and control access to your data.
Start by importing the library:
End of explanation
client = storage.Client()
print("Client created using default project: {}".format(client.project))
Explanation: The storage.Client object uses your default project. Alternatively, you can specify a project in the Client constructor. For more information about how the default project is determined, see the google-auth documentation.
Run the following to create a client with your default project:
End of explanation
# client = storage.Client(project='your-project-id')
Explanation: To explicitly specify a project when constructing the client, set the project parameter:
End of explanation
# Replace the string below with a unique name for the new bucket
bucket_name = "your-new-bucket"
# Creates the new bucket
bucket = client.create_bucket(bucket_name)
print("Bucket {} created.".format(bucket.name))
Explanation: Finally, create a bucket with a globally unique name.
For more information about naming buckets, see Bucket name requirements.
End of explanation
buckets = client.list_buckets()
print("Buckets in {}:".format(client.project))
for item in buckets:
    print("\t" + item.name)
Explanation: List buckets in a project
End of explanation
bucket = client.get_bucket(bucket_name)
print("Bucket name: {}".format(bucket.name))
print("Bucket location: {}".format(bucket.location))
print("Bucket storage class: {}".format(bucket.storage_class))
Explanation: Get bucket metadata
The next cell shows how to get information on metadata of your Cloud Storage buckets.
To learn more about specific bucket properties, see Bucket locations and Storage classes.
End of explanation
blob_name = "us-states.txt"
blob = bucket.blob(blob_name)
source_file_name = "resources/us-states.txt"
blob.upload_from_filename(source_file_name)
print("File uploaded to {}.".format(bucket.name))
Explanation: Upload a local file to a bucket
Objects are the individual pieces of data that you store in Cloud Storage. Objects are referred to as "blobs" in the Python client library. There is no limit on the number of objects that you can create in a bucket.
An object's name is treated as a piece of object metadata in Cloud Storage. Object names can contain any combination of Unicode characters (UTF-8 encoded) and must be less than 1024 bytes in length.
For more information, including how to rename an object, see the Object name requirements.
End of explanation
blobs = bucket.list_blobs()
print("Blobs in {}:".format(bucket.name))
for item in blobs:
    print("\t" + item.name)
Explanation: List blobs in a bucket
End of explanation
blob = bucket.get_blob(blob_name)
print("Name: {}".format(blob.id))
print("Size: {} bytes".format(blob.size))
print("Content type: {}".format(blob.content_type))
print("Public URL: {}".format(blob.public_url))
Explanation: Get a blob and display metadata
See documentation for more information about object metadata.
End of explanation
output_file_name = "resources/downloaded-us-states.txt"
blob.download_to_filename(output_file_name)
print("Downloaded blob {} to {}.".format(blob.name, output_file_name))
Explanation: Download a blob to a local directory
End of explanation
blob = client.get_bucket(bucket_name).get_blob(blob_name)
blob.delete()
print("Blob {} deleted.".format(blob.name))
Explanation: Cleaning up
Delete a blob
End of explanation
bucket = client.get_bucket(bucket_name)
bucket.delete()
print("Bucket {} deleted.".format(bucket.name))
Explanation: Delete a bucket
Note that the bucket must be empty before it can be deleted.
End of explanation
<END_TASK>