pax_global_header00006660000000000000000000000064124410765660014525gustar00rootroot0000000000000052 comment=835dae24dbd837ece804c0e5d0ed39832baa87dd pyapi-gitlab-7.5.0/000077500000000000000000000000001244107656600141205ustar00rootroot00000000000000pyapi-gitlab-7.5.0/.gitattributes000066400000000000000000000007431244107656600170170ustar00rootroot00000000000000# Auto detect text files and perform LF normalization * text=auto # Custom for Visual Studio *.cs diff=csharp *.sln merge=union *.csproj merge=union *.vbproj merge=union *.fsproj merge=union *.dbproj merge=union # Standard to msysgit *.doc diff=astextplain *.DOC diff=astextplain *.docx diff=astextplain *.DOCX diff=astextplain *.dot diff=astextplain *.DOT diff=astextplain *.pdf diff=astextplain *.PDF diff=astextplain *.rtf diff=astextplain *.RTF diff=astextplain pyapi-gitlab-7.5.0/.gitignore000066400000000000000000000005541244107656600161140ustar00rootroot00000000000000*.py[cod] # C extensions *.so # Packages *.egg *.egg-info dist build eggs parts bin var sdist develop-eggs .installed.cfg lib lib64 __pycache__ # Installer logs pip-log.txt # Unit test / coverage reports .coverage .tox nosetests.xml # Translations *.mo # Mr Developer .mr.developer.cfg .project .pydevproject # pycharm files .idea # build dir docs/_buildpyapi-gitlab-7.5.0/.travis.yml000066400000000000000000000010351244107656600162300ustar00rootroot00000000000000env: - gitlab_user=root gitlab_password=5iveL!fe gitlab_host=http://localhost:8080 services: - redis-server language: python python: - "2.7" - "3.2" - "3.3" - "3.4" rvm: - 2.1.0 # install local gitlab before_install: - gem install bundler --no-ri --no-rdoc - scripts/prepare_test_env.sh - scripts/install_gitlab.sh # command to install dependencies install: - pip install -r requirements.txt - pip install coveralls # command to run tests script: coverage run --source=gitlab setup.py test after_success: coveralls pyapi-gitlab-7.5.0/CONTRIBUTORS.md000066400000000000000000000012601244107656600163760ustar00rootroot00000000000000Thanks to all contributors to pyapy-gitlab. https://github.com/tobias-reese https://github.com/samrocketman https://github.com/Burstaholic https://github.com/jproffitt https://github.com/elho https://github.com/b-sh https://github.com/Tenzer https://github.com/jirihnidek https://github.com/arruda https://github.com/lovasb https://github.com/ptisserand https://github.com/dan-blanchard https://github.com/freakypie https://github.com/ianunruh https://github.com/rafax https://github.com/asmacdo https://github.com/dieterplex https://github.com/NickCraver https://github.com/jwreeder https://github.com/sloede https://github.com/waghanza https://github.com/the-glu pyapi-gitlab-7.5.0/LICENSE000066400000000000000000001045121244107656600151300ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read .pyapi-gitlab-7.5.0/README.md000066400000000000000000000070221244107656600154000ustar00rootroot00000000000000# pyapi-gitlab pyapi-gitlab is a python wrapper for the [Gitlab API](https://github.com/gitlabhq/gitlabhq/tree/master/doc/api). [![Build Status](https://travis-ci.org/Itxaka/pyapi-gitlab.svg?branch=develop)](https://travis-ci.org/Itxaka/pyapi-gitlab) [![PyPI version](https://badge.fury.io/py/pyapi-gitlab.png)](http://badge.fury.io/py/pyapi-gitlab) [![Coverage Status](https://coveralls.io/repos/Itxaka/pyapi-gitlab/badge.png?branch=develop)](https://coveralls.io/r/Itxaka/pyapi-gitlab?branch=develop) [![PyPi downloads](https://pypip.in/d/pyapi-gitlab/badge.png)](https://crate.io/packages/pyapi-gitlab/) [![License](http://img.shields.io/pypi/l/pyapi-gitlab.svg)](http://www.gnu.org/copyleft/gpl.html) [![Docs](https://readthedocs.org/projects/pyapi-gitlab/badge/?version=latest)](http://pyapi-gitlab.readthedocs.org/) ## Requirements - requests ## Naming convention pyapi-gitlab has its own versioning in which the 2 first numbers indicates the Gitlab version that its supported for that library. a 7.5 version means that its compatible with the Gitlab 7.5 and lower API versions. ## Installation pyapi-gitlab is now on Pypi! Depending on the gitlab version you are using (check it on your help section on gitlab) you will need a different version. Latest version Gitlab 7.5.0: ```bash pip install pyapi-gitlab=="7.5.0" ``` Old versions not maintained: Gitlab 5.4: ```bash pip install pyapi-gitlab=="5.4-0" ``` Gitlab 6.0 or 6.1: ```bash pip install pyapi-gitlab=="6.1.6" ``` Gitlab 6.2: ```bash pip install pyapi-gitlab=="6.2.3" ``` pyapi-gitlab supports python version 2.6, 2.7, 3.3 and 3.4 ## Changes in the latest version - Support for the full Gitlab 7.5 API - All methods have documentation (Inside the library only, the docs are lagging a bit behind). - New fork api that allows to actually fork a project instead of doing fork relations - New label methods (getlabel, createlabel, editlabel, deletelabel) - All get* methods that return more than one item support pagination. Check page and per_page args. Default to first page and 20 items per page. - BREAKING CHANGE: Old sudo arg in methods to execute as other user is gone. Now there is a method setsudo(user_id/user_username) which will setup the header, so all the subsequent API calls will be done as that user. To get back to your user just do a setsudo() and the sudo parameter will be cleared - BREAKING CHANGE: Some methods were returning True or False instead of the object created. Now all the methods in which there is something returning from the server is returned as a dictionary/list of dictionaries to the user - BREAKING CHANGE: Some methods now use kwargs for the optional parameters so the code is more easy and readable. Methods affected: createproject, createprojectuser, createmilestone, editmilestone, updatemergerequest - BREAKING CHANGE: Project wallnotes does not exist anymore, seems that they have been moved to project snippets (getsnippets, getsnippet, createsnippet, deletesnippet) - BREAKING CHANGE: Removed getreadme method as its not part of the gitlab api, nor was it ever. - BREAKING CHANGE: Old methods that started with list* are not get*. This is done in order to have a proper naming convention instead of having mixed listsomething and then getsomething. The actual - BREAKING CHANGE: Old methods with new names: getownprojects -> getprojectsowned, getallprojects -> getprojectsall ## Examples/Documentation Check the docs at [readthedocs.org](http://pyapi-gitlab.readthedocs.org) ## License pyapi-gitlab is licensed under the GPL3. Check the LICENSE file. pyapi-gitlab-7.5.0/TODO000066400000000000000000000001661244107656600146130ustar00rootroot00000000000000TODO: snippets TODO: repositories TODO: deploy keys TODO: notes TODO: check if edituser() can be ridden of all the ifspyapi-gitlab-7.5.0/docs/000077500000000000000000000000001244107656600150505ustar00rootroot00000000000000pyapi-gitlab-7.5.0/docs/Makefile000066400000000000000000000152061244107656600165140ustar00rootroot00000000000000# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # User-friendly check for sphinx-build ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) endif # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" @echo " text to make text files" @echo " man to make manual pages" @echo " texinfo to make Texinfo files" @echo " info to make Texinfo files and run them through makeinfo" @echo " gettext to make PO message catalogs" @echo " changes to make an overview of all changed/added/deprecated items" @echo " xml to make Docutils-native XML files" @echo " pseudoxml to make pseudoxml-XML files for display purposes" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/python-gitlab.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/python-gitlab.qhc" devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/python-gitlab" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/python-gitlab" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." latexpdfja: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through platex and dvipdfmx..." $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." texinfo: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." @echo "Run \`make' in that directory to run these through makeinfo" \ "(use \`make info' here to do that automatically)." info: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo "Running Texinfo files through makeinfo..." make -C $(BUILDDIR)/texinfo info @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." gettext: $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." xml: $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml @echo @echo "Build finished. The XML files are in $(BUILDDIR)/xml." pseudoxml: $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml @echo @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." pyapi-gitlab-7.5.0/docs/conf.py000066400000000000000000000175401244107656600163560ustar00rootroot00000000000000# -*- coding: utf-8 -*- # # pyapi-gitlab documentation build configuration file, created by # sphinx-quickstart on Sun Aug 04 20:46:27 2013. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys, os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.insert(0, os.path.abspath('../')) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'pyapi-gitlab' copyright = u'2013, Itxaka Serrano Garcia' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = '0.2' # The full version, including alpha/beta/rc tags. release = '0.2' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. #keep_warnings = False # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'pyapi-gitlabdoc' # -- Options for LaTeX output -------------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). #'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', # Additional stuff for the LaTeX preamble. #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ ('index', 'pyapi-gitlab.tex', u'pyapi-gitlab Documentation', u'Itxaka Serrano Garcia', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output -------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'pyapi-gitlab', u'pyapi-gitlab Documentation', [u'Itxaka Serrano Garcia'], 1) ] # If true, show URL addresses after external links. #man_show_urls = False # -- Options for Texinfo output ------------------------------------------------ # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ('index', 'pyapi-gitlab', u'pyapi-gitlab Documentation', u'Itxaka Serrano Garcia', 'pyapi-gitlab', 'One line description of project.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. #texinfo_appendices = [] # If false, no module index is generated. #texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. #texinfo_no_detailmenu = False pyapi-gitlab-7.5.0/docs/index.rst000066400000000000000000000055071244107656600167200ustar00rootroot00000000000000.. pyapi-gitlab documentation master file, created by sphinx-quickstart on Sun Aug 04 20:46:27 2013. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. Welcome to pyapi-gitlab's documentation! ========================================= pyapi-gitlab is a wrapper to access all the functions of Gitlab from our python scripts. How to use it ================== There are several optional parameters in a lot of the commands, you should check the command documentation or the command string, for example adding an user accepts up to 7 extra parameters. First we import our library:: import gitlab Then we need to authenticate to our Gitlab instance. There is 2 ways of doing this. Authenticating via user/password ================================== First create the instance passing the gitlab server as parameter:: git = gitlab.Gitlab("our_gitlab_host") Then call the login() method:: git.login("user", "password") That's it, now your gitlab instance is using the private token in all the calls. You can see it in the token variable Authenticating via private_token ==================================== You can also authenticate via the private_token that you can get from your gitlab profile and it's easier than using user/password Just call the instance with the parameter token:: git = gitlab.Gitlab("our_gitlab_host", token="mytoken") Using sudo on the functions ============================= All API calls support using sudo (e.g. calling the API as a different user) This is accomplished by using the setsudo() method to temporarily make all requests as another user, then calling it with no args to go back to the original user:: >>> git = gitlab.Gitlab(host=host) >>> git.login(user=user, password=password) True >>> git.currentuser()["username"] u'root' >>> [[u["id"], u["username"]] for u in git.getusers()] [[1, u'root'], [9, u'sudo_user'], [10, u'NMFUQ85Y']] >>> # lets try with sudo_user >>> git.setsudo(9) >>> git.currentuser()["username"] u'sudo_user' >>> # lets change back to the original user >>> git.setsudo(1) >>> git.currentuser()["username"] u'root' Pagination =========== All get* functions now accept a page and per_page parameter:: git.getissues(page=1, per_page=40) The default is to get page 1 and 20 results per page. The max value for per_page is 100. API doc ================== Every method now has the documentation as a docstring. The best way of checking what the API entails is to go to the Gitlab API page directly as this library is a 1:1 translation of it. http://doc.gitlab.com/ce/api/README.html Contents: .. toctree:: :maxdepth: 2 .. automodule:: gitlab .. autoclass:: Gitlab :members: Indices and tables ================== * :ref:`genindex` * :ref:`search`pyapi-gitlab-7.5.0/docs/make.bat000066400000000000000000000145111244107656600164570ustar00rootroot00000000000000@ECHO OFF REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) set BUILDDIR=_build set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . set I18NSPHINXOPTS=%SPHINXOPTS% . if NOT "%PAPER%" == "" ( set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% ) if "%1" == "" goto help if "%1" == "help" ( :help echo.Please use `make ^` where ^ is one of echo. html to make standalone HTML files echo. dirhtml to make HTML files named index.html in directories echo. singlehtml to make a single large HTML file echo. pickle to make pickle files echo. json to make JSON files echo. htmlhelp to make HTML files and a HTML help project echo. qthelp to make HTML files and a qthelp project echo. devhelp to make HTML files and a Devhelp project echo. epub to make an epub echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter echo. text to make text files echo. man to make manual pages echo. texinfo to make Texinfo files echo. gettext to make PO message catalogs echo. changes to make an overview over all changed/added/deprecated items echo. xml to make Docutils-native XML files echo. pseudoxml to make pseudoxml-XML files for display purposes echo. linkcheck to check all external links for integrity echo. doctest to run all doctests embedded in the documentation if enabled goto end ) if "%1" == "clean" ( for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i del /q /s %BUILDDIR%\* goto end ) %SPHINXBUILD% 2> nul if errorlevel 9009 ( echo. echo.The 'sphinx-build' command was not found. Make sure you have Sphinx echo.installed, then set the SPHINXBUILD environment variable to point echo.to the full path of the 'sphinx-build' executable. Alternatively you echo.may add the Sphinx directory to PATH. echo. echo.If you don't have Sphinx installed, grab it from echo.http://sphinx-doc.org/ exit /b 1 ) if "%1" == "html" ( %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/html. goto end ) if "%1" == "dirhtml" ( %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. goto end ) if "%1" == "singlehtml" ( %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. goto end ) if "%1" == "pickle" ( %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the pickle files. goto end ) if "%1" == "json" ( %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the JSON files. goto end ) if "%1" == "htmlhelp" ( %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run HTML Help Workshop with the ^ .hhp project file in %BUILDDIR%/htmlhelp. goto end ) if "%1" == "qthelp" ( %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run "qcollectiongenerator" with the ^ .qhcp project file in %BUILDDIR%/qthelp, like this: echo.^> qcollectiongenerator %BUILDDIR%\qthelp\python-gitlab.qhcp echo.To view the help file: echo.^> assistant -collectionFile %BUILDDIR%\qthelp\python-gitlab.ghc goto end ) if "%1" == "devhelp" ( %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp if errorlevel 1 exit /b 1 echo. echo.Build finished. goto end ) if "%1" == "epub" ( %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub if errorlevel 1 exit /b 1 echo. echo.Build finished. The epub file is in %BUILDDIR%/epub. goto end ) if "%1" == "latex" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex if errorlevel 1 exit /b 1 echo. echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. goto end ) if "%1" == "latexpdf" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex cd %BUILDDIR%/latex make all-pdf cd %BUILDDIR%/.. echo. echo.Build finished; the PDF files are in %BUILDDIR%/latex. goto end ) if "%1" == "latexpdfja" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex cd %BUILDDIR%/latex make all-pdf-ja cd %BUILDDIR%/.. echo. echo.Build finished; the PDF files are in %BUILDDIR%/latex. goto end ) if "%1" == "text" ( %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text if errorlevel 1 exit /b 1 echo. echo.Build finished. The text files are in %BUILDDIR%/text. goto end ) if "%1" == "man" ( %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man if errorlevel 1 exit /b 1 echo. echo.Build finished. The manual pages are in %BUILDDIR%/man. goto end ) if "%1" == "texinfo" ( %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo if errorlevel 1 exit /b 1 echo. echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. goto end ) if "%1" == "gettext" ( %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale if errorlevel 1 exit /b 1 echo. echo.Build finished. The message catalogs are in %BUILDDIR%/locale. goto end ) if "%1" == "changes" ( %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes if errorlevel 1 exit /b 1 echo. echo.The overview file is in %BUILDDIR%/changes. goto end ) if "%1" == "linkcheck" ( %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck if errorlevel 1 exit /b 1 echo. echo.Link check complete; look for any errors in the above output ^ or in %BUILDDIR%/linkcheck/output.txt. goto end ) if "%1" == "doctest" ( %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest if errorlevel 1 exit /b 1 echo. echo.Testing of doctests in the sources finished, look at the ^ results in %BUILDDIR%/doctest/output.txt. goto end ) if "%1" == "xml" ( %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml if errorlevel 1 exit /b 1 echo. echo.Build finished. The XML files are in %BUILDDIR%/xml. goto end ) if "%1" == "pseudoxml" ( %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml if errorlevel 1 exit /b 1 echo. echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. goto end ) :end pyapi-gitlab-7.5.0/gitlab/000077500000000000000000000000001244107656600153625ustar00rootroot00000000000000pyapi-gitlab-7.5.0/gitlab/__init__.py000066400000000000000000002141521244107656600175000ustar00rootroot00000000000000# -*- coding: utf-8 -*- """ pyapi-gitlab, a gitlab python wrapper for the gitlab API by Itxaka Serrano Garcia Check the license on the LICENSE file """ import requests import json from . import exceptions class Gitlab(object): """Gitlab class""" def __init__(self, host, token="", verify_ssl=True): """on init we setup the token used for all the api calls and all the urls :param host: host of gitlab :param token: token """ if token != "": self.token = token self.headers = {"PRIVATE-TOKEN": self.token} if not host: raise ValueError("host argument may not be empty") if host[-1] == '/': self.host = host[:-1] else: self.host = host if self.host[:7] == 'http://' or self.host[:8] == 'https://': pass else: self.host = 'https://' + self.host self.api_url = self.host + "/api/v3" self.projects_url = self.api_url + "/projects" self.users_url = self.api_url + "/users" self.keys_url = self.api_url + "/user/keys" self.groups_url = self.api_url + "/groups" self.search_url = self.api_url + "/projects/search" self.hook_url = self.api_url + "/hooks" self.verify_ssl = verify_ssl def login(self, email=None, password=None, user=None): """Logs the user in and setups the header with the private token :param user: gitlab user :param password: gitlab password :return: True if login successfull """ if user != None: data = {"login": user, "password": password} elif email != None: data = {"email": email, "password": password} else: raise ValueError('Neither username nor email provided to login') request = requests.post("{}/api/v3/session".format(self.host), data=data, verify=self.verify_ssl, headers={"connection": "close"}) if request.status_code == 201: self.token = json.loads(request.content.decode("utf-8"))['private_token'] self.headers = {"PRIVATE-TOKEN": self.token, "connection": "close"} return True else: msg = json.loads(request.content.decode("utf-8"))['message'] raise exceptions.HttpError(msg) def setsudo(self, user=None): """Set the subsequent API calls to the user provided :param user: User id or username to change to, None to return to the logged user :return: Nothing """ if user is None: try: self.headers.pop("SUDO") except KeyError: pass else: self.headers["SUDO"] = user def getusers(self, search=None, page=1, per_page=20): """Return a user list :param search: Optional search query :param page: Which page to return (default is 1) :param per_page: Number of items to return per page (default is 20) :return: returs a dictionary of the users, false if there is an error """ data = {'page': page, 'per_page': per_page} if search: data['search'] = search request = requests.get(self.users_url, params=data, headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getuser(self, user_id): """Get info for a user identified by id :param user_id: id of the user :return: False if not found, a dictionary if found """ request = requests.get("{}/{}".format(self.users_url, user_id), headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def createuser(self, name, username, password, email, **kwargs): """Create a user :param name: Obligatory :param username: Obligatory :param password: Obligatory :param email: Obligatory :param kwargs: Any param the the Gitlab API supports :return: True if the user was created,false if it wasn't(already exists) """ data = {"name": name, "username": username, "password": password, "email": email} if kwargs: data.update(kwargs) request = requests.post(self.users_url, headers=self.headers, data=data, verify=self.verify_ssl) if request.status_code == 201: return json.loads(request.content.decode("utf-8")) elif request.status_code == 404: return False def deleteuser(self, user_id): """Deletes an user by ID :param user_id: id of the user to delete :return: True if it deleted, False if it couldn't. False could happen for several reasons, but there isn't a good way of differenting them """ request = requests.delete("{}/{}".format(self.users_url, user_id), headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return True else: return False def currentuser(self): """Returns the current user parameters. The current user is linked to the secret token :return: a list with the current user properties """ request = requests.get("{}/api/v3/user".format(self.host), headers=self.headers, verify=self.verify_ssl) return json.loads(request.content.decode("utf-8")) def edituser(self, user_id, **kwargs): """Edits an user data. :param user_id: id of the user to change :param kwargs: Any param the the Gitlab API supports :return: Dict of the user """ data = {} if kwargs: data.update(kwargs) request = requests.put("{}/{}".format(self.users_url, user_id), headers=self.headers, data=data, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getsshkeys(self, page=1, per_page=20): """Gets all the ssh keys for the current user :return: a dictionary with the lists """ data = {'page': page, 'per_page': per_page} request = requests.get(self.keys_url, headers=self.headers, params=data, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getsshkey(self, key_id): """Get a single ssh key identified by key_id :param key_id: the id of the key :return: the key itself """ request = requests.get("{}/{}".format(self.keys_url, key_id), headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def addsshkey(self, title, key): """Add a new ssh key for the current user :param title: title of the new key :param key: the key itself :return: true if added, false if it didn't add it (it could be because the name or key already exists) """ data = {"title": title, "key": key} request = requests.post(self.keys_url, headers=self.headers, data=data, verify=self.verify_ssl) if request.status_code == 201: return True else: return False def addsshkeyuser(self, user_id, title, key): """Add a new ssh key for the user identified by id :param user_id: id of the user to add the key to :param title: title of the new key :param key: the key itself :return: true if added, false if it didn't add it (it could be because the name or key already exists) """ data = {"title": title, "key": key} request = requests.post("{}/{}/keys".format(self.users_url, user_id), headers=self.headers, data=data, verify=self.verify_ssl) if request.status_code == 201: return True else: return False def deletesshkey(self, key_id): """Deletes an sshkey for the current user identified by id :param key_id: the id of the key :return: False if it didn't delete it, True if it was deleted """ request = requests.delete("{}/{}".format(self.keys_url, key_id), headers=self.headers, verify=self.verify_ssl) if request.content == b"null": return False else: return True def getprojects(self, page=1, per_page=20): """Returns a dictionary of all the projects :return: list with the repo name, description, last activity,web url, ssh url, owner and if its public """ data = {'page': page, 'per_page': per_page} request = requests.get(self.projects_url, params=data, headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getprojectsall(self, page=1, per_page=20): """Returns a dictionary of all the projects for admins only :return: list with the repo name, description, last activity,web url, ssh url, owner and if its public """ data = {'page': page, 'per_page': per_page} request = requests.get("{}/all".format(self.projects_url), params=data, headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getprojectsowned(self, page=1, per_page=20): """Returns a dictionary of all the projects for the current user :return: list with the repo name, description, last activity, web url, ssh url, owner and if its public """ data = {'page': page, 'per_page': per_page} request = requests.get("{}/owned".format(self.projects_url), params=data, headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getproject(self, project_id): """Get info for a project identified by id :param project_id: id of the project :return: False if not found, a dictionary if found """ request = requests.get("{}/{}".format(self.projects_url, project_id), headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getprojectevents(self, project_id, page=1, per_page=20): """Get the project identified by id, events(commits) :param project_id: id of the project :return: False if no project with that id, a dictionary with the events if found """ data = {'page': page, 'per_page': per_page} request = requests.get("{}/{}/events".format(self.projects_url, project_id), params=data, headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def createproject(self, name, **kwargs): """Creates a new project owned by the authenticated user. :param name: new project name :param path: custom repository name for new project. By default generated based on name :param namespace_id: namespace for the new project (defaults to user) :param description: short project description :param issues_enabled: :param merge_requests_enabled: :param wiki_enabled: :param snippets_enabled: :param public: if true same as setting visibility_level = 20 :param visibility_level: :param sudo: :param import_url: :return: """ data = {"name": name} if kwargs: data.update(kwargs) request = requests.post(self.projects_url, headers=self.headers, data=data, verify=self.verify_ssl) if request.status_code == 201: return json.loads(request.content.decode("utf-8")) elif request.status_code == 403: if "Your own projects limit is 0" in request.text: print(request.text) return False else: return False def deleteproject(self, project_id): """Delete a project :param project_id: project id :return: always true """ request = requests.delete("{}/{}".format(self.projects_url, project_id), headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return True def createprojectuser(self, user_id, name, **kwargs): """Creates a new project owned by the specified user. Available only for admins. :param user_id: user_id of owner :param name: new project name :param description: short project description :param default_branch: 'master' by default :param issues_enabled: :param merge_requests_enabled: :param wiki_enabled: :param snippets_enabled: :param public: if true same as setting visibility_level = 20 :param visibility_level: :param import_url: :param sudo: :return: """ data = {"name": name} if kwargs: data.update(kwargs) request = requests.post("{}/user/{}".format(self.projects_url, user_id), headers=self.headers, data=data, verify=self.verify_ssl) if request.status_code == 201: return True else: return False def getprojectmembers(self, project_id, query=None, page=1, per_page=20): """Lists the members of a given project id :param project_id: the project id :param query: Optional search query :param page: Which page to return (default is 1) :param per_page: Number of items to return per page (default is 20) :return: the projects memebers, false if there is an error """ data = {'page': page, 'per_page': per_page} if query: data['query'] = query request = requests.get("{}/{}/members".format(self.projects_url, project_id), params=data, headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def addprojectmember(self, project_id, user_id, access_level): """Adds a project member to a project :param project_id: project id :param user_id: user id :param access_level: access level, see gitlab help to know more :return: True if success """ if access_level.lower() == "master": access_level = 40 elif access_level.lower() == "developer": access_level = 30 elif access_level.lower() == "reporter": access_level = 20 else: access_level = 10 data = {"id": project_id, "user_id": user_id, "access_level": access_level} request = requests.post("{}/{}/members".format(self.projects_url, project_id), headers=self.headers, data=data, verify=self.verify_ssl) if request.status_code == 201: return True else: return False def editprojectmember(self, project_id, user_id, access_level): """Edit a project member :param project_id: project id :param user_id: user id :param access_level: access level :return: True if success """ if access_level.lower() == "master": access_level = 40 elif access_level.lower() == "developer": access_level = 30 elif access_level.lower() == "reporter": access_level = 20 else: access_level = 10 data = {"id": project_id, "user_id": user_id, "access_level": access_level} request = requests.put("{}/{}/members/{}".format(self.projects_url, project_id, user_id), headers=self.headers, data=data, verify=self.verify_ssl) if request.status_code == 200: return True else: return False def deleteprojectmember(self, project_id, user_id): """Delete a project member :param project_id: project id :param user_id: user id :return: always true """ request = requests.delete("{}/{}/members/{}".format(self.projects_url, project_id, user_id), headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return True # It always returns true def getprojecthooks(self, project_id, page=1, per_page=20): """Get all the hooks from a project :param project_id: project id :return: the hooks """ data = {'page': page, 'per_page': per_page} request = requests.get("{}/{}/hooks".format(self.projects_url, project_id), params=data, headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getprojecthook(self, project_id, hook_id): """Get a particular hook from a project :param project_id: project id :param hook_id: hook id :return: the hook """ request = requests.get("{}/{}/hooks/{}".format(self.projects_url, project_id, hook_id), headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def addprojecthook(self, project_id, url): """Add a hook to a project :param project_id: project id :param url: url of the hook :return: True if success """ data = {"id": project_id, "url": url} request = requests.post("{}/{}/hooks".format(self.projects_url, project_id), headers=self.headers, data=data, verify=self.verify_ssl) if request.status_code == 201: return True else: return False def editprojecthook(self, project_id, hook_id, url): """Edit an existing hook from a project :param project_id: project id :param hook_id: hook id :param url: the new url :param sudo: do the request as another user :return: True if success """ data = {"id": project_id, "hook_id": hook_id, "url": url} request = requests.put("{}/{}/hooks/{}".format(self.projects_url, project_id, hook_id), headers=self.headers, data=data, verify=self.verify_ssl) if request.status_code == 200: return True else: return False def deleteprojecthook(self, project_id, hook_id): """Delete a project hook :param project_id: project id :param hook_id: hook id :return: True if success """ request = requests.delete("{}/{}/hooks/{}".format(self.projects_url, project_id, hook_id), headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return True else: return False def getsystemhooks(self, page=1, per_page=20): """Get all system hooks :return: list of hooks """ data = {'page': page, 'per_page': per_page} request = requests.get(self.hook_url, params=data, headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def addsystemhook(self, url): """Add a system hook :param url: url of the hook :return: True if success """ data = {"url": url} request = requests.post(self.hook_url, headers=self.headers, data=data, verify=self.verify_ssl) if request.status_code == 201: return True else: return False def testsystemhook(self, hook_id): """Test a system hook :param hook_id: hook id :return: list of hooks """ data = {"id": hook_id} request = requests.get(self.hook_url, data=data, headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def deletesystemhook(self, hook_id): """Delete a project hook :param hook_id: hook id :return: True if success """ data = {"id": hook_id} request = requests.delete("{}/{}".format(self.hook_url, hook_id), data=data, headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return True else: return False def getbranches(self, project_id, page=1, per_page=20): """List all the branches from a project :param project_id: project id :return: the branches """ data = {'page': page, 'per_page': per_page} request = requests.get("{}/{}/repository/branches".format(self.projects_url, project_id), params=data, headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getbranch(self, project_id, branch): """List one branch from a project :param project_id: project id :param branch: branch id :return: the branch """ request = requests.get("{}/{}/repository/branches/{}".format(self.projects_url, project_id, branch), headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def createbranch(self, project_id, branch, ref): """Create branch from commit SHA or existing branch :param project_id: The ID of a project :param branch: The name of the branch :param ref: Create branch from commit SHA or existing branch :return: True if success, False if not """ data = {"id": project_id, "branch_name": branch, "ref": ref} request = requests.post("{}/{}/repository/branches".format(self.projects_url, project_id), headers=self.headers, data=data, verify=self.verify_ssl) if request.status_code == 201: return json.loads(request.content.decode("utf-8")) else: return False def deletebranch(self, project_id, branch): """Delete branch by name :param project_id: The ID of a project :param branch: The name of the branch :return: True if success, False if not """ request = requests.delete("{}/{}/repository/branches/{}".format(self.projects_url, project_id, branch), headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return True else: return False def protectbranch(self, project_id, branch): """Protect a branch from changes :param project_id: project id :param branch: branch id :return: True if success """ request = requests.put("{}/{}/repository/branches/{}/protect".format(self.projects_url, project_id, branch), headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return True else: return False def unprotectbranch(self, project_id, branch): """Stop protecting a branch :param project_id: project id :param branch: branch id :return: true if success """ request = requests.put("{}/{}/repository/branches/{}/unprotect".format(self.projects_url, project_id, branch), headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return True else: return False def createforkrelation(self, project_id, from_project_id): """Create a fork relation. This DO NOT create a fork but only adds a link as fork the relation between 2 repositories :param project_id: project id :param from_project_id: from id :return: true if success """ data = {"id": project_id, "forked_from_id": from_project_id} request = requests.post("{}/{}/fork/{}".format(self.projects_url, project_id, from_project_id), headers=self.headers, data=data, verify=self.verify_ssl) if request.status_code == 201: return True else: return False def removeforkrelation(self, project_id): """Remove an existing fork relation. this DO NOT remove the fork,only the relation between them :param project_id: project id :return: true if success """ request = requests.delete("{}/{}/fork".format(self.projects_url, project_id), headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return True else: return False def createfork(self, project_id): """Forks a project into the user namespace of the authenticated user. :param project_id: Project ID to fork :return: True if succeed """ request = requests.post("{}/fork/{}".format(self.projects_url, project_id)) if request.status_code == 200: return True else: return False def getissues(self, page=1, per_page=20): """Return a global list of issues for your user. :return: list of issues """ data = {'page': page, 'per_page': per_page} request = requests.get("{}/api/v3/issues".format(self.host), params=data, headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getprojectissues(self, project_id, page=1, per_page=20): """Return a list of issues for project id. :param: project_id: The id for the project. :return: list of issues """ data = {'page': page, 'per_page': per_page} request = requests.get("{}/{}/issues".format(self.projects_url, project_id), params=data, headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getprojectissue(self, project_id, issue_id): """Get an specific issue id from a project :param project_id: project id :param issue_id: issue id :return: the issue """ request = requests.get("{}/{}/issues/{}".format(self.projects_url, project_id, issue_id), headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def createissue(self, project_id, title, **kwargs): """Create a new issue :param project_id: project id :param title: title of the issue :return: dict with the issue created """ data = {"id": id, "title": title} if kwargs: data.update(kwargs) request = requests.post("{}/{}/issues".format(self.projects_url, project_id), headers=self.headers, data=data, verify=self.verify_ssl) if request.status_code == 201: return json.loads(request.content.decode("utf-8")) else: return False def editissue(self, project_id, issue_id, **kwargs): """Edit an existing issue data :param project_id: project id :param issue_id: issue id :return: true if success """ data = {"id": project_id, "issue_id": issue_id} if kwargs: data.update(kwargs) request = requests.put("{}/{}/issues/{}".format(self.projects_url, project_id, issue_id), headers=self.headers, data=data, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getmilestones(self, project_id, page=1, per_page=20): """Get the milestones for a project :param project_id: project id :return: the milestones """ data = {'page': page, 'per_page': per_page} request = requests.get("{}/{}/milestones".format(self.projects_url, project_id), params=data, headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getmilestone(self, project_id, milestone_id): """Get an specific milestone :param project_id: project id :param milestone_id: milestone id :return: dict with the new milestone """ request = requests.get("{}/{}/milestones/{}".format(self.projects_url, project_id, milestone_id), headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def createmilestone(self, project_id, title, **kwargs): """Create a new milestone :param project_id: project id :param title: title :param description: description :param due_date: due date :param sudo: do the request as another user :return: dict of the new issue """ data = {"id": project_id, "title": title} if kwargs: data.update(kwargs) request = requests.post("{}/{}/milestones".format(self.projects_url, project_id), headers=self.headers, data=data, verify=self.verify_ssl) if request.status_code == 201: return json.loads(request.content.decode("utf-8")) else: return False def editmilestone(self, project_id, milestone_id, **kwargs): """Edit an existing milestone :param project_id: project id :param milestone_id: milestone id :param title: title :param description: description :param due_date: due date :param state_event: state :param sudo: do the request as another user :return: dict with the modified milestone """ data = {"id": project_id, "milestone_id": milestone_id} if kwargs: data.update(kwargs) request = requests.put("{}/{}/milestones/{}".format(self.projects_url, project_id, milestone_id), headers=self.headers, data=data, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getdeploykeys(self, project_id, page=1, per_page=20): """Get a list of a project's deploy keys. :param project_id: project id :return: the keys in a dictionary if success, false if not """ data = {'page': page, 'per_page': per_page} request = requests.get("{}/{}/keys".format(self.projects_url, project_id), params=data, headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getdeploykey(self, project_id, key_id): """Get a single key. :param project_id: project id :param key_id: key id :return: the key in a dict if success, false if not """ request = requests.get("{}/{}/keys/{}".format(self.projects_url, project_id, key_id), headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def adddeploykey(self, project_id, title, key): """Creates a new deploy key for a project. :param project_id: project id :param title: title of the key :param key: the key itself :return: true if sucess, false if not """ data = {"id": project_id, "title": title, "key": key} request = requests.post("{}/{}/keys".format(self.projects_url, project_id), headers=self.headers, data=data, verify=self.verify_ssl) if request.status_code == 201: return True else: return False def deletedeploykey(self, project_id, key_id): """Delete a deploy key from a project :param project_id: project id :param key_id: key id to delete :return: true if success, false if not """ request = requests.delete("{}/{}/keys/{}".format(self.projects_url, project_id, key_id), headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return True else: return False def creategroup(self, name, path): """Creates a new group :param name: The name of the group :param path: The path for the group :return: dict of the new group """ request = requests.post(self.groups_url, data={'name': name, 'path': path}, headers=self.headers, verify=self.verify_ssl) if request.status_code == 201: return json.loads(request.content.decode("utf-8")) else: msg = json.loads(request.content.decode("utf-8"))['message'] return exceptions.HttpError(msg) def getgroups(self, group_id=None, page=1, per_page=20): """Retrieve group information :param group_id: Specify a group. Otherwise, all groups are returned :return: list of groups """ data = {'page': page, 'per_page': per_page} request = requests.get("{}/{}".format(self.groups_url, group_id if group_id else ""), params=data, headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def moveproject(self, group_id, project_id): """Move a given project into a given group :param group_id: ID of the destination group :param project_id: ID of the project to be moved :return: dict of the updated project """ request = requests.post("{}/{}/projects/{}".format(self.groups_url, group_id, project_id), headers=self.headers, verify=self.verify_ssl) if request.status_code == 201: return json.loads(request.content.decode("utf-8")) else: return False def getmergerequests(self, project_id, page=1, per_page=20, state=None): """Get all the merge requests for a project. :param project_id: ID of the project to retrieve merge requests for :param state: Passes merge request state to filter them by it :return: list with all the merge requests """ data = {'page': page, 'per_page': per_page, 'state': state} request = requests.get('{}/{}/merge_requests'.format(self.projects_url, project_id), params=data, headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getmergerequest(self, project_id, mergerequest_id): """Get information about a specific merge request. :param project_id: ID of the project :param mergerequest_id: ID of the merge request :return: dict of the merge request """ request = requests.get('{}/{}/merge_request/{}'.format(self.projects_url, project_id, mergerequest_id), headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getmergerequestcomments(self, project_id, mergerequest_id, page=1, per_page=20): """Get comments of a merge request. :param project_id: ID of the project :param mergerequest_id: ID of the merge request :return: list of the comments """ data = {'page': page, 'per_page': per_page} request = requests.get('{}/{}/merge_request/{}/comments'.format(self.projects_url, project_id, mergerequest_id), params=data, headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def createmergerequest(self, project_id, sourcebranch, targetbranch, title, target_project_id=None, assignee_id=None): """Create a new merge request. :param project_id: ID of the project originating the merge request :param sourcebranch: name of the branch to merge from :param targetbranch: name of the branch to merge to :param title: Title of the merge request :param assignee_id: Assignee user ID :return: dict of the new merge request """ data = {'source_branch': sourcebranch, 'target_branch': targetbranch, 'title': title, 'assignee_id': assignee_id, 'target_project_id': target_project_id} request = requests.post('{}/{}/merge_requests'.format(self.projects_url, project_id), data=data, headers=self.headers, verify=self.verify_ssl) if request.status_code == 201: return json.loads(request.content.decode("utf-8")) else: return False def updatemergerequest(self, project_id, mergerequest_id, **kwargs): """Update an existing merge request. :param project_id: ID of the project originating the merge request :param mergerequest_id: ID of the merge request to update :param sourcebranch: name of the branch to merge from :param targetbranch: name of the branch to merge to :param title: Title of the merge request :param assignee_id: Assignee user ID :param closed: MR status. True = closed :return: dict of the modified merge request """ data = {} if kwargs: data.update(kwargs) request = requests.put('{}/{}/merge_request/{}'.format(self.projects_url, project_id, mergerequest_id), data=data, headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def acceptmergerequest(self, project_id, mergerequest_id, merge_commit_message=None): """Update an existing merge request. :param project_id: ID of the project originating the merge request :param mergerequest_id: ID of the merge request to accept :param merge_commit_message: Custom merge commit message :return: dict of the modified merge request """ data = {'merge_commit_message': merge_commit_message} request = requests.put('{}/{}/merge_request/{}/merge'.format(self.projects_url, project_id, mergerequest_id), data=data, headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def addcommenttomergerequest(self, project_id, mergerequest_id, note): """Add a comment to a merge request. :param project_id: ID of the project originating the merge request :param mergerequest_id: ID of the merge request to comment on :param note: Text of comment :return: True if success """ request = requests.post( '{}/{}/merge_request/{}/comments'.format(self.projects_url, project_id, mergerequest_id), data={'note': note}, headers=self.headers, verify=self.verify_ssl) if request.status_code == 201: return True else: return False def getsnippets(self, project_id, page=1, per_page=20): """Get all the snippets of the project identified by project_id :param project_id: project id to get the snippets from :return: list of dictionaries """ data = {'page': page, 'per_page': per_page} request = requests.get("{}/{}/snippets".format(self.projects_url, project_id), params=data, verify=self.verify_ssl, headers=self.headers) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getsnippet(self, project_id, snippet_id): """Get one snippet from a project :param project_id: project id to get the snippet from :param snippet_id: snippet id :return: dictionary """ request = requests.get("{}/{}/snippets/{}".format(self.projects_url, project_id, snippet_id), verify=self.verify_ssl, headers=self.headers) if request.status_code == 200: return json.loads(request.content.decode('utf-8')) else: return False def createsnippet(self, project_id, title, file_name, code, lifetime=""): """Creates an snippet :param project_id: project id to create the snippet under :param title: title of the snippet :param file_name: filename for the snippet :param code: content of the snippet :param lifetime: expiration date :return: True if correct, false if failed """ data = {"id": project_id, "title": title, "file_name": file_name, "code": code} if lifetime != "": data["lifetime"] = lifetime request = requests.post("{}/{}/snippets".format(self.projects_url, project_id), data=data, verify=self.verify_ssl, headers=self.headers) if request.status_code == 201: return json.loads(request.content.decode("utf-8")) else: return False def getsnippetcontent(self, project_id, snippet_id): """Get raw content of a given snippet :param project_id: project_id for the snippet :param snippet_id: snippet id :return: the content of the snippet """ request = requests.get("{}/{}/snippets/{}/raw".format(self.projects_url, project_id, snippet_id), verify=self.verify_ssl, headers=self.headers) if request.status_code == 200: return request.content.decode("utf-8") else: return False def deletesnippet(self, project_id, snippet_id): """Deletes a given snippet :param project_id: project_id :param snippet_id: snippet id :return: True if success """ request = requests.delete("{}/{}/snippets/{}".format(self.projects_url, project_id, snippet_id), headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return True else: return False def getrepositories(self, project_id, page=1, per_page=20): """Gets all repositories for a project id :param project_id: project id :return: list of repos """ data = {'page': page, 'per_page': per_page} request = requests.get("{}/{}/repository/branches".format(self.projects_url, project_id), params=data, verify=self.verify_ssl, headers=self.headers) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getrepositorybranch(self, project_id, branch): """Get a single project repository branch. :param project_id: project id :param branch: branch :return: dict of the branch """ request = requests.get("{}/{}/repository/branches/{}".format(self.projects_url, project_id, branch), verify=self.verify_ssl, headers=self.headers) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) elif request.status_code == 404: if json.loads(request.content.decode("utf-8"))['message'] == "404 Branch does not exist Not Found": # In the future we should raise an exception here return False else: return False def protectrepositorybranch(self, project_id, branch): """Protects a single project repository branch. This is an idempotent function, protecting an already protected repository branch still returns a 200 OK status code. :param project_id: project id :param branch: branch to protech :return: dict with the branch """ request = requests.put("{}/{}/repository/branches/{}/protect".format(self.projects_url, project_id, branch), headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def unprotectrepositorybranch(self, project_id, branch): """Unprotects a single project repository branch. This is an idempotent function, unprotecting an already unprotected repository branch still returns a 200 OK status code. :param project_id: project id :param branch: branch to unprotect :return: dict with the branch """ request = requests.put("{}/{}/repository/branches/{}/unprotect".format(self.projects_url, project_id, branch), headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return def getrepositorytags(self, project_id, page=1, per_page=20): """Get a list of repository tags from a project, sorted by name in reverse alphabetical order. :param project_id: project id :return: list with all the tags """ data = {'page': page, 'per_page': per_page} request = requests.get("{}/{}/repository/tags".format(self.projects_url, project_id), params=data, verify=self.verify_ssl, headers=self.headers) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def createrepositorytag(self, project_id, tag_name, ref, message=None): """Creates new tag in the repository that points to the supplied ref :param project_id: project id :param tag_name: tag :param ref: sha1 of the commit or branch to tag :param message: message :return: dict """ data = {"id": project_id, "tag_name": tag_name, "ref": ref, "message": message} request = requests.post("{}/{}/repository/tags".format(self.projects_url, project_id), data=data, verify=self.verify_ssl, headers=self.headers) if request.status_code == 201: return json.loads(request.content.decode("utf-8")) else: return False def getrepositorycommits(self, project_id, ref_name=None, page=1, per_page=20): """Get a list of repository commits in a project. :param project_id: The ID of a project :param ref_name: The name of a repository branch or tag or if not given the default branch :return: list of commits """ data = {'page': page, 'per_page': per_page} if ref_name is not None: data.update({"ref_name": ref_name}) request = requests.get("{}/{}/repository/commits".format(self.projects_url, project_id), verify=self.verify_ssl, params=data, headers=self.headers) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getrepositorycommit(self, project_id, sha1): """Get a specific commit identified by the commit hash or name of a branch or tag. :param project_id: The ID of a project :param sha1: The commit hash or name of a repository branch or tag :return: dic tof commit """ request = requests.get("{}/{}/repository/commits/{}".format(self.projects_url, project_id, sha1), verify=self.verify_ssl, headers=self.headers) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getrepositorycommitdiff(self, project_id, sha1): """Get the diff of a commit in a project :param project_id: The ID of a project :param sha1: The name of a repository branch or tag or if not given the default branch :return: dict with the diff """ request = requests.get("{}/{}/repository/commits/{}/diff".format(self.projects_url, project_id, sha1), verify=self.verify_ssl, headers=self.headers) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getrepositorytree(self, project_id, **kwargs): """Get a list of repository files and directories in a project. :param project_id: The ID of a project :param path: The path inside repository. Used to get contend of subdirectories :param ref_name: The name of a repository branch or tag or if not given the default branch :return: dcit with the tree """ data = {} if kwargs: data.update(kwargs) request = requests.get("{}/{}/repository/tree".format(self.projects_url, project_id), params=data, verify=self.verify_ssl, headers=self.headers) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getrawfile(self, project_id, sha1, filepath): """Get the raw file contents for a file by commit SHA and path. :param project_id: The ID of a project :param sha1: The commit or branch name :param filepath: The path the file :return: raw file contents """ data = {"filepath": filepath} request = requests.get("{}/{}/repository/blobs/{}".format(self.projects_url, project_id, sha1), params=data, verify=self.verify_ssl, headers=self.headers) if request.status_code == 200: return request.content.decode("utf-8") else: return False def getrawblob(self, project_id, sha1): """Get the raw file contents for a blob by blob SHA. :param project_id: The ID of a project :param sha1: the commit sha :return: raw blob """ request = requests.get("{}/{}/repository/raw_blobs/{}".format(self.projects_url, project_id, sha1), verify=self.verify_ssl, headers=self.headers) if request.status_code == 200: return request.content.decode("utf-8") else: return False def getcontributors(self, project_id, page=1, per_page=20): """Get repository contributors list :param: project_id: The ID of a project :return: list of contributors """ data = {'page': page, 'per_page': per_page} request = requests.get("{}/{}/repository/contributors".format(self.projects_url, project_id), params=data, verify=self.verify_ssl, headers=self.headers) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def compare_branches_tags_commits(self, project_id, from_id, to_id): """Compare branches, tags or commits :param project_id: The ID of a project :param from_id: the commit sha or branch name :param to_id: the commit sha or branch name :return: commit list and diff between two branches tags or commits provided by name """ data = {"from": from_id, "to": to_id} request = requests.get("{}/{}/repository/compare".format(self.projects_url, project_id), params=data, verify=self.verify_ssl, headers=self.headers) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def searchproject(self, search, page=1, per_page=20): """Search for projects by name which are accessible to the authenticated user :param search: query to search for :return: list of results """ data = {'page': page, 'per_page': per_page} request = requests.get("{}/{}".format(self.search_url, search), params=data, verify=self.verify_ssl, headers=self.headers) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getfilearchive(self, project_id, filepath=""): """Get an archive of the repository :param project_id: project id :param filepath: path to save the file to :return: True if the file was saved to the filepath """ request = requests.get("{}/{}/repository/archive".format(self.projects_url, project_id), verify=self.verify_ssl, headers=self.headers) if request.status_code == 200: if filepath == "": filepath = request.headers['content-disposition'].split(";")[1].split("=")[1].strip('"') with open(filepath, "wb") as filesave: filesave.write(request.content) # TODO: Catch oserror exceptions as no permissions and such # TODO: change the filepath to a path and keep always the filename? return True else: msg = json.loads(request.content.decode("utf-8"))['message'] raise exceptions.HttpError(msg) def deletegroup(self, group_id): """Deletes an group by ID :param group_id: id of the group to delete :return: True if it deleted, False if it couldn't. False could happen for several reasons, but there isn't a good way of differentiating them """ request = requests.delete("{}/{}".format(self.groups_url, group_id), headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return True else: return False def getgroupmembers(self, group_id, page=1, per_page=20): """Lists the members of a given group id :param group_id: the group id :param page: which page to return (default is 1) :param per_page: number of items to return per page (default is 20) :return: the group's members """ data = {'page': page, 'per_page': per_page} request = requests.get("{}/{}/members".format(self.groups_url, group_id), params=data, headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def addgroupmember(self, group_id, user_id, access_level): """Adds a project member to a project :param user_id: user id :param access_level: access level, see gitlab help to know more :return: True if success """ if not isinstance(access_level, int): if access_level.lower() == "owner": access_level = 50 elif access_level.lower() == "master": access_level = 40 elif access_level.lower() == "developer": access_level = 30 elif access_level.lower() == "reporter": access_level = 20 elif access_level.lower() == "guest": access_level = 10 else: return False data = {"id": group_id, "user_id": user_id, "access_level": access_level} request = requests.post("{}/{}/members".format(self.groups_url, group_id), headers=self.headers, data=data, verify=self.verify_ssl) if request.status_code == 201: return True else: return False def deletegroupmember(self, group_id, user_id): """Delete a group member :param group_id: group id to remove the member from :param user_id: user id :return: always true """ request = requests.delete("{}/{}/members/{}".format(self.groups_url, group_id, user_id), headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return True # It always returns true def getissuewallnotes(self, project_id, issue_id, page=1, per_page=20): """Get the notes from the wall of a issue """ data = {'page': page, 'per_page': per_page} request = requests.get("{}/{}/issues/{}/notes".format(self.projects_url, project_id, issue_id), params=data, verify=self.verify_ssl, headers=self.headers) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getissuewallnote(self, project_id, issue_id, note_id): """Get one note from the wall of the issue """ request = requests.get("{}/{}/issues/{}/notes/{}".format(self.projects_url, project_id, issue_id, note_id), verify=self.verify_ssl, headers=self.headers) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def createissuewallnote(self, project_id, issue_id, content): """Create a new note """ data = {"body": content} request = requests.post("{}/{}/issues/{}/notes".format(self.projects_url, project_id, issue_id), verify=self.verify_ssl, headers=self.headers, data=data) if request.status_code == 201: return json.loads(request.content.decode("utf-8")) else: return False def getsnippetwallnotes(self, project_id, snippet_id, page=1, per_page=20): """Get the notes from the wall of a snippet """ data = {'page': page, 'per_page': per_page} request = requests.get("{}/{}/snippets/{}/notes".format(self.projects_url, project_id, snippet_id), params=data, verify=self.verify_ssl, headers=self.headers) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getsnippetwallnote(self, project_id, snippet_id, note_id): """Get one note from the wall of the snippet """ request = requests.get("{}/{}/snippets/{}/notes/{}".format(self.projects_url, project_id, snippet_id, note_id), verify=self.verify_ssl, headers=self.headers) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def createsnippetewallnote(self, project_id, snippet_id, content): """Create a new note """ data = {"body": content} request = requests.post("{}/{}/snippets/{}/notes".format(self.projects_url, project_id, snippet_id), verify=self.verify_ssl, headers=self.headers, data=data) if request.status_code == 201: return json.loads(request.content.decode("utf-8")) else: return False def getmergerequestwallnotes(self, project_id, merge_request_id, page=1, per_page=20): """Get the notes from the wall of a merge request """ data = {'page': page, 'per_page': per_page} request = requests.get("{}/{}/merge_requests/{}/notes".format(self.projects_url, project_id, merge_request_id), params=data, verify=self.verify_ssl, headers=self.headers) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def getmergerequestwallnote(self, project_id, merge_request_id, note_id): """Get one note from the wall of the merge request """ request = requests.get("{}/{}/merge_requests/{}/notes/{}".format(self.projects_url, project_id, merge_request_id, note_id), verify=self.verify_ssl, headers=self.headers) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def createmergerequestewallnote(self, project_id, merge_request_id, content): """Create a new note """ data = {"body": content} request = requests.post("{}/{}/merge_requests/{}/notes".format(self.projects_url, project_id, merge_request_id), verify=self.verify_ssl, headers=self.headers, data=data) if request.status_code == 201: return json.loads(request.content.decode("utf-8")) else: return False def createfile(self, project_id, file_path, branch_name, content, commit_message): """Creates a new file in the repository :param project_id: project id :param file_path: Full path to new file. Ex. lib/class.rb :param branch_name: The name of branch :param content: File content :param commit_message: Commit message :return: true if success, false if not """ data = {"file_path": file_path, "branch_name": branch_name, "content": content, "commit_message": commit_message} request = requests.post("{}/{}/repository/files".format(self.projects_url, project_id), verify=self.verify_ssl, headers=self.headers, data=data) if request.status_code == 201: return True else: return False def updatefile(self, project_id, file_path, branch_name, content, commit_message): """Updates an existing file in the repository :param project_id: project id :param file_path: Full path to new file. Ex. lib/class.rb :param branch_name: The name of branch :param content: File content :param commit_message: Commit message :return: true if success, false if not """ data = {"file_path": file_path, "branch_name": branch_name, "content": content, "commit_message": commit_message} request = requests.put("{}/{}/repository/files".format(self.projects_url, project_id), headers=self.headers, data=data, verify=self.verify_ssl) if request.status_code == 200: return True else: return False def getfile(self, project_id, file_path, ref): """Allows you to receive information about file in repository like name, size, content. Note that file content is Base64 encoded. :param project_id: project_id :param file_path: Full path to file. Ex. lib/class.rb :param ref: The name of branch, tag or commit :return: """ data = {"file_path": file_path, "ref": ref} request = requests.get("{}/{}/repository/files".format(self.projects_url, project_id), headers=self.headers, data=data, verify=self.verify_ssl) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def deletefile(self, project_id, file_path, branch_name, commit_message): """Deletes existing file in the repository :param project_id: project id :param file_path: Full path to new file. Ex. lib/class.rb :param branch_name: The name of branch :param commit_message: Commit message :return: true if success, false if not """ data = {"file_path": file_path, "branch_name": branch_name, "commit_message": commit_message} request = requests.delete("{}/{}/repository/files".format(self.projects_url, project_id), headers=self.headers, data=data, verify=self.verify_ssl) if request.status_code == 200: return True else: return False def setgitlabciservice(self, project_id, token, project_url): """Set GitLab CI service for project :param project_id: project id :param token: CI project token :param project_url: CI project url :return: true if success, false if not """ data = {"token": token, "project_url": project_url} request = requests.put("{}/{}/services/gitlab-ci".format(self.projects_url, project_id), verify=self.verify_ssl, headers=self.headers, data=data) if request.status_code == 200: return True else: return False def deletegitlabciservice(self, project_id, token, project_url): """Delete GitLab CI service settings :return: true if success, false if not """ request = requests.delete("{}/{}/services/gitlab-ci".format(self.projects_url, project_id), headers=self.headers, verify=self.verify_ssl) if request.status_code == 200: return True else: return False def getlabels(self, project_id, page=1, per_page=20): """Get all labels for given project. :param project_id: The ID of a project :return: list of the labels """ data = {'page': page, 'per_page': per_page} request = requests.get("{}/{}/labels".format(self.projects_url, project_id), params=data, verify=self.verify_ssl, headers=self.headers) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False def createlabel(self, project_id, name, color): """Creates a new label for given repository with given name and color. :param project_id: The ID of a project :param name: The name of the label :param color: Color of the label given in 6-digit hex notation with leading '#' sign (e.g. #FFAABB) :return: """ data = {"name": name, "color": color} request = requests.post("{}/{}/labels".format(self.projects_url, project_id), data=data, verify=self.verify_ssl, headers=self.headers) if request.status_code == 201: return json.loads(request.content.decode("utf-8")) else: return False def deletelabel(self, project_id, name): """Deletes a label given by its name. :param project_id: The ID of a project :param name: The name of the label :return: True if succeed """ data = {"name": name} request = requests.delete("{}/{}/labels".format(self.projects_url, project_id), data=data, verify=self.verify_ssl, headers=self.headers) if request.status_code == 200: return True else: return False def editlabel(self, project_id, name, new_name=None, color=None): """Updates an existing label with new name or now color. At least one parameter is required, to update the label. :param project_id: The ID of a project :param name: The name of the label :return: True if succeed """ data = {"name": name, "new_name": new_name, "color": color} request = requests.put("{}/{}/labels".format(self.projects_url, project_id), data=data, verify=self.verify_ssl, headers=self.headers) if request.status_code == 200: return json.loads(request.content.decode("utf-8")) else: return False pyapi-gitlab-7.5.0/gitlab/exceptions.py000066400000000000000000000001201244107656600201060ustar00rootroot00000000000000class HttpError(Exception): """ An http error occurred """ pass pyapi-gitlab-7.5.0/gitlab_tests/000077500000000000000000000000001244107656600166045ustar00rootroot00000000000000pyapi-gitlab-7.5.0/gitlab_tests/__init__.py000066400000000000000000000000001244107656600207030ustar00rootroot00000000000000pyapi-gitlab-7.5.0/gitlab_tests/pyapi-gitlab_test.py000066400000000000000000000472401244107656600226060ustar00rootroot00000000000000""" pyapi-gitlab tests """ import unittest import gitlab import os import time import random import string try: from Crypto.PublicKey import RSA ssh_test = True except ImportError: ssh_test = False user = os.environ.get('gitlab_user', 'root') password = os.environ.get('gitlab_password', '5iveL!fe') host = os.environ.get('gitlab_host', 'http://192.168.1.100') class GitlabTest(unittest.TestCase): @classmethod def setUpClass(cls): cls.git = gitlab.Gitlab(host=host) cls.git.login(user=user, password=password) name = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(8)) cls.project = cls.git.createproject(name=name, visibility_level="private", import_url="https://github.com/Itxaka/pyapi-gitlab.git") # wait a bit for the project to be fully imported time.sleep(20) cls.project_id = cls.project['id'] cls.user_id = cls.git.currentuser()['id'] @classmethod def tearDownClass(cls): cls.git.deleteproject(cls.project_id) def test_user(self): assert isinstance(self.git.createuser(name="test", username="test", password="test1234", email="test@test.com", skype="this", linkedin="that"), dict) # get all users assert isinstance(self.git.getusers(), list) # compatible with 2.6 assert isinstance(self.git.currentuser(), dict) user = self.git.getusers(search="test")[0] self.assertTrue(self.git.deleteuser(user["id"])) # check can_create_user user = self.git.createuser("random", "random", "random1234", "random@random.org", can_create_group="false") self.assertFalse(self.git.getuser(user['id'])['can_create_group']) self.git.deleteuser(user['id']) user = self.git.createuser("random", "random", "random1234", "random@random.org", can_create_group="true") self.assertTrue(self.git.getuser(user['id'])['can_create_group']) assert isinstance(self.git.edituser(user['id'], can_create_group="false"), dict) # Check that indeed the user details were changed self.assertFalse(self.git.getuser(user['id'])['can_create_group']) self.git.deleteuser(user['id']) # get X pages assert isinstance(self.git.getusers(page=2), list) # compatible with 2.6 assert isinstance(self.git.getusers(per_page=4), list) # compatible with 2.6 self.assertEqual(self.git.getusers(page=800), list("")) # check against empty list self.assertTrue(self.git.getusers(per_page=43)) # check against false def test_project(self): # test project assert isinstance(self.git.getprojects(), list) assert isinstance(self.git.getprojects(page=5), list) assert isinstance(self.git.getprojects(per_page=7), list) assert isinstance(self.git.getproject(self.project_id), dict) self.assertFalse(self.git.getproject("wrong")) # test getprojectsall assert isinstance(self.git.getprojectsall(), list) assert isinstance(self.git.getprojectsall(page=5), list) assert isinstance(self.git.getprojectsall(per_page=7), list) # test getownprojects assert isinstance(self.git.getprojectsowned(), list) assert isinstance(self.git.getprojectsowned(page=5), list) assert isinstance(self.git.getprojectsowned(per_page=7), list) # test events assert isinstance(self.git.getprojectevents(self.project_id), list) assert isinstance(self.git.getprojectevents(self.project_id, page=3), list) assert isinstance(self.git.getprojectevents(self.project_id, per_page=4), list) # add-remove project members self.assertTrue(self.git.addprojectmember(self.project_id, user_id=self.user_id, access_level="reporter")) assert isinstance(self.git.getprojectmembers(self.project_id), list) self.assertTrue(self.git.editprojectmember(self.project_id, user_id=self.user_id, access_level="master")) self.assertTrue(self.git.deleteprojectmember(self.project_id, user_id=1)) # Hooks testing self.assertTrue(self.git.addprojecthook(self.project_id, "http://web.com")) assert isinstance(self.git.getprojecthooks(self.project_id), list) assert isinstance(self.git.getprojecthook(self.project_id, self.git.getprojecthooks(self.project_id)[0]['id']), dict) self.assertTrue(self.git.editprojecthook(self.project_id, self.git.getprojecthooks(self.project_id)[0]['id'], "http://another.com")) self.assertTrue(self.git.deleteprojecthook(self.project_id, self.git.getprojecthooks(self.project_id)[0]['id'])) # Forks testing name = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(8)) newproject = self.git.createproject(name) # set it as forker from the main project self.git.createforkrelation(newproject["id"], self.project_id) newproject = self.git.getproject(newproject["id"]) self.assertIn("forked_from_project", newproject) # remove the fork relation self.assertTrue(self.git.removeforkrelation(newproject["id"])) newproject = self.git.getproject(newproject["id"]) with self.assertRaises(KeyError) as raises: _ = newproject["forked_from_project"] # test moveproject for group in self.git.getgroups(): self.git.deletegroup(group["id"]) group = self.git.creategroup("movegroup", "movegroup") assert isinstance(group, dict) assert isinstance(self.git.moveproject(group["id"], newproject["id"]), dict) project = self.git.getproject(newproject["id"]) self.assertEqual("movegroup", project["namespace"]["name"]) # Clean up the newgroup self.git.deleteproject(newproject["id"]) # Create an actual fork of the main project self.git.createfork(self.project_id) def test_deploykeys(self): keys = self.git.getdeploykeys(self.project_id) assert isinstance(keys, list) self.assertEqual(len(keys), 0) if ssh_test: name = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(8)) rsa_key = RSA.generate(1024) self.assertTrue(self.git.adddeploykey(project_id=self.project_id, title=name, key=str(rsa_key.publickey().exportKey(format="OpenSSH")))) keys = self.git.getdeploykeys(self.project_id) self.assertGreater(len(keys), 0) key = keys[0] assert isinstance(self.git.getdeploykey(self.project_id, key["id"]), dict) self.assertTrue(self.git.deletedeploykey(self.project_id, key["id"])) keys = self.git.getdeploykeys(self.project_id) self.assertEqual(len(keys), 0) def test_branch(self): sha1 = self.git.getrepositorycommits(project_id=self.project_id)[0]["id"] assert isinstance(self.git.createbranch(self.project_id, branch="deleteme", ref=sha1), dict) self.assertTrue(self.git.deletebranch(self.project_id, branch="deleteme")) assert isinstance(self.git.getbranches(self.project_id), list) assert isinstance(self.git.getbranch(self.project_id, branch="develop"), dict) self.assertTrue(self.git.protectbranch(self.project_id, branch="develop")) self.assertTrue(self.git.unprotectbranch(self.project_id, branch="develop")) def test_sshkeys(self): assert isinstance(self.git.getsshkeys(), list) self.assertEquals(len(self.git.getsshkeys()), 0) # not working due a bug? in pycrypto: https://github.com/dlitz/pycrypto/issues/99 if ssh_test: name = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(8)) rsa_key = RSA.generate(1024) self.assertTrue(self.git.addsshkey(title=name, key=str(rsa_key.publickey().exportKey(format="OpenSSH")))) self.assertGreater(self.git.getsshkeys(), 0) keys = self.git.getsshkeys() assert isinstance(keys, list) key = self.git.getsshkeys()[0] assert isinstance(key, dict) self.assertTrue(self.git.deletesshkey(key["id"])) name = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(8)) rsa_key = RSA.generate(1024) self.assertTrue(self.git.addsshkeyuser(self.user_id, title=name, key=str(rsa_key.publickey().exportKey(format="OpenSSH")))) self.assertGreater(self.git.getsshkeys(), 0) keys = self.git.getsshkeys() assert isinstance(keys, list) key = self.git.getsshkeys()[0] assert isinstance(key, dict) self.assertTrue(self.git.deletesshkey(key["id"])) def test_snippets(self): assert isinstance(self.git.createsnippet(self.project_id, "test", "test", "codeee"), dict) assert isinstance(self.git.getsnippets(self.project_id), list) snippet = self.git.getsnippets(self.project_id)[0] assert isinstance(self.git.getsnippet(self.project_id, snippet["id"]), dict) self.assertTrue(self.git.deletesnippet(self.project_id, snippet["id"])) def test_repositories(self): assert isinstance(self.git.getrepositories(self.project_id), list) assert isinstance(self.git.getrepositorybranch(self.project_id, "develop"), dict) assert isinstance(self.git.protectrepositorybranch(self.project_id, "develop"), dict) assert isinstance(self.git.unprotectrepositorybranch(self.project_id, "develop"), dict) assert isinstance(self.git.getrepositorycommits(self.project_id), list) assert isinstance(self.git.getrepositorycommits(self.project_id, page=1), list) assert isinstance(self.git.getrepositorycommits(self.project_id, per_page=7), list) commit = self.git.getrepositorycommits(self.project_id)[0] # tags tags = self.git.getrepositorytags(self.project_id) assert isinstance(tags, list) tag = self.git.createrepositorytag(self.project_id, "test_tag", commit["id"], "test_tag_message") assert isinstance(tag, dict) self.assertEqual(tag["name"], "test_tag") assert isinstance(self.git.getrepositorycommit(self.project_id, commit["id"]), dict) assert isinstance(self.git.getrepositorycommitdiff(self.project_id, commit["id"]), list) assert isinstance(self.git.getrepositorytree(self.project_id), list) assert isinstance(self.git.getrepositorytree(self.project_id, path="docs"), list) assert isinstance(self.git.getrepositorytree(self.project_id, ref_name="develop"), list) assert isinstance(str(self.git.getrawblob(self.project_id, commit['id'])), str) assert isinstance(str(self.git.getrawfile(self.project_id, commit['id'], "setup.py")), str) commit = self.git.getrepositorycommits(self.project_id) assert isinstance(self.git.compare_branches_tags_commits(self.project_id, from_id=commit[1]["id"], to_id=commit[0]["id"]), dict) self.assertTrue(self.git.createfile(self.project_id, "test.file", "develop", "00000000", "testfile0")) firstfile = self.git.getfile(self.project_id, "test.file", "develop") self.assertTrue(self.git.updatefile(self.project_id, "test.file", "develop", "11111111", "testfile1")) secondfile = self.git.getfile(self.project_id, "test.file", "develop") self.assertNotEqual(firstfile["commit_id"], secondfile["commit_id"]) self.assertNotEqual(firstfile["content"], secondfile["content"]) self.assertTrue(self.git.deletefile(self.project_id, "test.file", "develop", "remove_testfile")) assert isinstance(self.git.getcontributors(self.project_id), list) def test_search(self): self.assertGreater(len(self.git.searchproject(self.project['name'])), 0) assert isinstance(self.git.searchproject(self.project['name']), list) def test_filearchive(self): # test it works self.assertTrue(self.git.getfilearchive(self.project_id, self.project["name"] + ".tar.gz")) # test for failure self.failUnlessRaises(gitlab.exceptions.HttpError, self.git.getfilearchive, 999999) def test_group(self): for group in self.git.getgroups(): self.git.deletegroup(group["id"]) assert isinstance(self.git.creategroup("test_group", "test_group"), dict) assert isinstance(self.git.getgroups(), list) group = self.git.getgroups()[0] assert isinstance(self.git.getgroupmembers(group["id"]), list) self.assertEqual(len(self.git.getgroupmembers(group["id"])), 0) self.assertTrue(self.git.addgroupmember(group["id"], self.user_id, "master")) assert isinstance(self.git.getgroupmembers(group["id"]), list) self.assertGreater(len(self.git.getgroupmembers(group["id"])), 0) self.assertTrue(self.git.deletegroupmember(group["id"], self.user_id)) self.assertFalse(self.git.addgroupmember(group["id"], self.user_id, "nonexistant")) self.assertTrue(self.git.deletegroup(group_id=group["id"])) def test_issues(self): issue = self.git.createissue(self.project_id, title="Test_issue", description="blaaaaa") assert isinstance(issue, dict) self.assertEqual(issue["title"], "Test_issue") issue = self.git.editissue(self.project_id, issue["id"], title="Changed") assert isinstance(issue, dict) self.assertEqual(issue["title"], "Changed") issue = self.git.editissue(self.project_id, issue["id"], state_event="close") self.assertEqual(issue["state"], "closed") self.assertGreater(len(self.git.getprojectissues(self.project_id)), 0) assert isinstance(self.git.getprojectissue(self.project_id, issue["id"]), dict) self.assertGreater(len(self.git.getissues()), 0) def test_system_hooks(self): # clean up before for hook in self.git.getsystemhooks(): self.git.deletesystemhook(hook["id"]) self.assertTrue(self.git.addsystemhook("http://github.com")) self.assertEqual(len(self.git.getsystemhooks()), 1) hook = self.git.getsystemhooks()[0] assert isinstance(self.git.testsystemhook(hook["id"]), list) self.assertTrue(self.git.deletesystemhook(hook["id"])) self.assertEqual(len(self.git.getsystemhooks()), 0) def test_milestones(self): milestone = self.git.createmilestone(self.project_id, title="test") assert isinstance(milestone, dict) self.assertGreater(len(self.git.getmilestones(self.project_id)), 0) assert isinstance(self.git.getmilestone(self.project_id, milestone["id"]), dict) self.assertEqual(milestone["title"], "test") milestone = self.git.editmilestone(self.project_id, milestone["id"], title="test2") self.assertEqual(milestone["title"], "test2") def test_merge(self): # prepare for the merge commit = self.git.getrepositorycommits(self.project_id)[5] branch = self.git.createbranch(self.project_id, "mergebranch", commit["id"]) merge = self.git.createmergerequest(self.project_id, "develop", "mergebranch", "testmerge") assert isinstance(self.git.getmergerequests(self.project_id), list) merge_request = self.git.getmergerequest(self.project_id, merge["id"]) assert isinstance(merge_request, dict) self.assertEqual(merge_request["title"], "testmerge") self.assertEqual(len(self.git.getmergerequestcomments(self.project_id, merge["id"])), 0) self.assertTrue(self.git.addcommenttomergerequest(self.project_id, merge["id"], "Hello")) comments = self.git.getmergerequestcomments(self.project_id, merge["id"]) self.assertEqual(comments[0]["note"], "Hello") self.assertTrue(self.git.updatemergerequest(self.project_id, merge["id"], title="testmerge2")) merge_request = self.git.getmergerequest(self.project_id, merge["id"]) self.assertEqual(merge_request["title"], "testmerge2") self.assertEqual(self.git.getmergerequest(self.project_id, merge["id"])["state"], "opened") self.assertTrue(self.git.acceptmergerequest(self.project_id, merge["id"], "closed!")) self.assertEqual(self.git.getmergerequest(self.project_id, merge["id"])["state"], "merged") def test_notes(self): # issue wallnotes issue = self.git.createissue(self.project_id, title="test_issue") note = self.git.createissuewallnote(self.project_id, issue["id"], content="Test_note") assert isinstance(issue, dict) assert isinstance(note, dict) self.assertEqual(note["body"], "Test_note") assert isinstance(self.git.getissuewallnotes(self.project_id, issue["id"]), list) note2 = self.git.getissuewallnote(self.project_id, issue["id"], note["id"]) assert isinstance(note2, dict) self.assertEqual(note["body"], note2["body"]) # snippet wallnotes snippet = self.git.createsnippet(self.project_id, "test_snippet", "test.py", "import this") note = self.git.createsnippetewallnote(self.project_id, snippet["id"], "test_snippet_content") assert isinstance(self.git.getsnippetwallnotes(self.project_id, snippet["id"]), list) note2 = self.git.getsnippetwallnote(self.project_id, snippet["id"], note["id"]) assert isinstance(note2, dict) self.assertEqual(note["body"], note2["body"]) # merge request wallnotes commit = self.git.getrepositorycommits(self.project_id)[5] branch = self.git.createbranch(self.project_id, "notesbranch", commit["id"]) merge = self.git.createmergerequest(self.project_id, "develop", "notesbranch", "testnotes") self.assertEqual(len(self.git.getmergerequestwallnotes(self.project_id, merge["id"])), 0) note = self.git.createmergerequestewallnote(self.project_id, merge["id"], "test_content") assert isinstance(note, dict) note2 = self.git.getmergerequestwallnote(self.project_id, merge["id"], note["id"]) assert isinstance(note2, dict) self.assertEqual(note["body"], note2["body"]) self.assertEqual(len(self.git.getmergerequestwallnotes(self.project_id, merge["id"])), 1) def test_labels(self): labels = self.git.getlabels(self.project_id) assert isinstance(labels, list) self.assertEqual(len(labels), 0) newlabel = self.git.createlabel(self.project_id, "test_label", "#FFAABB") assert isinstance(newlabel, dict) labels = self.git.getlabels(self.project_id) self.assertEqual(len(labels), 1) self.assertTrue(self.git.deletelabel(self.project_id, "test_label")) labels = self.git.getlabels(self.project_id) self.assertEqual(len(labels), 0) def test_sudo(self): name = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(8)) newuser = self.git.createuser(name, name, "sudo_user", "{}@user.org".format(name)) # change to the new user self.git.setsudo(user=newuser["id"]) self.assertEqual(len(self.git.getprojects()), 0) self.assertEqual(self.git.currentuser()["username"], name) # change back to logged user self.git.setsudo() self.assertGreaterEqual(len(self.git.getprojects()), 1) self.assertEqual(self.git.currentuser()["username"], "root") self.git.deleteuser(newuser["id"])pyapi-gitlab-7.5.0/requirements.txt000066400000000000000000000000111244107656600173740ustar00rootroot00000000000000requests pyapi-gitlab-7.5.0/scripts/000077500000000000000000000000001244107656600156075ustar00rootroot00000000000000pyapi-gitlab-7.5.0/scripts/install_gitlab.sh000077500000000000000000000034161244107656600211420ustar00rootroot00000000000000#!/bin/bash # install gitlab cd /home/git sudo -u git -H git clone --depth=1 https://gitlab.com/gitlab-org/gitlab-ce.git -b 7-5-stable gitlab cd /home/git/gitlab sudo -u git -H sh -c "cat config/gitlab.yml.example | sed 's/port: 80/port: 8080/g' > config/gitlab.yml" sudo chown -R git log/ sudo chown -R git tmp/ sudo chmod -R u+rwX log/ sudo chmod -R u+rwX tmp/ sudo -u git -H mkdir /home/git/gitlab-satellites sudo chmod u+rwx,g=rx,o-rwx /home/git/gitlab-satellites sudo chmod -R u+rwX tmp/pids/ sudo chmod -R u+rwX tmp/sockets/ sudo chmod -R u+rwX public/uploads sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb sudo -u git -H git config --global user.name "GitLab" sudo -u git -H git config --global user.email "example@example.com" sudo -u git -H git config --global core.autocrlf input sudo -u git -H sh -c "cat config/database.yml.mysql | sed 's/password: \".*\"/password: "git"/g' > config/database.yml" sudo -u git -H chmod o-rwx config/database.yml bundle -v sudo -u git -H bundle install --retry 5 --deployment --without development test postgres aws sudo -u git -H bundle install --retry 5 --deployment --without development test postgres aws # install gitlab shell sudo -u git -H bundle exec rake gitlab:shell:install[v2.2.0] REDIS_URL=redis://localhost:6379 RAILS_ENV=production echo "yes" | sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab sudo update-rc.d gitlab defaults 21 sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production sudo service gitlab restart sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production pyapi-gitlab-7.5.0/scripts/prepare_test_env.sh000077500000000000000000000027651244107656600215250ustar00rootroot00000000000000#!/bin/sh # install dependencies sudo apt-get update -qq # sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate python-docutils pkg-config cmake sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate python-docutils pkg-config cmake python-crypto sudo apt-get install -y git-core git --version # install ruby sudo apt-get remove -y ruby1.8 libruby1.8 libruby1.9.1 mkdir /tmp/ruby && cd /tmp/ruby curl -L --progress ftp://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz | tar xz cd ruby-2.1.2 ./configure --disable-install-rdoc make sudo make install sudo gem install bundler --no-ri --no-rdoc # install git user sudo adduser --disabled-login --gecos 'GitLab' git # install mysql sudo DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server mysql-client libmysqlclient-dev mysql --version mysql -u root -e "CREATE USER 'git'@'localhost' IDENTIFIED BY 'git';" mysql -u root -e "SET storage_engine=INNODB; CREATE DATABASE IF NOT EXISTS gitlabhq_production DEFAULT CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';" mysql -u root -e "GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON gitlabhq_production.* TO 'git'@'localhost';" pyapi-gitlab-7.5.0/setup.py000066400000000000000000000011001244107656600156220ustar00rootroot00000000000000# -*- coding: utf-8 -*- from setuptools import setup, find_packages setup( name = "pyapi-gitlab", version = "7.5.0", packages = find_packages(), install_requires = ['requests'], extras_require = { 'markdown': ["markdown"] }, # metadata for upload to PyPI author = "Itxaka Serrano Garcia", author_email = "itxakaserrano@gmail.com", description = "Gitlab API wrapper for Gitlab 7.X", license = "GPL3", keywords = "gitlab git wrapper", url = "http://github.com/itxaka/pyapi-gitlab/", test_suite="gitlab_tests", )