def _UpdateHmacKey(self, thread_state=None):
    """Update an HMAC key's state."""
    if not self.state:
      raise CommandException(
          'A state flag must be supplied for %s %s\n%s' %
          (self.command_name, self.action_subcommand, _UPDATE_SYNOPSIS))
    elif self.state not in _VALID_UPDATE_STATES:
      raise CommandException('The state flag value must be one of %s' %
                             ', '.join(_VALID_UPDATE_STATES))
    if self.args:
      access_id = self.args[0]
    else:
      raise _AccessIdException(self.command_name, self.action_subcommand,
                               _UPDATE_SYNOPSIS)

    gsutil_api = GetCloudApiInstance(self, thread_state=thread_state)

    response = gsutil_api.UpdateHmacKey(self.project_id,
                                        access_id,
                                        self.state,
                                        self.etag,
                                        provider='gs')

    print(_KeyMetadataOutput(response))