Adding a writer to a Catalog product

This example adds an additional writer to a product.

from descarteslabs.catalog import Product
import uuid


product_id = str(uuid.uuid4())[:8]

product = Product(id=product_id, name="My Product", description="This is my product.")
product.save()
print("Product {} added.".format(product.id))

Out:

/root/.cache/bazel/_bazel_drone-agent-b0bb/3517bd091dde6188868082e15543f179/sandbox/linux-sandbox/17/execroot/__main__/bazel-out/k8-opt/bin/docs/build_tools/public/descarteslabs/client/auth/auth.py:129: UserWarning: unable to read token_info from /root/.descarteslabs/token_info.json with error [Errno 2] No such file or directory: '/root/.descarteslabs/token_info.json'.
  self.token_info_path, str(e)
/root/.cache/bazel/_bazel_drone-agent-b0bb/3517bd091dde6188868082e15543f179/sandbox/linux-sandbox/17/execroot/__main__/bazel-out/k8-opt/bin/docs/build_tools/public/descarteslabs/client/auth/auth.py:397: UserWarning: unable to read token_info from /root/.descarteslabs/token_info.json with error [Errno 2] No such file or directory: '/root/.descarteslabs/token_info.json'.
  self.token_info_path, str(e)
Product descarteslabs:336a4fea added.

The product that we just created doesn’t have any writers.

print("Product writers: {}".format(product.writers))

Out:

Product writers: []

However, we can add a writer to this product.

product.writers = ["email:someuser@gmail.com"]
product.save()

Now, 'email:someuser@gmail.com' is a writer for this product. This user can now change the product metadata, add bands, and add imagery to this product.

print("Changed product writers: {}".format(product.writers))

Out:

Changed product writers: ['email:someuser@gmail.com']

Delete our product; we don’t need it anymore.

product.delete()
print("Product removed.")

Out:

Product removed.

Total running time of the script: ( 0 minutes 2.795 seconds)

Gallery generated by Sphinx-Gallery