def _build_gcs_destination(config):
  """Builds a GcsDestination from values in a config dict.

  Args:
    config: All the user-specified export parameters. Will be modified in-place
      by removing parameters used in the GcsDestination.

  Returns:
    A GcsDestination containing information extracted from
    config.
  """
  cloud_storage_export_destination = {'bucket': config.pop('outputBucket')}
  if 'outputPrefix' in config:
    cloud_storage_export_destination['filenamePrefix'] = config.pop(
        'outputPrefix')
  if config.pop('writePublicTiles', False):
    cloud_storage_export_destination['permissions'] = 'PUBLIC'
  return cloud_storage_export_destination