def __init__(self, url, username=None, password=None, cookie=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, insecure=False): super(SFJenkins, self).__init__(urljoin(url, 'jenkins/'), username, password, timeout) if not cookie and (not username or not password): raise ValueError("Authentication needed") if not cookie: self.cookie = sfauth.get_cookie(url, username, password, use_ssl=True, verify=not insecure) else: self.cookie = cookie self.insecure = insecure self.opener = build_opener() if self.insecure: ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE self.opener.add_handler(HTTPSHandler(context=ctx))
self.r.project_membership.create(project_id=pname, user_id=m['user_id'], role_ids=m['role_ids']) def delete_membership(self, id): try: return self.r.project_membership.delete(id) except ResourceNotFoundError: return None def delete_project(self, pname): try: return self.r.project.delete(pname) except ResourceNotFoundError: return None def active_users(self): try: return [(x.login, x.mail, ' '.join([x.firstname, x.lastname])) for x in self.r.user.filter(status=1)] except ResourceNotFoundError: return None # Here an usage example. if __name__ == "__main__": import sfauth c = sfauth.get_cookie('tests.dom', 'user1', 'userpass') a = RedmineUtils('http://redmine.tests.dom', auth_cookie=c) a.create_user('fbo', '*****@*****.**', 'Fabien B')
# Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from storyboardclient.v1.client import Client as StoryboardClient import urllib class SFStoryboard(StoryboardClient): def __init__(self, api_url, auth_cookie): uid = filter(lambda x: x.startswith('uid='), urllib.unquote(auth_cookie).split(';'))[0].split('=')[1] super(SFStoryboard, self).__init__(api_url=api_url, access_token=uid) self.http_client.http.cookies['auth_pubtkt'] = auth_cookie if __name__ == "__main__": import sfauth c = sfauth.get_cookie('sftests.com', 'admin', 'userpass') s = SFStoryboard("https://sftests.com/storyboard_api", c) s.stories.list()
gid = [g.id for g in groups if g.name == name][0] except IndexError: return None return gid def set_group_members(self, gid, user_ids): try: return self.r.group.update(gid, user_ids=user_ids) except ResourceNotFoundError: return None def list_group(self, gid): try: return self.r.group.get(gid, include='users').users except ResourceNotFoundError: return None def delete_group(self, gid): try: return self.r.group.delete(gid) except ResourceNotFoundError: return None # Here an usage example. if __name__ == "__main__": import sfauth c = sfauth.get_cookie('sftests.com', 'admin', 'userpass') a = RedmineUtils('http://sftests.com/redmine', auth_cookie=c) a.create_user('John', '*****@*****.**', 'John Doe')