Building Google Cloud Platform Solutions
上QQ阅读APP看书,第一时间看更新

Formatting attributes

Although providing a basic format type such as JSON or YAML is often enough to get the ball rolling when dealing with results, there are oftentimes when deeper formatting is needed. The gcloud tool includes a very powerful formatting engine. Formats are broken down into the following three key components:

  • The format type
  • The attributes that modify that format type
  • The projections that shape the results to be formatted

We just changed the format type for the services to JSON, but suppose we want to modify the way results are serialized into that format. This is where attributes come into play. Attributes allow us to control the actual serialization process of a given format type. For JSON, this is limited to excluding fields that have a null value, but other formats can have many configurable attributes. To exclude undefined fields, try running the following command:

gcloud services list --available --format=json['no-undefined']