code: async def add_credential(self, name=None, credential=None, cloud=None,
                               owner=None, force=False):
          if not cloud:
              cloud = await self.get_cloud()
          if not owner:
              owner = self.connection().info['user-info']['identity']
          if credential and not name:
              raise errors.JujuError('Name must be provided for credential')
          if not credential:
              name, credential = self._connector.jujudata.load_credential(cloud,
                                                                          name)
              if credential is None:
                  raise errors.JujuError(
                      'Unable to find credential: {}'.format(name))
          if credential.auth_type == 'jsonfile' and 'file' in credential.attrs:
              try:
                  json.loads(credential.attrs['file'])
              except json.JSONDecodeError:
                  cred_path = Path(credential.attrs['file'])
                  if cred_path.exists():
                      cred_json = credential.to_json()
                      credential = client.CloudCredential.from_json(cred_json)
                      credential.attrs['file'] = cred_path.read_text()
          log.debug('Uploading credential %s', name)
          cloud_facade = client.CloudFacade.from_connection(self.connection())
          tagged_credentials = [
              client.UpdateCloudCredential(
                  tag=tag.credential(cloud, tag.untag('user-', owner), name),
                  credential=credential,
              )]
          if cloud_facade.version >= 3:
              await cloud_facade.UpdateCredentialsCheckModels(
                  credentials=tagged_credentials, force=force,
              )
          else:
              await cloud_facade.UpdateCredentials(tagged_credentials)
          return name