code: def share_database(self, username, roles=None):
          
          if roles is None:
              roles = ['_reader']
          valid_roles = [
              '_reader',
              '_writer',
              '_admin',
              '_replicator',
              '_db_updates',
              '_design',
              '_shards',
              '_security'
          ]
          doc = self.security_document()
          data = doc.get('cloudant', {})
          perms = []
          if all(role in valid_roles for role in roles):
              perms = list(set(roles))
  
          if not perms:
              raise CloudantArgumentError(102, roles, valid_roles)
  
          data[username] = perms
          doc['cloudant'] = data
          resp = self.r_session.put(
              self.security_url,
              data=json.dumps(doc, cls=self.client.encoder),
              headers={'Content-Type': 'application/json'}
          )
          resp.raise_for_status()
          return response_to_json_dict(resp)
docs: Shares the current remote database with the username provided.
          You can grant varying degrees of access rights,
          default is to share read-only, but additional
          roles can be added by providing the specific roles as a
          ``list`` argument.  If the user already has this database shared with
          them then it will modify/overwrite the existing permissions.
  
          :param str username: Cloudant user to share the database with.
          :param list roles: A list of
              `roles
              <https://console.bluemix.net/docs/services/Cloudant/api/authorization.html#roles>`_
              to grant to the named user.
  
          :returns: Share database status in JSON format