<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def lock(self, resource_id, region, account_id=None):
 """Lock a given resource """

        account_id = self.get_account_id(account_id)
        return self.http.post(
            "%s/%s/locks/%s/lock" % (self.endpoint, account_id, resource_id),
            json={'region': region},
            auth=self.get_api_auth())