diff --git a/venv/lib/python3.10/site-packages/PyGithub-2.6.1.dist-info/COPYING b/venv/lib/python3.10/site-packages/PyGithub-2.6.1.dist-info/COPYING new file mode 100644 index 0000000000000000000000000000000000000000..94a9ed024d3859793618152ea559a168bbcbb5e2 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PyGithub-2.6.1.dist-info/COPYING @@ -0,0 +1,674 @@ + 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 +. diff --git a/venv/lib/python3.10/site-packages/PyGithub-2.6.1.dist-info/COPYING.LESSER b/venv/lib/python3.10/site-packages/PyGithub-2.6.1.dist-info/COPYING.LESSER new file mode 100644 index 0000000000000000000000000000000000000000..65c5ca88a67c30becee01c5a8816d964b03862f9 --- /dev/null +++ b/venv/lib/python3.10/site-packages/PyGithub-2.6.1.dist-info/COPYING.LESSER @@ -0,0 +1,165 @@ + GNU LESSER 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. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser 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 +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/venv/lib/python3.10/site-packages/github/AccessToken.py b/venv/lib/python3.10/site-packages/github/AccessToken.py new file mode 100644 index 0000000000000000000000000000000000000000..a127d77059ab7ada465be547cb2b32980299828f --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/AccessToken.py @@ -0,0 +1,158 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Adam Baratz # +# Copyright 2019 Nick Campbell # +# Copyright 2019 Rigas Papathanasopoulos # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2022 Liuyang Wan # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2023 chantra # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from datetime import datetime, timedelta, timezone +from typing import Any + +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + + +class AccessToken(NonCompletableGithubObject): + """ + This class represents access tokens. + """ + + _created: datetime + + def _initAttributes(self) -> None: + self._expires_in: Attribute[int | None] = NotSet + self._refresh_expires_in: Attribute[int | None] = NotSet + self._refresh_token: Attribute[str] = NotSet + self._scope: Attribute[str] = NotSet + self._token: Attribute[str] = NotSet + self._type: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__( + { + "token": f"{self.token[:5]}...", + "scope": self.scope, + "type": self.type, + "expires_in": self.expires_in, + "refresh_token": (f"{self.refresh_token[:5]}..." if self.refresh_token else None), + "refresh_token_expires_in": self.refresh_expires_in, + } + ) + + @property + def created(self) -> datetime: + """ + :type: datetime + """ + return self._created + + @property + def expires_at(self) -> datetime | None: + """ + :type: Optional[datetime] + """ + seconds = self.expires_in + if seconds is not None: + return self._created + timedelta(seconds=seconds) + return None + + @property + def expires_in(self) -> int | None: + """ + :type: Optional[int] + """ + return self._expires_in.value + + @property + def refresh_expires_at(self) -> datetime | None: + """ + :type: Optional[datetime] + """ + seconds = self.refresh_expires_in + if seconds is not None: + return self._created + timedelta(seconds=seconds) + return None + + @property + def refresh_expires_in(self) -> int | None: + """ + :type: Optional[int] + """ + return self._refresh_expires_in.value + + @property + def refresh_token(self) -> str | None: + """ + :type: Optional[string] + """ + return self._refresh_token.value + + @property + def scope(self) -> str: + """ + :type: string + """ + return self._scope.value + + @property + def token(self) -> str: + """ + :type: string + """ + return self._token.value + + @property + def type(self) -> str: + """ + :type: string + """ + return self._type.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + self._created = datetime.now(timezone.utc) + if "access_token" in attributes: # pragma no branch + self._token = self._makeStringAttribute(attributes["access_token"]) + if "expires_in" in attributes: # pragma no branch + self._expires_in = self._makeIntAttribute(attributes["expires_in"]) + if "refresh_token" in attributes: # pragma no branch + self._refresh_token = self._makeStringAttribute(attributes["refresh_token"]) + if "refresh_token_expires_in" in attributes: # pragma no branch + self._refresh_expires_in = self._makeIntAttribute(attributes["refresh_token_expires_in"]) + if "scope" in attributes: # pragma no branch + self._scope = self._makeStringAttribute(attributes["scope"]) + if "token_type" in attributes: # pragma no branch + self._type = self._makeStringAttribute(attributes["token_type"]) diff --git a/venv/lib/python3.10/site-packages/github/AdvisoryBase.py b/venv/lib/python3.10/site-packages/github/AdvisoryBase.py new file mode 100644 index 0000000000000000000000000000000000000000..b9008cf0eaa62870402d0d626e84df9b3fbc4c54 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/AdvisoryBase.py @@ -0,0 +1,157 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Joseph Henrich # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Thomas Cooper # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from datetime import datetime +from typing import Any + +from github.CVSS import CVSS +from github.CWE import CWE +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + + +class AdvisoryBase(NonCompletableGithubObject): + """ + This class represents the shared attributes between GlobalAdvisory, RepositoryAdvisory and DependabotAdvisory + https://docs.github.com/en/rest/security-advisories/global-advisories + https://docs.github.com/en/rest/security-advisories/repository-advisories + https://docs.github.com/en/rest/dependabot/alerts + """ + + def _initAttributes(self) -> None: + self._cve_id: Attribute[str] = NotSet + self._cvss: Attribute[CVSS] = NotSet + self._cvss_severities: Attribute[dict[str, Any]] = NotSet + self._cwes: Attribute[list[CWE]] = NotSet + self._description: Attribute[str] = NotSet + self._ghsa_id: Attribute[str] = NotSet + self._html_url: Attribute[str] = NotSet + self._identifiers: Attribute[list[dict]] = NotSet + self._published_at: Attribute[datetime] = NotSet + self._severity: Attribute[str] = NotSet + self._summary: Attribute[str] = NotSet + self._updated_at: Attribute[datetime] = NotSet + self._url: Attribute[str] = NotSet + self._withdrawn_at: Attribute[datetime] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"ghsa_id": self.ghsa_id, "summary": self.summary}) + + @property + def cve_id(self) -> str: + return self._cve_id.value + + @property + def cvss(self) -> CVSS: + return self._cvss.value + + @property + def cvss_severities(self) -> dict[str, Any]: + return self._cvss_severities.value + + @property + def cwes(self) -> list[CWE]: + return self._cwes.value + + @property + def description(self) -> str: + return self._description.value + + @property + def ghsa_id(self) -> str: + return self._ghsa_id.value + + @property + def html_url(self) -> str: + return self._html_url.value + + @property + def identifiers(self) -> list[dict]: + return self._identifiers.value + + @property + def published_at(self) -> datetime: + return self._published_at.value + + @property + def severity(self) -> str: + return self._severity.value + + @property + def summary(self) -> str: + return self._summary.value + + @property + def updated_at(self) -> datetime: + return self._updated_at.value + + @property + def url(self) -> str: + return self._url.value + + @property + def withdrawn_at(self) -> datetime: + return self._withdrawn_at.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "cve_id" in attributes: # pragma no branch + self._cve_id = self._makeStringAttribute(attributes["cve_id"]) + if "cvss" in attributes: # pragma no branch + self._cvss = self._makeClassAttribute(CVSS, attributes["cvss"]) + if "cvss_severities" in attributes: # pragma no branch + self._cvss_severities = self._makeDictAttribute(attributes["cvss_severities"]) + if "cwes" in attributes: # pragma no branch + self._cwes = self._makeListOfClassesAttribute(CWE, attributes["cwes"]) + if "description" in attributes: # pragma no branch + self._description = self._makeStringAttribute(attributes["description"]) + if "ghsa_id" in attributes: # pragma no branch + self._ghsa_id = self._makeStringAttribute(attributes["ghsa_id"]) + if "html_url" in attributes: # pragma no branch + self._html_url = self._makeStringAttribute(attributes["html_url"]) + if "identifiers" in attributes: # pragma no branch + self._identifiers = self._makeListOfDictsAttribute(attributes["identifiers"]) + if "published_at" in attributes: # pragma no branch + assert attributes["published_at"] is None or isinstance(attributes["published_at"], str), attributes[ + "published_at" + ] + self._published_at = self._makeDatetimeAttribute(attributes["published_at"]) + if "severity" in attributes: # pragma no branch + self._severity = self._makeStringAttribute(attributes["severity"]) + if "summary" in attributes: # pragma no branch + self._summary = self._makeStringAttribute(attributes["summary"]) + if "updated_at" in attributes: # pragma no branch + assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], str), attributes[ + "updated_at" + ] + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) + if "url" in attributes: # pragma no branch + self._url = self._makeStringAttribute(attributes["url"]) + if "withdrawn_at" in attributes: # pragma no branch + assert attributes["withdrawn_at"] is None or isinstance(attributes["withdrawn_at"], str), attributes[ + "withdrawn_at" + ] + self._withdrawn_at = self._makeDatetimeAttribute(attributes["withdrawn_at"]) diff --git a/venv/lib/python3.10/site-packages/github/AdvisoryCredit.py b/venv/lib/python3.10/site-packages/github/AdvisoryCredit.py new file mode 100644 index 0000000000000000000000000000000000000000..9267772050dfabea2bc8f8ee429ff6ed54fa9265 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/AdvisoryCredit.py @@ -0,0 +1,126 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Jonathan Leitschuh # +# Copyright 2023 Joseph Henrich # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from typing import Any, Union + +from typing_extensions import TypedDict + +import github.NamedUser +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + + +class SimpleCredit(TypedDict): + """ + A simple credit for a security advisory. + """ + + login: str | github.NamedUser.NamedUser + type: str + + +Credit = Union[SimpleCredit, "AdvisoryCredit"] + + +class AdvisoryCredit(NonCompletableGithubObject): + """ + This class represents a credit that is assigned to a SecurityAdvisory. + + The reference can be found here + https://docs.github.com/en/rest/security-advisories/repository-advisories + + The OpenAPI schema can be found at + - /components/schemas/repository-advisory/properties/credits/items + + """ + + def _initAttributes(self) -> None: + self._login: Attribute[str] = NotSet + self._type: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__( + { + "login": self.login, + "type": self.type, + } + ) + + @property + def login(self) -> str: + """ + :type: string + """ + return self._login.value + + @property + def type(self) -> str: + """ + :type: string + """ + return self._type.value + + @staticmethod + def _validate_credit(credit: Credit) -> None: + assert isinstance(credit, (dict, AdvisoryCredit)), credit + if isinstance(credit, dict): + assert "login" in credit, credit + assert "type" in credit, credit + assert isinstance(credit["login"], (str, github.NamedUser.NamedUser)), credit["login"] + assert isinstance(credit["type"], str), credit["type"] + else: + assert isinstance(credit.login, str), credit.login + assert isinstance(credit.type, str), credit.type + + @staticmethod + def _to_github_dict(credit: Credit) -> SimpleCredit: + assert isinstance(credit, (dict, AdvisoryCredit)), credit + if isinstance(credit, dict): + assert "login" in credit, credit + assert "type" in credit, credit + assert isinstance(credit["login"], (str, github.NamedUser.NamedUser)), credit["login"] + login = credit["login"] + if isinstance(login, github.NamedUser.NamedUser): + login = login.login + return { + "login": login, + "type": credit["type"], + } + else: + return { + "login": credit.login, + "type": credit.type, + } + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "login" in attributes: # pragma no branch + self._login = self._makeStringAttribute(attributes["login"]) + if "type" in attributes: # pragma no branch + self._type = self._makeStringAttribute(attributes["type"]) diff --git a/venv/lib/python3.10/site-packages/github/AdvisoryCreditDetailed.py b/venv/lib/python3.10/site-packages/github/AdvisoryCreditDetailed.py new file mode 100644 index 0000000000000000000000000000000000000000..d156843b603f830d26e756057650c05203d56383 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/AdvisoryCreditDetailed.py @@ -0,0 +1,104 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Adam Baratz # +# Copyright 2019 Nick Campbell # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Jonathan Leitschuh # +# Copyright 2023 Joseph Henrich # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from typing import Any + +import github.NamedUser +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + + +class AdvisoryCreditDetailed(NonCompletableGithubObject): + """ + This class represents a credit that is assigned to a SecurityAdvisory. + + The reference can be found here + https://docs.github.com/en/rest/security-advisories/repository-advisories + + The OpenAPI schema can be found at + - /components/schemas/global-advisory/properties/credits/items + - /components/schemas/repository-advisory-credit + + """ + + def _initAttributes(self) -> None: + self._state: Attribute[str] = NotSet + self._type: Attribute[str] = NotSet + self._user: Attribute[github.NamedUser.NamedUser] = NotSet + + def __repr__(self) -> str: + return self.get__repr__( + { + "user": self.user, + "type": self.type, + } + ) + + @property + def state(self) -> str: + """ + :type: string + """ + return self._state.value + + @property + def type(self) -> str: + """ + :type: string + """ + return self._type.value + + @property + def user(self) -> github.NamedUser.NamedUser: + """ + :type: :class:`github.NamedUser.NamedUser` + """ + return self._user.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "state" in attributes: # pragma no branch + self._state = self._makeStringAttribute(attributes["state"]) + if "type" in attributes: # pragma no branch + self._type = self._makeStringAttribute(attributes["type"]) + if "user" in attributes: # pragma no branch + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) diff --git a/venv/lib/python3.10/site-packages/github/AdvisoryVulnerability.py b/venv/lib/python3.10/site-packages/github/AdvisoryVulnerability.py new file mode 100644 index 0000000000000000000000000000000000000000..c64d29c5af94f9a0e614a06e9678dc91bac9eb17 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/AdvisoryVulnerability.py @@ -0,0 +1,190 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Jonathan Leitschuh # +# Copyright 2023 Joseph Henrich # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from typing import TYPE_CHECKING, Any, Union + +from typing_extensions import TypedDict + +import github.AdvisoryVulnerabilityPackage +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + +if TYPE_CHECKING: + from github.AdvisoryVulnerabilityPackage import AdvisoryVulnerabilityPackage + + +class SimpleAdvisoryVulnerabilityPackage(TypedDict): + """ + A simple package in an advisory. + """ + + ecosystem: str + name: str | None + + +class SimpleAdvisoryVulnerability(TypedDict): + """ + A simple vulnerability in a security advisory. + """ + + package: SimpleAdvisoryVulnerabilityPackage + patched_versions: str | None + vulnerable_functions: list[str] | None + vulnerable_version_range: str | None + + +AdvisoryVulnerabilityInput = Union[SimpleAdvisoryVulnerability, "AdvisoryVulnerability"] + + +class AdvisoryVulnerability(NonCompletableGithubObject): + """ + This class represents a package that is vulnerable to a parent SecurityAdvisory. + + The reference can be found here + https://docs.github.com/en/rest/security-advisories/repository-advisories + + The OpenAPI schema can be found at + - /components/schemas/repository-advisory-vulnerability + - /components/schemas/vulnerability + + """ + + def _initAttributes(self) -> None: + self._first_patched_version: Attribute[str] = NotSet + self._package: Attribute[AdvisoryVulnerabilityPackage] = NotSet + self._patched_versions: Attribute[str] = NotSet + self._vulnerable_functions: Attribute[list[str]] = NotSet + self._vulnerable_version_range: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"package": self.package}) + + @property + def first_patched_version(self) -> str: + return self._first_patched_version.value + + @property + def package( + self, + ) -> AdvisoryVulnerabilityPackage: + """ + :type: :class:`github.AdvisoryVulnerability.AdvisoryVulnerability` + """ + return self._package.value + + @property + def patched_versions(self) -> str: + """ + :type: string + """ + return self._patched_versions.value + + @property + def vulnerable_functions(self) -> list[str] | None: + """ + :type: list of string + """ + return self._vulnerable_functions.value + + @property + def vulnerable_version_range(self) -> str | None: + """ + :type: string + """ + return self._vulnerable_version_range.value + + @classmethod + def _validate_vulnerability(cls, vulnerability: AdvisoryVulnerabilityInput) -> None: + assert isinstance(vulnerability, (dict, cls)), vulnerability + if isinstance(vulnerability, dict): + assert "package" in vulnerability, vulnerability + package: SimpleAdvisoryVulnerabilityPackage = vulnerability["package"] + assert isinstance(package, dict), package + assert "ecosystem" in package, package + assert isinstance(package["ecosystem"], str), package + assert "name" in package, package + assert isinstance(package["name"], (str, type(None))), package + assert "patched_versions" in vulnerability, vulnerability + assert isinstance(vulnerability["patched_versions"], (str, type(None))), vulnerability + assert "vulnerable_functions" in vulnerability, vulnerability + assert isinstance(vulnerability["vulnerable_functions"], (list, type(None))), vulnerability + assert "vulnerable_functions" in vulnerability, vulnerability + assert ( + all(isinstance(vf, str) for vf in vulnerability["vulnerable_functions"]) + if vulnerability["vulnerable_functions"] is not None + else True + ), vulnerability + assert "vulnerable_version_range" in vulnerability, vulnerability + assert isinstance(vulnerability["vulnerable_version_range"], (str, type(None))), vulnerability + + else: + assert ( + vulnerability.package is github.AdvisoryVulnerabilityPackage.AdvisoryVulnerabilityPackage + ), vulnerability + + @staticmethod + def _to_github_dict( + vulnerability: AdvisoryVulnerabilityInput, + ) -> SimpleAdvisoryVulnerability: + if isinstance(vulnerability, dict): + vulnerability_package: SimpleAdvisoryVulnerabilityPackage = vulnerability["package"] + return { + "package": { + "ecosystem": vulnerability_package["ecosystem"], + "name": vulnerability_package["name"], + }, + "patched_versions": vulnerability["patched_versions"], + "vulnerable_functions": vulnerability["vulnerable_functions"], + "vulnerable_version_range": vulnerability["vulnerable_version_range"], + } + return { + "package": { + "ecosystem": vulnerability.package.ecosystem, + "name": vulnerability.package.name, + }, + "patched_versions": vulnerability.patched_versions, + "vulnerable_functions": vulnerability.vulnerable_functions, + "vulnerable_version_range": vulnerability.vulnerable_version_range, + } + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "first_patched_version" in attributes: # pragma no branch + self._first_patched_version = self._makeStringAttribute(attributes["first_patched_version"]) + if "package" in attributes: # pragma no branch + self._package = self._makeClassAttribute( + github.AdvisoryVulnerabilityPackage.AdvisoryVulnerabilityPackage, + attributes["package"], + ) + if "patched_versions" in attributes: # pragma no branch + self._patched_versions = self._makeStringAttribute(attributes["patched_versions"]) + if "vulnerable_functions" in attributes: # pragma no branch + self._vulnerable_functions = self._makeListOfStringsAttribute(attributes["vulnerable_functions"]) + if "vulnerable_version_range" in attributes: # pragma no branch + self._vulnerable_version_range = self._makeStringAttribute(attributes["vulnerable_version_range"]) diff --git a/venv/lib/python3.10/site-packages/github/AdvisoryVulnerabilityPackage.py b/venv/lib/python3.10/site-packages/github/AdvisoryVulnerabilityPackage.py new file mode 100644 index 0000000000000000000000000000000000000000..07c85b67016679e8f39ef6be711da57e44bc1b84 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/AdvisoryVulnerabilityPackage.py @@ -0,0 +1,91 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Steve Kowalik # +# Copyright 2022 Eric Nieuwland # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Jonathan Leitschuh # +# Copyright 2023 Joseph Henrich # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2024 Thomas Cooper # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from typing import Any + +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + + +class AdvisoryVulnerabilityPackage(NonCompletableGithubObject): + """ + This class represents an identifier for a package that is vulnerable to a parent SecurityAdvisory. + + The reference can be found here + https://docs.github.com/en/rest/security-advisories/repository-advisories + + The OpenAPI schema can be found at + - /components/schemas/dependabot-alert-package + - /components/schemas/repository-advisory-vulnerability/properties/package + - /components/schemas/vulnerability/properties/package + + """ + + def _initAttributes(self) -> None: + self._ecosystem: Attribute[str] = NotSet + self._name: Attribute[str | None] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"name": self.name}) + + @property + def ecosystem(self) -> str: + """ + :type: string + """ + return self._ecosystem.value + + @property + def name(self) -> str | None: + """ + :type: string or None + """ + return self._name.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "ecosystem" in attributes: # pragma no branch + self._ecosystem = self._makeStringAttribute(attributes["ecosystem"]) + if "name" in attributes: # pragma no branch + self._name = self._makeStringAttribute(attributes["name"]) diff --git a/venv/lib/python3.10/site-packages/github/AppAuthentication.py b/venv/lib/python3.10/site-packages/github/AppAuthentication.py new file mode 100644 index 0000000000000000000000000000000000000000..6b9c3b0e8a1c31941e4b3d45b9b83f9011e954e7 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/AppAuthentication.py @@ -0,0 +1,57 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Peter Buckley # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 TechnicalPirate <35609336+TechnicalPirate@users.noreply.github.com># +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2022 Eric Nieuwland # +# Copyright 2023 Denis Blanchette # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Trim21 # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + + +from typing import Dict, Optional, Union + +import deprecated + +from github.Auth import AppAuth, AppInstallationAuth + + +@deprecated.deprecated("Use github.Auth.AppInstallationAuth instead") +class AppAuthentication(AppInstallationAuth): + def __init__( + self, + app_id: Union[int, str], + private_key: str, + installation_id: int, + token_permissions: Optional[Dict[str, str]] = None, + ): + super().__init__( + app_auth=AppAuth(app_id, private_key), + installation_id=installation_id, + token_permissions=token_permissions, + ) diff --git a/venv/lib/python3.10/site-packages/github/ApplicationOAuth.py b/venv/lib/python3.10/site-packages/github/ApplicationOAuth.py new file mode 100644 index 0000000000000000000000000000000000000000..5143aa6217d062c8f2b9d6da05462b185dabaa83 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/ApplicationOAuth.py @@ -0,0 +1,198 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2019 Rigas Papathanasopoulos # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Mark Walker # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +import urllib.parse +from typing import TYPE_CHECKING, Any + +import github.AccessToken +import github.Auth +from github.Consts import DEFAULT_BASE_URL, DEFAULT_OAUTH_URL +from github.GithubException import BadCredentialsException, GithubException +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet +from github.Requester import Requester + +if TYPE_CHECKING: + from github.AccessToken import AccessToken + from github.Auth import AppUserAuth + + +class ApplicationOAuth(NonCompletableGithubObject): + """ + This class is used for identifying and authorizing users for Github Apps. + + The reference can be found at + https://docs.github.com/en/developers/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps + + """ + + def _initAttributes(self) -> None: + self._client_id: Attribute[str] = NotSet + self._client_secret: Attribute[str] = NotSet + + def __init__( + self, + requester: Requester, + headers: dict[str, Any], + attributes: Any, + ) -> None: + # this object requires a request without authentication + requester = requester.withAuth(auth=None) + super().__init__(requester, headers, attributes) + + def __repr__(self) -> str: + return self.get__repr__({"client_id": self._client_id.value}) + + @property + def client_id(self) -> str: + return self._client_id.value + + @property + def client_secret(self) -> str: + return self._client_secret.value + + def get_oauth_url(self, path: str) -> str: + if not path.startswith("/"): + path = f"/{path}" + + if self._requester.base_url == DEFAULT_BASE_URL: + base_url = DEFAULT_OAUTH_URL + else: + base_url = f"{self._requester.scheme}://{self._requester.hostname_and_port}/login/oauth" + return f"{base_url}{path}" + + def get_login_url( + self, + redirect_uri: str | None = None, + state: str | None = None, + login: str | None = None, + ) -> str: + """ + Return the URL you need to redirect a user to in order to authorize your App. + """ + parameters = {"client_id": self.client_id} + if redirect_uri is not None: + assert isinstance(redirect_uri, str), redirect_uri + parameters["redirect_uri"] = redirect_uri + if state is not None: + assert isinstance(state, str), state + parameters["state"] = state + if login is not None: + assert isinstance(login, str), login + parameters["login"] = login + + query = urllib.parse.urlencode(parameters) + + return self.get_oauth_url(f"/authorize?{query}") + + def get_access_token(self, code: str, state: str | None = None) -> AccessToken: + """ + :calls: `POST /login/oauth/access_token `_ + """ + assert isinstance(code, str), code + post_parameters = { + "code": code, + "client_id": self.client_id, + "client_secret": self.client_secret, + } + + if state is not None: + post_parameters["state"] = state + + headers, data = self._checkError( + *self._requester.requestJsonAndCheck( + "POST", + self.get_oauth_url("/access_token"), + headers={"Accept": "application/json"}, + input=post_parameters, + ) + ) + + return github.AccessToken.AccessToken( + requester=self._requester, + headers=headers, + attributes=data, + ) + + def get_app_user_auth(self, token: AccessToken) -> AppUserAuth: + return github.Auth.AppUserAuth( + client_id=self.client_id, + client_secret=self.client_secret, + token=token.token, + token_type=token.type, + expires_at=token.expires_at, + refresh_token=token.refresh_token, + refresh_expires_at=token.refresh_expires_at, + requester=self._requester, + ) + + def refresh_access_token(self, refresh_token: str) -> AccessToken: + """ + :calls: `POST /login/oauth/access_token `_ + :param refresh_token: string + """ + assert isinstance(refresh_token, str) + post_parameters = { + "client_id": self.client_id, + "client_secret": self.client_secret, + "grant_type": "refresh_token", + "refresh_token": refresh_token, + } + + headers, data = self._checkError( + *self._requester.requestJsonAndCheck( + "POST", + self.get_oauth_url("/access_token"), + headers={"Accept": "application/json"}, + input=post_parameters, + ) + ) + + return github.AccessToken.AccessToken( + requester=self._requester, + headers=headers, + attributes=data, + ) + + @staticmethod + def _checkError(headers: dict[str, Any], data: Any) -> tuple[dict[str, Any], Any]: + if isinstance(data, dict) and "error" in data: + if data["error"] == "bad_verification_code": + raise BadCredentialsException(200, data, headers) + raise GithubException(200, data, headers) + + return headers, data + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "client_id" in attributes: # pragma no branch + self._client_id = self._makeStringAttribute(attributes["client_id"]) + if "client_secret" in attributes: # pragma no branch + self._client_secret = self._makeStringAttribute(attributes["client_secret"]) diff --git a/venv/lib/python3.10/site-packages/github/Artifact.py b/venv/lib/python3.10/site-packages/github/Artifact.py new file mode 100644 index 0000000000000000000000000000000000000000..9431aa1f028c85c47eb49c8b692c651e007f778d --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/Artifact.py @@ -0,0 +1,172 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2015 Matt Babineau # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Martijn Koster # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Colby Gallup # +# Copyright 2020 Mahesh Raju # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Steve Kowalik # +# Copyright 2022 Aleksei Fedotov # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from datetime import datetime +from typing import TYPE_CHECKING, Any + +import github.WorkflowRun +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + +if TYPE_CHECKING: + from github.WorkflowRun import WorkflowRun + + +class Artifact(NonCompletableGithubObject): + """ + This class represents an Artifact of Github Run. + + The OpenAPI schema can be found at + - /components/schemas/artifact + + """ + + def _initAttributes(self) -> None: + self._archive_download_url: Attribute[str] = NotSet + self._created_at: Attribute[datetime] = NotSet + self._expired: Attribute[bool] = NotSet + self._expires_at: Attribute[datetime] = NotSet + self._head_sha: Attribute[str] = NotSet + self._id: Attribute[int] = NotSet + self._name: Attribute[str] = NotSet + self._node_id: Attribute[str] = NotSet + self._size_in_bytes: Attribute[int] = NotSet + self._updated_at: Attribute[datetime] = NotSet + self._url: Attribute[str] = NotSet + self._workflow_run: Attribute[WorkflowRun] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"name": self._name.value, "id": self._id.value}) + + @property + def archive_download_url(self) -> str: + return self._archive_download_url.value + + @property + def created_at(self) -> datetime: + return self._created_at.value + + @property + def expired(self) -> bool: + return self._expired.value + + @property + def expires_at(self) -> datetime: + return self._expires_at.value + + @property + def head_sha(self) -> str: + return self._head_sha.value + + @property + def id(self) -> int: + return self._id.value + + @property + def name(self) -> str: + return self._name.value + + @property + def node_id(self) -> str: + return self._node_id.value + + @property + def size_in_bytes(self) -> int: + return self._size_in_bytes.value + + @property + def updated_at(self) -> datetime: + return self._updated_at.value + + @property + def url(self) -> str: + return self._url.value + + @property + def workflow_run(self) -> WorkflowRun: + return self._workflow_run.value + + def delete(self) -> bool: + """ + :calls: `DELETE /repos/{owner}/{repo}/actions/artifacts/{artifact_id} `_ + """ + status, headers, data = self._requester.requestBlob("DELETE", self.url) + return status == 204 + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "archive_download_url" in attributes: # pragma no branch + self._archive_download_url = self._makeStringAttribute(attributes["archive_download_url"]) + if "created_at" in attributes: # pragma no branch + assert attributes["created_at"] is None or isinstance(attributes["created_at"], (str,)), attributes[ + "created_at" + ] + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) + if "expired" in attributes: # pragma no branch + self._expired = self._makeBoolAttribute(attributes["expired"]) + if "expires_at" in attributes: # pragma no branch + assert attributes["expires_at"] is None or isinstance(attributes["expires_at"], (str,)), attributes[ + "expires_at" + ] + self._expires_at = self._makeDatetimeAttribute(attributes["expires_at"]) + if "head_sha" in attributes: # pragma no branch + self._head_sha = self._makeStringAttribute(attributes["head_sha"]) + if "id" in attributes: # pragma no branch + self._id = self._makeIntAttribute(attributes["id"]) + if "name" in attributes: # pragma no branch + self._name = self._makeStringAttribute(attributes["name"]) + if "node_id" in attributes: # pragma no branch + self._node_id = self._makeStringAttribute(attributes["node_id"]) + if "size_in_bytes" in attributes: # pragma no branch + self._size_in_bytes = self._makeIntAttribute(attributes["size_in_bytes"]) + if "updated_at" in attributes: # pragma no branch + assert attributes["updated_at"] is None or isinstance(attributes["updated_at"], (str,)), attributes[ + "updated_at" + ] + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) + if "url" in attributes: # pragma no branch + self._url = self._makeStringAttribute(attributes["url"]) + if "workflow_run" in attributes: # pragma no branch + self._workflow_run = self._makeClassAttribute(github.WorkflowRun.WorkflowRun, attributes["workflow_run"]) diff --git a/venv/lib/python3.10/site-packages/github/Auth.py b/venv/lib/python3.10/site-packages/github/Auth.py new file mode 100644 index 0000000000000000000000000000000000000000..7a71ec8ba198ae2fa3bda545b36bd14cdf148b42 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/Auth.py @@ -0,0 +1,551 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2023 chantra # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2024 Jonathan Kliem # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +import abc +import base64 +import time +from abc import ABC +from datetime import datetime, timedelta, timezone +from typing import TYPE_CHECKING, Callable, Dict, Optional, Union + +import jwt +from requests import utils + +from github import Consts +from github.InstallationAuthorization import InstallationAuthorization +from github.Requester import Requester, WithRequester + +if TYPE_CHECKING: + from github.GithubIntegration import GithubIntegration + +PrivateKeyGenerator = Callable[[], Union[str, bytes]] +DictSignFunction = Callable[[dict], Union[str, bytes]] + +# For App authentication, time remaining before token expiration to request a new one +ACCESS_TOKEN_REFRESH_THRESHOLD_SECONDS = 20 +TOKEN_REFRESH_THRESHOLD_TIMEDELTA = timedelta(seconds=ACCESS_TOKEN_REFRESH_THRESHOLD_SECONDS) + + +# add new implementations of github.Auth.Auth to docs/utilities.rst +class Auth(abc.ABC): + """ + This class is the base class of all authentication methods for Requester. + """ + + @property + @abc.abstractmethod + def token_type(self) -> str: + """ + The type of the auth token as used in the HTTP Authorization header, e.g. Bearer or Basic. + + :return: token type + + """ + + @property + @abc.abstractmethod + def token(self) -> str: + """ + The auth token as used in the HTTP Authorization header. + + :return: token + + """ + + def authentication(self, headers: dict) -> None: + """ + Add authorization to the headers. + """ + headers["Authorization"] = f"{self.token_type} {self.token}" + + def mask_authentication(self, headers: dict) -> None: + """ + Mask header, e.g. for logging. + """ + headers["Authorization"] = self._masked_token + + @property + def _masked_token(self) -> str: + return "(unknown auth removed)" + + +class HTTPBasicAuth(Auth, abc.ABC): + @property + @abc.abstractmethod + def username(self) -> str: + """ + The username. + """ + + @property + @abc.abstractmethod + def password(self) -> str: + """ + The password. + """ + + @property + def token_type(self) -> str: + return "Basic" + + @property + def token(self) -> str: + return base64.b64encode(f"{self.username}:{self.password}".encode()).decode("utf-8").replace("\n", "") + + @property + def _masked_token(self) -> str: + return "Basic (login and password removed)" + + +class Login(HTTPBasicAuth): + """ + This class is used to authenticate with login and password. + """ + + def __init__(self, login: str, password: str): + assert isinstance(login, str) + assert len(login) > 0 + assert isinstance(password, str) + assert len(password) > 0 + + self._login = login + self._password = password + + @property + def login(self) -> str: + return self._login + + @property + def username(self) -> str: + return self.login + + @property + def password(self) -> str: + return self._password + + +class Token(Auth): + """ + This class is used to authenticate with a single constant token. + """ + + def __init__(self, token: str): + assert isinstance(token, str) + assert len(token) > 0 + self._token = token + + @property + def token_type(self) -> str: + return "token" + + @property + def token(self) -> str: + return self._token + + @property + def _masked_token(self) -> str: + return "token (oauth token removed)" + + +class JWT(Auth, ABC): + """ + This class is the base class to authenticate with a JSON Web Token (JWT). + + https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-json-web-token-jwt-for-a-github-app + + """ + + @property + def token_type(self) -> str: + return "Bearer" + + +class JwtSigner: + def __init__(self, private_key_or_func: Union[str, PrivateKeyGenerator], jwt_algorithm: str): + self._private_key_or_func = private_key_or_func + self._jwt_algorithm = jwt_algorithm + + def jwt_sign(self, payload: dict) -> Union[str, bytes]: + if callable(self._private_key_or_func): + private_key = self._private_key_or_func() + else: + private_key = self._private_key_or_func + return jwt.encode(payload, key=private_key, algorithm=self._jwt_algorithm) + + +class AppAuth(JWT): + """ + This class is used to authenticate as a GitHub App. + + https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app + + """ + + @staticmethod + def create_jwt_sign(private_key_or_func: Union[str, PrivateKeyGenerator], jwt_algorithm: str) -> DictSignFunction: + return JwtSigner(private_key_or_func, jwt_algorithm).jwt_sign + + # v3: move * above private_key + def __init__( + self, + app_id: Union[int, str], + private_key: Optional[Union[str, PrivateKeyGenerator]] = None, + *, + sign_func: Optional[DictSignFunction] = None, + jwt_expiry: int = Consts.DEFAULT_JWT_EXPIRY, + jwt_issued_at: int = Consts.DEFAULT_JWT_ISSUED_AT, + ): + assert isinstance(app_id, (int, str)), app_id + if isinstance(app_id, str): + assert len(app_id) > 0, "app_id must not be empty" + assert private_key is not None or sign_func is not None, "either private_key or sign_func must be given" + assert private_key is None or sign_func is None, "private_key or sign_func cannot both be given" + if private_key is not None: + assert isinstance(private_key, str) or callable(private_key) + if isinstance(private_key, str): + assert len(private_key) > 0, "private_key must not be empty" + sign_func = AppAuth.create_jwt_sign(private_key, Consts.DEFAULT_JWT_ALGORITHM) + assert isinstance(jwt_expiry, int), jwt_expiry + assert Consts.MIN_JWT_EXPIRY <= jwt_expiry <= Consts.MAX_JWT_EXPIRY, jwt_expiry + + self._app_id = app_id + self._sign_func = sign_func + self._jwt_expiry = jwt_expiry + self._jwt_issued_at = jwt_issued_at + + @property + def app_id(self) -> Union[int, str]: + return self._app_id + + @property + def token(self) -> str: + return self.create_jwt() + + def get_installation_auth( + self, + installation_id: int, + token_permissions: Optional[Dict[str, str]] = None, + requester: Optional[Requester] = None, + ) -> "AppInstallationAuth": + """ + Creates a github.Auth.AppInstallationAuth instance for an installation. + + :param installation_id: installation id + :param token_permissions: optional permissions + :param requester: optional requester with app authentication + :return: + + """ + return AppInstallationAuth(self, installation_id, token_permissions, requester) + + def create_jwt(self, expiration: Optional[int] = None) -> str: + """ + Create a signed JWT + https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps#authenticating-as-a-github-app + + :return string: jwt + """ + if expiration is not None: + assert isinstance(expiration, int), expiration + assert Consts.MIN_JWT_EXPIRY <= expiration <= Consts.MAX_JWT_EXPIRY, expiration + + now = int(time.time()) + payload = { + "iat": now + self._jwt_issued_at, + "exp": now + (expiration if expiration is not None else self._jwt_expiry), + "iss": self._app_id, + } + assert self._sign_func is not None + encrypted = self._sign_func(payload) + + if isinstance(encrypted, bytes): + return encrypted.decode("utf-8") + return encrypted + + +class AppAuthToken(JWT): + """ + This class is used to authenticate as a GitHub App with a single constant JWT. + + https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app + + """ + + def __init__(self, token: str): + assert isinstance(token, str) + assert len(token) > 0 + self._token = token + + @property + def token(self) -> str: + return self._token + + +class AppInstallationAuth(Auth, WithRequester["AppInstallationAuth"]): + """ + This class is used to authenticate as a GitHub App Installation. + + https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app-installation + + """ + + # used to fetch live access token when calling self.token + __integration: Optional["GithubIntegration"] = None + __installation_authorization: Optional[InstallationAuthorization] = None + + def __init__( + self, + app_auth: AppAuth, + installation_id: int, + token_permissions: Optional[Dict[str, str]] = None, + requester: Optional[Requester] = None, + ): + super().__init__() + + assert isinstance(app_auth, AppAuth), app_auth + assert isinstance(installation_id, int), installation_id + assert token_permissions is None or isinstance(token_permissions, dict), token_permissions + assert requester is None or isinstance(requester, Requester), requester + + self._app_auth = app_auth + self._installation_id = installation_id + self._token_permissions = token_permissions + + if requester is not None: + self.withRequester(requester) + + def withRequester(self, requester: Requester) -> "AppInstallationAuth": + assert isinstance(requester, Requester), requester + super().withRequester(requester.withAuth(self._app_auth)) + + # imported here to avoid circular import + from github.GithubIntegration import GithubIntegration + + self.__integration = GithubIntegration(**self.requester.kwargs) + + return self + + @property + def app_id(self) -> Union[int, str]: + return self._app_auth.app_id + + @property + def installation_id(self) -> int: + return self._installation_id + + @property + def token_permissions(self) -> Optional[Dict[str, str]]: + return self._token_permissions + + @property + def token_type(self) -> str: + return "token" + + @property + def token(self) -> str: + if self.__installation_authorization is None or self._is_expired: + self.__installation_authorization = self._get_installation_authorization() + return self.__installation_authorization.token + + @property + def _is_expired(self) -> bool: + assert self.__installation_authorization is not None + token_expires_at = self.__installation_authorization.expires_at - TOKEN_REFRESH_THRESHOLD_TIMEDELTA + return token_expires_at < datetime.now(timezone.utc) + + def _get_installation_authorization(self) -> InstallationAuthorization: + assert self.__integration is not None, "Method withRequester(Requester) must be called first" + return self.__integration.get_access_token( + self._installation_id, + permissions=self._token_permissions, + ) + + @property + def _masked_token(self) -> str: + return "token (oauth token removed)" + + +class AppUserAuth(Auth, WithRequester["AppUserAuth"]): + """ + This class is used to authenticate as a GitHub App on behalf of a user. + + https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-with-a-github-app-on-behalf-of-a-user + + """ + + _client_id: str + _client_secret: str + _token: str + _type: str + _scope: Optional[str] + _expires_at: Optional[datetime] + _refresh_token: Optional[str] + _refresh_expires_at: Optional[datetime] + + # imported here to avoid circular import + from github.ApplicationOAuth import ApplicationOAuth + + __app: ApplicationOAuth + + def __init__( + self, + client_id: str, + client_secret: str, + token: str, + token_type: Optional[str] = None, + expires_at: Optional[datetime] = None, + refresh_token: Optional[str] = None, + refresh_expires_at: Optional[datetime] = None, + requester: Optional[Requester] = None, + ) -> None: + super().__init__() + + assert isinstance(client_id, str) and len(client_id) > 0 + assert isinstance(client_secret, str) and len(client_secret) > 0 + assert isinstance(token, str) and len(token) > 0 + assert token_type is None or isinstance(token_type, str) and len(token_type) > 0, token_type + assert expires_at is None or isinstance(expires_at, datetime), expires_at + assert refresh_token is None or isinstance(refresh_token, str) and len(refresh_token) > 0 + assert refresh_expires_at is None or isinstance(refresh_expires_at, datetime), refresh_expires_at + assert requester is None or isinstance(requester, Requester), requester + + self._client_id = client_id + self._client_secret = client_secret + self._token = token + self._type = token_type or "bearer" + self._expires_at = expires_at + self._refresh_token = refresh_token + self._refresh_expires_at = refresh_expires_at + + if requester is not None: + self.withRequester(requester) + + @property + def token_type(self) -> str: + return self._type + + @property + def token(self) -> str: + if self._is_expired: + self._refresh() + return self._token + + def withRequester(self, requester: Requester) -> "AppUserAuth": + assert isinstance(requester, Requester), requester + super().withRequester(requester.withAuth(None)) + + # imported here to avoid circular import + from github.ApplicationOAuth import ApplicationOAuth + + self.__app = ApplicationOAuth( + # take requester given to super().withRequester, not given to this method + super().requester, + headers={}, + attributes={ + "client_id": self._client_id, + "client_secret": self._client_secret, + }, + ) + + return self + + @property + def _is_expired(self) -> bool: + return self._expires_at is not None and self._expires_at < datetime.now(timezone.utc) + + def _refresh(self) -> None: + if self._refresh_token is None: + raise RuntimeError("Cannot refresh expired token because no refresh token has been provided") + if self._refresh_expires_at is not None and self._refresh_expires_at < datetime.now(timezone.utc): + raise RuntimeError("Cannot refresh expired token because refresh token also expired") + + # refresh token + token = self.__app.refresh_access_token(self._refresh_token) + + # update this auth + self._token = token.token + self._type = token.type + self._scope = token.scope + self._expires_at = token.expires_at + self._refresh_token = token.refresh_token + self._refresh_expires_at = token.refresh_expires_at + + @property + def expires_at(self) -> Optional[datetime]: + return self._expires_at + + @property + def refresh_token(self) -> Optional[str]: + return self._refresh_token + + @property + def refresh_expires_at(self) -> Optional[datetime]: + return self._refresh_expires_at + + @property + def _masked_token(self) -> str: + return "Bearer (jwt removed)" + + +class NetrcAuth(HTTPBasicAuth, WithRequester["NetrcAuth"]): + """ + This class is used to authenticate via .netrc. + """ + + def __init__(self) -> None: + super().__init__() + + self._login: Optional[str] = None + self._password: Optional[str] = None + + @property + def username(self) -> str: + return self.login + + @property + def login(self) -> str: + assert self._login is not None, "Method withRequester(Requester) must be called first" + return self._login + + @property + def password(self) -> str: + assert self._password is not None, "Method withRequester(Requester) must be called first" + return self._password + + def withRequester(self, requester: Requester) -> "NetrcAuth": + assert isinstance(requester, Requester), requester + super().withRequester(requester) + + auth = utils.get_netrc_auth(requester.base_url, raise_errors=True) + if auth is None: + raise RuntimeError(f"Could not get credentials from netrc for host {requester.hostname}") + + self._login, self._password = auth + + return self diff --git a/venv/lib/python3.10/site-packages/github/AuthenticatedUser.py b/venv/lib/python3.10/site-packages/github/AuthenticatedUser.py new file mode 100644 index 0000000000000000000000000000000000000000..e1334b61f412347c202759325c73b1a7d38c578c --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/AuthenticatedUser.py @@ -0,0 +1,1167 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Steve English # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Cameron White # +# Copyright 2013 Vincent Jacques # +# Copyright 2013 poulp # +# Copyright 2014 Tomas Radej # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 E. Dunham # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2017 Balázs Rostás # +# Copyright 2017 Jannis Gebauer # +# Copyright 2017 Simon # +# Copyright 2018 Alice GIRARD # +# Copyright 2018 Bruce Richardson # +# Copyright 2018 Riccardo Pittau # +# Copyright 2018 Shubham Singh <41840111+singh811@users.noreply.github.com> # +# Copyright 2018 Steve Kowalik # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 bryanhuntesl <31992054+bryanhuntesl@users.noreply.github.com> # +# Copyright 2018 sfdye # +# Copyright 2019 Adam Baratz # +# Copyright 2019 Jamie van Brunschot # +# Copyright 2019 Jon Dufresne # +# Copyright 2019 Pavan Kunisetty # +# Copyright 2019 Rigas Papathanasopoulos # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Surya Teja <94suryateja@gmail.com> # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Anuj Bansal # +# Copyright 2020 Glenn McDonald # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 MeggyCal # +# Copyright 2021 Steve Kowalik # +# Copyright 2021 Yuya Nakamura # +# Copyright 2021 sshekdar-VMware <87147229+sshekdar-VMware@users.noreply.github.com># +# Copyright 2021 秋葉 # +# Copyright 2022 KimSia Sim <245021+simkimsia@users.noreply.github.com> # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Jonathan Leitschuh # +# Copyright 2023 Kevin Grandjean # +# Copyright 2023 Mark Amery # +# Copyright 2023 Trim21 # +# Copyright 2023 chantra # +# Copyright 2024 Chris Wells # +# Copyright 2024 Eduardo Ramírez # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Oskar Jansson <56458534+janssonoskar@users.noreply.github.com># +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +import urllib.parse +from datetime import datetime, timezone +from typing import TYPE_CHECKING, Any, NamedTuple + +import github.Authorization +import github.Event +import github.Gist +import github.GithubObject +import github.Invitation +import github.Issue +import github.Membership +import github.Migration +import github.NamedUser +import github.Notification +import github.Organization +import github.Plan +import github.Repository +import github.UserKey +from github import Consts +from github.GithubObject import ( + Attribute, + CompletableGithubObject, + NotSet, + Opt, + is_defined, + is_optional, + is_optional_list, + is_undefined, +) +from github.PaginatedList import PaginatedList + +if TYPE_CHECKING: + from github.Authorization import Authorization + from github.Event import Event + from github.Gist import Gist + from github.InputFileContent import InputFileContent + from github.Installation import Installation + from github.Invitation import Invitation + from github.Issue import Issue + from github.Label import Label + from github.Membership import Membership + from github.Migration import Migration + from github.NamedUser import NamedUser + from github.Notification import Notification + from github.Organization import Organization + from github.Plan import Plan + from github.Project import Project + from github.Repository import Repository + from github.Team import Team + from github.UserKey import UserKey + + +class EmailData(NamedTuple): + email: str + primary: bool + verified: bool + visibility: str + + +class AuthenticatedUser(CompletableGithubObject): + """ + This class represents AuthenticatedUsers as returned by https://docs.github.com/en/rest/reference/users#get-the-authenticated-user + + An AuthenticatedUser object can be created by calling ``get_user()`` on a Github object. + """ + + def _initAttributes(self) -> None: + self._avatar_url: Attribute[str] = NotSet + self._bio: Attribute[str] = NotSet + self._blog: Attribute[str] = NotSet + self._collaborators: Attribute[int] = NotSet + self._company: Attribute[str] = NotSet + self._created_at: Attribute[datetime] = NotSet + self._disk_usage: Attribute[int] = NotSet + self._email: Attribute[str] = NotSet + self._events_url: Attribute[str] = NotSet + self._followers: Attribute[int] = NotSet + self._followers_url: Attribute[str] = NotSet + self._following: Attribute[int] = NotSet + self._following_url: Attribute[str] = NotSet + self._gists_url: Attribute[str] = NotSet + self._gravatar_id: Attribute[str] = NotSet + self._hireable: Attribute[bool] = NotSet + self._html_url: Attribute[str] = NotSet + self._id: Attribute[int] = NotSet + self._location: Attribute[str] = NotSet + self._login: Attribute[str] = NotSet + self._name: Attribute[str] = NotSet + self._node_id: Attribute[str] = NotSet + self._organizations_url: Attribute[str] = NotSet + self._owned_private_repos: Attribute[int] = NotSet + self._plan: Attribute[github.Plan.Plan] = NotSet + self._private_gists: Attribute[int] = NotSet + self._public_gists: Attribute[int] = NotSet + self._public_repos: Attribute[int] = NotSet + self._received_events_url: Attribute[str] = NotSet + self._repos_url: Attribute[str] = NotSet + self._site_admin: Attribute[bool] = NotSet + self._starred_url: Attribute[str] = NotSet + self._subscriptions_url: Attribute[str] = NotSet + self._total_private_repos: Attribute[int] = NotSet + self._two_factor_authentication: Attribute[bool] = NotSet + self._type: Attribute[str] = NotSet + self._updated_at: Attribute[datetime] = NotSet + self._url: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"login": self._login.value}) + + @property + def avatar_url(self) -> str: + self._completeIfNotSet(self._avatar_url) + return self._avatar_url.value + + @property + def bio(self) -> str: + self._completeIfNotSet(self._bio) + return self._bio.value + + @property + def blog(self) -> str: + self._completeIfNotSet(self._blog) + return self._blog.value + + @property + def collaborators(self) -> int: + self._completeIfNotSet(self._collaborators) + return self._collaborators.value + + @property + def company(self) -> str: + self._completeIfNotSet(self._company) + return self._company.value + + @property + def created_at(self) -> datetime: + self._completeIfNotSet(self._created_at) + return self._created_at.value + + @property + def disk_usage(self) -> int: + self._completeIfNotSet(self._disk_usage) + return self._disk_usage.value + + @property + def email(self) -> str: + self._completeIfNotSet(self._email) + return self._email.value + + @property + def events_url(self) -> str: + self._completeIfNotSet(self._events_url) + return self._events_url.value + + @property + def followers(self) -> int: + self._completeIfNotSet(self._followers) + return self._followers.value + + @property + def followers_url(self) -> str: + self._completeIfNotSet(self._followers_url) + return self._followers_url.value + + @property + def following(self) -> int: + self._completeIfNotSet(self._following) + return self._following.value + + @property + def following_url(self) -> str: + self._completeIfNotSet(self._following_url) + return self._following_url.value + + @property + def gists_url(self) -> str: + self._completeIfNotSet(self._gists_url) + return self._gists_url.value + + @property + def gravatar_id(self) -> str: + self._completeIfNotSet(self._gravatar_id) + return self._gravatar_id.value + + @property + def hireable(self) -> bool: + self._completeIfNotSet(self._hireable) + return self._hireable.value + + @property + def html_url(self) -> str: + self._completeIfNotSet(self._html_url) + return self._html_url.value + + @property + def id(self) -> int: + self._completeIfNotSet(self._id) + return self._id.value + + @property + def location(self) -> str: + self._completeIfNotSet(self._location) + return self._location.value + + @property + def login(self) -> str: + self._completeIfNotSet(self._login) + return self._login.value + + @property + def name(self) -> str: + self._completeIfNotSet(self._name) + return self._name.value + + @property + def node_id(self) -> str: + self._completeIfNotSet(self._node_id) + return self._node_id.value + + @property + def organizations_url(self) -> str: + self._completeIfNotSet(self._organizations_url) + return self._organizations_url.value + + @property + def owned_private_repos(self) -> int: + self._completeIfNotSet(self._owned_private_repos) + return self._owned_private_repos.value + + @property + def plan(self) -> Plan: + self._completeIfNotSet(self._plan) + return self._plan.value + + @property + def private_gists(self) -> int: + self._completeIfNotSet(self._private_gists) + return self._private_gists.value + + @property + def public_gists(self) -> int: + self._completeIfNotSet(self._public_gists) + return self._public_gists.value + + @property + def public_repos(self) -> int: + self._completeIfNotSet(self._public_repos) + return self._public_repos.value + + @property + def received_events_url(self) -> str: + self._completeIfNotSet(self._received_events_url) + return self._received_events_url.value + + @property + def repos_url(self) -> str: + self._completeIfNotSet(self._repos_url) + return self._repos_url.value + + @property + def site_admin(self) -> bool: + self._completeIfNotSet(self._site_admin) + return self._site_admin.value + + @property + def starred_url(self) -> str: + self._completeIfNotSet(self._starred_url) + return self._starred_url.value + + @property + def subscriptions_url(self) -> str: + self._completeIfNotSet(self._subscriptions_url) + return self._subscriptions_url.value + + @property + def total_private_repos(self) -> int: + self._completeIfNotSet(self._total_private_repos) + return self._total_private_repos.value + + @property + def two_factor_authentication(self) -> bool: + self._completeIfNotSet(self._two_factor_authentication) + return self._two_factor_authentication.value + + @property + def type(self) -> str: + self._completeIfNotSet(self._type) + return self._type.value + + @property + def updated_at(self) -> datetime: + self._completeIfNotSet(self._updated_at) + return self._updated_at.value + + @property + def url(self) -> str: + self._completeIfNotSet(self._url) + return self._url.value + + def add_to_emails(self, *emails: str) -> None: + """ + :calls: `POST /user/emails `_ + """ + assert all(isinstance(element, str) for element in emails), emails + post_parameters = {"emails": emails} + headers, data = self._requester.requestJsonAndCheck("POST", "/user/emails", input=post_parameters) + + def add_to_following(self, following: NamedUser) -> None: + """ + :calls: `PUT /user/following/{user} `_ + """ + assert isinstance(following, github.NamedUser.NamedUser), following + headers, data = self._requester.requestJsonAndCheck("PUT", f"/user/following/{following._identity}") + + def add_to_starred(self, starred: Repository) -> None: + """ + :calls: `PUT /user/starred/{owner}/{repo} `_ + """ + assert isinstance(starred, github.Repository.Repository), starred + headers, data = self._requester.requestJsonAndCheck("PUT", f"/user/starred/{starred._identity}") + + def add_to_subscriptions(self, subscription: Repository) -> None: + """ + :calls: `PUT /user/subscriptions/{owner}/{repo} `_ + """ + assert isinstance(subscription, github.Repository.Repository), subscription + headers, data = self._requester.requestJsonAndCheck("PUT", f"/user/subscriptions/{subscription._identity}") + + def add_to_watched(self, watched: Repository) -> None: + """ + :calls: `PUT /repos/{owner}/{repo}/subscription `_ + """ + assert isinstance(watched, github.Repository.Repository), watched + headers, data = self._requester.requestJsonAndCheck( + "PUT", + f"/repos/{watched._identity}/subscription", + input={"subscribed": True}, + ) + + def create_authorization( + self, + scopes: Opt[list[str]] = NotSet, + note: Opt[str] = NotSet, + note_url: Opt[str] = NotSet, + client_id: Opt[str] = NotSet, + client_secret: Opt[str] = NotSet, + onetime_password: str | None = None, + ) -> Authorization: + """ + :calls: `POST /authorizations `_ + """ + assert is_optional_list(scopes, str), scopes + assert is_optional(note, str), note + assert is_optional(note_url, str), note_url + assert is_optional(client_id, str), client_id + assert is_optional(client_secret, str), client_secret + assert onetime_password is None or isinstance(onetime_password, str), onetime_password + post_parameters: dict[str, Any] = NotSet.remove_unset_items( + { + "scopes": scopes, + "note": note, + "note_url": note_url, + "client_id": client_id, + "client_secret": client_secret, + } + ) + + if onetime_password is not None: + request_header = {Consts.headerOTP: onetime_password} # pragma no cover (Should be covered) + else: + request_header = None + headers, data = self._requester.requestJsonAndCheck( + "POST", + "/authorizations", + input=post_parameters, + headers=request_header, + ) + return github.Authorization.Authorization(self._requester, headers, data, completed=True) + + @staticmethod + def create_fork( + repo: Repository, + name: Opt[str] = NotSet, + default_branch_only: Opt[bool] = NotSet, + ) -> Repository: + """ + :calls: `POST /repos/{owner}/{repo}/forks `_ + """ + assert isinstance(repo, github.Repository.Repository), repo + return repo.create_fork( + organization=github.GithubObject.NotSet, + name=name, + default_branch_only=default_branch_only, + ) + + def create_repo_from_template( + self, + name: str, + repo: Repository, + description: Opt[str] = NotSet, + include_all_branches: Opt[bool] = NotSet, + private: Opt[bool] = NotSet, + ) -> Repository: + """ + :calls: `POST /repos/{template_owner}/{template_repo}/generate `_ + """ + assert isinstance(name, str), name + assert isinstance(repo, github.Repository.Repository), repo + assert is_optional(description, str), description + assert is_optional(include_all_branches, bool), include_all_branches + assert is_optional(private, bool), private + post_parameters: dict[str, Any] = NotSet.remove_unset_items( + { + "name": name, + "owner": self.login, + "description": description, + "include_all_branches": include_all_branches, + "private": private, + } + ) + + headers, data = self._requester.requestJsonAndCheck( + "POST", + f"/repos/{repo.owner.login}/{repo.name}/generate", + input=post_parameters, + headers={"Accept": "application/vnd.github.v3+json"}, + ) + return github.Repository.Repository(self._requester, headers, data, completed=True) + + def create_gist( + self, + public: bool, + files: dict[str, InputFileContent], + description: Opt[str] = NotSet, + ) -> Gist: + """ + :calls: `POST /gists `_ + """ + assert isinstance(public, bool), public + assert all(isinstance(element, github.InputFileContent) for element in files.values()), files + assert is_undefined(description) or isinstance(description, str), description + post_parameters = { + "public": public, + "files": {key: value._identity for key, value in files.items()}, + } + if is_defined(description): + post_parameters["description"] = description + headers, data = self._requester.requestJsonAndCheck("POST", "/gists", input=post_parameters) + return github.Gist.Gist(self._requester, headers, data, completed=True) + + def create_key(self, title: str, key: str) -> UserKey: + """ + :calls: `POST /user/keys `_ + :param title: string + :param key: string + :rtype: :class:`github.UserKey.UserKey` + """ + assert isinstance(title, str), title + assert isinstance(key, str), key + post_parameters = { + "title": title, + "key": key, + } + headers, data = self._requester.requestJsonAndCheck("POST", "/user/keys", input=post_parameters) + return github.UserKey.UserKey(self._requester, headers, data, completed=True) + + def create_project(self, name: str, body: Opt[str] = NotSet) -> Project: + """ + :calls: `POST /user/projects `_ + :param name: string + :param body: string + :rtype: :class:`github.Project.Project` + """ + assert isinstance(name, str), name + assert is_undefined(body) or isinstance(body, str), body + post_parameters = { + "name": name, + "body": body, + } + headers, data = self._requester.requestJsonAndCheck( + "POST", + "/user/projects", + input=post_parameters, + headers={"Accept": Consts.mediaTypeProjectsPreview}, + ) + return github.Project.Project(self._requester, headers, data, completed=True) + + def create_repo( + self, + name: str, + description: Opt[str] = NotSet, + homepage: Opt[str] = NotSet, + private: Opt[bool] = NotSet, + has_issues: Opt[bool] = NotSet, + has_wiki: Opt[bool] = NotSet, + has_downloads: Opt[bool] = NotSet, + has_projects: Opt[bool] = NotSet, + has_discussions: Opt[bool] = NotSet, + auto_init: Opt[bool] = NotSet, + license_template: Opt[str] = NotSet, + gitignore_template: Opt[str] = NotSet, + allow_squash_merge: Opt[bool] = NotSet, + allow_merge_commit: Opt[bool] = NotSet, + allow_rebase_merge: Opt[bool] = NotSet, + delete_branch_on_merge: Opt[bool] = NotSet, + ) -> Repository: + """ + :calls: `POST /user/repos `_ + """ + assert isinstance(name, str), name + assert is_optional(description, str), description + assert is_optional(homepage, str), homepage + assert is_optional(private, bool), private + assert is_optional(has_issues, bool), has_issues + assert is_optional(has_wiki, bool), has_wiki + assert is_optional(has_downloads, bool), has_downloads + assert is_optional(has_projects, bool), has_projects + assert is_optional(has_discussions, bool), has_discussions + assert is_optional(auto_init, bool), auto_init + assert is_optional(license_template, str), license_template + assert is_optional(gitignore_template, str), gitignore_template + assert is_optional(allow_squash_merge, bool), allow_squash_merge + assert is_optional(allow_merge_commit, bool), allow_merge_commit + assert is_optional(allow_rebase_merge, bool), allow_rebase_merge + assert is_optional(delete_branch_on_merge, bool), delete_branch_on_merge + post_parameters: dict[str, Any] = NotSet.remove_unset_items( + { + "name": name, + "description": description, + "homepage": homepage, + "private": private, + "has_issues": has_issues, + "has_wiki": has_wiki, + "has_downloads": has_downloads, + "has_projects": has_projects, + "has_discussions": has_discussions, + "auto_init": auto_init, + "license_template": license_template, + "gitignore_template": gitignore_template, + "allow_squash_merge": allow_squash_merge, + "allow_merge_commit": allow_merge_commit, + "allow_rebase_merge": allow_rebase_merge, + "delete_branch_on_merge": delete_branch_on_merge, + } + ) + + headers, data = self._requester.requestJsonAndCheck("POST", "/user/repos", input=post_parameters) + return github.Repository.Repository(self._requester, headers, data, completed=True) + + def edit( + self, + name: Opt[str] = NotSet, + email: Opt[str] = NotSet, + blog: Opt[str] = NotSet, + company: Opt[str] = NotSet, + location: Opt[str] = NotSet, + hireable: Opt[bool] = NotSet, + bio: Opt[str] = NotSet, + ) -> None: + """ + :calls: `PATCH /user `_ + """ + assert is_optional(name, str), name + assert is_optional(email, str), email + assert is_optional(blog, str), blog + assert is_optional(company, str), company + assert is_optional(location, str), location + assert is_optional(hireable, bool), hireable + assert is_optional(bio, str), bio + post_parameters: dict[str, Any] = NotSet.remove_unset_items( + { + "name": name, + "email": email, + "blog": blog, + "company": company, + "location": location, + "hireable": hireable, + "bio": bio, + } + ) + + headers, data = self._requester.requestJsonAndCheck("PATCH", "/user", input=post_parameters) + self._useAttributes(data) + + def get_authorization(self, id: int) -> Authorization: + """ + :calls: `GET /authorizations/{id} `_ + """ + assert isinstance(id, int), id + headers, data = self._requester.requestJsonAndCheck("GET", f"/authorizations/{id}") + return github.Authorization.Authorization(self._requester, headers, data, completed=True) + + def get_authorizations(self) -> PaginatedList[Authorization]: + """ + :calls: `GET /authorizations `_ + """ + return PaginatedList(github.Authorization.Authorization, self._requester, "/authorizations", None) + + def get_emails(self) -> list[EmailData]: + """ + :calls: `GET /user/emails `_ + """ + headers, data = self._requester.requestJsonAndCheck("GET", "/user/emails") + return [EmailData(**item) for item in data] + + def get_events(self) -> PaginatedList[Event]: + """ + :calls: `GET /events `_ + """ + return PaginatedList(github.Event.Event, self._requester, "/events", None) + + def get_followers(self) -> PaginatedList[NamedUser]: + """ + :calls: `GET /user/followers `_ + """ + return PaginatedList(github.NamedUser.NamedUser, self._requester, "/user/followers", None) + + def get_following(self) -> PaginatedList[NamedUser]: + """ + :calls: `GET /user/following `_ + """ + return PaginatedList(github.NamedUser.NamedUser, self._requester, "/user/following", None) + + def get_gists(self, since: Opt[datetime] = NotSet) -> PaginatedList[Gist]: + """ + :calls: `GET /gists `_ + :param since: datetime format YYYY-MM-DDTHH:MM:SSZ + :rtype: :class:`PaginatedList` of :class:`github.Gist.Gist` + """ + assert is_optional(since, datetime), since + url_parameters: dict[str, Any] = {} + if is_defined(since): + url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") + return PaginatedList(github.Gist.Gist, self._requester, "/gists", url_parameters) + + def get_issues( + self, + filter: Opt[str] = NotSet, + state: Opt[str] = NotSet, + labels: Opt[list[Label]] = NotSet, + sort: Opt[str] = NotSet, + direction: Opt[str] = NotSet, + since: Opt[datetime] = NotSet, + ) -> PaginatedList[Issue]: + """ + :calls: `GET /issues `_ + """ + assert is_optional(filter, str), filter + assert is_optional(state, str), state + assert is_optional_list(labels, github.Label.Label), labels + assert is_optional(sort, str), sort + assert is_optional(direction, str), direction + assert is_optional(since, datetime), since + url_parameters: dict[str, Any] = {} + if is_defined(filter): + url_parameters["filter"] = filter + if is_defined(state): + url_parameters["state"] = state + if is_defined(labels): + url_parameters["labels"] = ",".join(label.name for label in labels) + if is_defined(sort): + url_parameters["sort"] = sort + if is_defined(direction): + url_parameters["direction"] = direction + if is_defined(since): + url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") + return PaginatedList(github.Issue.Issue, self._requester, "/issues", url_parameters) + + def get_user_issues( + self, + filter: Opt[str] = NotSet, + state: Opt[str] = NotSet, + labels: Opt[list[Label]] = NotSet, + sort: Opt[str] = NotSet, + direction: Opt[str] = NotSet, + since: Opt[datetime] = NotSet, + ) -> PaginatedList[Issue]: + """ + :calls: `GET /user/issues `_ + """ + assert is_optional(filter, str), filter + assert is_optional(state, str), state + assert is_optional_list(labels, github.Label.Label), labels + assert is_optional(sort, str), sort + assert is_optional(direction, str), direction + assert is_optional(since, datetime), since + url_parameters: dict[str, Any] = {} + if is_defined(filter): + url_parameters["filter"] = filter + if is_defined(state): + url_parameters["state"] = state + if is_defined(labels): + url_parameters["labels"] = ",".join(label.name for label in labels) + if is_defined(sort): + url_parameters["sort"] = sort + if is_defined(direction): + url_parameters["direction"] = direction + if is_defined(since): + url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") + return PaginatedList(github.Issue.Issue, self._requester, "/user/issues", url_parameters) + + def get_key(self, id: int) -> UserKey: + """ + :calls: `GET /user/keys/{id} `_ + """ + assert isinstance(id, int), id + headers, data = self._requester.requestJsonAndCheck("GET", f"/user/keys/{id}") + return github.UserKey.UserKey(self._requester, headers, data, completed=True) + + def get_keys(self) -> PaginatedList[UserKey]: + """ + :calls: `GET /user/keys `_ + """ + return PaginatedList(github.UserKey.UserKey, self._requester, "/user/keys", None) + + def get_notification(self, id: str) -> Notification: + """ + :calls: `GET /notifications/threads/{id} `_ + """ + + assert isinstance(id, str), id + headers, data = self._requester.requestJsonAndCheck("GET", f"/notifications/threads/{id}") + return github.Notification.Notification(self._requester, headers, data, completed=True) + + def get_notifications( + self, + all: Opt[bool] = NotSet, + participating: Opt[bool] = NotSet, + since: Opt[datetime] = NotSet, + before: Opt[datetime] = NotSet, + ) -> PaginatedList[Notification]: + """ + :calls: `GET /notifications `_ + """ + + assert is_optional(all, bool), all + assert is_optional(participating, bool), participating + assert is_optional(since, datetime), since + assert is_optional(before, datetime), before + + params: dict[str, Any] = {} + if is_defined(all): + # convert True, False to true, false for api parameters + params["all"] = "true" if all else "false" + if is_defined(participating): + # convert True, False to true, false for api parameters + params["participating"] = "true" if participating else "false" + if is_defined(since): + params["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") + if is_defined(before): + params["before"] = before.strftime("%Y-%m-%dT%H:%M:%SZ") + + return PaginatedList(github.Notification.Notification, self._requester, "/notifications", params) + + def get_organization_events(self, org: Organization) -> PaginatedList[Event]: + """ + :calls: `GET /users/{user}/events/orgs/{org} `_ + """ + assert isinstance(org, github.Organization.Organization), org + return PaginatedList( + github.Event.Event, + self._requester, + f"/users/{self.login}/events/orgs/{org.login}", + None, + ) + + def get_orgs(self) -> PaginatedList[Organization]: + """ + :calls: `GET /user/orgs `_ + """ + return PaginatedList(github.Organization.Organization, self._requester, "/user/orgs", None) + + def get_repo(self, name: str) -> Repository: + """ + :calls: `GET /repos/{owner}/{repo} `_ + """ + assert isinstance(name, str), name + name = urllib.parse.quote(name) + headers, data = self._requester.requestJsonAndCheck("GET", f"/repos/{self.login}/{name}") + return github.Repository.Repository(self._requester, headers, data, completed=True) + + def get_repos( + self, + visibility: Opt[str] = NotSet, + affiliation: Opt[str] = NotSet, + type: Opt[str] = NotSet, + sort: Opt[str] = NotSet, + direction: Opt[str] = NotSet, + ) -> PaginatedList[Repository]: + """ + :calls: `GET /user/repos `_ + """ + assert is_optional(visibility, str), visibility + assert is_optional(affiliation, str), affiliation + assert is_optional(type, str), type + assert is_optional(sort, str), sort + assert is_optional(direction, str), direction + url_parameters = NotSet.remove_unset_items( + { + "visibility": visibility, + "affiliation": affiliation, + "type": type, + "sort": sort, + "direction": direction, + } + ) + return PaginatedList(github.Repository.Repository, self._requester, "/user/repos", url_parameters) + + def get_starred(self) -> PaginatedList[Repository]: + """ + :calls: `GET /user/starred `_ + """ + return PaginatedList(github.Repository.Repository, self._requester, "/user/starred", None) + + def get_starred_gists(self) -> PaginatedList[Gist]: + """ + :calls: `GET /gists/starred `_ + """ + return PaginatedList(github.Gist.Gist, self._requester, "/gists/starred", None) + + def get_subscriptions(self) -> PaginatedList[Repository]: + """ + :calls: `GET /user/subscriptions `_ + """ + return PaginatedList(github.Repository.Repository, self._requester, "/user/subscriptions", None) + + def get_teams(self) -> PaginatedList[Team]: + """ + :calls: `GET /user/teams `_ + """ + return PaginatedList(github.Team.Team, self._requester, "/user/teams", None) + + def get_watched(self) -> PaginatedList[Repository]: + """ + :calls: `GET /user/subscriptions `_ + """ + return PaginatedList(github.Repository.Repository, self._requester, "/user/subscriptions", None) + + def get_installations(self) -> PaginatedList[Installation]: + """ + :calls: `GET /user/installations `_ + """ + return PaginatedList( + github.Installation.Installation, + self._requester, + "/user/installations", + None, + headers={"Accept": Consts.mediaTypeIntegrationPreview}, + list_item="installations", + ) + + def has_in_following(self, following: NamedUser) -> bool: + """ + :calls: `GET /user/following/{user} `_ + """ + assert isinstance(following, github.NamedUser.NamedUser), following + status, headers, data = self._requester.requestJson("GET", f"/user/following/{following._identity}") + return status == 204 + + def has_in_starred(self, starred: Repository) -> bool: + """ + :calls: `GET /user/starred/{owner}/{repo} `_ + """ + assert isinstance(starred, github.Repository.Repository), starred + status, headers, data = self._requester.requestJson("GET", f"/user/starred/{starred._identity}") + return status == 204 + + def has_in_subscriptions(self, subscription: Repository) -> bool: + """ + :calls: `GET /user/subscriptions/{owner}/{repo} `_ + """ + assert isinstance(subscription, github.Repository.Repository), subscription + status, headers, data = self._requester.requestJson("GET", f"/user/subscriptions/{subscription._identity}") + return status == 204 + + def has_in_watched(self, watched: Repository) -> bool: + """ + :calls: `GET /repos/{owner}/{repo}/subscription `_ + """ + assert isinstance(watched, github.Repository.Repository), watched + status, headers, data = self._requester.requestJson("GET", f"/repos/{watched._identity}/subscription") + return status == 200 + + def mark_notifications_as_read(self, last_read_at: datetime | None = None) -> None: + """ + :calls: `PUT /notifications `_ + """ + if last_read_at is None: + last_read_at = datetime.now(timezone.utc) + assert isinstance(last_read_at, datetime) + put_parameters = {"last_read_at": last_read_at.strftime("%Y-%m-%dT%H:%M:%SZ")} + + headers, data = self._requester.requestJsonAndCheck("PUT", "/notifications", input=put_parameters) + + def remove_from_emails(self, *emails: str) -> None: + """ + :calls: `DELETE /user/emails `_ + """ + assert all(isinstance(element, str) for element in emails), emails + post_parameters = {"emails": emails} + headers, data = self._requester.requestJsonAndCheck("DELETE", "/user/emails", input=post_parameters) + + def remove_from_following(self, following: NamedUser) -> None: + """ + :calls: `DELETE /user/following/{user} `_ + """ + assert isinstance(following, github.NamedUser.NamedUser), following + headers, data = self._requester.requestJsonAndCheck("DELETE", f"/user/following/{following._identity}") + + def remove_from_starred(self, starred: Repository) -> None: + """ + :calls: `DELETE /user/starred/{owner}/{repo} `_ + """ + assert isinstance(starred, github.Repository.Repository), starred + headers, data = self._requester.requestJsonAndCheck("DELETE", f"/user/starred/{starred._identity}") + + def remove_from_subscriptions(self, subscription: Repository) -> None: + """ + :calls: `DELETE /user/subscriptions/{owner}/{repo} `_ + """ + assert isinstance(subscription, github.Repository.Repository), subscription + headers, data = self._requester.requestJsonAndCheck("DELETE", f"/user/subscriptions/{subscription._identity}") + + def remove_from_watched(self, watched: Repository) -> None: + """ + :calls: `DELETE /repos/{owner}/{repo}/subscription `_ + """ + assert isinstance(watched, github.Repository.Repository), watched + headers, data = self._requester.requestJsonAndCheck("DELETE", f"/repos/{watched._identity}/subscription") + + def accept_invitation(self, invitation: Invitation | int) -> None: + """ + :calls: `PATCH /user/repository_invitations/{invitation_id} `_ + """ + assert isinstance(invitation, github.Invitation.Invitation) or isinstance(invitation, int) + + if isinstance(invitation, github.Invitation.Invitation): + invitation = invitation.id + + headers, data = self._requester.requestJsonAndCheck( + "PATCH", f"/user/repository_invitations/{invitation}", input={} + ) + + def get_invitations(self) -> PaginatedList[Invitation]: + """ + :calls: `GET /user/repository_invitations `_ + """ + return PaginatedList( + github.Invitation.Invitation, + self._requester, + "/user/repository_invitations", + None, + ) + + def create_migration( + self, + repos: list[Repository] | tuple[Repository], + lock_repositories: Opt[bool] = NotSet, + exclude_attachments: Opt[bool] = NotSet, + ) -> Migration: + """ + :calls: `POST /user/migrations `_ + """ + assert isinstance(repos, (list, tuple)), repos + assert all(isinstance(repo, str) for repo in repos), repos + assert is_optional(lock_repositories, bool), lock_repositories + assert is_optional(exclude_attachments, bool), exclude_attachments + post_parameters: dict[str, Any] = NotSet.remove_unset_items( + { + "repositories": repos, + "lock_repositories": lock_repositories, + "exclude_attachments": exclude_attachments, + } + ) + + headers, data = self._requester.requestJsonAndCheck( + "POST", + "/user/migrations", + input=post_parameters, + headers={"Accept": Consts.mediaTypeMigrationPreview}, + ) + return github.Migration.Migration(self._requester, headers, data, completed=True) + + def get_migrations(self) -> PaginatedList[Migration]: + """ + :calls: `GET /user/migrations `_ + """ + return PaginatedList( + github.Migration.Migration, + self._requester, + "/user/migrations", + None, + headers={"Accept": Consts.mediaTypeMigrationPreview}, + ) + + def get_organization_memberships(self) -> PaginatedList[Membership]: + """ + :calls: `GET /user/memberships/orgs/ `_ + """ + return PaginatedList( + github.Membership.Membership, + self._requester, + "/user/memberships/orgs", + None, + ) + + def get_organization_membership(self, org: str) -> Membership: + """ + :calls: `GET /user/memberships/orgs/{org} `_ + """ + assert isinstance(org, str) + org = urllib.parse.quote(org) + headers, data = self._requester.requestJsonAndCheck("GET", f"/user/memberships/orgs/{org}") + return github.Membership.Membership(self._requester, headers, data, completed=True) + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "avatar_url" in attributes: # pragma no branch + self._avatar_url = self._makeStringAttribute(attributes["avatar_url"]) + if "bio" in attributes: # pragma no branch + self._bio = self._makeStringAttribute(attributes["bio"]) + if "blog" in attributes: # pragma no branch + self._blog = self._makeStringAttribute(attributes["blog"]) + if "collaborators" in attributes: # pragma no branch + self._collaborators = self._makeIntAttribute(attributes["collaborators"]) + if "company" in attributes: # pragma no branch + self._company = self._makeStringAttribute(attributes["company"]) + if "created_at" in attributes: # pragma no branch + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) + if "disk_usage" in attributes: # pragma no branch + self._disk_usage = self._makeIntAttribute(attributes["disk_usage"]) + if "email" in attributes: # pragma no branch + self._email = self._makeStringAttribute(attributes["email"]) + if "events_url" in attributes: # pragma no branch + self._events_url = self._makeStringAttribute(attributes["events_url"]) + if "followers" in attributes: # pragma no branch + self._followers = self._makeIntAttribute(attributes["followers"]) + if "followers_url" in attributes: # pragma no branch + self._followers_url = self._makeStringAttribute(attributes["followers_url"]) + if "following" in attributes: # pragma no branch + self._following = self._makeIntAttribute(attributes["following"]) + if "following_url" in attributes: # pragma no branch + self._following_url = self._makeStringAttribute(attributes["following_url"]) + if "gists_url" in attributes: # pragma no branch + self._gists_url = self._makeStringAttribute(attributes["gists_url"]) + if "gravatar_id" in attributes: # pragma no branch + self._gravatar_id = self._makeStringAttribute(attributes["gravatar_id"]) + if "hireable" in attributes: # pragma no branch + self._hireable = self._makeBoolAttribute(attributes["hireable"]) + if "html_url" in attributes: # pragma no branch + self._html_url = self._makeStringAttribute(attributes["html_url"]) + if "id" in attributes: # pragma no branch + self._id = self._makeIntAttribute(attributes["id"]) + if "location" in attributes: # pragma no branch + self._location = self._makeStringAttribute(attributes["location"]) + if "login" in attributes: # pragma no branch + self._login = self._makeStringAttribute(attributes["login"]) + if "name" in attributes: # pragma no branch + self._name = self._makeStringAttribute(attributes["name"]) + if "node_id" in attributes: # pragma no branch + self._node_id = self._makeStringAttribute(attributes["node_id"]) + if "organizations_url" in attributes: # pragma no branch + self._organizations_url = self._makeStringAttribute(attributes["organizations_url"]) + if "owned_private_repos" in attributes: # pragma no branch + self._owned_private_repos = self._makeIntAttribute(attributes["owned_private_repos"]) + if "plan" in attributes: # pragma no branch + self._plan = self._makeClassAttribute(github.Plan.Plan, attributes["plan"]) + if "private_gists" in attributes: # pragma no branch + self._private_gists = self._makeIntAttribute(attributes["private_gists"]) + if "public_gists" in attributes: # pragma no branch + self._public_gists = self._makeIntAttribute(attributes["public_gists"]) + if "public_repos" in attributes: # pragma no branch + self._public_repos = self._makeIntAttribute(attributes["public_repos"]) + if "received_events_url" in attributes: # pragma no branch + self._received_events_url = self._makeStringAttribute(attributes["received_events_url"]) + if "repos_url" in attributes: # pragma no branch + self._repos_url = self._makeStringAttribute(attributes["repos_url"]) + if "site_admin" in attributes: # pragma no branch + self._site_admin = self._makeBoolAttribute(attributes["site_admin"]) + if "starred_url" in attributes: # pragma no branch + self._starred_url = self._makeStringAttribute(attributes["starred_url"]) + if "subscriptions_url" in attributes: # pragma no branch + self._subscriptions_url = self._makeStringAttribute(attributes["subscriptions_url"]) + if "total_private_repos" in attributes: # pragma no branch + self._total_private_repos = self._makeIntAttribute(attributes["total_private_repos"]) + if "two_factor_authentication" in attributes: + self._two_factor_authentication = self._makeBoolAttribute(attributes["two_factor_authentication"]) + if "type" in attributes: # pragma no branch + self._type = self._makeStringAttribute(attributes["type"]) + if "updated_at" in attributes: # pragma no branch + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) + if "url" in attributes: # pragma no branch + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/venv/lib/python3.10/site-packages/github/Authorization.py b/venv/lib/python3.10/site-packages/github/Authorization.py new file mode 100644 index 0000000000000000000000000000000000000000..2dbd2505aa990bb732959409a20bf04146183d61 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/Authorization.py @@ -0,0 +1,191 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from datetime import datetime +from typing import TYPE_CHECKING, Any + +import github.AuthorizationApplication +import github.GithubObject +from github.GithubObject import Attribute, NotSet, Opt, _NotSetType + +if TYPE_CHECKING: + from github.AuthorizationApplication import AuthorizationApplication + + +class Authorization(github.GithubObject.CompletableGithubObject): + """ + This class represents Authorizations. + + The reference can be found here + https://docs.github.com/en/enterprise-server@3.0/rest/reference/oauth-authorizations + + """ + + def _initAttributes(self) -> None: + self._app: Attribute[AuthorizationApplication] = NotSet + self._created_at: Attribute[datetime] = NotSet + self._id: Attribute[int] = NotSet + self._note: Attribute[str | None] = NotSet + self._note_url: Attribute[str | None] = NotSet + self._scopes: Attribute[str] = NotSet + self._token: Attribute[str] = NotSet + self._updated_at: Attribute[datetime] = NotSet + self._url: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"scopes": self._scopes.value}) + + @property + def app(self) -> AuthorizationApplication: + self._completeIfNotSet(self._app) + return self._app.value + + @property + def created_at(self) -> datetime: + """ + :type: datetime.datetime + """ + self._completeIfNotSet(self._created_at) + return self._created_at.value + + @property + def id(self) -> int: + self._completeIfNotSet(self._id) + return self._id.value + + @property + def note(self) -> str | None: + self._completeIfNotSet(self._note) + return self._note.value + + @property + def note_url(self) -> str | None: + self._completeIfNotSet(self._note_url) + return self._note_url.value + + @property + def scopes(self) -> str: + self._completeIfNotSet(self._scopes) + return self._scopes.value + + @property + def token(self) -> str: + self._completeIfNotSet(self._token) + return self._token.value + + @property + def updated_at(self) -> datetime: + self._completeIfNotSet(self._updated_at) + return self._updated_at.value + + @property + def url(self) -> str: + self._completeIfNotSet(self._url) + return self._url.value + + def delete(self) -> None: + """ + :calls: `DELETE /authorizations/{id} `_ + """ + headers, data = self._requester.requestJsonAndCheck("DELETE", self.url) + + def edit( + self, + scopes: Opt[list[str]] = NotSet, + add_scopes: Opt[list[str]] = NotSet, + remove_scopes: Opt[list[str]] = NotSet, + note: Opt[str] = NotSet, + note_url: Opt[str] = NotSet, + ) -> None: + """ + :calls: `PATCH /authorizations/{id} `_ + :param scopes: list of string + :param add_scopes: list of string + :param remove_scopes: list of string + :param note: string + :param note_url: string + :rtype: None + """ + assert isinstance(scopes, _NotSetType) or all(isinstance(element, str) for element in scopes), scopes + assert isinstance(add_scopes, _NotSetType) or all( + isinstance(element, str) for element in add_scopes + ), add_scopes + assert isinstance(remove_scopes, _NotSetType) or all( + isinstance(element, str) for element in remove_scopes + ), remove_scopes + assert isinstance(note, (_NotSetType, str)), note + assert isinstance(note_url, (_NotSetType, str)), note_url + + post_parameters = NotSet.remove_unset_items( + { + "scopes": scopes, + "add_scopes": add_scopes, + "remove_scopes": remove_scopes, + "note": note, + "note_url": note_url, + } + ) + + headers, data = self._requester.requestJsonAndCheck("PATCH", self.url, input=post_parameters) + self._useAttributes(data) + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "app" in attributes: # pragma no branch + self._app = self._makeClassAttribute( + github.AuthorizationApplication.AuthorizationApplication, + attributes["app"], + ) + if "created_at" in attributes: # pragma no branch + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) + if "id" in attributes: # pragma no branch + self._id = self._makeIntAttribute(attributes["id"]) + if "note" in attributes: # pragma no branch + self._note = self._makeStringAttribute(attributes["note"]) + if "note_url" in attributes: # pragma no branch + self._note_url = self._makeStringAttribute(attributes["note_url"]) + if "scopes" in attributes: # pragma no branch + self._scopes = self._makeListOfStringsAttribute(attributes["scopes"]) + if "token" in attributes: # pragma no branch + self._token = self._makeStringAttribute(attributes["token"]) + if "updated_at" in attributes: # pragma no branch + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) + if "url" in attributes: # pragma no branch + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/venv/lib/python3.10/site-packages/github/AuthorizationApplication.py b/venv/lib/python3.10/site-packages/github/AuthorizationApplication.py new file mode 100644 index 0000000000000000000000000000000000000000..afeaa97a386cdc811c58724368d4a0c5648654ba --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/AuthorizationApplication.py @@ -0,0 +1,69 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from typing import Any, Dict + +from github.GithubObject import Attribute, CompletableGithubObject, NotSet + + +class AuthorizationApplication(CompletableGithubObject): + """ + This class represents AuthorizationApplications. + """ + + def _initAttributes(self) -> None: + self._name: Attribute[str] = NotSet + self._url: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"name": self._name.value}) + + @property + def name(self) -> str: + self._completeIfNotSet(self._name) + return self._name.value + + @property + def url(self) -> str: + self._completeIfNotSet(self._url) + return self._url.value + + def _useAttributes(self, attributes: Dict[str, Any]) -> None: + if "name" in attributes: # pragma no branch + self._name = self._makeStringAttribute(attributes["name"]) + if "url" in attributes: # pragma no branch + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/venv/lib/python3.10/site-packages/github/Autolink.py b/venv/lib/python3.10/site-packages/github/Autolink.py new file mode 100644 index 0000000000000000000000000000000000000000..27a6bea89cd525df8400573045a2180422736963 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/Autolink.py @@ -0,0 +1,92 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Adam Baratz # +# Copyright 2019 Nick Campbell # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Steve Kowalik # +# Copyright 2022 Marco Köpcke # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Oskar Jansson <56458534+janssonoskar@users.noreply.github.com># +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from typing import Any, Dict + +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + + +class Autolink(NonCompletableGithubObject): + """ + This class represents Repository autolinks. + + The reference can be found here + https://docs.github.com/en/rest/repos/autolinks?apiVersion=2022-11-28 + + The OpenAPI schema can be found at + - /components/schemas/autolink + + """ + + def _initAttributes(self) -> None: + self._id: Attribute[int] = NotSet + self._is_alphanumeric: Attribute[bool] = NotSet + self._key_prefix: Attribute[str] = NotSet + self._url_template: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"id": self._id.value}) + + @property + def id(self) -> int: + return self._id.value + + @property + def is_alphanumeric(self) -> bool: + return self._is_alphanumeric.value + + @property + def key_prefix(self) -> str: + return self._key_prefix.value + + @property + def url_template(self) -> str: + return self._url_template.value + + def _useAttributes(self, attributes: Dict[str, Any]) -> None: + if "id" in attributes: # pragma no branch + self._id = self._makeIntAttribute(attributes["id"]) + if "is_alphanumeric" in attributes: # pragma no branch + self._is_alphanumeric = self._makeBoolAttribute(attributes["is_alphanumeric"]) + if "key_prefix" in attributes: # pragma no branch + self._key_prefix = self._makeStringAttribute(attributes["key_prefix"]) + if "url_template" in attributes: # pragma no branch + self._url_template = self._makeStringAttribute(attributes["url_template"]) diff --git a/venv/lib/python3.10/site-packages/github/Branch.py b/venv/lib/python3.10/site-packages/github/Branch.py new file mode 100644 index 0000000000000000000000000000000000000000..f77116f79d6b15d92d2b7662a72e1427ffc8c7a8 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/Branch.py @@ -0,0 +1,657 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2013 martinqt # +# Copyright 2014 Vincent Jacques # +# Copyright 2015 Kyle Hornberg # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Alice GIRARD # +# Copyright 2018 Steve Kowalik # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Mark Walker # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Juan Manuel "Kang" Pérez # +# Copyright 2023 Kevin Grandjean # +# Copyright 2023 Paul Luna # +# Copyright 2023 Thomas Devoogdt # +# Copyright 2023 Trim21 # +# Copyright 2023 terenho <33275803+terenho@users.noreply.github.com> # +# Copyright 2024 Benjamin K <53038537+treee111@users.noreply.github.com> # +# Copyright 2024 Benjamin K. <53038537+treee111@users.noreply.github.com> # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from typing import TYPE_CHECKING, Any + +import github.BranchProtection +import github.Commit +import github.RequiredPullRequestReviews +import github.RequiredStatusChecks +from github import Consts +from github.GithubObject import ( + Attribute, + NonCompletableGithubObject, + NotSet, + Opt, + is_defined, + is_optional, + is_optional_list, + is_undefined, +) + +if TYPE_CHECKING: + from github.BranchProtection import BranchProtection + from github.Commit import Commit + from github.NamedUser import NamedUser + from github.PaginatedList import PaginatedList + from github.RequiredPullRequestReviews import RequiredPullRequestReviews + from github.RequiredStatusChecks import RequiredStatusChecks + from github.Team import Team + + +class Branch(NonCompletableGithubObject): + """ + This class represents Branches. + + The reference can be found here + https://docs.github.com/en/rest/reference/repos#branches + + The OpenAPI schema can be found at + - /components/schemas/branch-short + - /components/schemas/branch-with-protection + - /components/schemas/short-branch + + """ + + def _initAttributes(self) -> None: + self.__links: Attribute[dict[str, Any]] = NotSet + self._commit: Attribute[Commit] = github.GithubObject.NotSet + self._name: Attribute[str] = github.GithubObject.NotSet + self._pattern: Attribute[str] = NotSet + self._protected: Attribute[bool] = github.GithubObject.NotSet + self._protection: Attribute[BranchProtection] = NotSet + self._protection_url: Attribute[str] = github.GithubObject.NotSet + self._required_approving_review_count: Attribute[int] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"name": self._name.value}) + + @property + def _links(self) -> dict[str, Any]: + return self.__links.value + + @property + def commit(self) -> Commit: + return self._commit.value + + @property + def name(self) -> str: + return self._name.value + + @property + def pattern(self) -> str: + return self._pattern.value + + @property + def protected(self) -> bool: + return self._protected.value + + @property + def protection(self) -> BranchProtection: + if is_undefined(self._protection): + return self.get_protection() + return self._protection.value + + @property + def protection_url(self) -> str: + return self._protection_url.value + + @property + def required_approving_review_count(self) -> int: + return self._required_approving_review_count.value + + def get_protection(self) -> BranchProtection: + """ + :calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection `_ + """ + headers, data = self._requester.requestJsonAndCheck( + "GET", + self.protection_url, + headers={"Accept": Consts.mediaTypeRequireMultipleApprovingReviews}, + ) + return github.BranchProtection.BranchProtection(self._requester, headers, data, completed=True) + + def edit_protection( + self, + strict: Opt[bool] = NotSet, + contexts: Opt[list[str]] = NotSet, + enforce_admins: Opt[bool] = NotSet, + dismissal_users: Opt[list[str]] = NotSet, + dismissal_teams: Opt[list[str]] = NotSet, + dismissal_apps: Opt[list[str]] = NotSet, + dismiss_stale_reviews: Opt[bool] = NotSet, + require_code_owner_reviews: Opt[bool] = NotSet, + required_approving_review_count: Opt[int] = NotSet, + user_push_restrictions: Opt[list[str]] = NotSet, + team_push_restrictions: Opt[list[str]] = NotSet, + app_push_restrictions: Opt[list[str]] = NotSet, + required_linear_history: Opt[bool] = NotSet, + allow_force_pushes: Opt[bool] = NotSet, + required_conversation_resolution: Opt[bool] = NotSet, + lock_branch: Opt[bool] = NotSet, + allow_fork_syncing: Opt[bool] = NotSet, + users_bypass_pull_request_allowances: Opt[list[str]] = NotSet, + teams_bypass_pull_request_allowances: Opt[list[str]] = NotSet, + apps_bypass_pull_request_allowances: Opt[list[str]] = NotSet, + block_creations: Opt[bool] = NotSet, + require_last_push_approval: Opt[bool] = NotSet, + allow_deletions: Opt[bool] = NotSet, + checks: Opt[list[str | tuple[str, int]]] = NotSet, + ) -> BranchProtection: + """ + :calls: `PUT /repos/{owner}/{repo}/branches/{branch}/protection `_ + + NOTE: The GitHub API groups strict and contexts together, both must + be submitted. Take care to pass both as arguments even if only one is + changing. Use edit_required_status_checks() to avoid this. + """ + assert is_optional(strict, bool), strict + assert is_optional_list(contexts, str), contexts + assert is_optional(enforce_admins, bool), enforce_admins + assert is_optional_list(dismissal_users, str), dismissal_users + assert is_optional_list(dismissal_teams, str), dismissal_teams + assert is_optional_list(dismissal_apps, str), dismissal_apps + assert is_optional(dismiss_stale_reviews, bool), dismiss_stale_reviews + assert is_optional(require_code_owner_reviews, bool), require_code_owner_reviews + assert is_optional(required_approving_review_count, int), required_approving_review_count + assert is_optional(required_linear_history, bool), required_linear_history + assert is_optional(allow_force_pushes, bool), allow_force_pushes + assert is_optional(required_conversation_resolution, bool), required_conversation_resolution + assert is_optional(lock_branch, bool), lock_branch + assert is_optional(allow_fork_syncing, bool), allow_fork_syncing + assert is_optional_list(users_bypass_pull_request_allowances, str), users_bypass_pull_request_allowances + assert is_optional_list(teams_bypass_pull_request_allowances, str), teams_bypass_pull_request_allowances + assert is_optional_list(apps_bypass_pull_request_allowances, str), apps_bypass_pull_request_allowances + assert is_optional(require_last_push_approval, bool), require_last_push_approval + assert is_optional(allow_deletions, bool), allow_deletions + assert is_optional_list(checks, (str, tuple)), checks + if is_defined(checks): + assert all(not isinstance(check, tuple) or list(map(type, check)) == [str, int] for check in checks), checks + + post_parameters: dict[str, Any] = {} + if is_defined(strict) or is_defined(contexts) or is_defined(checks): + if is_undefined(strict): + strict = False + + checks_parameters = [] + if is_defined(checks): + checks_parameters = [ + {"context": check[0], "app_id": check[1]} if isinstance(check, tuple) else {"context": check} + for check in checks + ] + elif is_defined(contexts): + checks_parameters = [{"context": context} for context in contexts] + + post_parameters["required_status_checks"] = { + "strict": strict, + "checks": checks_parameters, + } + else: + post_parameters["required_status_checks"] = None + + if is_defined(enforce_admins): + post_parameters["enforce_admins"] = enforce_admins + else: + post_parameters["enforce_admins"] = None + + if ( + is_defined(dismissal_users) + or is_defined(dismissal_teams) + or is_defined(dismissal_apps) + or is_defined(dismiss_stale_reviews) + or is_defined(require_code_owner_reviews) + or is_defined(required_approving_review_count) + or is_defined(users_bypass_pull_request_allowances) + or is_defined(teams_bypass_pull_request_allowances) + or is_defined(apps_bypass_pull_request_allowances) + or is_defined(require_last_push_approval) + ): + post_parameters["required_pull_request_reviews"] = {} + if is_defined(dismiss_stale_reviews): + post_parameters["required_pull_request_reviews"]["dismiss_stale_reviews"] = dismiss_stale_reviews + if is_defined(require_code_owner_reviews): + post_parameters["required_pull_request_reviews"][ + "require_code_owner_reviews" + ] = require_code_owner_reviews + if is_defined(required_approving_review_count): + post_parameters["required_pull_request_reviews"][ + "required_approving_review_count" + ] = required_approving_review_count + if is_defined(require_last_push_approval): + post_parameters["required_pull_request_reviews"][ + "require_last_push_approval" + ] = require_last_push_approval + + dismissal_restrictions = {} + if is_defined(dismissal_users): + dismissal_restrictions["users"] = dismissal_users + if is_defined(dismissal_teams): + dismissal_restrictions["teams"] = dismissal_teams + if is_defined(dismissal_apps): + dismissal_restrictions["apps"] = dismissal_apps + + if dismissal_restrictions: + post_parameters["required_pull_request_reviews"]["dismissal_restrictions"] = dismissal_restrictions + + bypass_pull_request_allowances = {} + if is_defined(users_bypass_pull_request_allowances): + bypass_pull_request_allowances["users"] = users_bypass_pull_request_allowances + if is_defined(teams_bypass_pull_request_allowances): + bypass_pull_request_allowances["teams"] = teams_bypass_pull_request_allowances + if is_defined(apps_bypass_pull_request_allowances): + bypass_pull_request_allowances["apps"] = apps_bypass_pull_request_allowances + + if bypass_pull_request_allowances: + post_parameters["required_pull_request_reviews"][ + "bypass_pull_request_allowances" + ] = bypass_pull_request_allowances + else: + post_parameters["required_pull_request_reviews"] = None + if ( + is_defined(user_push_restrictions) + or is_defined(team_push_restrictions) + or is_defined(app_push_restrictions) + ): + if is_undefined(user_push_restrictions): + user_push_restrictions = [] + if is_undefined(team_push_restrictions): + team_push_restrictions = [] + if is_undefined(app_push_restrictions): + app_push_restrictions = [] + post_parameters["restrictions"] = { + "users": user_push_restrictions, + "teams": team_push_restrictions, + "apps": app_push_restrictions, + } + else: + post_parameters["restrictions"] = None + if is_defined(required_linear_history): + post_parameters["required_linear_history"] = required_linear_history + else: + post_parameters["required_linear_history"] = None + if is_defined(allow_force_pushes): + post_parameters["allow_force_pushes"] = allow_force_pushes + else: + post_parameters["allow_force_pushes"] = None + if is_defined(required_conversation_resolution): + post_parameters["required_conversation_resolution"] = required_conversation_resolution + else: + post_parameters["required_conversation_resolution"] = None + if is_defined(lock_branch): + post_parameters["lock_branch"] = lock_branch + else: + post_parameters["lock_branch"] = None + if is_defined(allow_fork_syncing): + post_parameters["allow_fork_syncing"] = allow_fork_syncing + else: + post_parameters["allow_fork_syncing"] = None + if is_defined(block_creations): + post_parameters["block_creations"] = block_creations + else: + post_parameters["block_creations"] = None + if is_defined(allow_deletions): + post_parameters["allow_deletions"] = allow_deletions + else: + post_parameters["allow_deletions"] = None + + headers, data = self._requester.requestJsonAndCheck( + "PUT", + self.protection_url, + headers={"Accept": Consts.mediaTypeRequireMultipleApprovingReviews}, + input=post_parameters, + ) + + return github.BranchProtection.BranchProtection(self._requester, headers, data, completed=True) + + def remove_protection(self) -> None: + """ + :calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection `_ + """ + headers, data = self._requester.requestJsonAndCheck( + "DELETE", + self.protection_url, + ) + + def get_required_status_checks(self) -> RequiredStatusChecks: + """ + :calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks `_ + :rtype: :class:`github.RequiredStatusChecks.RequiredStatusChecks` + """ + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.protection_url}/required_status_checks") + return github.RequiredStatusChecks.RequiredStatusChecks(self._requester, headers, data, completed=True) + + def edit_required_status_checks( + self, + strict: Opt[bool] = NotSet, + contexts: Opt[list[str]] = NotSet, + checks: Opt[list[str | tuple[str, int]]] = NotSet, + ) -> RequiredStatusChecks: + """ + :calls: `PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks `_ + """ + assert is_optional(strict, bool), strict + assert is_optional_list(contexts, str), contexts + assert is_optional_list(checks, (str, tuple)), checks + if is_defined(checks): + assert all(not isinstance(check, tuple) or list(map(type, check)) == [str, int] for check in checks), checks + + checks_parameters: Opt[list[dict[str, Any]]] = NotSet + if is_defined(checks): + checks_parameters = [ + {"context": check[0], "app_id": check[1]} if isinstance(check, tuple) else {"context": check} + for check in checks + ] + elif is_defined(contexts): + checks_parameters = [{"context": context} for context in contexts] + + post_parameters: dict[str, Any] = NotSet.remove_unset_items({"strict": strict, "checks": checks_parameters}) + + headers, data = self._requester.requestJsonAndCheck( + "PATCH", + f"{self.protection_url}/required_status_checks", + input=post_parameters, + ) + + return github.RequiredStatusChecks.RequiredStatusChecks(self._requester, headers, data, completed=True) + + def remove_required_status_checks(self) -> None: + """ + :calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks `_ + """ + headers, data = self._requester.requestJsonAndCheck( + "DELETE", + f"{self.protection_url}/required_status_checks", + ) + + def get_required_pull_request_reviews(self) -> RequiredPullRequestReviews: + """ + :calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews `_ + """ + headers, data = self._requester.requestJsonAndCheck( + "GET", + f"{self.protection_url}/required_pull_request_reviews", + headers={"Accept": Consts.mediaTypeRequireMultipleApprovingReviews}, + ) + return github.RequiredPullRequestReviews.RequiredPullRequestReviews( + self._requester, headers, data, completed=True + ) + + def edit_required_pull_request_reviews( + self, + dismissal_users: Opt[list[str]] = NotSet, + dismissal_teams: Opt[list[str]] = NotSet, + dismissal_apps: Opt[list[str]] = NotSet, + dismiss_stale_reviews: Opt[bool] = NotSet, + require_code_owner_reviews: Opt[bool] = NotSet, + required_approving_review_count: Opt[int] = NotSet, + require_last_push_approval: Opt[bool] = NotSet, + ) -> RequiredStatusChecks: + """ + :calls: `PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews `_ + """ + assert is_optional_list(dismissal_users, str), dismissal_users + assert is_optional_list(dismissal_teams, str), dismissal_teams + assert is_optional(dismiss_stale_reviews, bool), dismiss_stale_reviews + assert is_optional(require_code_owner_reviews, bool), require_code_owner_reviews + assert is_optional(required_approving_review_count, int), required_approving_review_count + assert is_optional(require_last_push_approval, bool), require_last_push_approval + + post_parameters: dict[str, Any] = NotSet.remove_unset_items( + { + "dismiss_stale_reviews": dismiss_stale_reviews, + "require_code_owner_reviews": require_code_owner_reviews, + "required_approving_review_count": required_approving_review_count, + "require_last_push_approval": require_last_push_approval, + } + ) + + dismissal_restrictions: dict[str, Any] = NotSet.remove_unset_items( + {"users": dismissal_users, "teams": dismissal_teams, "apps": dismissal_apps} + ) + + if dismissal_restrictions: + post_parameters["dismissal_restrictions"] = dismissal_restrictions + + headers, data = self._requester.requestJsonAndCheck( + "PATCH", + f"{self.protection_url}/required_pull_request_reviews", + headers={"Accept": Consts.mediaTypeRequireMultipleApprovingReviews}, + input=post_parameters, + ) + + return github.RequiredStatusChecks.RequiredStatusChecks(self._requester, headers, data, completed=True) + + def remove_required_pull_request_reviews(self) -> None: + """ + :calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews `_ + """ + headers, data = self._requester.requestJsonAndCheck( + "DELETE", + f"{self.protection_url}/required_pull_request_reviews", + ) + + def get_admin_enforcement(self) -> bool: + """ + :calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins `_ + """ + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.protection_url}/enforce_admins") + return data["enabled"] + + def set_admin_enforcement(self) -> None: + """ + :calls: `POST /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins `_ + """ + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.protection_url}/enforce_admins") + + def remove_admin_enforcement(self) -> None: + """ + :calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins `_ + """ + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.protection_url}/enforce_admins") + + def get_user_push_restrictions(self) -> PaginatedList[NamedUser]: + """ + :calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users `_ + """ + return github.PaginatedList.PaginatedList( + github.NamedUser.NamedUser, + self._requester, + f"{self.protection_url}/restrictions/users", + None, + ) + + def get_team_push_restrictions(self) -> PaginatedList[Team]: + """ + :calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams `_ + """ + return github.PaginatedList.PaginatedList( + github.Team.Team, + self._requester, + f"{self.protection_url}/restrictions/teams", + None, + ) + + def add_user_push_restrictions(self, *users: str) -> None: + """ + :calls: `POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users `_ + :users: list of strings (user names) + """ + assert all(isinstance(element, str) for element in users), users + + headers, data = self._requester.requestJsonAndCheck( + "POST", f"{self.protection_url}/restrictions/users", input=users + ) + + def replace_user_push_restrictions(self, *users: str) -> None: + """ + :calls: `PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users `_ + :users: list of strings (user names) + """ + assert all(isinstance(element, str) for element in users), users + + headers, data = self._requester.requestJsonAndCheck( + "PUT", f"{self.protection_url}/restrictions/users", input=users + ) + + def remove_user_push_restrictions(self, *users: str) -> None: + """ + :calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users `_ + :users: list of strings (user names) + """ + assert all(isinstance(element, str) for element in users), users + + headers, data = self._requester.requestJsonAndCheck( + "DELETE", f"{self.protection_url}/restrictions/users", input=users + ) + + def add_team_push_restrictions(self, *teams: str) -> None: + """ + :calls: `POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams `_ + :teams: list of strings (team slugs) + """ + assert all(isinstance(element, str) for element in teams), teams + + headers, data = self._requester.requestJsonAndCheck( + "POST", f"{self.protection_url}/restrictions/teams", input=teams + ) + + def replace_team_push_restrictions(self, *teams: str) -> None: + """ + :calls: `PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams `_ + :teams: list of strings (team slugs) + """ + assert all(isinstance(element, str) for element in teams), teams + + headers, data = self._requester.requestJsonAndCheck( + "PUT", f"{self.protection_url}/restrictions/teams", input=teams + ) + + def remove_team_push_restrictions(self, *teams: str) -> None: + """ + :calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams `_ + :teams: list of strings (team slugs) + """ + assert all(isinstance(element, str) for element in teams), teams + + headers, data = self._requester.requestJsonAndCheck( + "DELETE", f"{self.protection_url}/restrictions/teams", input=teams + ) + + def remove_push_restrictions(self) -> None: + """ + :calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions `_ + """ + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.protection_url}/restrictions") + + def get_required_signatures(self) -> bool: + """ + :calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures `_ + """ + headers, data = self._requester.requestJsonAndCheck( + "GET", + f"{self.protection_url}/required_signatures", + headers={"Accept": Consts.signaturesProtectedBranchesPreview}, + ) + return data["enabled"] + + def add_required_signatures(self) -> None: + """ + :calls: `POST /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures `_ + """ + headers, data = self._requester.requestJsonAndCheck( + "POST", + f"{self.protection_url}/required_signatures", + headers={"Accept": Consts.signaturesProtectedBranchesPreview}, + ) + + def remove_required_signatures(self) -> None: + """ + :calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures `_ + """ + headers, data = self._requester.requestJsonAndCheck( + "DELETE", + f"{self.protection_url}/required_signatures", + headers={"Accept": Consts.signaturesProtectedBranchesPreview}, + ) + + def get_allow_deletions(self) -> bool: + """ + :calls: `GET /repos/{owner}/{repo}/branches/{branch}/protection/allow_deletions `_ + """ + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.protection_url}/allow_deletions") + return data["enabled"] + + def set_allow_deletions(self) -> None: + """ + :calls: `POST /repos/{owner}/{repo}/branches/{branch}/protection/allow_deletions `_ + """ + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.protection_url}/allow_deletions") + + def remove_allow_deletions(self) -> None: + """ + :calls: `DELETE /repos/{owner}/{repo}/branches/{branch}/protection/allow_deletions `_ + """ + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.protection_url}/allow_deletions") + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "_links" in attributes: # pragma no branch + self.__links = self._makeDictAttribute(attributes["_links"]) + if "commit" in attributes: # pragma no branch + self._commit = self._makeClassAttribute(github.Commit.Commit, attributes["commit"]) + if "name" in attributes: # pragma no branch + self._name = self._makeStringAttribute(attributes["name"]) + if "pattern" in attributes: # pragma no branch + self._pattern = self._makeStringAttribute(attributes["pattern"]) + if "protected" in attributes: # pragma no branch + self._protected = self._makeBoolAttribute(attributes["protected"]) + if "protection" in attributes: # pragma no branch + self._protection = self._makeClassAttribute( + github.BranchProtection.BranchProtection, attributes["protection"] + ) + if "protection_url" in attributes: # pragma no branch + self._protection_url = self._makeStringAttribute(attributes["protection_url"]) + if "required_approving_review_count" in attributes: # pragma no branch + self._required_approving_review_count = self._makeIntAttribute( + attributes["required_approving_review_count"] + ) diff --git a/venv/lib/python3.10/site-packages/github/BranchProtection.py b/venv/lib/python3.10/site-packages/github/BranchProtection.py new file mode 100644 index 0000000000000000000000000000000000000000..ae5de1c8b9cf4bc490409604147cb236654d288d --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/BranchProtection.py @@ -0,0 +1,219 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2018 Steve Kowalik # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2024 Benjamin K <53038537+treee111@users.noreply.github.com> # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from typing import TYPE_CHECKING, Any + +import github.GithubObject +import github.NamedUser +import github.RequiredPullRequestReviews +import github.RequiredStatusChecks +import github.Team +from github.GithubObject import Attribute, NotSet, Opt, is_defined +from github.PaginatedList import PaginatedList + +if TYPE_CHECKING: + from github.NamedUser import NamedUser + from github.RequiredPullRequestReviews import RequiredPullRequestReviews + from github.RequiredStatusChecks import RequiredStatusChecks + from github.Team import Team + + +class BranchProtection(github.GithubObject.CompletableGithubObject): + """ + This class represents Branch Protection. + + The reference can be found here + https://docs.github.com/en/rest/reference/repos#get-branch-protection + + The OpenAPI schema can be found at + - /components/schemas/branch-protection + - /components/schemas/protected-branch + + """ + + def _initAttributes(self) -> None: + self._allow_deletions: Attribute[bool] = NotSet + self._allow_force_pushes: Attribute[bool] = NotSet + self._allow_fork_syncing: Attribute[bool] = NotSet + self._block_creations: Attribute[bool] = NotSet + self._enabled: Attribute[bool] = NotSet + self._enforce_admins: Attribute[bool] = NotSet + self._lock_branch: Attribute[bool] = NotSet + self._name: Attribute[str] = NotSet + self._protection_url: Attribute[str] = NotSet + self._required_conversation_resolution: Attribute[bool] = NotSet + self._required_linear_history: Attribute[bool] = github.GithubObject.NotSet + self._required_pull_request_reviews: Attribute[RequiredPullRequestReviews] = NotSet + self._required_signatures: Attribute[bool] = NotSet + self._required_status_checks: Attribute[RequiredStatusChecks] = NotSet + self._restrictions: Attribute[dict[str, Any]] = NotSet + self._team_push_restrictions: Opt[str] = NotSet + self._url: Attribute[str] = NotSet + self._user_push_restrictions: Opt[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"url": self._url.value}) + + @property + def allow_deletions(self) -> bool: + self._completeIfNotSet(self._allow_deletions) + return self._allow_deletions.value + + @property + def allow_force_pushes(self) -> bool: + self._completeIfNotSet(self._allow_force_pushes) + return self._allow_force_pushes.value + + @property + def allow_fork_syncing(self) -> bool: + self._completeIfNotSet(self._allow_fork_syncing) + return self._allow_fork_syncing.value + + @property + def block_creations(self) -> bool: + return self._block_creations.value + + @property + def enabled(self) -> bool: + return self._enabled.value + + @property + def enforce_admins(self) -> bool: + self._completeIfNotSet(self._enforce_admins) + return self._enforce_admins.value + + @property + def lock_branch(self) -> bool: + self._completeIfNotSet(self._lock_branch) + return self._lock_branch.value + + @property + def name(self) -> str: + return self._name.value + + @property + def protection_url(self) -> str: + return self._protection_url.value + + @property + def required_conversation_resolution(self) -> bool: + self._completeIfNotSet(self._required_conversation_resolution) + return self._required_conversation_resolution.value + + @property + def required_linear_history(self) -> bool: + self._completeIfNotSet(self._required_linear_history) + return self._required_linear_history.value + + @property + def required_pull_request_reviews(self) -> RequiredPullRequestReviews: + self._completeIfNotSet(self._required_pull_request_reviews) + return self._required_pull_request_reviews.value + + @property + def required_signatures(self) -> bool: + return self._required_signatures.value + + @property + def required_status_checks(self) -> RequiredStatusChecks: + self._completeIfNotSet(self._required_status_checks) + return self._required_status_checks.value + + @property + def restrictions(self) -> dict[str, Any]: + return self._restrictions.value + + @property + def url(self) -> str: + return self._url.value + + def get_user_push_restrictions(self) -> PaginatedList[NamedUser] | None: + if not is_defined(self._user_push_restrictions): + return None + return PaginatedList( + github.NamedUser.NamedUser, + self._requester, + self._user_push_restrictions, + None, + ) + + def get_team_push_restrictions(self) -> PaginatedList[Team] | None: + if not is_defined(self._team_push_restrictions): + return None + return github.PaginatedList.PaginatedList(github.Team.Team, self._requester, self._team_push_restrictions, None) + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "allow_deletions" in attributes: # pragma no branch + self._allow_deletions = self._makeBoolAttribute(attributes["allow_deletions"]["enabled"]) + if "allow_force_pushes" in attributes: # pragma no branch + self._allow_force_pushes = self._makeBoolAttribute(attributes["allow_force_pushes"]["enabled"]) + if "allow_fork_syncing" in attributes: # pragma no branch + self._allow_fork_syncing = self._makeBoolAttribute(attributes["allow_fork_syncing"]["enabled"]) + if "block_creations" in attributes: # pragma no branch + self._block_creations = self._makeBoolAttribute(attributes["block_creations"]["enabled"]) + if "enabled" in attributes: # pragma no branch + self._enabled = self._makeBoolAttribute(attributes["enabled"]) + if "enforce_admins" in attributes: # pragma no branch + self._enforce_admins = self._makeBoolAttribute(attributes["enforce_admins"]["enabled"]) + if "lock_branch" in attributes: # pragma no branch + self._lock_branch = self._makeBoolAttribute(attributes["lock_branch"]["enabled"]) + if "name" in attributes: # pragma no branch + self._name = self._makeStringAttribute(attributes["name"]) + if "protection_url" in attributes: # pragma no branch + self._protection_url = self._makeStringAttribute(attributes["protection_url"]) + if "required_conversation_resolution" in attributes: # pragma no branch + self._required_conversation_resolution = self._makeBoolAttribute( + attributes["required_conversation_resolution"]["enabled"] + ) + if "required_linear_history" in attributes: # pragma no branch + self._required_linear_history = self._makeBoolAttribute(attributes["required_linear_history"]["enabled"]) + if "required_pull_request_reviews" in attributes: # pragma no branch + self._required_pull_request_reviews = self._makeClassAttribute( + github.RequiredPullRequestReviews.RequiredPullRequestReviews, + attributes["required_pull_request_reviews"], + ) + if "required_signatures" in attributes: # pragma no branch + self._required_signatures = self._makeBoolAttribute(attributes["required_signatures"]["enabled"]) + if "required_status_checks" in attributes: # pragma no branch + self._required_status_checks = self._makeClassAttribute( + github.RequiredStatusChecks.RequiredStatusChecks, + attributes["required_status_checks"], + ) + if "restrictions" in attributes: # pragma no branch + self._restrictions = attributes["restrictions"] + self._user_push_restrictions = attributes["restrictions"]["users_url"] + self._team_push_restrictions = attributes["restrictions"]["teams_url"] + if "url" in attributes: # pragma no branch + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/venv/lib/python3.10/site-packages/github/CVSS.py b/venv/lib/python3.10/site-packages/github/CVSS.py new file mode 100644 index 0000000000000000000000000000000000000000..a9c37032c4a11a38b67a877e372949096074de76 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/CVSS.py @@ -0,0 +1,80 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Steve Kowalik # +# Copyright 2022 Eric Nieuwland # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Joseph Henrich # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from decimal import Decimal +from typing import Any, Dict + +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + + +class CVSS(NonCompletableGithubObject): + """ + This class represents a CVSS. + + The reference can be found here + + + """ + + def _initAttributes(self) -> None: + self._score: Attribute[Decimal] = NotSet + self._vector_string: Attribute[str] = NotSet + self._version: Attribute[Decimal] = NotSet + + @property + def score(self) -> Decimal: + return self._score.value + + @property + def vector_string(self) -> str: + return self._vector_string.value + + @property + def version(self) -> Decimal: + return self._version.value + + def _useAttributes(self, attributes: Dict[str, Any]) -> None: + if "score" in attributes and attributes["score"] is not None: # pragma no branch + # ensure string so we don't have all the float extra nonsense + self._score = self._makeDecimalAttribute(Decimal(str(attributes["score"]))) + if "vector_string" in attributes and attributes["vector_string"] is not None: # pragma no branch + self._vector_string = self._makeStringAttribute(attributes["vector_string"]) + self._version = self._makeDecimalAttribute(Decimal(self.vector_string.split(":")[1].split("/")[0])) diff --git a/venv/lib/python3.10/site-packages/github/CWE.py b/venv/lib/python3.10/site-packages/github/CWE.py new file mode 100644 index 0000000000000000000000000000000000000000..173fba03227cf6bf35a3544d2f70b1c4d9852de4 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/CWE.py @@ -0,0 +1,72 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Steve Kowalik # +# Copyright 2022 Eric Nieuwland # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jonathan Leitschuh # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + + +from typing import Any, Dict + +from github.GithubObject import Attribute, CompletableGithubObject, NotSet + + +class CWE(CompletableGithubObject): + """ + This class represents a CWE. + + The reference can be found here + https://docs.github.com/en/rest/security-advisories/repository-advisories + + """ + + def _initAttributes(self) -> None: + self._cwe_id: Attribute[str] = NotSet + self._name: Attribute[str] = NotSet + + @property + def cwe_id(self) -> str: + return self._cwe_id.value + + @property + def name(self) -> str: + return self._name.value + + def _useAttributes(self, attributes: Dict[str, Any]) -> None: + if "cwe_id" in attributes: # pragma no branch + self._cwe_id = self._makeStringAttribute(attributes["cwe_id"]) + if "name" in attributes: # pragma no branch + self._name = self._makeStringAttribute(attributes["name"]) diff --git a/venv/lib/python3.10/site-packages/github/CheckRun.py b/venv/lib/python3.10/site-packages/github/CheckRun.py new file mode 100644 index 0000000000000000000000000000000000000000..3a3588aa666aa3ad8f73a3dc9b0f5d01627bfc6d --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/CheckRun.py @@ -0,0 +1,298 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2020 Dhruv Manilawala # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Steve Kowalik # +# Copyright 2021 majorvin # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from datetime import datetime +from typing import TYPE_CHECKING, Any + +import deprecated + +import github.CheckRunAnnotation +import github.CheckRunOutput +import github.CheckSuite +import github.Deployment +import github.GithubApp +import github.GithubObject +import github.PullRequest +from github.GithubObject import ( + Attribute, + CompletableGithubObject, + NotSet, + Opt, + is_defined, + is_optional, + is_optional_list, +) +from github.PaginatedList import PaginatedList + +if TYPE_CHECKING: + from github.CheckRunAnnotation import CheckRunAnnotation + from github.CheckRunOutput import CheckRunOutput + from github.CheckSuite import CheckSuite + from github.Deployment import Deployment + from github.GithubApp import GithubApp + from github.PullRequest import PullRequest + + +class CheckRun(CompletableGithubObject): + """ + This class represents check runs. + + The reference can be found here + https://docs.github.com/en/rest/reference/checks#check-runs + + The OpenAPI schema can be found at + - /components/schemas/check-run + + """ + + def _initAttributes(self) -> None: + self._app: Attribute[GithubApp] = NotSet + self._check_suite: Attribute[CheckSuite] = NotSet + self._check_suite_id: Attribute[int] = NotSet + self._completed_at: Attribute[datetime | None] = NotSet + self._conclusion: Attribute[str] = NotSet + self._deployment: Attribute[Deployment] = NotSet + self._details_url: Attribute[str] = NotSet + self._external_id: Attribute[str] = NotSet + self._head_sha: Attribute[str] = NotSet + self._html_url: Attribute[str] = NotSet + self._id: Attribute[int] = NotSet + self._name: Attribute[str] = NotSet + self._node_id: Attribute[str] = NotSet + self._output: Attribute[github.CheckRunOutput.CheckRunOutput] = NotSet + self._pull_requests: Attribute[list[PullRequest]] = NotSet + self._started_at: Attribute[datetime] = NotSet + self._status: Attribute[str] = NotSet + self._url: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"id": self._id.value, "conclusion": self._conclusion.value}) + + @property + def app(self) -> GithubApp: + self._completeIfNotSet(self._app) + return self._app.value + + @property + def check_suite(self) -> CheckSuite: + self._completeIfNotSet(self._check_suite) + return self._check_suite.value + + @property + @deprecated.deprecated("Use property check_suite.id instead") + def check_suite_id(self) -> int: + self._completeIfNotSet(self._check_suite_id) + return self._check_suite_id.value + + @property + def completed_at(self) -> datetime | None: + self._completeIfNotSet(self._completed_at) + return self._completed_at.value + + @property + def conclusion(self) -> str: + self._completeIfNotSet(self._conclusion) + return self._conclusion.value + + @property + def deployment(self) -> Deployment: + self._completeIfNotSet(self._deployment) + return self._deployment.value + + @property + def details_url(self) -> str: + self._completeIfNotSet(self._details_url) + return self._details_url.value + + @property + def external_id(self) -> str: + self._completeIfNotSet(self._external_id) + return self._external_id.value + + @property + def head_sha(self) -> str: + self._completeIfNotSet(self._head_sha) + return self._head_sha.value + + @property + def html_url(self) -> str: + self._completeIfNotSet(self._html_url) + return self._html_url.value + + @property + def id(self) -> int: + self._completeIfNotSet(self._id) + return self._id.value + + @property + def name(self) -> str: + self._completeIfNotSet(self._name) + return self._name.value + + @property + def node_id(self) -> str: + self._completeIfNotSet(self._node_id) + return self._node_id.value + + @property + def output(self) -> CheckRunOutput: + self._completeIfNotSet(self._output) + return self._output.value + + @property + def pull_requests(self) -> list[PullRequest]: + self._completeIfNotSet(self._pull_requests) + return self._pull_requests.value + + @property + def started_at(self) -> datetime: + self._completeIfNotSet(self._started_at) + return self._started_at.value + + @property + def status(self) -> str: + self._completeIfNotSet(self._status) + return self._status.value + + @property + def url(self) -> str: + return self._url.value + + def get_annotations(self) -> PaginatedList[CheckRunAnnotation]: + """ + :calls: `GET /repos/{owner}/{repo}/check-runs/{check_run_id}/annotations `_ + """ + return PaginatedList( + github.CheckRunAnnotation.CheckRunAnnotation, + self._requester, + f"{self.url}/annotations", + None, + headers={"Accept": "application/vnd.github.v3+json"}, + ) + + def edit( + self, + name: Opt[str] = NotSet, + head_sha: Opt[str] = NotSet, + details_url: Opt[str] = NotSet, + external_id: Opt[str] = NotSet, + status: Opt[str] = NotSet, + started_at: Opt[datetime] = NotSet, + conclusion: Opt[str] = NotSet, + completed_at: Opt[datetime] = NotSet, + output: Opt[dict] = NotSet, + actions: Opt[list[dict]] = NotSet, + ) -> None: + """ + :calls: `PATCH /repos/{owner}/{repo}/check-runs/{check_run_id} `_ + """ + assert is_optional(name, str), name + assert is_optional(head_sha, str), head_sha + assert is_optional(details_url, str), details_url + assert is_optional(external_id, str), external_id + assert is_optional(status, str), status + assert is_optional(started_at, datetime), started_at + assert is_optional(conclusion, str), conclusion + assert is_optional(completed_at, datetime), completed_at + assert is_optional(output, dict), output + assert is_optional_list(actions, dict), actions + + post_parameters: dict[str, Any] = {} + if is_defined(name): + post_parameters["name"] = name + if is_defined(head_sha): + post_parameters["head_sha"] = head_sha + if is_defined(details_url): + post_parameters["details_url"] = details_url + if is_defined(external_id): + post_parameters["external_id"] = external_id + if is_defined(status): + post_parameters["status"] = status + if is_defined(started_at): + post_parameters["started_at"] = started_at.strftime("%Y-%m-%dT%H:%M:%SZ") + if is_defined(completed_at): + post_parameters["completed_at"] = completed_at.strftime("%Y-%m-%dT%H:%M:%SZ") + if is_defined(conclusion): + post_parameters["conclusion"] = conclusion + if is_defined(output): + post_parameters["output"] = output + if is_defined(actions): + post_parameters["actions"] = actions + + headers, data = self._requester.requestJsonAndCheck("PATCH", self.url, input=post_parameters) + self._useAttributes(data) + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "app" in attributes: # pragma no branch + self._app = self._makeClassAttribute(github.GithubApp.GithubApp, attributes["app"]) + # This only gives us a dictionary with `id` attribute of `check_suite` + if "check_suite" in attributes and "id" in attributes["check_suite"]: # pragma no branch + id = attributes["check_suite"]["id"] + if "url" not in attributes["check_suite"] and "url" in attributes: + url = attributes["url"].split("/")[:-2] + ["check-suites", str(id)] + attributes["check_suite"]["url"] = "/".join(url) + self._check_suite = self._makeClassAttribute(github.CheckSuite.CheckSuite, attributes["check_suite"]) + # deprecated check suite id property + self._check_suite_id = self._makeIntAttribute(id) + if "completed_at" in attributes: # pragma no branch + self._completed_at = self._makeDatetimeAttribute(attributes["completed_at"]) + if "conclusion" in attributes: # pragma no branch + self._conclusion = self._makeStringAttribute(attributes["conclusion"]) + if "deployment" in attributes: # pragma no branch + self._deployment = self._makeClassAttribute(github.Deployment.Deployment, attributes["deployment"]) + if "details_url" in attributes: # pragma no branch + self._details_url = self._makeStringAttribute(attributes["details_url"]) + if "external_id" in attributes: # pragma no branch + self._external_id = self._makeStringAttribute(attributes["external_id"]) + if "head_sha" in attributes: # pragma no branch + self._head_sha = self._makeStringAttribute(attributes["head_sha"]) + if "html_url" in attributes: # pragma no branch + self._html_url = self._makeStringAttribute(attributes["html_url"]) + if "id" in attributes: # pragma no branch + self._id = self._makeIntAttribute(attributes["id"]) + if "name" in attributes: # pragma no branch + self._name = self._makeStringAttribute(attributes["name"]) + if "node_id" in attributes: # pragma no branch + self._node_id = self._makeStringAttribute(attributes["node_id"]) + if "output" in attributes: # pragma no branch + self._output = self._makeClassAttribute(github.CheckRunOutput.CheckRunOutput, attributes["output"]) + if "pull_requests" in attributes: # pragma no branch + self._pull_requests = self._makeListOfClassesAttribute( + github.PullRequest.PullRequest, attributes["pull_requests"] + ) + if "started_at" in attributes: # pragma no branch + self._started_at = self._makeDatetimeAttribute(attributes["started_at"]) + if "status" in attributes: # pragma no branch + self._status = self._makeStringAttribute(attributes["status"]) + if "url" in attributes: # pragma no branch + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/venv/lib/python3.10/site-packages/github/CheckRunAnnotation.py b/venv/lib/python3.10/site-packages/github/CheckRunAnnotation.py new file mode 100644 index 0000000000000000000000000000000000000000..f5f52ff3d9824ef163f286b4cb91d8db3aa48cb3 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/CheckRunAnnotation.py @@ -0,0 +1,123 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2020 Dhruv Manilawala # +# Copyright 2020 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from typing import Any + +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + + +class CheckRunAnnotation(NonCompletableGithubObject): + """ + This class represents check run annotations. + + The reference can be found here: https://docs.github.com/en/rest/reference/checks#list-check-run-annotations + + The OpenAPI schema can be found at + - /components/schemas/check-annotation + + """ + + def _initAttributes(self) -> None: + self._annotation_level: Attribute[str] = NotSet + self._blob_href: Attribute[str] = NotSet + self._end_column: Attribute[int] = NotSet + self._end_line: Attribute[int] = NotSet + self._message: Attribute[str] = NotSet + self._path: Attribute[str] = NotSet + self._raw_details: Attribute[str] = NotSet + self._start_column: Attribute[int] = NotSet + self._start_line: Attribute[int] = NotSet + self._title: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"title": self._title.value}) + + @property + def annotation_level(self) -> str: + return self._annotation_level.value + + @property + def blob_href(self) -> str: + return self._blob_href.value + + @property + def end_column(self) -> int: + return self._end_column.value + + @property + def end_line(self) -> int: + return self._end_line.value + + @property + def message(self) -> str: + return self._message.value + + @property + def path(self) -> str: + return self._path.value + + @property + def raw_details(self) -> str: + return self._raw_details.value + + @property + def start_column(self) -> int: + return self._start_column.value + + @property + def start_line(self) -> int: + return self._start_line.value + + @property + def title(self) -> str: + return self._title.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "annotation_level" in attributes: # pragma no branch + self._annotation_level = self._makeStringAttribute(attributes["annotation_level"]) + if "blob_href" in attributes: # pragma no branch + self._blob_href = self._makeStringAttribute(attributes["blob_href"]) + if "end_column" in attributes: # pragma no branch + self._end_column = self._makeIntAttribute(attributes["end_column"]) + if "end_line" in attributes: # pragma no branch + self._end_line = self._makeIntAttribute(attributes["end_line"]) + if "message" in attributes: # pragma no branch + self._message = self._makeStringAttribute(attributes["message"]) + if "path" in attributes: # pragma no branch + self._path = self._makeStringAttribute(attributes["path"]) + if "raw_details" in attributes: # pragma no branch + self._raw_details = self._makeStringAttribute(attributes["raw_details"]) + if "start_column" in attributes: # pragma no branch + self._start_column = self._makeIntAttribute(attributes["start_column"]) + if "start_line" in attributes: # pragma no branch + self._start_line = self._makeIntAttribute(attributes["start_line"]) + if "title" in attributes: # pragma no branch + self._title = self._makeStringAttribute(attributes["title"]) diff --git a/venv/lib/python3.10/site-packages/github/CheckRunOutput.py b/venv/lib/python3.10/site-packages/github/CheckRunOutput.py new file mode 100644 index 0000000000000000000000000000000000000000..f782573da72626818c10bbbdae8c5aed7a06b05e --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/CheckRunOutput.py @@ -0,0 +1,95 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Dhruv Manilawala # +# Copyright 2020 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from typing import Any, Dict + +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + + +class CheckRunOutput(NonCompletableGithubObject): + """ + This class represents the output of check run. + + The OpenAPI schema can be found at + - /components/schemas/check-run/properties/output + + """ + + def _initAttributes(self) -> None: + self._annotations_count: Attribute[int] = NotSet + self._annotations_url: Attribute[str] = NotSet + self._summary: Attribute[str] = NotSet + self._text: Attribute[str] = NotSet + self._title: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"title": self._title.value}) + + @property + def annotations_count(self) -> int: + return self._annotations_count.value + + @property + def annotations_url(self) -> str: + return self._annotations_url.value + + @property + def summary(self) -> str: + return self._summary.value + + @property + def text(self) -> str: + return self._text.value + + @property + def title(self) -> str: + return self._title.value + + def _useAttributes(self, attributes: Dict[str, Any]) -> None: + if "annotations_count" in attributes: # pragma no branch + self._annotations_count = self._makeIntAttribute(attributes["annotations_count"]) + if "annotations_url" in attributes: # pragma no branch + self._annotations_url = self._makeStringAttribute(attributes["annotations_url"]) + if "summary" in attributes: # pragma no branch + self._summary = self._makeStringAttribute(attributes["summary"]) + if "text" in attributes: # pragma no branch + self._text = self._makeStringAttribute(attributes["text"]) + if "title" in attributes: # pragma no branch + self._title = self._makeStringAttribute(attributes["title"]) diff --git a/venv/lib/python3.10/site-packages/github/CheckSuite.py b/venv/lib/python3.10/site-packages/github/CheckSuite.py new file mode 100644 index 0000000000000000000000000000000000000000..97c312ad5ebc92a5ecf5e89a74598b0567418e35 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/CheckSuite.py @@ -0,0 +1,313 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2020 Dhruv Manilawala # +# Copyright 2020 Steve Kowalik # +# Copyright 2020 Yannick Jadoul # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from datetime import datetime +from typing import TYPE_CHECKING, Any + +import github.CheckRun +import github.GitCommit +import github.GithubApp +import github.PullRequest +import github.Repository +from github.GithubObject import Attribute, CompletableGithubObject, NotSet, Opt, is_defined, is_optional +from github.PaginatedList import PaginatedList + +if TYPE_CHECKING: + from github.CheckRun import CheckRun + from github.GitCommit import GitCommit + from github.GithubApp import GithubApp + from github.PullRequest import PullRequest + from github.Repository import Repository + + +class CheckSuite(CompletableGithubObject): + """ + This class represents check suites. + + The reference can be found here + https://docs.github.com/en/rest/reference/checks#check-suites + + The OpenAPI schema can be found at + - /components/schemas/check-run/properties/check_suite + - /components/schemas/check-suite + + """ + + def _initAttributes(self) -> None: + self._after: Attribute[str] = NotSet + self._app: Attribute[GithubApp] = NotSet + self._before: Attribute[str] = NotSet + self._check_runs_url: Attribute[str] = NotSet + self._conclusion: Attribute[str] = NotSet + self._created_at: Attribute[datetime] = NotSet + self._head_branch: Attribute[str] = NotSet + self._head_commit: Attribute[GitCommit] = NotSet + self._head_sha: Attribute[str] = NotSet + self._id: Attribute[int] = NotSet + self._latest_check_runs_count: Attribute[int] = NotSet + self._node_id: Attribute[str] = NotSet + self._pull_requests: Attribute[list[PullRequest]] = NotSet + self._repository: Attribute[Repository] = NotSet + self._rerequestable: Attribute[bool] = NotSet + self._runs_rerequestable: Attribute[bool] = NotSet + self._status: Attribute[str] = NotSet + self._updated_at: Attribute[datetime] = NotSet + self._url: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"id": self._id.value, "url": self._url.value}) + + @property + def after(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._after) + return self._after.value + + @property + def app(self) -> GithubApp: + """ + :type: :class:`github.GithubApp.GithubApp` + """ + self._completeIfNotSet(self._app) + return self._app.value + + @property + def before(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._before) + return self._before.value + + @property + def check_runs_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._check_runs_url) + return self._check_runs_url.value + + @property + def conclusion(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._conclusion) + return self._conclusion.value + + @property + def created_at(self) -> datetime: + """ + :type: datetime.datetime + """ + self._completeIfNotSet(self._created_at) + return self._created_at.value + + @property + def head_branch(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._head_branch) + return self._head_branch.value + + @property + def head_commit(self) -> GitCommit: + """ + :type: :class:`github.GitCommit.GitCommit` + """ + self._completeIfNotSet(self._head_commit) + return self._head_commit.value + + @property + def head_sha(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._head_sha) + return self._head_sha.value + + @property + def id(self) -> int: + """ + :type: int + """ + self._completeIfNotSet(self._id) + return self._id.value + + @property + def latest_check_runs_count(self) -> int: + """ + :type: int + """ + self._completeIfNotSet(self._latest_check_runs_count) + return self._latest_check_runs_count.value + + @property + def node_id(self) -> str: + self._completeIfNotSet(self._node_id) + return self._node_id.value + + @property + def pull_requests(self) -> list[PullRequest]: + """ + :type: list of :class:`github.PullRequest.PullRequest` + """ + self._completeIfNotSet(self._pull_requests) + return self._pull_requests.value + + @property + def repository(self) -> Repository: + """ + :type: :class:`github.Repository.Repository` + """ + self._completeIfNotSet(self._repository) + return self._repository.value + + @property + def rerequestable(self) -> bool: + self._completeIfNotSet(self._rerequestable) + return self._rerequestable.value + + @property + def runs_rerequestable(self) -> bool: + self._completeIfNotSet(self._runs_rerequestable) + return self._runs_rerequestable.value + + @property + def status(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._status) + return self._status.value + + @property + def updated_at(self) -> datetime: + """ + :type: datetime.datetime + """ + self._completeIfNotSet(self._updated_at) + return self._updated_at.value + + @property + def url(self) -> str: + """ + :type: string + """ + return self._url.value + + def rerequest(self) -> bool: + """ + :calls: `POST /repos/{owner}/{repo}/check-suites/{check_suite_id}/rerequest `_ + :rtype: bool + """ + request_headers = {"Accept": "application/vnd.github.v3+json"} + status, _, _ = self._requester.requestJson("POST", f"{self.url}/rerequest", headers=request_headers) + return status == 201 + + def get_check_runs( + self, + check_name: Opt[str] = NotSet, + status: Opt[str] = NotSet, + filter: Opt[str] = NotSet, + ) -> PaginatedList[CheckRun]: + """ + :calls: `GET /repos/{owner}/{repo}/check-suites/{check_suite_id}/check-runs `_ + """ + assert is_optional(check_name, str), check_name + assert is_optional(status, str), status + assert is_optional(filter, str), filter + url_parameters: dict[str, Any] = {} + if is_defined(check_name): + url_parameters["check_name"] = check_name + if is_defined(status): + url_parameters["status"] = status + if is_defined(filter): + url_parameters["filter"] = filter + return PaginatedList( + github.CheckRun.CheckRun, + self._requester, + f"{self.url}/check-runs", + url_parameters, + headers={"Accept": "application/vnd.github.v3+json"}, + list_item="check_runs", + ) + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "after" in attributes: # pragma no branch + self._after = self._makeStringAttribute(attributes["after"]) + if "app" in attributes: # pragma no branch + self._app = self._makeClassAttribute(github.GithubApp.GithubApp, attributes["app"]) + if "before" in attributes: # pragma no branch + self._before = self._makeStringAttribute(attributes["before"]) + if "check_runs_url" in attributes: # pragma no branch + self._check_runs_url = self._makeStringAttribute(attributes["check_runs_url"]) + if "conclusion" in attributes: # pragma no branch + self._conclusion = self._makeStringAttribute(attributes["conclusion"]) + if "created_at" in attributes: # pragma no branch + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) + if "head_branch" in attributes: # pragma no branch + self._head_branch = self._makeStringAttribute(attributes["head_branch"]) + if "head_commit" in attributes: # pragma no branch + # This JSON swaps the 'sha' attribute for an 'id' attribute. + # The GitCommit object only looks for 'sha' + if "id" in attributes["head_commit"]: + attributes["head_commit"]["sha"] = attributes["head_commit"]["id"] + self._head_commit = self._makeClassAttribute(github.GitCommit.GitCommit, attributes["head_commit"]) + if "head_sha" in attributes: # pragma no branch + self._head_sha = self._makeStringAttribute(attributes["head_sha"]) + if "id" in attributes: # pragma no branch + self._id = self._makeIntAttribute(attributes["id"]) + if "latest_check_runs_count" in attributes: # pragma no branch + self._latest_check_runs_count = self._makeIntAttribute(attributes["latest_check_runs_count"]) + if "node_id" in attributes: # pragma no branch + self._node_id = self._makeStringAttribute(attributes["node_id"]) + if "pull_requests" in attributes: # pragma no branch + self._pull_requests = self._makeListOfClassesAttribute( + github.PullRequest.PullRequest, attributes["pull_requests"] + ) + if "repository" in attributes: # pragma no branch + self._repository = self._makeClassAttribute(github.Repository.Repository, attributes["repository"]) + if "rerequestable" in attributes: # pragma no branch + self._rerequestable = self._makeBoolAttribute(attributes["rerequestable"]) + if "runs_rerequestable" in attributes: # pragma no branch + self._runs_rerequestable = self._makeBoolAttribute(attributes["runs_rerequestable"]) + if "status" in attributes: # pragma no branch + self._status = self._makeStringAttribute(attributes["status"]) + if "updated_at" in attributes: # pragma no branch + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) + if "url" in attributes: # pragma no branch + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/venv/lib/python3.10/site-packages/github/Clones.py b/venv/lib/python3.10/site-packages/github/Clones.py new file mode 100644 index 0000000000000000000000000000000000000000..b27fc0bb859ba9deedec255ff84dbbcb7ba9ff48 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/Clones.py @@ -0,0 +1,95 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Justin Kufro # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from typing import TYPE_CHECKING, Any + +import github.Traffic +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + +if TYPE_CHECKING: + from github.Traffic import Traffic + + +class Clones(NonCompletableGithubObject): + """ + This class represents the total number of clones and breakdown per day or week for a GitHub repository. + + The reference can be found here + https://docs.github.com/en/rest/metrics/traffic#get-repository-clones + + The OpenAPI schema can be found at + - /components/schemas/clone-traffic + + """ + + def _initAttributes(self) -> None: + self._clones: Attribute[list[Traffic]] = NotSet + self._count: Attribute[int] = NotSet + self._uniques: Attribute[int] = NotSet + + def __repr__(self) -> str: + return self.get__repr__( + { + "count": self._count.value, + "uniques": self._uniques.value, + } + ) + + @property + def clones(self) -> list[Traffic]: + return self._clones.value + + @property + def count(self) -> int: + return self._count.value + + @property + def uniques(self) -> int: + return self._uniques.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "clones" in attributes: # pragma no branch + self._clones = self._makeListOfClassesAttribute(github.Traffic.Traffic, attributes["clones"]) + if "count" in attributes: # pragma no branch + self._count = self._makeIntAttribute(attributes["count"]) + if "uniques" in attributes: # pragma no branch + self._uniques = self._makeIntAttribute(attributes["uniques"]) diff --git a/venv/lib/python3.10/site-packages/github/CodeScanAlert.py b/venv/lib/python3.10/site-packages/github/CodeScanAlert.py new file mode 100644 index 0000000000000000000000000000000000000000..fad087e8e6e7fa2e680506c9833ed238216cac1d --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/CodeScanAlert.py @@ -0,0 +1,160 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2022 Eric Nieuwland # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from datetime import datetime +from typing import Any + +import github.CodeScanAlertInstance +import github.CodeScanRule +import github.CodeScanTool +import github.GithubObject +import github.NamedUser +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet +from github.PaginatedList import PaginatedList + + +class CodeScanAlert(NonCompletableGithubObject): + """ + This class represents alerts from code scanning. + + The reference can be found here + https://docs.github.com/en/rest/reference/code-scanning. + + """ + + def _initAttributes(self) -> None: + self._created_at: Attribute[datetime] = NotSet + self._dismissed_at: Attribute[datetime | None] = NotSet + self._dismissed_by: Attribute[github.NamedUser.NamedUser | None] = NotSet + self._dismissed_reason: Attribute[str | None] = NotSet + self._html_url: Attribute[str] = NotSet + self._instances_url: Attribute[str] = NotSet + self._most_recent_instance: Attribute[github.CodeScanAlertInstance.CodeScanAlertInstance] = NotSet + self._number: Attribute[int] = NotSet + self._rule: Attribute[github.CodeScanRule.CodeScanRule] = NotSet + self._state: Attribute[str] = NotSet + self._tool: Attribute[github.CodeScanTool.CodeScanTool] = NotSet + self._url: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"number": self.number}) + + @property + def created_at(self) -> datetime: + return self._created_at.value + + @property + def dismissed_at(self) -> datetime | None: + return self._dismissed_at.value + + @property + def dismissed_by(self) -> github.NamedUser.NamedUser | None: + return self._dismissed_by.value + + @property + def dismissed_reason(self) -> str | None: + return self._dismissed_reason.value + + @property + def html_url(self) -> str: + return self._html_url.value + + @property + def instances_url(self) -> str: + return self._instances_url.value + + @property + def most_recent_instance(self) -> github.CodeScanAlertInstance.CodeScanAlertInstance: + return self._most_recent_instance.value + + @property + def number(self) -> int: + return self._number.value + + @property + def rule(self) -> github.CodeScanRule.CodeScanRule: + return self._rule.value + + @property + def state(self) -> str: + return self._state.value + + @property + def tool(self) -> github.CodeScanTool.CodeScanTool: + return self._tool.value + + @property + def url(self) -> str: + return self._url.value + + def get_instances(self) -> PaginatedList[github.CodeScanAlertInstance.CodeScanAlertInstance]: + """ + Get instances. + + :calls: `GET` on the URL for instances as provided by Github. + + """ + return PaginatedList( + github.CodeScanAlertInstance.CodeScanAlertInstance, + self._requester, + self.instances_url, + None, + ) + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "created_at" in attributes: # pragma no branch + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) + if "dismissed_at" in attributes: # pragma no branch + self._dismissed_at = self._makeDatetimeAttribute(attributes["dismissed_at"]) + if "dismissed_by" in attributes: # pragma no branch + self._dismissed_by = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["dismissed_by"]) + if "dismissed_reason" in attributes: # pragma no branch + self._dismissed_reason = self._makeStringAttribute(attributes["dismissed_reason"]) + if "html_url" in attributes: # pragma no branch + self._html_url = self._makeStringAttribute(attributes["html_url"]) + if "instances_url" in attributes: # pragma no branch + self._instances_url = self._makeStringAttribute(attributes["instances_url"]) + + if "most_recent_instance" in attributes: # pragma no branch + self._most_recent_instance = self._makeClassAttribute( + github.CodeScanAlertInstance.CodeScanAlertInstance, + attributes["most_recent_instance"], + ) + if "number" in attributes: # pragma no branch + self._number = self._makeIntAttribute(attributes["number"]) + if "rule" in attributes: # pragma no branch + self._rule = self._makeClassAttribute(github.CodeScanRule.CodeScanRule, attributes["rule"]) + if "state" in attributes: # pragma no branch + self._state = self._makeStringAttribute(attributes["state"]) + if "tool" in attributes: # pragma no branch + self._tool = self._makeClassAttribute(github.CodeScanTool.CodeScanTool, attributes["tool"]) + + if "url" in attributes: # pragma no branch + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/venv/lib/python3.10/site-packages/github/PullRequestMergeStatus.py b/venv/lib/python3.10/site-packages/github/PullRequestMergeStatus.py new file mode 100644 index 0000000000000000000000000000000000000000..986985d31df5f3ed50db7ee2faa7275d7f471008 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/PullRequestMergeStatus.py @@ -0,0 +1,81 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2013 martinqt # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Mark Walker # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from typing import Any, Dict + +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + + +class PullRequestMergeStatus(NonCompletableGithubObject): + """ + This class represents PullRequestMergeStatuses. + + The reference can be found here + https://docs.github.com/en/rest/reference/pulls#check-if-a-pull-request-has-been-merged + + """ + + def _initAttributes(self) -> None: + self._merged: Attribute[bool] = NotSet + self._message: Attribute[str] = NotSet + self._sha: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"sha": self._sha.value, "merged": self._merged.value}) + + @property + def merged(self) -> bool: + return self._merged.value + + @property + def message(self) -> str: + return self._message.value + + @property + def sha(self) -> str: + return self._sha.value + + def _useAttributes(self, attributes: Dict[str, Any]) -> None: + if "merged" in attributes: # pragma no branch + self._merged = self._makeBoolAttribute(attributes["merged"]) + if "message" in attributes: # pragma no branch + self._message = self._makeStringAttribute(attributes["message"]) + if "sha" in attributes: # pragma no branch + self._sha = self._makeStringAttribute(attributes["sha"]) diff --git a/venv/lib/python3.10/site-packages/github/RateLimit.py b/venv/lib/python3.10/site-packages/github/RateLimit.py new file mode 100644 index 0000000000000000000000000000000000000000..434562c0f87c0be2ae9d7c9644c90cf13055f725 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/RateLimit.py @@ -0,0 +1,166 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Mark Walker # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2024 Bill Napier # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from typing import TYPE_CHECKING, Any + +import github.Rate +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + +if TYPE_CHECKING: + from github.Rate import Rate + + +class RateLimit(NonCompletableGithubObject): + """ + This class represents RateLimits. + + The reference can be found here + https://docs.github.com/en/rest/reference/rate-limit + + The OpenAPI schema can be found at + - /components/schemas/rate-limit-overview/properties/resources + + """ + + def _initAttributes(self) -> None: + self._actions_runner_registration: Attribute[Rate] = NotSet + self._code_scanning_upload: Attribute[Rate] = NotSet + self._code_search: Attribute[Rate] = NotSet + self._core: Attribute[Rate] = NotSet + self._dependency_snapshots: Attribute[Rate] = NotSet + self._graphql: Attribute[Rate] = NotSet + self._integration_manifest: Attribute[Rate] = NotSet + self._scim: Attribute[Rate] = NotSet + self._search: Attribute[Rate] = NotSet + self._source_import: Attribute[Rate] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"core": self._core.value}) + + @property + def actions_runner_registration(self) -> Rate: + """ + Rate limit for registering self-hosted runners in GitHub Actions. + """ + return self._actions_runner_registration.value + + @property + def code_scanning_upload(self) -> Rate: + """ + Rate limit for uploading SARIF results to code scanning. + """ + return self._code_scanning_upload.value + + @property + def code_search(self) -> Rate: + """ + Rate limit for the REST API for searching code. + """ + return self._code_search.value + + @property + def core(self) -> Rate: + """ + Rate limit for the non-search-related API. + """ + return self._core.value + + @property + def dependency_snapshots(self) -> Rate: + """ + Rate limit for submitting snapshots to the dependency graph. + """ + return self._dependency_snapshots.value + + @property + def graphql(self) -> Rate: + """ + (Experimental) Rate limit for GraphQL API, use with caution. + """ + return self._graphql.value + + @property + def integration_manifest(self) -> Rate: + """ + Rate limit for POST /app-manifests/{code}/conversions operation. + """ + return self._integration_manifest.value + + @property + def scim(self) -> github.Rate.Rate: + return self._scim.value + + @property + def search(self) -> Rate: + """ + Rate limit for the Search API. + """ + return self._search.value + + @property + def source_import(self) -> github.Rate.Rate: + return self._source_import.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "actions_runner_registration" in attributes: # pragma no branch + self._actions_runner_registration = self._makeClassAttribute( + github.Rate.Rate, attributes["actions_runner_registration"] + ) + if "code_scanning_upload" in attributes: # pragma no branch + self._code_scanning_upload = self._makeClassAttribute(github.Rate.Rate, attributes["code_scanning_upload"]) + if "code_search" in attributes: # pragma no branch + self._code_search = self._makeClassAttribute(github.Rate.Rate, attributes["code_search"]) + if "core" in attributes: # pragma no branch + self._core = self._makeClassAttribute(github.Rate.Rate, attributes["core"]) + if "dependency_snapshots" in attributes: # pragma no branch + self._dependency_snapshots = self._makeClassAttribute(github.Rate.Rate, attributes["dependency_snapshots"]) + if "graphql" in attributes: # pragma no branch + self._graphql = self._makeClassAttribute(github.Rate.Rate, attributes["graphql"]) + if "integration_manifest" in attributes: # pragma no branch + self._integration_manifest = self._makeClassAttribute(github.Rate.Rate, attributes["integration_manifest"]) + if "scim" in attributes: # pragma no branch + self._scim = self._makeClassAttribute(github.Rate.Rate, attributes["scim"]) + if "search" in attributes: # pragma no branch + self._search = self._makeClassAttribute(github.Rate.Rate, attributes["search"]) + if "source_import" in attributes: # pragma no branch + self._source_import = self._makeClassAttribute(github.Rate.Rate, attributes["source_import"]) diff --git a/venv/lib/python3.10/site-packages/github/Reaction.py b/venv/lib/python3.10/site-packages/github/Reaction.py new file mode 100644 index 0000000000000000000000000000000000000000..56e2c6c81b9c553d432c5a6b4094d48df696a367 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/Reaction.py @@ -0,0 +1,113 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2017 Nicolas Agustín Torres # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Mark Walker # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from datetime import datetime +from typing import TYPE_CHECKING, Any + +import github.NamedUser +from github.GithubObject import Attribute, CompletableGithubObject, NotSet + +from . import Consts + +if TYPE_CHECKING: + from github.NamedUser import NamedUser + + +class Reaction(CompletableGithubObject): + """ + This class represents Reactions. + + The reference can be found here + https://docs.github.com/en/rest/reference/reactions + + """ + + def _initAttributes(self) -> None: + self._content: Attribute[str] = NotSet + self._created_at: Attribute[datetime] = NotSet + self._id: Attribute[int] = NotSet + self._user: Attribute[NamedUser] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"id": self._id.value, "user": self._user.value}) + + @property + def content(self) -> str: + self._completeIfNotSet(self._content) + return self._content.value + + @property + def created_at(self) -> datetime: + self._completeIfNotSet(self._created_at) + return self._created_at.value + + @property + def id(self) -> int: + self._completeIfNotSet(self._id) + return self._id.value + + @property + def user(self) -> NamedUser: + self._completeIfNotSet(self._user) + return self._user.value + + def delete(self) -> None: + """ + :calls: `DELETE /reactions/{id} `_ + :rtype: None + """ + self._requester.requestJsonAndCheck( + "DELETE", + f"{self._parentUrl('')}/reactions/{self.id}", + headers={"Accept": Consts.mediaTypeReactionsPreview}, + ) + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "content" in attributes: # pragma no branch + self._content = self._makeStringAttribute(attributes["content"]) + if "created_at" in attributes: # pragma no branch + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) + if "id" in attributes: # pragma no branch + self._id = self._makeIntAttribute(attributes["id"]) + if "user" in attributes: # pragma no branch + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) diff --git a/venv/lib/python3.10/site-packages/github/RepoCodeSecurityConfig.py b/venv/lib/python3.10/site-packages/github/RepoCodeSecurityConfig.py new file mode 100644 index 0000000000000000000000000000000000000000..29c1c7e1cb3ed6f83b371177d01cd233ff1cd4ba --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/RepoCodeSecurityConfig.py @@ -0,0 +1,87 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Justin Kufro # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Bill Napier # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from typing import TYPE_CHECKING, Any + +import github.CodeSecurityConfig +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + +if TYPE_CHECKING: + pass + + +class RepoCodeSecurityConfig(NonCompletableGithubObject): + """ + This class represents Configurations for Code Security for a Repository. + + The reference can be found here + https://docs.github.com/en/rest/code-security/configurations. + + """ + + def _initAttributes(self) -> None: + self._configuration: Attribute[github.CodeSecurityConfig.CodeSecurityConfig] = NotSet + self._status: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__( + { + "configuration": self.configuration, + } + ) + + @property + def configuration(self) -> github.CodeSecurityConfig.CodeSecurityConfig: + return self._configuration.value + + @property + def status(self) -> str: + return self._status.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "configuration" in attributes: # pragma no branch + self._configuration = self._makeClassAttribute( + github.CodeSecurityConfig.CodeSecurityConfig, attributes["configuration"] + ) + if "status" in attributes: # pragma no branch + self._status = self._makeStringAttribute(attributes["status"]) diff --git a/venv/lib/python3.10/site-packages/github/Repository.py b/venv/lib/python3.10/site-packages/github/Repository.py new file mode 100644 index 0000000000000000000000000000000000000000..66d0afc9c7f7e5095bd146a92abe992d2de2fcea --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/Repository.py @@ -0,0 +1,4656 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Christopher Gilbert # +# Copyright 2012 Steve English # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Adrian Petrescu # +# Copyright 2013 Cameron White # +# Copyright 2013 David Farr # +# Copyright 2013 Mark Roddy # +# Copyright 2013 Vincent Jacques # +# Copyright 2013 martinqt # +# Copyright 2014 Vincent Jacques # +# Copyright 2015 Aaron Levine # +# Copyright 2015 Christopher Wilcox # +# Copyright 2015 Dan Vanderkam # +# Copyright 2015 Ed Holland # +# Copyright 2015 Enix Yu # +# Copyright 2015 Jay # +# Copyright 2015 Jonathan Debonis # +# Copyright 2015 Kevin Lewandowski # +# Copyright 2015 Kyle Hornberg # +# Copyright 2016 @tmshn # +# Copyright 2016 Dustin Spicuzza # +# Copyright 2016 Enix Yu # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Per Øyvind Karlsen # +# Copyright 2016 Peter Buckley # +# Copyright 2016 Sylvus # +# Copyright 2016 fukatani # +# Copyright 2016 ghfan # +# Copyright 2017 Andreas Lutro # +# Copyright 2017 Ben Firshman # +# Copyright 2017 Chris McBride # +# Copyright 2017 Hugo # +# Copyright 2017 Jannis Gebauer # +# Copyright 2017 Jason White # +# Copyright 2017 Jimmy Zelinskie # +# Copyright 2017 Simon # +# Copyright 2018 Aaron L. Levine # +# Copyright 2018 AetherDeity # +# Copyright 2018 Alice GIRARD # +# Copyright 2018 Andrew Smith # +# Copyright 2018 Benoit Latinier # +# Copyright 2018 Brian Torres-Gil # +# Copyright 2018 Hayden Fuss # +# Copyright 2018 Ilya Konstantinov # +# Copyright 2018 Jacopo Notarstefano # +# Copyright 2018 John Hui # +# Copyright 2018 Justin Kufro # +# Copyright 2018 Mateusz Loskot # +# Copyright 2018 Michael Behrisch # +# Copyright 2018 Nicholas Buse # +# Copyright 2018 Philip May # +# Copyright 2018 Raihaan <31362124+res0nance@users.noreply.github.com> # +# Copyright 2018 Shinichi TAMURA # +# Copyright 2018 Steve Kowalik # +# Copyright 2018 Vinay Hegde # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 Will Yardley # +# Copyright 2018 Yossarian King # +# Copyright 2018 per1234 # +# Copyright 2018 sechastain # +# Copyright 2018 sfdye # +# Copyright 2019 Adam Baratz # +# Copyright 2019 Alex # +# Copyright 2019 Kevin LaFlamme # +# Copyright 2019 Olof-Joachim Frahm (欧雅福) # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Tim Gates # +# Copyright 2019 Wan Liuyang # +# Copyright 2019 Will Li # +# Copyright 2020 Alice GIRARD # +# Copyright 2020 Anuj Bansal # +# Copyright 2020 Chris de Graaf # +# Copyright 2020 Dhruv Manilawala # +# Copyright 2020 Dominic Davis-Foster # +# Copyright 2020 Florent Clarret # +# Copyright 2020 Glenn McDonald # +# Copyright 2020 Huw Jones # +# Copyright 2020 Mark Bromell # +# Copyright 2020 Max Wittig # +# Copyright 2020 Pascal Hofmann # +# Copyright 2020 Steve Kowalik # +# Copyright 2020 Tim Gates # +# Copyright 2020 Victor Zeng # +# Copyright 2020 ton-katsu # +# Copyright 2021 Chris Keating # +# Copyright 2021 Floyd Hightower # +# Copyright 2021 Mark Walker # +# Copyright 2021 Steve Kowalik # +# Copyright 2021 Tanner <51724788+lightningboltemoji@users.noreply.github.com> # +# Copyright 2021 xmo-odoo # +# Copyright 2022 Aleksei Fedotov # +# Copyright 2022 Eric Nieuwland # +# Copyright 2022 Ibrahim Hussaini # +# Copyright 2022 KimSia Sim <245021+simkimsia@users.noreply.github.com> # +# Copyright 2022 Marco Köpcke # +# Copyright 2023 Andrew Collington # +# Copyright 2023 Andrew Dawes <53574062+AndrewJDawes@users.noreply.github.com> # +# Copyright 2023 Armen Martirosyan # +# Copyright 2023 BradChengIRESS <49461141+BradChengIRESS@users.noreply.github.com># +# Copyright 2023 Enrico Minack # +# Copyright 2023 Felipe Peter # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Jonathan Greg <31892308+jmgreg31@users.noreply.github.com> # +# Copyright 2023 Jonathan Leitschuh # +# Copyright 2023 Joseph Henrich # +# Copyright 2023 Kevin Grandjean # +# Copyright 2023 Mark Amery # +# Copyright 2023 Mauricio Alejandro Martínez Pacheco # +# Copyright 2023 Mauricio Alejandro Martínez Pacheco # +# Copyright 2023 Max Mehl <6170081+mxmehl@users.noreply.github.com> # +# Copyright 2023 Micael <10292135+notmicaelfilipe@users.noreply.github.com> # +# Copyright 2023 Mikhail f. Shiryaev # +# Copyright 2023 Oskar Jansson <56458534+janssonoskar@users.noreply.github.com># +# Copyright 2023 Philipp A # +# Copyright 2023 Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com># +# Copyright 2023 Sol Redfern <59831933+Tsuesun@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2023 Wojciech Barczyński <104033489+WojciechBarczynski@users.noreply.github.com># +# Copyright 2023 alson # +# Copyright 2023 chantra # +# Copyright 2024 Benjamin K <53038537+treee111@users.noreply.github.com> # +# Copyright 2024 Caleb McCombs # +# Copyright 2024 Chris Wells # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Heitor Polidoro # +# Copyright 2024 Heitor de Bittencourt # +# Copyright 2024 Jacky Lam # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2024 Sebastien NICOT # +# Copyright 2024 Sebastián Ramírez # +# Copyright 2024 Thomas Cooper # +# Copyright 2024 Thomas Crowley <15927917+thomascrowley@users.noreply.github.com># +# Copyright 2024 jodelasur <34933233+jodelasur@users.noreply.github.com> # +# Copyright 2025 Bill Napier # +# Copyright 2025 Enrico Minack # +# Copyright 2025 Mikhail f. Shiryaev # +# Copyright 2025 Tan An Nie <121005973+tanannie22@users.noreply.github.com> # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +import collections +import urllib.parse +from base64 import b64encode +from collections.abc import Iterable +from datetime import date, datetime, timezone +from typing import TYPE_CHECKING, Any + +from deprecated import deprecated + +import github.AdvisoryCredit +import github.AdvisoryVulnerability +import github.Artifact +import github.AuthenticatedUser +import github.Autolink +import github.Branch +import github.CheckRun +import github.CheckSuite +import github.Clones +import github.CodeScanAlert +import github.Commit +import github.CommitComment +import github.Comparison +import github.ContentFile +import github.DependabotAlert +import github.Deployment +import github.Download +import github.Environment +import github.EnvironmentDeploymentBranchPolicy +import github.EnvironmentProtectionRule +import github.EnvironmentProtectionRuleReviewer +import github.Event +import github.GitBlob +import github.GitCommit +import github.GithubObject +import github.GitRef +import github.GitRelease +import github.GitReleaseAsset +import github.GitTag +import github.GitTree +import github.Hook +import github.HookDelivery +import github.Invitation +import github.Issue +import github.IssueComment +import github.IssueEvent +import github.Label +import github.License +import github.MergedUpstream +import github.Milestone +import github.NamedUser +import github.Notification +import github.Organization +import github.PaginatedList +import github.Path +import github.Permissions +import github.Project +import github.PublicKey +import github.PullRequest +import github.PullRequestComment +import github.Referrer +import github.RepoCodeSecurityConfig +import github.RepositoryAdvisory +import github.RepositoryDiscussion +import github.RepositoryKey +import github.RepositoryPreferences +import github.Secret +import github.SecurityAndAnalysis +import github.SelfHostedActionsRunner +import github.SourceImport +import github.Stargazer +import github.StatsCodeFrequency +import github.StatsCommitActivity +import github.StatsContributor +import github.StatsParticipation +import github.StatsPunchCard +import github.Tag +import github.Team +import github.Variable +import github.View +import github.Workflow +import github.WorkflowRun +from github import Consts +from github.Environment import Environment +from github.GithubObject import ( + Attribute, + CompletableGithubObject, + NotSet, + Opt, + _NotSetType, + is_defined, + is_optional, + is_optional_list, + is_undefined, +) +from github.PaginatedList import PaginatedList + +if TYPE_CHECKING: + from github.Artifact import Artifact + from github.AuthenticatedUser import AuthenticatedUser + from github.Autolink import Autolink + from github.Branch import Branch + from github.CheckRun import CheckRun + from github.CheckSuite import CheckSuite + from github.Clones import Clones + from github.CodeScanAlert import CodeScanAlert + from github.Commit import Commit + from github.CommitComment import CommitComment + from github.Comparison import Comparison + from github.ContentFile import ContentFile + from github.DependabotAlert import DependabotAlert + from github.Deployment import Deployment + from github.Download import Download + from github.EnvironmentDeploymentBranchPolicy import ( + EnvironmentDeploymentBranchPolicyParams, + ) + from github.EnvironmentProtectionRuleReviewer import ReviewerParams + from github.Event import Event + from github.GitBlob import GitBlob + from github.GitCommit import GitCommit + from github.GitRef import GitRef + from github.GitRelease import GitRelease + from github.GitReleaseAsset import GitReleaseAsset + from github.GitTag import GitTag + from github.GitTree import GitTree + from github.Hook import Hook + from github.InputGitAuthor import InputGitAuthor + from github.InputGitTreeElement import InputGitTreeElement + from github.Invitation import Invitation + from github.Issue import Issue + from github.IssueComment import IssueComment + from github.IssueEvent import IssueEvent + from github.Label import Label + from github.License import License + from github.MergedUpstream import MergedUpstream + from github.Milestone import Milestone + from github.NamedUser import NamedUser + from github.Notification import Notification + from github.Organization import Organization + from github.Path import Path + from github.Permissions import Permissions + from github.Project import Project + from github.PublicKey import PublicKey + from github.PullRequest import PullRequest + from github.PullRequestComment import PullRequestComment + from github.Referrer import Referrer + from github.RepoCodeSecurityConfig import RepoCodeSecurityConfig + from github.RepositoryDiscussion import RepositoryDiscussion + from github.RepositoryKey import RepositoryKey + from github.RepositoryPreferences import RepositoryPreferences + from github.SecurityAndAnalysis import SecurityAndAnalysis + from github.SelfHostedActionsRunner import SelfHostedActionsRunner + from github.SourceImport import SourceImport + from github.Stargazer import Stargazer + from github.StatsCodeFrequency import StatsCodeFrequency + from github.StatsCommitActivity import StatsCommitActivity + from github.StatsContributor import StatsContributor + from github.StatsParticipation import StatsParticipation + from github.StatsPunchCard import StatsPunchCard + from github.Tag import Tag + from github.Team import Team + from github.View import View + from github.Workflow import Workflow + from github.WorkflowRun import WorkflowRun + + +class Repository(CompletableGithubObject): + """ + This class represents Repositories. + + The reference can be found here + https://docs.github.com/en/rest/reference/repos + + The OpenAPI schema can be found at + - /components/schemas/event/properties/repo + - /components/schemas/full-repository + - /components/schemas/minimal-repository + - /components/schemas/nullable-repository + - /components/schemas/pull-request-minimal/properties/base/properties/repo + - /components/schemas/pull-request-minimal/properties/head/properties/repo + - /components/schemas/repository + - /components/schemas/simple-repository + + """ + + def _initAttributes(self) -> None: + self._allow_auto_merge: Attribute[bool] = NotSet + self._allow_forking: Attribute[bool] = NotSet + self._allow_merge_commit: Attribute[bool] = NotSet + self._allow_rebase_merge: Attribute[bool] = NotSet + self._allow_squash_merge: Attribute[bool] = NotSet + self._allow_update_branch: Attribute[bool] = NotSet + self._anonymous_access_enabled: Attribute[bool] = NotSet + self._archive_url: Attribute[str] = NotSet + self._archived: Attribute[bool] = NotSet + self._assignees_url: Attribute[str] = NotSet + self._blobs_url: Attribute[str] = NotSet + self._branches_url: Attribute[str] = NotSet + self._clone_url: Attribute[str] = NotSet + self._code_of_conduct: Attribute[dict[str, Any]] = NotSet + self._collaborators_url: Attribute[str] = NotSet + self._comments_url: Attribute[str] = NotSet + self._commits_url: Attribute[str] = NotSet + self._compare_url: Attribute[str] = NotSet + self._contents_url: Attribute[str] = NotSet + self._contributors_url: Attribute[str] = NotSet + self._created_at: Attribute[datetime] = NotSet + self._custom_properties: Attribute[dict[str, None | str | list]] = NotSet # type: ignore + self._default_branch: Attribute[str] = NotSet + self._delete_branch_on_merge: Attribute[bool] = NotSet + self._deployments_url: Attribute[str] = NotSet + self._description: Attribute[str] = NotSet + self._disabled: Attribute[bool] = NotSet + self._downloads_url: Attribute[str] = NotSet + self._events_url: Attribute[str] = NotSet + self._fork: Attribute[bool] = NotSet + self._forks: Attribute[int] = NotSet + self._forks_count: Attribute[int] = NotSet + self._forks_url: Attribute[str] = NotSet + self._full_name: Attribute[str] = NotSet + self._git_commits_url: Attribute[str] = NotSet + self._git_refs_url: Attribute[str] = NotSet + self._git_tags_url: Attribute[str] = NotSet + self._git_url: Attribute[str] = NotSet + self._has_discussions: Attribute[bool] = NotSet + self._has_downloads: Attribute[bool] = NotSet + self._has_issues: Attribute[bool] = NotSet + self._has_pages: Attribute[bool] = NotSet + self._has_projects: Attribute[bool] = NotSet + self._has_wiki: Attribute[bool] = NotSet + self._homepage: Attribute[str] = NotSet + self._hooks_url: Attribute[str] = NotSet + self._html_url: Attribute[str] = NotSet + self._id: Attribute[int] = NotSet + self._is_template: Attribute[bool] = NotSet + self._issue_comment_url: Attribute[str] = NotSet + self._issue_events_url: Attribute[str] = NotSet + self._issues_url: Attribute[str] = NotSet + self._keys_url: Attribute[str] = NotSet + self._labels_url: Attribute[str] = NotSet + self._language: Attribute[str] = NotSet + self._languages_url: Attribute[str] = NotSet + self._license: Attribute[License] = NotSet + self._master_branch: Attribute[str] = NotSet + self._merge_commit_message: Attribute[str] = NotSet + self._merge_commit_title: Attribute[str] = NotSet + self._merges_url: Attribute[str] = NotSet + self._milestones_url: Attribute[str] = NotSet + self._mirror_url: Attribute[str] = NotSet + self._name: Attribute[str] = NotSet + self._network_count: Attribute[int] = NotSet + self._node_id: Attribute[str] = NotSet + self._notifications_url: Attribute[str] = NotSet + self._open_issues: Attribute[int] = NotSet + self._open_issues_count: Attribute[int] = NotSet + self._organization: Attribute[Organization] = NotSet + self._owner: Attribute[NamedUser] = NotSet + self._parent: Attribute[Repository] = NotSet + self._permissions: Attribute[Permissions] = NotSet + self._private: Attribute[bool] = NotSet + self._pulls_url: Attribute[str] = NotSet + self._pushed_at: Attribute[datetime] = NotSet + self._releases_url: Attribute[str] = NotSet + self._role_name: Attribute[str] = NotSet + self._security_and_analysis: Attribute[SecurityAndAnalysis] = NotSet + self._size: Attribute[int] = NotSet + self._source: Attribute[Repository] = NotSet + self._squash_merge_commit_message: Attribute[str] = NotSet + self._squash_merge_commit_title: Attribute[str] = NotSet + self._ssh_url: Attribute[str] = NotSet + self._stargazers_count: Attribute[int] = NotSet + self._stargazers_url: Attribute[str] = NotSet + self._starred_at: Attribute[str] = NotSet + self._statuses_url: Attribute[str] = NotSet + self._subscribers_count: Attribute[int] = NotSet + self._subscribers_url: Attribute[str] = NotSet + self._subscription_url: Attribute[str] = NotSet + self._svn_url: Attribute[str] = NotSet + self._tags_url: Attribute[str] = NotSet + self._teams_url: Attribute[str] = NotSet + self._temp_clone_token: Attribute[str] = NotSet + self._template_repository: Attribute[Repository] = NotSet + self._topics: Attribute[list[str]] = NotSet + self._trees_url: Attribute[str] = NotSet + self._updated_at: Attribute[datetime] = NotSet + self._url: Attribute[str] = NotSet + self._use_squash_pr_title_as_default: Attribute[bool] = NotSet + self._visibility: Attribute[str] = NotSet + self._watchers: Attribute[int] = NotSet + self._watchers_count: Attribute[int] = NotSet + self._web_commit_signoff_required: Attribute[bool] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"full_name": self._full_name.value}) + + @property + def _identity(self) -> str: + return f"{self.owner.login}/{self.name}" + + @property + def allow_auto_merge(self) -> bool: + """ + :type: bool + """ + self._completeIfNotSet(self._allow_auto_merge) + return self._allow_auto_merge.value + + @property + def allow_forking(self) -> bool: + """ + :type: bool + """ + self._completeIfNotSet(self._allow_forking) + return self._allow_forking.value + + @property + def allow_merge_commit(self) -> bool: + """ + :type: bool + """ + self._completeIfNotSet(self._allow_merge_commit) + return self._allow_merge_commit.value + + @property + def allow_rebase_merge(self) -> bool: + """ + :type: bool + """ + self._completeIfNotSet(self._allow_rebase_merge) + return self._allow_rebase_merge.value + + @property + def allow_squash_merge(self) -> bool: + """ + :type: bool + """ + self._completeIfNotSet(self._allow_squash_merge) + return self._allow_squash_merge.value + + @property + def allow_update_branch(self) -> bool: + """ + :type: bool + """ + self._completeIfNotSet(self._allow_update_branch) + return self._allow_update_branch.value + + @property + def anonymous_access_enabled(self) -> bool: + self._completeIfNotSet(self._anonymous_access_enabled) + return self._anonymous_access_enabled.value + + @property + def archive_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._archive_url) + return self._archive_url.value + + @property + def archived(self) -> bool: + """ + :type: bool + """ + self._completeIfNotSet(self._archived) + return self._archived.value + + @property + def assignees_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._assignees_url) + return self._assignees_url.value + + @property + def blobs_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._blobs_url) + return self._blobs_url.value + + @property + def branches_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._branches_url) + return self._branches_url.value + + @property + def clone_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._clone_url) + return self._clone_url.value + + @property + def code_of_conduct(self) -> dict[str, Any]: + self._completeIfNotSet(self._code_of_conduct) + return self._code_of_conduct.value + + @property + def collaborators_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._collaborators_url) + return self._collaborators_url.value + + @property + def comments_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._comments_url) + return self._comments_url.value + + @property + def commits_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._commits_url) + return self._commits_url.value + + @property + def compare_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._compare_url) + return self._compare_url.value + + @property + def contents_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._contents_url) + return self._contents_url.value + + @property + def contributors_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._contributors_url) + return self._contributors_url.value + + @property + def created_at(self) -> datetime: + """ + :type: datetime + """ + self._completeIfNotSet(self._created_at) + return self._created_at.value + + @property + def custom_properties(self) -> dict[str, None | str | list]: + """ + :type: dict[str, None | str | list] + """ + self._completeIfNotSet(self._custom_properties) + return self._custom_properties.value + + @property + def default_branch(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._default_branch) + return self._default_branch.value + + @property + def delete_branch_on_merge(self) -> bool: + """ + :type: bool + """ + self._completeIfNotSet(self._delete_branch_on_merge) + return self._delete_branch_on_merge.value + + @property + def deployments_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._deployments_url) + return self._deployments_url.value + + @property + def description(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._description) + return self._description.value + + @property + def disabled(self) -> bool: + self._completeIfNotSet(self._disabled) + return self._disabled.value + + @property + def downloads_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._downloads_url) + return self._downloads_url.value + + @property + def events_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._events_url) + return self._events_url.value + + @property + def fork(self) -> bool: + """ + :type: bool + """ + self._completeIfNotSet(self._fork) + return self._fork.value + + @property + def forks(self) -> int: + """ + :type: integer + """ + self._completeIfNotSet(self._forks) + return self._forks.value + + @property + def forks_count(self) -> int: + """ + :type: integer + """ + self._completeIfNotSet(self._forks_count) + return self._forks_count.value + + @property + def forks_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._forks_url) + return self._forks_url.value + + @property + def full_name(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._full_name) + return self._full_name.value + + @property + def git_commits_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._git_commits_url) + return self._git_commits_url.value + + @property + def git_refs_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._git_refs_url) + return self._git_refs_url.value + + @property + def git_tags_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._git_tags_url) + return self._git_tags_url.value + + @property + def git_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._git_url) + return self._git_url.value + + @property + def has_discussions(self) -> bool: + """ + :type: bool + """ + self._completeIfNotSet(self._has_discussions) + return self._has_discussions.value + + @property + def has_downloads(self) -> bool: + """ + :type: bool + """ + self._completeIfNotSet(self._has_downloads) + return self._has_downloads.value + + @property + def has_issues(self) -> bool: + """ + :type: bool + """ + self._completeIfNotSet(self._has_issues) + return self._has_issues.value + + @property + def has_pages(self) -> bool: + """ + :type: bool + """ + self._completeIfNotSet(self._has_pages) + return self._has_pages.value + + @property + def has_projects(self) -> bool: + """ + :type: bool + """ + self._completeIfNotSet(self._has_projects) + return self._has_projects.value + + @property + def has_wiki(self) -> bool: + """ + :type: bool + """ + self._completeIfNotSet(self._has_wiki) + return self._has_wiki.value + + @property + def homepage(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._homepage) + return self._homepage.value + + @property + def hooks_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._hooks_url) + return self._hooks_url.value + + @property + def html_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._html_url) + return self._html_url.value + + @property + def id(self) -> int: + """ + :type: integer + """ + self._completeIfNotSet(self._id) + return self._id.value + + @property + def is_template(self) -> bool: + """ + :type: bool + """ + self._completeIfNotSet(self._is_template) + return self._is_template.value + + @property + def issue_comment_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._issue_comment_url) + return self._issue_comment_url.value + + @property + def issue_events_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._issue_events_url) + return self._issue_events_url.value + + @property + def issues_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._issues_url) + return self._issues_url.value + + @property + def keys_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._keys_url) + return self._keys_url.value + + @property + def labels_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._labels_url) + return self._labels_url.value + + @property + def language(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._language) + return self._language.value + + @property + def languages_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._languages_url) + return self._languages_url.value + + @property + def license(self) -> License: + self._completeIfNotSet(self._license) + return self._license.value + + @property + def master_branch(self) -> str: + self._completeIfNotSet(self._master_branch) + return self._master_branch.value + + @property + def merge_commit_message(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._merge_commit_message) + return self._merge_commit_message.value + + @property + def merge_commit_title(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._merge_commit_title) + return self._merge_commit_title.value + + @property + def merges_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._merges_url) + return self._merges_url.value + + @property + def milestones_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._milestones_url) + return self._milestones_url.value + + @property + def mirror_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._mirror_url) + return self._mirror_url.value + + @property + def name(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._name) + return self._name.value + + @property + def network_count(self) -> int: + """ + :type: integer + """ + self._completeIfNotSet(self._network_count) + return self._network_count.value + + @property + def node_id(self) -> str: + self._completeIfNotSet(self._node_id) + return self._node_id.value + + @property + def notifications_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._notifications_url) + return self._notifications_url.value + + @property + def open_issues(self) -> int: + """ + :type: integer + """ + self._completeIfNotSet(self._open_issues) + return self._open_issues.value + + @property + def open_issues_count(self) -> int: + """ + :type: integer + """ + self._completeIfNotSet(self._open_issues_count) + return self._open_issues_count.value + + @property + def organization(self) -> Organization: + """ + :type: :class:`github.Organization.Organization` + """ + self._completeIfNotSet(self._organization) + return self._organization.value + + @property + def owner(self) -> NamedUser: + """ + :type: :class:`github.NamedUser.NamedUser` + """ + self._completeIfNotSet(self._owner) + return self._owner.value + + @property + def parent(self) -> Repository: + """ + :type: :class:`github.Repository.Repository` + """ + self._completeIfNotSet(self._parent) + return self._parent.value + + @property + def permissions(self) -> Permissions: + """ + :type: :class:`github.Permissions.Permissions` + """ + self._completeIfNotSet(self._permissions) + return self._permissions.value + + @property + def private(self) -> bool: + """ + :type: bool + """ + self._completeIfNotSet(self._private) + return self._private.value + + @property + def pulls_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._pulls_url) + return self._pulls_url.value + + @property + def pushed_at(self) -> datetime: + """ + :type: datetime + """ + self._completeIfNotSet(self._pushed_at) + return self._pushed_at.value + + @property + def releases_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._releases_url) + return self._releases_url.value + + @property + def role_name(self) -> str: + self._completeIfNotSet(self._role_name) + return self._role_name.value + + @property + def security_and_analysis(self) -> SecurityAndAnalysis: + """ + :type: :class:`github.SecurityAndAnalysis.SecurityAndAnalysis` + """ + self._completeIfNotSet(self._security_and_analysis) + return self._security_and_analysis.value + + @property + def size(self) -> int: + """ + :type: integer + """ + self._completeIfNotSet(self._size) + return self._size.value + + @property + def source(self) -> Repository | None: + """ + :type: :class:`github.Repository.Repository` + """ + self._completeIfNotSet(self._source) + return self._source.value + + @property + def squash_merge_commit_message(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._squash_merge_commit_message) + return self._squash_merge_commit_message.value + + @property + def squash_merge_commit_title(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._squash_merge_commit_title) + return self._squash_merge_commit_title.value + + @property + def ssh_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._ssh_url) + return self._ssh_url.value + + @property + def stargazers_count(self) -> int: + """ + :type: integer + """ + self._completeIfNotSet(self._stargazers_count) # pragma no cover (Should be covered) + return self._stargazers_count.value # pragma no cover (Should be covered) + + @property + def stargazers_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._stargazers_url) + return self._stargazers_url.value + + @property + def starred_at(self) -> str: + self._completeIfNotSet(self._starred_at) + return self._starred_at.value + + @property + def statuses_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._statuses_url) + return self._statuses_url.value + + @property + def subscribers_count(self) -> int: + """ + :type: integer + """ + self._completeIfNotSet(self._subscribers_count) + return self._subscribers_count.value + + @property + def subscribers_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._subscribers_url) + return self._subscribers_url.value + + @property + def subscription_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._subscription_url) + return self._subscription_url.value + + @property + def svn_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._svn_url) + return self._svn_url.value + + @property + def tags_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._tags_url) + return self._tags_url.value + + @property + def teams_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._teams_url) + return self._teams_url.value + + @property + def temp_clone_token(self) -> str: + self._completeIfNotSet(self._temp_clone_token) + return self._temp_clone_token.value + + @property + def template_repository(self) -> github.Repository.Repository: + self._completeIfNotSet(self._template_repository) + return self._template_repository.value + + @property + def topics(self) -> list[str]: + """ + :type: list of strings + """ + self._completeIfNotSet(self._topics) + return self._topics.value + + @property + def trees_url(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._trees_url) + return self._trees_url.value + + @property + def updated_at(self) -> datetime: + """ + :type: datetime + """ + self._completeIfNotSet(self._updated_at) + return self._updated_at.value + + @property + def url(self) -> str: + if is_undefined(self._url) and is_defined(self._owner) and is_defined(self._name): + self._url = self._makeStringAttribute(self._requester.base_url + f"/repos/{self.owner.login}/{self.name}") + self._completeIfNotSet(self._url) + return self._url.value + + @property + def use_squash_pr_title_as_default(self) -> bool: + self._completeIfNotSet(self._use_squash_pr_title_as_default) + return self._use_squash_pr_title_as_default.value + + @property + def visibility(self) -> str: + self._completeIfNotSet(self._visibility) + return self._visibility.value + + @property + def watchers(self) -> int: + self._completeIfNotSet(self._watchers) + return self._watchers.value + + @property + def watchers_count(self) -> int: + self._completeIfNotSet(self._watchers_count) + return self._watchers_count.value + + @property + def web_commit_signoff_required(self) -> bool: + """ + :type: bool + """ + self._completeIfNotSet(self._web_commit_signoff_required) + return self._web_commit_signoff_required.value + + def add_to_collaborators(self, collaborator: str | NamedUser, permission: Opt[str] = NotSet) -> Invitation | None: + """ + :calls: `PUT /repos/{owner}/{repo}/collaborators/{user} `_ + :param collaborator: string or :class:`github.NamedUser.NamedUser` + :param permission: string 'pull', 'push', 'admin', 'maintain', 'triage', or a custom repository role name, if the owning organization has defined any + :rtype: None + """ + assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, str), collaborator + assert is_optional(permission, str), permission + + if isinstance(collaborator, github.NamedUser.NamedUser): + collaborator = collaborator._identity + else: + collaborator = urllib.parse.quote(collaborator) + + if is_defined(permission): + put_parameters = {"permission": permission} + else: + put_parameters = None + + headers, data = self._requester.requestJsonAndCheck( + "PUT", f"{self.url}/collaborators/{collaborator}", input=put_parameters + ) + # return an invitation object if there's data returned by the API. If data is empty + # there's a pending invitation for the given user. + return ( + github.Invitation.Invitation(self._requester, headers, data, completed=True) if data is not None else None + ) + + def get_collaborator_permission(self, collaborator: str | NamedUser) -> str: + """ + :calls: `GET /repos/{owner}/{repo}/collaborators/{username}/permission `_ + :param collaborator: string or :class:`github.NamedUser.NamedUser` + :rtype: string + """ + assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, str), collaborator + if isinstance(collaborator, github.NamedUser.NamedUser): + collaborator = collaborator._identity + else: + collaborator = urllib.parse.quote(collaborator) + headers, data = self._requester.requestJsonAndCheck( + "GET", + f"{self.url}/collaborators/{collaborator}/permission", + ) + return data["permission"] + + def get_pending_invitations(self) -> PaginatedList[Invitation]: + """ + :calls: `GET /repos/{owner}/{repo}/invitations `_ + :rtype: :class:`PaginatedList` of :class:`github.Invitation.Invitation` + """ + return PaginatedList( + github.Invitation.Invitation, + self._requester, + f"{self.url}/invitations", + None, + ) + + def remove_invitation(self, invite_id: int) -> None: + """ + :calls: `DELETE /repos/{owner}/{repo}/invitations/{invitation_id} `_ + :rtype: None + """ + assert isinstance(invite_id, int), invite_id + + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.url}/invitations/{invite_id}") + + def compare(self, base: str, head: str) -> Comparison: + """ + :calls: `GET /repos/{owner}/{repo}/compare/{base...:head} `_ + :param base: string + :param head: string + :rtype: :class:`github.Comparison.Comparison` + """ + assert isinstance(base, str), base + assert isinstance(head, str), head + base = urllib.parse.quote(base) + head = urllib.parse.quote(head) + # the compare API has a per_page default of 250, which is different to Consts.DEFAULT_PER_PAGE + per_page = self._requester.per_page if self._requester.per_page != Consts.DEFAULT_PER_PAGE else 250 + # only with page=1 we get the pagination headers for the commits element + params = {"page": 1, "per_page": per_page} + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/compare/{base}...{head}", params) + return github.Comparison.Comparison(self._requester, headers, data, completed=True) + + def create_autolink( + self, key_prefix: str, url_template: str, is_alphanumeric: Opt[bool] = NotSet + ) -> github.Autolink.Autolink: + """ + :calls: `POST /repos/{owner}/{repo}/autolinks `_ + :param key_prefix: string + :param url_template: string + :param is_alphanumeric: bool + :rtype: :class:`github.Autolink.Autolink` + """ + assert isinstance(key_prefix, str), key_prefix + assert isinstance(url_template, str), url_template + assert is_optional(is_alphanumeric, bool), is_alphanumeric + + post_parameters = NotSet.remove_unset_items( + {"key_prefix": key_prefix, "url_template": url_template, "is_alphanumeric": is_alphanumeric} + ) + + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/autolinks", input=post_parameters) + + return github.Autolink.Autolink(self._requester, headers, data) + + def create_git_blob(self, content: str, encoding: str) -> GitBlob: + """ + :calls: `POST /repos/{owner}/{repo}/git/blobs `_ + :param content: string + :param encoding: string + :rtype: :class:`github.GitBlob.GitBlob` + """ + assert isinstance(content, str), content + assert isinstance(encoding, str), encoding + post_parameters = { + "content": content, + "encoding": encoding, + } + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/git/blobs", input=post_parameters) + return github.GitBlob.GitBlob(self._requester, headers, data, completed=True) + + def create_git_commit( + self, + message: str, + tree: GitTree, + parents: list[GitCommit], + author: Opt[InputGitAuthor] = NotSet, + committer: Opt[InputGitAuthor] = NotSet, + ) -> GitCommit: + """ + :calls: `POST /repos/{owner}/{repo}/git/commits `_ + :param message: string + :param tree: :class:`github.GitTree.GitTree` + :param parents: list of :class:`github.GitCommit.GitCommit` + :param author: :class:`github.InputGitAuthor.InputGitAuthor` + :param committer: :class:`github.InputGitAuthor.InputGitAuthor` + :rtype: :class:`github.GitCommit.GitCommit` + """ + assert isinstance(message, str), message + assert isinstance(tree, github.GitTree.GitTree), tree + assert all(isinstance(element, github.GitCommit.GitCommit) for element in parents), parents + assert is_optional(author, github.InputGitAuthor), author + assert is_optional(committer, github.InputGitAuthor), committer + post_parameters: dict[str, Any] = { + "message": message, + "tree": tree._identity, + "parents": [element._identity for element in parents], + } + if is_defined(author): + post_parameters["author"] = author._identity + if is_defined(committer): + post_parameters["committer"] = committer._identity + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/git/commits", input=post_parameters) + return github.GitCommit.GitCommit(self._requester, headers, data, completed=True) + + def create_git_ref(self, ref: str, sha: str) -> GitRef: + """ + :calls: `POST /repos/{owner}/{repo}/git/refs `_ + :param ref: string + :param sha: string + :rtype: :class:`github.GitRef.GitRef` + """ + assert isinstance(ref, str), ref + assert isinstance(sha, str), sha + post_parameters = { + "ref": ref, + "sha": sha, + } + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/git/refs", input=post_parameters) + return github.GitRef.GitRef(self._requester, headers, data, completed=True) + + # TODO: v3: reorder arguments and add default value `NotSet` where `Opt[str]` + def create_git_tag_and_release( + self, + tag: str, + tag_message: str, + release_name: Opt[str], + release_message: Opt[str], + object: str, + type: str, + tagger: Opt[InputGitAuthor] = NotSet, + draft: bool = False, + prerelease: bool = False, + generate_release_notes: bool = False, + make_latest: str = "true", + ) -> GitRelease: + """ + Convenience function that calls :meth:`Repository.create_git_tag` and :meth:`Repository.create_git_release`. + + :param tag: string + :param tag_message: string + :param release_name: string + :param release_message: string + :param object: string + :param type: string + :param tagger: :class:github.InputGitAuthor.InputGitAuthor + :param draft: bool + :param prerelease: bool + :param generate_release_notes: bool + :param make_latest: string + :rtype: :class:`github.GitRelease.GitRelease` + + """ + self.create_git_tag(tag, tag_message, object, type, tagger) + return self.create_git_release( + tag, + release_name, + release_message, + draft, + prerelease, + generate_release_notes, + target_commitish=object, + make_latest=make_latest, + ) + + def create_git_release( + self, + tag: str, + name: Opt[str] = NotSet, + message: Opt[str] = NotSet, + draft: bool = False, + prerelease: bool = False, + generate_release_notes: bool = False, + target_commitish: Opt[str] = NotSet, + make_latest: str = "true", + ) -> GitRelease: + """ + :calls: `POST /repos/{owner}/{repo}/releases `_ + :param tag: string + :param name: string + :param message: string + :param draft: bool + :param prerelease: bool + :param generate_release_notes: bool + :param target_commitish: string or :class:`github.Branch.Branch` or :class:`github.Commit.Commit` or :class:`github.GitCommit.GitCommit` + :param make_latest: string + :rtype: :class:`github.GitRelease.GitRelease` + """ + assert isinstance(tag, str), tag + assert isinstance(generate_release_notes, bool), generate_release_notes + assert isinstance(name, str) or generate_release_notes and is_optional(name, str), name + assert isinstance(message, str) or generate_release_notes and is_optional(message, str), message + assert isinstance(draft, bool), draft + assert isinstance(prerelease, bool), prerelease + assert is_optional( + target_commitish, + (str, github.Branch.Branch, github.Commit.Commit, github.GitCommit.GitCommit), + ), target_commitish + post_parameters = { + "tag_name": tag, + "draft": draft, + "prerelease": prerelease, + "generate_release_notes": generate_release_notes, + } + assert make_latest in ["true", "false", "legacy"], make_latest + if is_defined(name): + post_parameters["name"] = name + if is_defined(message): + post_parameters["body"] = message + if isinstance(target_commitish, str): + post_parameters["target_commitish"] = target_commitish + elif isinstance(target_commitish, github.Branch.Branch): + post_parameters["target_commitish"] = target_commitish.name + elif isinstance(target_commitish, (github.Commit.Commit, github.GitCommit.GitCommit)): + post_parameters["target_commitish"] = target_commitish.sha + if is_defined(make_latest): + post_parameters["make_latest"] = make_latest + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/releases", input=post_parameters) + return github.GitRelease.GitRelease(self._requester, headers, data, completed=True) + + def create_git_tag( + self, + tag: str, + message: str, + object: str, + type: str, + tagger: Opt[InputGitAuthor] = NotSet, + ) -> GitTag: + """ + :calls: `POST /repos/{owner}/{repo}/git/tags `_ + """ + assert isinstance(tag, str), tag + assert isinstance(message, str), message + assert isinstance(object, str), object + assert isinstance(type, str), type + assert is_optional(tagger, github.InputGitAuthor), tagger + post_parameters: dict[str, Any] = { + "tag": tag, + "message": message, + "object": object, + "type": type, + } + if is_defined(tagger): + post_parameters["tagger"] = tagger._identity + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/git/tags", input=post_parameters) + return github.GitTag.GitTag(self._requester, headers, data, completed=True) + + def create_git_tree(self, tree: list[InputGitTreeElement], base_tree: Opt[GitTree] = NotSet) -> GitTree: + """ + :calls: `POST /repos/{owner}/{repo}/git/trees `_ + :param tree: list of :class:`github.InputGitTreeElement.InputGitTreeElement` + :param base_tree: :class:`github.GitTree.GitTree` + :rtype: :class:`github.GitTree.GitTree` + """ + assert all(isinstance(element, github.InputGitTreeElement) for element in tree), tree + assert is_optional(base_tree, github.GitTree.GitTree), base_tree + post_parameters: dict[str, Any] = { + "tree": [element._identity for element in tree], + } + if is_defined(base_tree): + post_parameters["base_tree"] = base_tree._identity + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/git/trees", input=post_parameters) + return github.GitTree.GitTree(self._requester, headers, data, completed=True) + + def create_hook( + self, + name: str, + config: dict[str, str], + events: Opt[list[str]] = NotSet, + active: Opt[bool] = NotSet, + ) -> Hook: + """ + :calls: `POST /repos/{owner}/{repo}/hooks `_ + :param name: string + :param config: dict + :param events: list of string + :param active: bool + :rtype: :class:`github.Hook.Hook` + """ + assert isinstance(name, str), name + assert isinstance(config, dict), config + assert is_optional_list(events, str), events + assert is_optional(active, bool), active + post_parameters = NotSet.remove_unset_items( + {"name": name, "config": config, "events": events, "active": active} + ) + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/hooks", input=post_parameters) + return github.Hook.Hook(self._requester, headers, data, completed=True) + + def create_issue( + self, + title: str, + body: Opt[str] = NotSet, + assignee: NamedUser | Opt[str] = NotSet, + milestone: Opt[Milestone] = NotSet, + labels: list[Label] | Opt[list[str]] = NotSet, + assignees: Opt[list[str]] | list[NamedUser] = NotSet, + ) -> Issue: + """ + :calls: `POST /repos/{owner}/{repo}/issues `_ + :param title: string + :param body: string + :param assignee: string or :class:`github.NamedUser.NamedUser` + :param assignees: list of string or :class:`github.NamedUser.NamedUser` + :param milestone: :class:`github.Milestone.Milestone` + :param labels: list of :class:`github.Label.Label` + :rtype: :class:`github.Issue.Issue` + """ + assert isinstance(title, str), title + assert is_optional(body, str), body + assert is_optional(assignee, (str, github.NamedUser.NamedUser)), assignee + assert is_optional_list(assignees, (github.NamedUser.NamedUser, str)), assignees + assert is_optional(milestone, github.Milestone.Milestone), milestone + assert is_optional_list(labels, (github.Label.Label, str)), labels + + post_parameters: dict[str, Any] = { + "title": title, + } + if is_defined(body): + post_parameters["body"] = body + if is_defined(assignee): + if isinstance(assignee, github.NamedUser.NamedUser): + post_parameters["assignee"] = assignee._identity + else: + post_parameters["assignee"] = assignee + if is_defined(assignees): + post_parameters["assignees"] = [ + element._identity if isinstance(element, github.NamedUser.NamedUser) else element + for element in assignees # type: ignore + ] + if is_defined(milestone): + post_parameters["milestone"] = milestone._identity + if is_defined(labels): + post_parameters["labels"] = [ + element.name if isinstance(element, github.Label.Label) else element + for element in labels # type: ignore + ] + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/issues", input=post_parameters) + return github.Issue.Issue(self._requester, headers, data, completed=True) + + def create_key(self, title: str, key: str, read_only: bool = False) -> RepositoryKey: + """ + :calls: `POST /repos/{owner}/{repo}/keys `_ + :param title: string + :param key: string + :param read_only: bool + :rtype: :class:`github.RepositoryKey.RepositoryKey` + """ + assert isinstance(title, str), title + assert isinstance(key, str), key + assert isinstance(read_only, bool), read_only + post_parameters = { + "title": title, + "key": key, + "read_only": read_only, + } + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/keys", input=post_parameters) + return github.RepositoryKey.RepositoryKey(self._requester, headers, data, completed=True) + + def create_label(self, name: str, color: str, description: Opt[str] = NotSet) -> Label: + """ + :calls: `POST /repos/{owner}/{repo}/labels `_ + :param name: string + :param color: string + :param description: string + :rtype: :class:`github.Label.Label` + """ + assert isinstance(name, str), name + assert isinstance(color, str), color + assert is_optional(description, str), description + post_parameters = { + "name": name, + "color": color, + } + if is_defined(description): + post_parameters["description"] = description + headers, data = self._requester.requestJsonAndCheck( + "POST", + f"{self.url}/labels", + input=post_parameters, + headers={"Accept": Consts.mediaTypeLabelDescriptionSearchPreview}, + ) + return github.Label.Label(self._requester, headers, data, completed=True) + + def create_milestone( + self, + title: str, + state: Opt[str] = NotSet, + description: Opt[str] = NotSet, + due_on: Opt[date] = NotSet, + ) -> Milestone: + """ + :calls: `POST /repos/{owner}/{repo}/milestones `_ + :param title: string + :param state: string + :param description: string + :param due_on: datetime + :rtype: :class:`github.Milestone.Milestone` + """ + assert isinstance(title, str), title + assert is_optional(state, str), state + assert is_optional(description, str), description + assert is_optional(due_on, (datetime, date)), due_on + post_parameters = { + "title": title, + } + if is_defined(state): + post_parameters["state"] = state + if is_defined(description): + post_parameters["description"] = description + if is_defined(due_on): + if isinstance(due_on, date): + post_parameters["due_on"] = due_on.strftime("%Y-%m-%dT%H:%M:%SZ") + else: + post_parameters["due_on"] = due_on.isoformat() + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/milestones", input=post_parameters) + return github.Milestone.Milestone(self._requester, headers, data, completed=True) + + def create_project(self, name: str, body: Opt[str] = NotSet) -> Project: + """ + :calls: `POST /repos/{owner}/{repo}/projects `_ + :param name: string + :param body: string + :rtype: :class:`github.Project.Project` + """ + assert isinstance(name, str), name + assert is_optional(body, str), body + post_parameters = { + "name": name, + } + import_header = {"Accept": Consts.mediaTypeProjectsPreview} + if is_defined(body): + post_parameters["body"] = body + headers, data = self._requester.requestJsonAndCheck( + "POST", f"{self.url}/projects", headers=import_header, input=post_parameters + ) + return github.Project.Project(self._requester, headers, data, completed=True) + + def create_pull( + self, + base: str, + head: str, + *, + title: Opt[str] = NotSet, + body: Opt[str] = NotSet, + maintainer_can_modify: Opt[bool] = NotSet, + draft: Opt[bool] = NotSet, + issue: Opt[github.Issue.Issue] = NotSet, + ) -> github.PullRequest.PullRequest: + """ + :calls: `POST /repos/{owner}/{repo}/pulls `_ + """ + assert isinstance(base, str), base + assert isinstance(head, str), head + assert is_optional(title, str), title + assert is_optional(body, str), body + assert is_optional(maintainer_can_modify, bool), maintainer_can_modify + assert is_optional(draft, bool), draft + assert is_optional(issue, github.Issue.Issue), issue + + post_parameters = NotSet.remove_unset_items( + { + "base": base, + "head": head, + "title": title, + "body": body, + "maintainer_can_modify": maintainer_can_modify, + "draft": draft, + } + ) + + if is_defined(issue): + post_parameters["issue"] = issue._identity + + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/pulls", input=post_parameters) + return github.PullRequest.PullRequest(self._requester, headers, data, completed=True) + + def create_repository_advisory( + self, + summary: str, + description: str, + severity_or_cvss_vector_string: str, + cve_id: str | None = None, + vulnerabilities: Iterable[github.AdvisoryVulnerability.AdvisoryVulnerabilityInput] | None = None, + cwe_ids: Iterable[str] | None = None, + credits: Iterable[github.AdvisoryCredit.AdvisoryCredit] | None = None, + ) -> github.RepositoryAdvisory.RepositoryAdvisory: + """ + :calls: `POST /repos/{owner}/{repo}/security-advisories `_ + :param summary: string + :param description: string + :param severity_or_cvss_vector_string: string + :param cve_id: string + :param vulnerabilities: iterable of :class:`github.AdvisoryVulnerability.AdvisoryVulnerabilityInput` + :param cwe_ids: iterable of string + :param credits: iterable of :class:`github.AdvisoryCredit.AdvisoryCredit` + :rtype: :class:`github.RepositoryAdvisory.RepositoryAdvisory` + """ + return self.__create_repository_advisory( + summary=summary, + description=description, + severity_or_cvss_vector_string=severity_or_cvss_vector_string, + cve_id=cve_id, + vulnerabilities=vulnerabilities, + cwe_ids=cwe_ids, + credits=credits, + private_vulnerability_reporting=False, + ) + + def report_security_vulnerability( + self, + summary: str, + description: str, + severity_or_cvss_vector_string: str, + cve_id: str | None = None, + vulnerabilities: Iterable[github.AdvisoryVulnerability.AdvisoryVulnerabilityInput] | None = None, + cwe_ids: Iterable[str] | None = None, + credits: Iterable[github.AdvisoryCredit.AdvisoryCredit] | None = None, + ) -> github.RepositoryAdvisory.RepositoryAdvisory: + """ + :calls: `POST /repos/{owner}/{repo}/security-advisories/reports `_ + :param summary: string + :param description: string + :param severity_or_cvss_vector_string: string + :param cve_id: string + :param vulnerabilities: iterable of :class:`github.AdvisoryVulnerability.AdvisoryVulnerabilityInput` + :param cwe_ids: iterable of string + :param credits: iterable of :class:`github.AdvisoryCredit.AdvisoryCredit` + :rtype: :class:`github.RepositoryAdvisory.RepositoryAdvisory` + """ + return self.__create_repository_advisory( + summary=summary, + description=description, + severity_or_cvss_vector_string=severity_or_cvss_vector_string, + cve_id=cve_id, + vulnerabilities=vulnerabilities, + cwe_ids=cwe_ids, + credits=credits, + private_vulnerability_reporting=True, + ) + + def __create_repository_advisory( + self, + summary: str, + description: str, + severity_or_cvss_vector_string: str, + cve_id: str | None, + vulnerabilities: Iterable[github.AdvisoryVulnerability.AdvisoryVulnerabilityInput] | None, + cwe_ids: Iterable[str] | None, + credits: Iterable[github.AdvisoryCredit.AdvisoryCredit] | None, + private_vulnerability_reporting: bool, + ) -> github.RepositoryAdvisory.RepositoryAdvisory: + if vulnerabilities is None: + vulnerabilities = [] + if cwe_ids is None: + cwe_ids = [] + assert isinstance(summary, str), summary + assert isinstance(description, str), description + assert isinstance(severity_or_cvss_vector_string, str), severity_or_cvss_vector_string + assert isinstance(cve_id, (str, type(None))), cve_id + assert isinstance(vulnerabilities, Iterable), vulnerabilities + for vulnerability in vulnerabilities: + github.AdvisoryVulnerability.AdvisoryVulnerability._validate_vulnerability(vulnerability) + assert isinstance(cwe_ids, Iterable), cwe_ids + assert all(isinstance(element, str) for element in cwe_ids), cwe_ids + assert isinstance(credits, (Iterable, type(None))), credits + if credits is not None: + for credit in credits: + github.AdvisoryCredit.AdvisoryCredit._validate_credit(credit) + post_parameters = { + "summary": summary, + "description": description, + "vulnerabilities": [ + github.AdvisoryVulnerability.AdvisoryVulnerability._to_github_dict(vulnerability) + for vulnerability in vulnerabilities + ], + "cwe_ids": list(cwe_ids), + } + if cve_id is not None: + post_parameters["cve_id"] = cve_id + if credits is not None: + post_parameters["credits"] = [ + github.AdvisoryCredit.AdvisoryCredit._to_github_dict(credit) for credit in credits + ] + if severity_or_cvss_vector_string.startswith("CVSS:"): + post_parameters["cvss_vector_string"] = severity_or_cvss_vector_string + else: + post_parameters["severity"] = severity_or_cvss_vector_string + if private_vulnerability_reporting: + headers, data = self._requester.requestJsonAndCheck( + "POST", f"{self.url}/security-advisories/reports", input=post_parameters + ) + else: + headers, data = self._requester.requestJsonAndCheck( + "POST", f"{self.url}/security-advisories", input=post_parameters + ) + return github.RepositoryAdvisory.RepositoryAdvisory(self._requester, headers, data) + + def create_repository_dispatch(self, event_type: str, client_payload: Opt[dict[str, Any]] = NotSet) -> bool: + """ + :calls: POST /repos/{owner}/{repo}/dispatches + :param event_type: string + :param client_payload: dict + :rtype: bool + """ + assert isinstance(event_type, str), event_type + assert is_optional(client_payload, dict), client_payload + post_parameters = NotSet.remove_unset_items({"event_type": event_type, "client_payload": client_payload}) + status, headers, data = self._requester.requestJson("POST", f"{self.url}/dispatches", input=post_parameters) + return status == 204 + + def create_secret( + self, + secret_name: str, + unencrypted_value: str, + secret_type: str = "actions", + ) -> github.Secret.Secret: + """ + :calls: `PUT /repos/{owner}/{repo}/{secret_type}/secrets/{secret_name} `_ + :param secret_type: string options actions or dependabot + """ + assert isinstance(secret_name, str), secret_name + assert isinstance(unencrypted_value, str), unencrypted_value + assert secret_type in ["actions", "dependabot"], "secret_type should be actions or dependabot" + + secret_name = urllib.parse.quote(secret_name) + public_key = self.get_public_key(secret_type=secret_type) + payload = public_key.encrypt(unencrypted_value) + put_parameters = { + "key_id": public_key.key_id, + "encrypted_value": payload, + } + self._requester.requestJsonAndCheck( + "PUT", f"{self.url}/{secret_type}/secrets/{secret_name}", input=put_parameters + ) + return github.Secret.Secret( + requester=self._requester, + headers={}, + attributes={ + "name": secret_name, + "url": f"{self.url}/{secret_type}/secrets/{secret_name}", + }, + completed=False, + ) + + def get_secrets( + self, + secret_type: str = "actions", + ) -> PaginatedList[github.Secret.Secret]: + """ + Gets all repository secrets :param secret_type: string options actions or dependabot. + """ + assert secret_type in ["actions", "dependabot"], "secret_type should be actions or dependabot" + + return PaginatedList( + github.Secret.Secret, + self._requester, + f"{self.url}/{secret_type}/secrets", + None, + attributesTransformer=PaginatedList.override_attributes( + {"secrets_url": f"{self.url}/{secret_type}/secrets"} + ), + list_item="secrets", + ) + + def get_secret(self, secret_name: str, secret_type: str = "actions") -> github.Secret.Secret: + """ + :calls: 'GET /repos/{owner}/{repo}/actions/secrets/{secret_name} `_ + :param secret_type: string options actions or dependabot + """ + assert isinstance(secret_name, str), secret_name + assert secret_type in ["actions", "dependabot"], "secret_type should be actions or dependabot" + + secret_name = urllib.parse.quote(secret_name) + return github.Secret.Secret( + requester=self._requester, + headers={}, + attributes={"url": f"{self.url}/{secret_type}/secrets/{secret_name}"}, + completed=False, + ) + + def create_variable(self, variable_name: str, value: str) -> github.Variable.Variable: + """ + :calls: `POST /repos/{owner}/{repo}/actions/variables/{variable_name} `_ + """ + assert isinstance(variable_name, str), variable_name + assert isinstance(value, str), value + post_parameters = { + "name": variable_name, + "value": value, + } + self._requester.requestJsonAndCheck("POST", f"{self.url}/actions/variables", input=post_parameters) + return github.Variable.Variable( + self._requester, + headers={}, + attributes={ + "name": variable_name, + "value": value, + "url": f"{self.url}/actions/variables/{variable_name}", + }, + completed=False, + ) + + def get_variables(self) -> PaginatedList[github.Variable.Variable]: + """ + Gets all repository variables :rtype: :class:`PaginatedList` of :class:`github.Variable.Variable` + """ + return PaginatedList( + github.Variable.Variable, + self._requester, + f"{self.url}/actions/variables", + None, + attributesTransformer=PaginatedList.override_attributes({"variables_url": f"{self.url}/actions/variables"}), + list_item="variables", + ) + + def get_variable(self, variable_name: str) -> github.Variable.Variable: + """ + :calls: 'GET /orgs/{org}/actions/variables/{variable_name} `_ + :param variable_name: string + :rtype: github.Variable.Variable + """ + assert isinstance(variable_name, str), variable_name + variable_name = urllib.parse.quote(variable_name) + return github.Variable.Variable( + requester=self._requester, + headers={}, + attributes={"url": f"{self.url}/actions/variables/{variable_name}"}, + completed=False, + ) + + def delete_secret(self, secret_name: str, secret_type: str = "actions") -> bool: + """ + :calls: `DELETE /repos/{owner}/{repo}/{secret_type}/secrets/{secret_name} `_ + :param secret_name: string + :param secret_type: string options actions or dependabot + :rtype: bool + """ + assert isinstance(secret_name, str), secret_name + assert secret_type in ["actions", "dependabot"], "secret_type should be actions or dependabot" + secret_name = urllib.parse.quote(secret_name) + status, headers, data = self._requester.requestJson("DELETE", f"{self.url}/{secret_type}/secrets/{secret_name}") + return status == 204 + + def delete_variable(self, variable_name: str) -> bool: + """ + :calls: `DELETE /repos/{owner}/{repo}/actions/variables/{variable_name} `_ + :param variable_name: string + :rtype: bool + """ + assert isinstance(variable_name, str), variable_name + variable_name = urllib.parse.quote(variable_name) + status, headers, data = self._requester.requestJson("DELETE", f"{self.url}/actions/variables/{variable_name}") + return status == 204 + + def create_source_import( + self, + vcs: str, + vcs_url: str, + vcs_username: Opt[str] = NotSet, + vcs_password: Opt[str] = NotSet, + ) -> SourceImport: + """ + :calls: `PUT /repos/{owner}/{repo}/import `_ + :param vcs: string + :param vcs_url: string + :param vcs_username: string + :param vcs_password: string + :rtype: :class:`github.SourceImport.SourceImport` + """ + assert isinstance(vcs, str), vcs + assert isinstance(vcs_url, str), vcs_url + assert is_optional(vcs_username, str), vcs_username + assert is_optional(vcs_password, str), vcs_password + put_parameters = {"vcs": vcs, "vcs_url": vcs_url} + + if is_defined(vcs_username): + put_parameters["vcs_username"] = vcs_username + + if is_defined(vcs_password): + put_parameters["vcs_password"] = vcs_password + + import_header = {"Accept": Consts.mediaTypeImportPreview} + + headers, data = self._requester.requestJsonAndCheck( + "PUT", f"{self.url}/import", headers=import_header, input=put_parameters + ) + + return github.SourceImport.SourceImport(self._requester, headers, data, completed=False) + + def delete(self) -> None: + """ + :calls: `DELETE /repos/{owner}/{repo} `_ + :rtype: None + """ + headers, data = self._requester.requestJsonAndCheck("DELETE", self.url) + + def edit( + self, + name: str | None = None, + description: Opt[str] = NotSet, + homepage: Opt[str] = NotSet, + private: Opt[bool] = NotSet, + visibility: Opt[str] = NotSet, + has_issues: Opt[bool] = NotSet, + has_projects: Opt[bool] = NotSet, + has_wiki: Opt[bool] = NotSet, + has_discussions: Opt[bool] = NotSet, + is_template: Opt[bool] = NotSet, + default_branch: Opt[str] = NotSet, + allow_squash_merge: Opt[bool] = NotSet, + allow_merge_commit: Opt[bool] = NotSet, + allow_rebase_merge: Opt[bool] = NotSet, + allow_auto_merge: Opt[bool] = NotSet, + delete_branch_on_merge: Opt[bool] = NotSet, + allow_update_branch: Opt[bool] = NotSet, + use_squash_pr_title_as_default: Opt[bool] = NotSet, + squash_merge_commit_title: Opt[str] = NotSet, + squash_merge_commit_message: Opt[str] = NotSet, + merge_commit_title: Opt[str] = NotSet, + merge_commit_message: Opt[str] = NotSet, + archived: Opt[bool] = NotSet, + allow_forking: Opt[bool] = NotSet, + web_commit_signoff_required: Opt[bool] = NotSet, + ) -> None: + """ + :calls: `PATCH /repos/{owner}/{repo} `_ + """ + if name is None: + name = self.name + assert isinstance(name, str), name + assert is_optional(description, str), description + assert is_optional(homepage, str), homepage + assert is_optional(private, bool), private + assert visibility in ["public", "private", "internal", NotSet], visibility + assert is_optional(has_issues, bool), has_issues + assert is_optional(has_projects, bool), has_projects + assert is_optional(has_wiki, bool), has_wiki + assert is_optional(has_discussions, bool), has_discussions + assert is_optional(is_template, bool), is_template + assert is_optional(default_branch, str), default_branch + assert is_optional(allow_squash_merge, bool), allow_squash_merge + assert is_optional(allow_merge_commit, bool), allow_merge_commit + assert is_optional(allow_rebase_merge, bool), allow_rebase_merge + assert is_optional(allow_auto_merge, bool), allow_auto_merge + assert is_optional(delete_branch_on_merge, bool), delete_branch_on_merge + assert is_optional(allow_update_branch, bool), allow_update_branch + assert is_optional(use_squash_pr_title_as_default, bool), use_squash_pr_title_as_default + assert squash_merge_commit_title in ["PR_TITLE", "COMMIT_OR_PR_TITLE", NotSet], squash_merge_commit_title + assert squash_merge_commit_message in [ + "PR_BODY", + "COMMIT_MESSAGES", + "BLANK", + NotSet, + ], squash_merge_commit_message + assert merge_commit_title in ["PR_TITLE", "MERGE_MESSAGE", NotSet], merge_commit_title + assert merge_commit_message in ["PR_TITLE", "PR_BODY", "BLANK", NotSet], merge_commit_message + assert is_optional(archived, bool), archived + assert is_optional(allow_forking, bool), allow_forking + assert is_optional(web_commit_signoff_required, bool), web_commit_signoff_required + + post_parameters: dict[str, Any] = NotSet.remove_unset_items( + { + "name": name, + "description": description, + "homepage": homepage, + "private": private, + "visibility": visibility, + "has_issues": has_issues, + "has_projects": has_projects, + "has_wiki": has_wiki, + "has_discussions": has_discussions, + "is_template": is_template, + "default_branch": default_branch, + "allow_squash_merge": allow_squash_merge, + "allow_merge_commit": allow_merge_commit, + "allow_rebase_merge": allow_rebase_merge, + "allow_auto_merge": allow_auto_merge, + "delete_branch_on_merge": delete_branch_on_merge, + "allow_update_branch": allow_update_branch, + "use_squash_pr_title_as_default": use_squash_pr_title_as_default, + "squash_merge_commit_title": squash_merge_commit_title, + "squash_merge_commit_message": squash_merge_commit_message, + "merge_commit_title": merge_commit_title, + "merge_commit_message": merge_commit_message, + "archived": archived, + "allow_forking": allow_forking, + "web_commit_signoff_required": web_commit_signoff_required, + } + ) + + headers, data = self._requester.requestJsonAndCheck("PATCH", self.url, input=post_parameters) + self._useAttributes(data) + + def get_archive_link(self, archive_format: str, ref: Opt[str] = NotSet) -> str: + """ + :calls: `GET /repos/{owner}/{repo}/{archive_format}/{ref} `_ + :param archive_format: string + :param ref: string + :rtype: string + """ + assert isinstance(archive_format, str), archive_format + archive_format = urllib.parse.quote(archive_format) + assert is_optional(ref, str), ref + url = f"{self.url}/{archive_format}" + if is_defined(ref): + ref = urllib.parse.quote(ref) + url += f"/{ref}" + headers, data = self._requester.requestJsonAndCheck("GET", url) + return headers["location"] + + def get_assignees(self) -> PaginatedList[NamedUser]: + """ + :calls: `GET /repos/{owner}/{repo}/assignees `_ + :rtype: :class:`PaginatedList` of :class:`github.NamedUser.NamedUser` + """ + return PaginatedList(github.NamedUser.NamedUser, self._requester, f"{self.url}/assignees", None) + + def get_branch(self, branch: str) -> Branch: + """ + :calls: `GET /repos/{owner}/{repo}/branches/{branch} `_ + :param branch: string + :rtype: :class:`github.Branch.Branch` + """ + assert isinstance(branch, str), branch + branch = urllib.parse.quote(branch) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/branches/{branch}") + return github.Branch.Branch(self._requester, headers, data) + + def rename_branch(self, branch: str | Branch, new_name: str) -> bool: + """ + :calls: `POST /repos/{owner}/{repo}/branches/{branch}/rename `_ + :param branch: :class:`github.Branch.Branch` or string + :param new_name: string + :rtype: bool + + NOTE: This method does not return the branch since it may take some + time to fully complete server-side. + """ + is_branch = isinstance(branch, github.Branch.Branch) + assert isinstance(new_name, str), new_name + if is_branch: + branch = branch.name # type: ignore + else: + assert isinstance(branch, str), branch + branch = urllib.parse.quote(branch) + parameters = {"new_name": new_name} + status, _, _ = self._requester.requestJson("POST", f"{self.url}/branches/{branch}/rename", input=parameters) + return status == 201 + + def get_branches(self) -> PaginatedList[Branch]: + """ + :calls: `GET /repos/{owner}/{repo}/branches `_ + :rtype: :class:`PaginatedList` of :class:`github.Branch.Branch` + """ + return PaginatedList(github.Branch.Branch, self._requester, f"{self.url}/branches", None) + + def get_collaborators( + self, affiliation: Opt[str] = NotSet, permission: Opt[str] = NotSet + ) -> PaginatedList[NamedUser]: + """ + :calls: `GET /repos/{owner}/{repo}/collaborators `_ + :param affiliation: string + :param permission: string + :rtype: :class:`PaginatedList` of :class:`github.NamedUser.NamedUser` + """ + + url_parameters = dict() + allowed_affiliations = ["outside", "direct", "all"] + allowed_permissions = ["pull", "triage", "push", "maintain", "admin"] + if is_defined(affiliation): + assert isinstance(affiliation, str), affiliation + assert affiliation in allowed_affiliations, f"Affiliation can be one of {', '.join(allowed_affiliations)}" + url_parameters["affiliation"] = affiliation + + if is_defined(permission): + assert isinstance(permission, str), permission + assert permission in allowed_permissions, f"permission can be one of {', '.join(allowed_permissions)}" + url_parameters["permission"] = permission + + return PaginatedList( + github.NamedUser.NamedUser, + self._requester, + f"{self.url}/collaborators", + url_parameters, + ) + + def get_comment(self, id: int) -> CommitComment: + """ + :calls: `GET /repos/{owner}/{repo}/comments/{id} `_ + :param id: integer + :rtype: :class:`github.CommitComment.CommitComment` + """ + assert isinstance(id, int), id + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/comments/{id}") + return github.CommitComment.CommitComment(self._requester, headers, data, completed=True) + + def get_comments(self) -> PaginatedList[CommitComment]: + """ + :calls: `GET /repos/{owner}/{repo}/comments `_ + :rtype: :class:`PaginatedList` of :class:`github.CommitComment.CommitComment` + """ + return PaginatedList( + github.CommitComment.CommitComment, + self._requester, + f"{self.url}/comments", + None, + ) + + def get_commit(self, sha: str) -> Commit: + """ + :calls: `GET /repos/{owner}/{repo}/commits/{sha} `_ + :param sha: string + :rtype: :class:`github.Commit.Commit` + """ + assert isinstance(sha, str), sha + sha = urllib.parse.quote(sha) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/commits/{sha}") + return github.Commit.Commit(self._requester, headers, data, completed=True) + + def get_commits( + self, + sha: Opt[str] = NotSet, + path: Opt[str] = NotSet, + since: Opt[datetime] = NotSet, + until: Opt[datetime] = NotSet, + author: Opt[AuthenticatedUser | NamedUser | str] = NotSet, + ) -> PaginatedList[Commit]: + """ + :calls: `GET /repos/{owner}/{repo}/commits `_ + :param sha: string + :param path: string + :param since: datetime + :param until: datetime + :param author: string or :class:`github.NamedUser.NamedUser` or :class:`github.AuthenticatedUser.AuthenticatedUser` + :rtype: :class:`PaginatedList` of :class:`github.Commit.Commit` + """ + assert is_optional(sha, str), sha + assert is_optional(path, str), path + assert is_optional(since, datetime), since + assert is_optional(until, datetime), until + assert is_optional( + author, + (str, github.NamedUser.NamedUser, github.AuthenticatedUser.AuthenticatedUser), + ), author + url_parameters: dict[str, Any] = {} + if is_defined(sha): + url_parameters["sha"] = sha + if is_defined(path): + url_parameters["path"] = path + if is_defined(since): + url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") + if is_defined(until): + url_parameters["until"] = until.strftime("%Y-%m-%dT%H:%M:%SZ") + if is_defined(author): + if isinstance( + author, + (github.NamedUser.NamedUser, github.AuthenticatedUser.AuthenticatedUser), + ): + url_parameters["author"] = author.login + else: + url_parameters["author"] = author + return PaginatedList(github.Commit.Commit, self._requester, f"{self.url}/commits", url_parameters) + + def get_contents(self, path: str, ref: Opt[str] = NotSet) -> list[ContentFile] | ContentFile: + """ + :calls: `GET /repos/{owner}/{repo}/contents/{path} `_ + :param path: string + :param ref: string + :rtype: :class:`github.ContentFile.ContentFile` or a list of them + """ + assert isinstance(path, str), path + assert is_optional(ref, str), ref + # Path of '/' should be the empty string. + if path == "/": + path = "" + url_parameters = dict() + if is_defined(ref): + url_parameters["ref"] = ref + headers, data = self._requester.requestJsonAndCheck( + "GET", + f"{self.url}/contents/{urllib.parse.quote(path)}", + parameters=url_parameters, + follow_302_redirect=True, + ) + + if isinstance(data, list): + return [ + # Lazy completion only makes sense for files. See discussion + # here: https://github.com/jacquev6/PyGithub/issues/140#issuecomment-13481130 + github.ContentFile.ContentFile(self._requester, headers, item, completed=(item["type"] != "file")) + for item in data + ] + return github.ContentFile.ContentFile(self._requester, headers, data, completed=True) + + def get_deployments( + self, + sha: Opt[str] = NotSet, + ref: Opt[str] = NotSet, + task: Opt[str] = NotSet, + environment: Opt[str] = NotSet, + ) -> PaginatedList[Deployment]: + """ + :calls: `GET /repos/{owner}/{repo}/deployments `_ + :param: sha: string + :param: ref: string + :param: task: string + :param: environment: string + :rtype: :class:`PaginatedList` of :class:`github.Deployment.Deployment` + """ + assert is_optional(sha, str), sha + assert is_optional(ref, str), ref + assert is_optional(task, str), task + assert is_optional(environment, str), environment + parameters = {} + if is_defined(sha): + parameters["sha"] = sha + if is_defined(ref): + parameters["ref"] = ref + if is_defined(task): + parameters["task"] = task + if is_defined(environment): + parameters["environment"] = environment + return PaginatedList( + github.Deployment.Deployment, + self._requester, + f"{self.url}/deployments", + parameters, + headers={"Accept": Consts.deploymentEnhancementsPreview}, + ) + + def get_deployment(self, id_: int) -> Deployment: + """ + :calls: `GET /repos/{owner}/{repo}/deployments/{deployment_id} `_ + :param: id_: int + :rtype: :class:`github.Deployment.Deployment` + """ + assert isinstance(id_, int), id_ + headers, data = self._requester.requestJsonAndCheck( + "GET", + f"{self.url}/deployments/{id_}", + headers={"Accept": Consts.deploymentEnhancementsPreview}, + ) + return github.Deployment.Deployment(self._requester, headers, data, completed=True) + + def create_deployment( + self, + ref: str, + task: Opt[str] = NotSet, + auto_merge: Opt[bool] = NotSet, + required_contexts: Opt[list[str]] = NotSet, + payload: Opt[dict[str, Any]] = NotSet, + environment: Opt[str] = NotSet, + description: Opt[str] = NotSet, + transient_environment: Opt[bool] = NotSet, + production_environment: Opt[bool] = NotSet, + ) -> Deployment: + """ + :calls: `POST /repos/{owner}/{repo}/deployments `_ + :param: ref: string + :param: task: string + :param: auto_merge: bool + :param: required_contexts: list of status contexts + :param: payload: dict + :param: environment: string + :param: description: string + :param: transient_environment: bool + :param: production_environment: bool + :rtype: :class:`github.Deployment.Deployment` + """ + assert isinstance(ref, str), ref + assert is_optional(task, str), task + assert is_optional(auto_merge, bool), auto_merge + assert is_optional(required_contexts, list), required_contexts # need to do better checking here + assert is_optional(payload, dict), payload + assert is_optional(environment, str), environment + assert is_optional(description, str), description + assert is_optional(transient_environment, bool), transient_environment + assert is_optional(production_environment, bool), production_environment + + post_parameters: dict[str, Any] = {"ref": ref} + if is_defined(task): + post_parameters["task"] = task + if is_defined(auto_merge): + post_parameters["auto_merge"] = auto_merge + if is_defined(required_contexts): + post_parameters["required_contexts"] = required_contexts + if is_defined(payload): + post_parameters["payload"] = payload + if is_defined(environment): + post_parameters["environment"] = environment + if is_defined(description): + post_parameters["description"] = description + if is_defined(transient_environment): + post_parameters["transient_environment"] = transient_environment + if is_defined(production_environment): + post_parameters["production_environment"] = production_environment + + headers, data = self._requester.requestJsonAndCheck( + "POST", + f"{self.url}/deployments", + input=post_parameters, + headers={"Accept": Consts.deploymentEnhancementsPreview}, + ) + + return github.Deployment.Deployment(self._requester, headers, data, completed=True) + + def get_discussion( + self, + number: int, + discussion_graphql_schema: str, + ) -> RepositoryDiscussion: + assert isinstance(number, int), number + if not discussion_graphql_schema.startswith("\n"): + discussion_graphql_schema = f" {discussion_graphql_schema} " + query = ( + """ + query Q($repo: String!, $owner: String!, $number: Int!) { + repository(name: $repo, owner: $owner) { + discussion(number: $number) {""" + + discussion_graphql_schema + + """} + } + } + """ + ) + variables = { + "repo": self.name, + "owner": self.owner.login, + "number": number, + } + return self._requester.graphql_query_class( + query, variables, ["repository", "discussion"], github.RepositoryDiscussion.RepositoryDiscussion + ) + + def get_discussions( + self, + discussion_graphql_schema: str, + *, + answered: bool | None = None, + category_id: str | None = None, + states: list[str] | None = None, + ) -> PaginatedList[RepositoryDiscussion]: + if not discussion_graphql_schema.startswith("\n"): + discussion_graphql_schema = f" {discussion_graphql_schema} " + query = ( + """ + query Q($repo: String!, $owner: String!, $answered: Boolean, $category_id: ID, $states: [DiscussionState!], $first: Int, $last: Int, $before: String, $after: String) { + repository(name: $repo, owner: $owner) { + discussions(answered: $answered, categoryId: $category_id, states: $states, first: $first, last: $last, before: $before, after: $after) { + totalCount + pageInfo { + startCursor + endCursor + hasNextPage + hasPreviousPage + } + nodes {""" + + discussion_graphql_schema + + """} + } + } + } + """ + ) + variables = { + "repo": self.name, + "owner": self.owner.login, + "answered": answered, + "category_id": category_id, + "states": states, + } + return PaginatedList( + github.RepositoryDiscussion.RepositoryDiscussion, + self._requester, + graphql_query=query, + graphql_variables=variables, + list_item=["repository", "discussions"], + ) + + def get_top_referrers(self) -> None | list[Referrer]: + """ + :calls: `GET /repos/{owner}/{repo}/traffic/popular/referrers `_ + """ + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/traffic/popular/referrers") + if isinstance(data, list): + return [github.Referrer.Referrer(self._requester, headers, item) for item in data] + + def get_top_paths(self) -> None | list[Path]: + """ + :calls: `GET /repos/{owner}/{repo}/traffic/popular/paths `_ + :rtype: :class:`list` of :class:`github.Path.Path` + """ + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/traffic/popular/paths") + if isinstance(data, list): + return [github.Path.Path(self._requester, headers, item) for item in data] + + def get_views_traffic(self, per: Opt[str] = NotSet) -> View | None: + """ + :calls: `GET /repos/{owner}/{repo}/traffic/views `_ + :param per: string, must be one of day or week, day by default + :rtype: None or list of :class:`github.View.View` + """ + assert per in ["day", "week", NotSet], "per must be day or week, day by default" + url_parameters = dict() + if is_defined(per): + url_parameters["per"] = per + headers, data = self._requester.requestJsonAndCheck( + "GET", f"{self.url}/traffic/views", parameters=url_parameters + ) + return github.View.View(self._requester, headers, data) + + def get_clones_traffic(self, per: Opt[str] = NotSet) -> Clones | None: + """ + :calls: `GET /repos/{owner}/{repo}/traffic/clones `_ + :param per: string, must be one of day or week, day by default + :rtype: None or list of :class:`github.Clones.Clones` + """ + assert per in ["day", "week", NotSet], "per must be day or week, day by default" + url_parameters: dict[str, Any] = NotSet.remove_unset_items({"per": per}) + headers, data = self._requester.requestJsonAndCheck( + "GET", f"{self.url}/traffic/clones", parameters=url_parameters + ) + return github.Clones.Clones(self._requester, headers, data) + + def get_projects(self, state: Opt[str] = NotSet) -> PaginatedList[Project]: + """ + :calls: `GET /repos/{owner}/{repo}/projects `_ + :rtype: :class:`PaginatedList` of :class:`github.Project.Project` + :param state: string + """ + + url_parameters = dict() + if is_defined(state): + url_parameters["state"] = state + + return PaginatedList( + github.Project.Project, + self._requester, + f"{self.url}/projects", + url_parameters, + headers={"Accept": Consts.mediaTypeProjectsPreview}, + ) + + def get_autolinks(self) -> PaginatedList[Autolink]: + """ + :calls: `GET /repos/{owner}/{repo}/autolinks `_ + :rtype: :class:`PaginatedList` of :class:`github.Autolink.Autolink` + """ + return PaginatedList(github.Autolink.Autolink, self._requester, f"{self.url}/autolinks", None) + + def create_file( + self, + path: str, + message: str, + content: str | bytes, + branch: Opt[str] = NotSet, + committer: Opt[InputGitAuthor] = NotSet, + author: Opt[InputGitAuthor] = NotSet, + ) -> dict[str, ContentFile | Commit]: + """ + Create a file in this repository. + + :calls: `PUT /repos/{owner}/{repo}/contents/{path} `_ + :param path: string, (required), path of the file in the repository + :param message: string, (required), commit message + :param content: string, (required), the actual data in the file + :param branch: string, (optional), branch to create the commit on. Defaults to the default branch of the + repository + :param committer: InputGitAuthor, (optional), if no information is given the authenticated user's information + will be used. You must specify both a name and email. + :param author: InputGitAuthor, (optional), if omitted this will be filled in with committer information. If + passed, you must specify both a name and email. + :rtype: { 'content': :class:`ContentFile `:, 'commit': :class:`Commit + `} + + """ + assert isinstance(path, str) + assert isinstance(message, str) + assert isinstance(content, (str, bytes)) + assert is_optional(branch, str) + assert is_optional(author, github.InputGitAuthor) + assert is_optional(committer, github.InputGitAuthor) + + if not isinstance(content, bytes): + content = content.encode("utf-8") + content = b64encode(content).decode("utf-8") + put_parameters: dict[str, Any] = {"message": message, "content": content} + + if is_defined(branch): + put_parameters["branch"] = branch + if is_defined(author): + put_parameters["author"] = author._identity + if is_defined(committer): + put_parameters["committer"] = committer._identity + + headers, data = self._requester.requestJsonAndCheck( + "PUT", + f"{self.url}/contents/{urllib.parse.quote(path)}", + input=put_parameters, + ) + + return { + "content": github.ContentFile.ContentFile(self._requester, headers, data["content"], completed=False), + "commit": github.Commit.Commit(self._requester, headers, data["commit"], completed=True), + } + + def get_repository_advisories( + self, + ) -> PaginatedList[github.RepositoryAdvisory.RepositoryAdvisory]: + """ + :calls: `GET /repos/{owner}/{repo}/security-advisories `_ + :rtype: :class:`PaginatedList` of :class:`github.RepositoryAdvisory.RepositoryAdvisory` + """ + return PaginatedList( + github.RepositoryAdvisory.RepositoryAdvisory, + self._requester, + f"{self.url}/security-advisories", + None, + ) + + def get_repository_advisory(self, ghsa: str) -> github.RepositoryAdvisory.RepositoryAdvisory: + """ + :calls: `GET /repos/{owner}/{repo}/security-advisories/{ghsa} `_ + :param ghsa: string + :rtype: :class:`github.RepositoryAdvisory.RepositoryAdvisory` + """ + assert isinstance(ghsa, str), ghsa + ghsa = urllib.parse.quote(ghsa) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/security-advisories/{ghsa}") + return github.RepositoryAdvisory.RepositoryAdvisory(self._requester, headers, data) + + def update_file( + self, + path: str, + message: str, + content: bytes | str, + sha: str, + branch: Opt[str] = NotSet, + committer: Opt[InputGitAuthor] = NotSet, + author: Opt[InputGitAuthor] = NotSet, + ) -> dict[str, ContentFile | Commit]: + """ + This method updates a file in a repository. + + :calls: `PUT /repos/{owner}/{repo}/contents/{path} `_ + :param path: string, Required. The content path. + :param message: string, Required. The commit message. + :param content: string, Required. The updated file content, either base64 encoded, or ready to be encoded. + :param sha: string, Required. The blob SHA of the file being replaced. + :param branch: string. The branch name. Default: the repository’s default branch (usually master) + :param committer: InputGitAuthor, (optional), if no information is given the authenticated user's information + will be used. You must specify both a name and email. + :param author: InputGitAuthor, (optional), if omitted this will be filled in with committer information. If + passed, you must specify both a name and email. + :rtype: { 'content': :class:`ContentFile `:, 'commit': :class:`Commit + `} + + """ + assert isinstance(path, str) + assert isinstance(message, str) + assert isinstance(content, (str, bytes)) + assert isinstance(sha, str) + assert is_optional(branch, str) + assert is_optional(author, github.InputGitAuthor) + assert is_optional(committer, github.InputGitAuthor) + + if not isinstance(content, bytes): + content = content.encode("utf-8") + content = b64encode(content).decode("utf-8") + + put_parameters: dict[str, Any] = {"message": message, "content": content, "sha": sha} + + if is_defined(branch): + put_parameters["branch"] = branch + if is_defined(author): + put_parameters["author"] = author._identity + if is_defined(committer): + put_parameters["committer"] = committer._identity + + headers, data = self._requester.requestJsonAndCheck( + "PUT", + f"{self.url}/contents/{urllib.parse.quote(path)}", + input=put_parameters, + ) + + return { + "commit": github.Commit.Commit(self._requester, headers, data["commit"], completed=True), + "content": github.ContentFile.ContentFile(self._requester, headers, data["content"], completed=False), + } + + def delete_file( + self, + path: str, + message: str, + sha: str, + branch: Opt[str] = NotSet, + committer: Opt[InputGitAuthor] = NotSet, + author: Opt[InputGitAuthor] = NotSet, + ) -> dict[str, Commit | _NotSetType]: + """ + This method deletes a file in a repository. + + :calls: `DELETE /repos/{owner}/{repo}/contents/{path} `_ + :param path: string, Required. The content path. + :param message: string, Required. The commit message. + :param sha: string, Required. The blob SHA of the file being replaced. + :param branch: string. The branch name. Default: the repository’s default branch (usually master) + :param committer: InputGitAuthor, (optional), if no information is given the authenticated user's information + will be used. You must specify both a name and email. + :param author: InputGitAuthor, (optional), if omitted this will be filled in with committer information. If + passed, you must specify both a name and email. + :rtype: { 'content': :class:`null `:, 'commit': :class:`Commit `} + + """ + assert isinstance(path, str), "path must be str/unicode object" + assert isinstance(message, str), "message must be str/unicode object" + assert isinstance(sha, str), "sha must be a str/unicode object" + assert is_optional(branch, str), "branch must be a str/unicode object" + assert is_optional(author, github.InputGitAuthor), "author must be a github.InputGitAuthor object" + assert is_optional(committer, github.InputGitAuthor), "committer must be a github.InputGitAuthor object" + + url_parameters: dict[str, Any] = {"message": message, "sha": sha} + if is_defined(branch): + url_parameters["branch"] = branch + if is_defined(author): + url_parameters["author"] = author._identity + if is_defined(committer): + url_parameters["committer"] = committer._identity + + headers, data = self._requester.requestJsonAndCheck( + "DELETE", + f"{self.url}/contents/{urllib.parse.quote(path)}", + input=url_parameters, + ) + + return { + "commit": github.Commit.Commit(self._requester, headers, data["commit"], completed=True), + "content": NotSet, + } + + @deprecated( + reason=""" + Repository.get_dir_contents() is deprecated, use + Repository.get_contents() instead. + """ + ) + def get_dir_contents(self, path: str, ref: Opt[str] = NotSet) -> list[ContentFile]: + """ + :calls: `GET /repos/{owner}/{repo}/contents/{path} `_ + """ + return self.get_contents(path, ref=ref) # type: ignore + + def get_contributors(self, anon: Opt[str] = NotSet) -> PaginatedList[NamedUser]: + """ + :calls: `GET /repos/{owner}/{repo}/contributors `_ + :param anon: string + :rtype: :class:`PaginatedList` of :class:`github.NamedUser.NamedUser` + """ + url_parameters = dict() + if is_defined(anon): + url_parameters["anon"] = anon + + return PaginatedList( + github.NamedUser.NamedUser, + self._requester, + f"{self.url}/contributors", + url_parameters, + ) + + def get_download(self, id: int) -> Download: + """ + :calls: `GET /repos/{owner}/{repo}/downloads/{id} `_ + :param id: integer + :rtype: :class:`github.Download.Download` + """ + assert isinstance(id, int), id + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/downloads/{id}") + return github.Download.Download(self._requester, headers, data, completed=True) + + def get_downloads(self) -> PaginatedList[Download]: + """ + :calls: `GET /repos/{owner}/{repo}/downloads `_ + :rtype: :class:`PaginatedList` of :class:`github.Download.Download` + """ + return PaginatedList(github.Download.Download, self._requester, f"{self.url}/downloads", None) + + def get_events(self) -> PaginatedList[Event]: + """ + :calls: `GET /repos/{owner}/{repo}/events `_ + :rtype: :class:`PaginatedList` of :class:`github.Event.Event` + """ + return PaginatedList(github.Event.Event, self._requester, f"{self.url}/events", None) + + def get_forks(self) -> PaginatedList[Repository]: + """ + :calls: `GET /repos/{owner}/{repo}/forks `_ + :rtype: :class:`PaginatedList` of :class:`github.Repository.Repository` + """ + return PaginatedList(Repository, self._requester, f"{self.url}/forks", None) + + def create_fork( + self, + organization: Organization | Opt[str] = NotSet, + name: Opt[str] = NotSet, + default_branch_only: Opt[bool] = NotSet, + ) -> Repository: + """ + :calls: `POST /repos/{owner}/{repo}/forks `_ + :param organization: :class:`github.Organization.Organization` or string + :param name: string + :param default_branch_only: bool + :rtype: :class:`github.Repository.Repository` + """ + post_parameters: dict[str, Any] = {} + if isinstance(organization, github.Organization.Organization): + post_parameters["organization"] = organization.login + elif isinstance(organization, str): + post_parameters["organization"] = organization + else: + assert is_undefined(organization), organization + assert is_optional(name, str), name + assert is_optional(default_branch_only, bool), default_branch_only + if is_defined(name): + post_parameters["name"] = name + if is_defined(default_branch_only): + post_parameters["default_branch_only"] = default_branch_only + headers, data = self._requester.requestJsonAndCheck( + "POST", + f"{self.url}/forks", + input=post_parameters, + ) + return Repository(self._requester, headers, data, completed=True) + + def get_git_blob(self, sha: str) -> GitBlob: + """ + :calls: `GET /repos/{owner}/{repo}/git/blobs/{sha} `_ + :param sha: string + :rtype: :class:`github.GitBlob.GitBlob` + """ + assert isinstance(sha, str), sha + sha = urllib.parse.quote(sha) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/git/blobs/{sha}") + return github.GitBlob.GitBlob(self._requester, headers, data, completed=True) + + def get_git_commit(self, sha: str) -> GitCommit: + """ + :calls: `GET /repos/{owner}/{repo}/git/commits/{sha} `_ + :param sha: string + :rtype: :class:`github.GitCommit.GitCommit` + """ + assert isinstance(sha, str), sha + sha = urllib.parse.quote(sha) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/git/commits/{sha}") + return github.GitCommit.GitCommit(self._requester, headers, data, completed=True) + + def get_git_ref(self, ref: str) -> GitRef: + """ + :calls: `GET /repos/{owner}/{repo}/git/refs/{ref} `_ + :param ref: string + :rtype: :class:`github.GitRef.GitRef` + """ + prefix = "/git/refs/" + if not self._requester.FIX_REPO_GET_GIT_REF: + prefix = "/git/" + assert isinstance(ref, str), ref + ref = urllib.parse.quote(ref) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}{prefix}{ref}") + return github.GitRef.GitRef(self._requester, headers, data, completed=True) + + def get_git_refs(self) -> PaginatedList[GitRef]: + """ + :calls: `GET /repos/{owner}/{repo}/git/refs `_ + :rtype: :class:`PaginatedList` of :class:`github.GitRef.GitRef` + """ + return PaginatedList(github.GitRef.GitRef, self._requester, f"{self.url}/git/refs", None) + + def get_git_matching_refs(self, ref: str) -> PaginatedList[GitRef]: + """ + :calls: `GET /repos/{owner}/{repo}/git/matching-refs/{ref} `_ + :rtype: :class:`PaginatedList` of :class:`github.GitRef.GitRef` + """ + assert isinstance(ref, str), ref + ref = urllib.parse.quote(ref) + return PaginatedList( + github.GitRef.GitRef, + self._requester, + f"{self.url}/git/matching-refs/{ref}", + None, + ) + + def get_git_tag(self, sha: str) -> GitTag: + """ + :calls: `GET /repos/{owner}/{repo}/git/tags/{sha} `_ + :param sha: string + :rtype: :class:`github.GitTag.GitTag` + """ + assert isinstance(sha, str), sha + sha = urllib.parse.quote(sha) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/git/tags/{sha}") + return github.GitTag.GitTag(self._requester, headers, data, completed=True) + + def get_git_tree(self, sha: str, recursive: Opt[bool] = NotSet) -> GitTree: + """ + :calls: `GET /repos/{owner}/{repo}/git/trees/{sha} `_ + :param sha: string + :param recursive: bool + :rtype: :class:`github.GitTree.GitTree` + """ + assert isinstance(sha, str), sha + assert is_optional(recursive, bool), recursive + sha = urllib.parse.quote(sha) + url_parameters = dict() + if is_defined(recursive) and recursive: + # GitHub API requires the recursive parameter be set to 1. + url_parameters["recursive"] = 1 + headers, data = self._requester.requestJsonAndCheck( + "GET", f"{self.url}/git/trees/{sha}", parameters=url_parameters + ) + return github.GitTree.GitTree(self._requester, headers, data, completed=True) + + def get_hook(self, id: int) -> Hook: + """ + :calls: `GET /repos/{owner}/{repo}/hooks/{id} `_ + :param id: integer + :rtype: :class:`github.Hook.Hook` + """ + assert isinstance(id, int), id + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/hooks/{id}") + return github.Hook.Hook(self._requester, headers, data, completed=True) + + def get_hooks(self) -> PaginatedList[Hook]: + """ + :calls: `GET /repos/{owner}/{repo}/hooks `_ + :rtype: :class:`PaginatedList` of :class:`github.Hook.Hook` + """ + return PaginatedList(github.Hook.Hook, self._requester, f"{self.url}/hooks", None) + + def get_hook_delivery(self, hook_id: int, delivery_id: int) -> github.HookDelivery.HookDelivery: + """ + :calls: `GET /repos/{owner}/{repo}/hooks/{hook_id}/deliveries/{delivery_id} `_ + :param hook_id: integer + :param delivery_id: integer + :rtype: :class:`github.HookDelivery.HookDelivery` + """ + assert isinstance(hook_id, int), hook_id + assert isinstance(delivery_id, int), delivery_id + headers, data = self._requester.requestJsonAndCheck( + "GET", f"{self.url}/hooks/{hook_id}/deliveries/{delivery_id}" + ) + return github.HookDelivery.HookDelivery(self._requester, headers, data) + + def get_hook_deliveries(self, hook_id: int) -> PaginatedList[github.HookDelivery.HookDeliverySummary]: + """ + :calls: `GET /repos/{owner}/{repo}/hooks/{hook_id}/deliveries `_ + :param hook_id: integer + :rtype: :class:`PaginatedList` of :class:`github.HookDelivery.HookDeliverySummary` + """ + assert isinstance(hook_id, int), hook_id + + return PaginatedList( + github.HookDelivery.HookDeliverySummary, + self._requester, + f"{self.url}/hooks/{hook_id}/deliveries", + None, + ) + + def get_issue(self, number: int) -> Issue: + """ + :calls: `GET /repos/{owner}/{repo}/issues/{number} `_ + :param number: integer + :rtype: :class:`github.Issue.Issue` + """ + assert isinstance(number, int), number + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/issues/{number}") + return github.Issue.Issue(self._requester, headers, data, completed=True) + + def get_issues( + self, + milestone: Milestone | Opt[str] = NotSet, + state: Opt[str] = NotSet, + assignee: NamedUser | Opt[str] = NotSet, + mentioned: Opt[NamedUser] = NotSet, + labels: Opt[list[str] | list[Label]] = NotSet, + sort: Opt[str] = NotSet, + direction: Opt[str] = NotSet, + since: Opt[datetime] = NotSet, + creator: Opt[NamedUser] = NotSet, + ) -> PaginatedList[Issue]: + """ + :calls: `GET /repos/{owner}/{repo}/issues `_ + :param milestone: :class:`github.Milestone.Milestone` or "none" or "*" + :param state: string. `open`, `closed`, or `all`. If this is not set the GitHub API default behavior will be used. At the moment this is to return only open issues. This might change anytime on GitHub API side and it could be clever to explicitly specify the state value. + :param assignee: string or :class:`github.NamedUser.NamedUser` or "none" or "*" + :param mentioned: :class:`github.NamedUser.NamedUser` + :param labels: list of string or :class:`github.Label.Label` + :param sort: string + :param direction: string + :param since: datetime + :param creator: string or :class:`github.NamedUser.NamedUser` + :rtype: :class:`PaginatedList` of :class:`github.Issue.Issue` + """ + assert milestone in ["*", "none", NotSet] or isinstance(milestone, github.Milestone.Milestone), milestone + assert is_optional(state, str), state + assert is_optional(assignee, (str, github.NamedUser.NamedUser)), assignee + assert is_optional(mentioned, github.NamedUser.NamedUser), mentioned + assert is_optional_list(labels, (github.Label.Label, str)), labels + assert is_optional(sort, str), sort + assert is_optional(direction, str), direction + assert is_optional(since, datetime), since + assert is_optional(creator, (str, github.NamedUser.NamedUser)), creator + url_parameters: dict[str, Any] = {} + if is_defined(milestone): + if isinstance(milestone, github.Milestone.Milestone): + url_parameters["milestone"] = milestone._identity + else: + url_parameters["milestone"] = milestone + if is_defined(state): + url_parameters["state"] = state + if is_defined(assignee): + if isinstance(assignee, github.NamedUser.NamedUser): + url_parameters["assignee"] = assignee._identity + else: + url_parameters["assignee"] = assignee + if is_defined(mentioned): + url_parameters["mentioned"] = mentioned._identity + if is_defined(labels): + url_parameters["labels"] = ",".join( + [label.name if isinstance(label, github.Label.Label) else label for label in labels] # type: ignore + ) + if is_defined(sort): + url_parameters["sort"] = sort + if is_defined(direction): + url_parameters["direction"] = direction + if is_defined(since): + url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") + if is_defined(creator): + if isinstance(creator, str): + url_parameters["creator"] = creator + else: + url_parameters["creator"] = creator._identity + return PaginatedList(github.Issue.Issue, self._requester, f"{self.url}/issues", url_parameters) + + def get_issues_comments( + self, + sort: Opt[str] = NotSet, + direction: Opt[str] = NotSet, + since: Opt[datetime] = NotSet, + ) -> PaginatedList[IssueComment]: + """ + :calls: `GET /repos/{owner}/{repo}/issues/comments `_ + :param sort: string + :param direction: string + :param since: datetime + :rtype: :class:`PaginatedList` of :class:`github.IssueComment.IssueComment` + """ + assert is_optional(sort, str), sort + assert is_optional(direction, str), direction + assert is_optional(since, datetime), since + url_parameters = dict() + if is_defined(sort): + url_parameters["sort"] = sort + if is_defined(direction): + url_parameters["direction"] = direction + if is_defined(since): + url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") + return PaginatedList( + github.IssueComment.IssueComment, + self._requester, + f"{self.url}/issues/comments", + url_parameters, + ) + + def get_issues_event(self, id: int) -> IssueEvent: + """ + :calls: `GET /repos/{owner}/{repo}/issues/events/{id} `_ + :param id: integer + :rtype: :class:`github.IssueEvent.IssueEvent` + """ + assert isinstance(id, int), id + headers, data = self._requester.requestJsonAndCheck( + "GET", + f"{self.url}/issues/events/{id}", + headers={"Accept": Consts.mediaTypeLockReasonPreview}, + ) + return github.IssueEvent.IssueEvent(self._requester, headers, data, completed=True) + + def get_issues_events(self) -> PaginatedList[IssueEvent]: + """ + :calls: `GET /repos/{owner}/{repo}/issues/events `_ + :rtype: :class:`PaginatedList` of :class:`github.IssueEvent.IssueEvent` + """ + return PaginatedList( + github.IssueEvent.IssueEvent, + self._requester, + f"{self.url}/issues/events", + None, + headers={"Accept": Consts.mediaTypeLockReasonPreview}, + ) + + def get_key(self, id: int) -> RepositoryKey: + """ + :calls: `GET /repos/{owner}/{repo}/keys/{id} `_ + :param id: integer + :rtype: :class:`github.RepositoryKey.RepositoryKey` + """ + assert isinstance(id, int), id + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/keys/{id}") + return github.RepositoryKey.RepositoryKey(self._requester, headers, data, completed=True) + + def get_keys(self) -> PaginatedList[RepositoryKey]: + """ + :calls: `GET /repos/{owner}/{repo}/keys `_ + :rtype: :class:`PaginatedList` of :class:`github.RepositoryKey.RepositoryKey` + """ + return PaginatedList( + github.RepositoryKey.RepositoryKey, + self._requester, + f"{self.url}/keys", + None, + ) + + def get_label(self, name: str) -> Label: + """ + :calls: `GET /repos/{owner}/{repo}/labels/{name} `_ + :param name: string + :rtype: :class:`github.Label.Label` + """ + assert isinstance(name, str), name + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/labels/{urllib.parse.quote(name)}") + return github.Label.Label(self._requester, headers, data, completed=True) + + def get_labels(self) -> PaginatedList[Label]: + """ + :calls: `GET /repos/{owner}/{repo}/labels `_ + :rtype: :class:`PaginatedList` of :class:`github.Label.Label` + """ + return PaginatedList(github.Label.Label, self._requester, f"{self.url}/labels", None) + + def get_languages(self) -> dict[str, int]: + """ + :calls: `GET /repos/{owner}/{repo}/languages `_ + :rtype: dict of string to integer + """ + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/languages") + return data + + def get_license(self) -> ContentFile: + """ + :calls: `GET /repos/{owner}/{repo}/license `_ + :rtype: :class:`github.ContentFile.ContentFile` + """ + + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/license") + return github.ContentFile.ContentFile(self._requester, headers, data, completed=True) + + def get_milestone(self, number: int) -> Milestone: + """ + :calls: `GET /repos/{owner}/{repo}/milestones/{number} `_ + :param number: integer + :rtype: :class:`github.Milestone.Milestone` + """ + assert isinstance(number, int), number + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/milestones/{number}") + return github.Milestone.Milestone(self._requester, headers, data, completed=True) + + def get_milestones( + self, + state: Opt[str] = NotSet, + sort: Opt[str] = NotSet, + direction: Opt[str] = NotSet, + ) -> PaginatedList[Milestone]: + """ + :calls: `GET /repos/{owner}/{repo}/milestones `_ + :param state: string + :param sort: string + :param direction: string + :rtype: :class:`PaginatedList` of :class:`github.Milestone.Milestone` + """ + assert is_optional(state, str), state + assert is_optional(sort, str), sort + assert is_optional(direction, str), direction + url_parameters = dict() + if is_defined(state): + url_parameters["state"] = state + if is_defined(sort): + url_parameters["sort"] = sort + if is_defined(direction): + url_parameters["direction"] = direction + return PaginatedList( + github.Milestone.Milestone, + self._requester, + f"{self.url}/milestones", + url_parameters, + ) + + def get_network_events(self) -> PaginatedList[Event]: + """ + :calls: `GET /networks/{owner}/{repo}/events `_ + :rtype: :class:`PaginatedList` of :class:`github.Event.Event` + """ + return PaginatedList( + github.Event.Event, + self._requester, + f"/networks/{self.owner.login}/{self.name}/events", + None, + ) + + def get_public_key(self, secret_type: str = "actions") -> PublicKey: + """ + :calls: `GET /repos/{owner}/{repo}/actions/secrets/public-key `_ + :param secret_type: string options actions or dependabot + :rtype: :class:`github.PublicKey.PublicKey` + """ + assert secret_type in ["actions", "dependabot"], "secret_type should be actions or dependabot" + + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/{secret_type}/secrets/public-key") + return github.PublicKey.PublicKey(self._requester, headers, data, completed=True) + + def get_pull(self, number: int) -> PullRequest: + """ + :calls: `GET /repos/{owner}/{repo}/pulls/{number} `_ + :param number: integer + :rtype: :class:`github.PullRequest.PullRequest` + """ + assert isinstance(number, int), number + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/pulls/{number}") + return github.PullRequest.PullRequest(self._requester, headers, data, completed=True) + + def get_pulls( + self, + state: Opt[str] = NotSet, + sort: Opt[str] = NotSet, + direction: Opt[str] = NotSet, + base: Opt[str] = NotSet, + head: Opt[str] = NotSet, + ) -> PaginatedList[PullRequest]: + """ + :calls: `GET /repos/{owner}/{repo}/pulls `_ + :param state: string + :param sort: string + :param direction: string + :param base: string + :param head: string + :rtype: :class:`PaginatedList` of :class:`github.PullRequest.PullRequest` + """ + assert is_optional(state, str), state + assert is_optional(sort, str), sort + assert is_optional(direction, str), direction + assert is_optional(base, str), base + assert is_optional(head, str), head + url_parameters = dict() + if is_defined(state): + url_parameters["state"] = state + if is_defined(sort): + url_parameters["sort"] = sort + if is_defined(direction): + url_parameters["direction"] = direction + if is_defined(base): + url_parameters["base"] = base + if is_defined(head): + url_parameters["head"] = head + return PaginatedList( + github.PullRequest.PullRequest, + self._requester, + f"{self.url}/pulls", + url_parameters, + ) + + def get_pulls_comments( + self, + sort: Opt[str] = NotSet, + direction: Opt[str] = NotSet, + since: Opt[datetime] = NotSet, + ) -> PaginatedList[PullRequestComment]: + """ + :calls: `GET /repos/{owner}/{repo}/pulls/comments `_ + :param sort: string + :param direction: string + :param since: datetime + :rtype: :class:`PaginatedList` of :class:`github.PullRequestComment.PullRequestComment` + """ + return self.get_pulls_review_comments(sort, direction, since) + + def get_pulls_review_comments( + self, + sort: Opt[str] = NotSet, + direction: Opt[str] = NotSet, + since: Opt[datetime] = NotSet, + ) -> PaginatedList[PullRequestComment]: + """ + :calls: `GET /repos/{owner}/{repo}/pulls/comments `_ + :param sort: string 'created', 'updated', 'created_at' + :param direction: string 'asc' or 'desc' + :param since: datetime + :rtype: :class:`PaginatedList` of :class:`github.PullRequestComment.PullRequestComment` + """ + assert is_optional(sort, str), sort + assert is_optional(direction, str), direction + assert is_optional(since, datetime), since + url_parameters = dict() + if is_defined(sort): + url_parameters["sort"] = sort + if is_defined(direction): + url_parameters["direction"] = direction + if is_defined(since): + url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") + return PaginatedList( + github.PullRequestComment.PullRequestComment, + self._requester, + f"{self.url}/pulls/comments", + url_parameters, + ) + + def get_readme(self, ref: Opt[str] = NotSet) -> ContentFile: + """ + :calls: `GET /repos/{owner}/{repo}/readme `_ + :param ref: string + :rtype: :class:`github.ContentFile.ContentFile` + """ + assert is_optional(ref, str), ref + url_parameters = dict() + if is_defined(ref): + url_parameters["ref"] = ref + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/readme", parameters=url_parameters) + return github.ContentFile.ContentFile(self._requester, headers, data, completed=True) + + def get_self_hosted_runner(self, runner_id: int) -> SelfHostedActionsRunner: + """ + :calls: `GET /repos/{owner}/{repo}/actions/runners/{id} `_ + :param runner_id: int + :rtype: :class:`github.SelfHostedActionsRunner.SelfHostedActionsRunner` + """ + assert isinstance(runner_id, int), runner_id + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/actions/runners/{runner_id}") + return github.SelfHostedActionsRunner.SelfHostedActionsRunner(self._requester, headers, data) + + def get_self_hosted_runners(self) -> PaginatedList[SelfHostedActionsRunner]: + """ + :calls: `GET /repos/{owner}/{repo}/actions/runners `_ + :rtype: :class:`PaginatedList` of :class:`github.SelfHostedActionsRunner.SelfHostedActionsRunner` + """ + return PaginatedList( + github.SelfHostedActionsRunner.SelfHostedActionsRunner, + self._requester, + f"{self.url}/actions/runners", + None, + list_item="runners", + ) + + def get_source_import(self) -> SourceImport | None: + """ + :calls: `GET /repos/{owner}/{repo}/import `_ + """ + import_header = {"Accept": Consts.mediaTypeImportPreview} + headers, data = self._requester.requestJsonAndCheck( + "GET", + f"{self.url}/import", + headers=import_header, + ) + if not data: + return None + else: + return github.SourceImport.SourceImport(self._requester, headers, data, completed=True) + + def get_stargazers(self) -> PaginatedList[NamedUser]: + """ + :calls: `GET /repos/{owner}/{repo}/stargazers `_ + :rtype: :class:`PaginatedList` of :class:`github.NamedUser.NamedUser` + """ + return PaginatedList(github.NamedUser.NamedUser, self._requester, f"{self.url}/stargazers", None) + + def get_stargazers_with_dates(self) -> PaginatedList[Stargazer]: + """ + :calls: `GET /repos/{owner}/{repo}/stargazers `_ + :rtype: :class:`PaginatedList` of :class:`github.Stargazer.Stargazer` + """ + return PaginatedList( + github.Stargazer.Stargazer, + self._requester, + f"{self.url}/stargazers", + None, + headers={"Accept": Consts.mediaTypeStarringPreview}, + ) + + def get_stats_contributors(self) -> list[StatsContributor] | None: + """ + :calls: `GET /repos/{owner}/{repo}/stats/contributors `_ + :rtype: None or list of :class:`github.StatsContributor.StatsContributor` + """ + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/stats/contributors") + if not data: + return None + else: + return [ + github.StatsContributor.StatsContributor(self._requester, headers, attributes) for attributes in data + ] + + def get_stats_commit_activity(self) -> list[StatsCommitActivity] | None: + """ + :calls: `GET /repos/{owner}/{repo}/stats/commit_activity `_ + :rtype: None or list of :class:`github.StatsCommitActivity.StatsCommitActivity` + """ + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/stats/commit_activity") + if not data: + return None + else: + return [ + github.StatsCommitActivity.StatsCommitActivity(self._requester, headers, attributes) + for attributes in data + ] + + def get_stats_code_frequency(self) -> list[StatsCodeFrequency] | None: + """ + :calls: `GET /repos/{owner}/{repo}/stats/code_frequency `_ + :rtype: None or list of :class:`github.StatsCodeFrequency.StatsCodeFrequency` + """ + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/stats/code_frequency") + if not data: + return None + else: + return [ + github.StatsCodeFrequency.StatsCodeFrequency(self._requester, headers, attributes) + for attributes in data + ] + + def get_stats_participation(self) -> StatsParticipation | None: + """ + :calls: `GET /repos/{owner}/{repo}/stats/participation `_ + :rtype: None or :class:`github.StatsParticipation.StatsParticipation` + """ + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/stats/participation") + if not data: + return None + else: + return github.StatsParticipation.StatsParticipation(self._requester, headers, data) + + def get_stats_punch_card(self) -> StatsPunchCard | None: + """ + :calls: `GET /repos/{owner}/{repo}/stats/punch_card `_ + :rtype: None or :class:`github.StatsPunchCard.StatsPunchCard` + """ + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/stats/punch_card") + if not data: + return None + else: + return github.StatsPunchCard.StatsPunchCard(self._requester, headers, data) + + def get_subscribers(self) -> PaginatedList[NamedUser]: + """ + :calls: `GET /repos/{owner}/{repo}/subscribers `_ + :rtype: :class:`PaginatedList` of :class:`github.NamedUser.NamedUser` + """ + return PaginatedList(github.NamedUser.NamedUser, self._requester, f"{self.url}/subscribers", None) + + def get_tags(self) -> PaginatedList[Tag]: + """ + :calls: `GET /repos/{owner}/{repo}/tags `_ + :rtype: :class:`PaginatedList` of :class:`github.Tag.Tag` + """ + return PaginatedList(github.Tag.Tag, self._requester, f"{self.url}/tags", None) + + def get_releases(self) -> PaginatedList[GitRelease]: + """ + :calls: `GET /repos/{owner}/{repo}/releases `_ + :rtype: :class:`PaginatedList` of :class:`github.GitRelease.GitRelease` + """ + return PaginatedList(github.GitRelease.GitRelease, self._requester, f"{self.url}/releases", None) + + def get_release(self, id: int | str) -> GitRelease: + """ + :calls: `GET /repos/{owner}/{repo}/releases/{id} `_ + :param id: int (release id), str (tag name) + :rtype: None or :class:`github.GitRelease.GitRelease` + """ + assert isinstance(id, (int, str)), id + if isinstance(id, int): + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/releases/{id}") + return github.GitRelease.GitRelease(self._requester, headers, data, completed=True) + elif isinstance(id, str): + id = urllib.parse.quote(id) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/releases/tags/{id}") + return github.GitRelease.GitRelease(self._requester, headers, data, completed=True) + + def get_latest_release(self) -> GitRelease: + """ + :calls: `GET /repos/{owner}/{repo}/releases/latest `_ + :rtype: :class:`github.GitRelease.GitRelease` + """ + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/releases/latest") + return github.GitRelease.GitRelease(self._requester, headers, data, completed=True) + + def get_teams(self) -> PaginatedList[Team]: + """ + :calls: `GET /repos/{owner}/{repo}/teams `_ + :rtype: :class:`PaginatedList` of :class:`github.Team.Team` + """ + return PaginatedList(github.Team.Team, self._requester, f"{self.url}/teams", None) + + def get_topics(self) -> list[str]: + """ + :calls: `GET /repos/{owner}/{repo}/topics `_ + :rtype: list of strings + """ + headers, data = self._requester.requestJsonAndCheck( + "GET", + f"{self.url}/topics", + headers={"Accept": Consts.mediaTypeTopicsPreview}, + ) + return data["names"] + + def get_watchers(self) -> PaginatedList[NamedUser]: + """ + :calls: `GET /repos/{owner}/{repo}/watchers `_ + :rtype: :class:`PaginatedList` of :class:`github.NamedUser.NamedUser` + """ + return PaginatedList(github.NamedUser.NamedUser, self._requester, f"{self.url}/watchers", None) + + def get_workflows(self) -> PaginatedList[Workflow]: + """ + :calls: `GET /repos/{owner}/{repo}/actions/workflows `_ + :rtype: :class:`PaginatedList` of :class:`github.Workflow.Workflow` + """ + return PaginatedList( + github.Workflow.Workflow, + self._requester, + f"{self.url}/actions/workflows", + None, + list_item="workflows", + ) + + def get_workflow(self, id_or_file_name: str | int) -> Workflow: + """ + :calls: `GET /repos/{owner}/{repo}/actions/workflows/{workflow_id} `_ + :param id_or_file_name: int or string. Can be either a workflow ID or a filename. + :rtype: :class:`github.Workflow.Workflow` + """ + assert isinstance(id_or_file_name, (int, str)), id_or_file_name + id_or_file_name = urllib.parse.quote(str(id_or_file_name)) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/actions/workflows/{id_or_file_name}") + return github.Workflow.Workflow(self._requester, headers, data, completed=True) + + def get_workflow_runs( + self, + actor: Opt[NamedUser] = NotSet, + branch: Opt[Branch] = NotSet, + event: Opt[str] = NotSet, + status: Opt[str] = NotSet, + exclude_pull_requests: Opt[bool] = NotSet, + head_sha: Opt[str] = NotSet, + created: Opt[str] = NotSet, + check_suite_id: Opt[int] = NotSet, + ) -> PaginatedList[WorkflowRun]: + """ + :calls: `GET /repos/{owner}/{repo}/actions/runs `_ + :param actor: :class:`github.NamedUser.NamedUser` or string + :param branch: :class:`github.Branch.Branch` or string + :param event: string + :param status: string `queued`, `in_progress`, `completed`, `success`, `failure`, `neutral`, `cancelled`, `skipped`, `timed_out`, or `action_required` + :param exclude_pull_requests: bool + :param head_sha: string + :param created: string Created filter, see https://docs.github.com/en/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax#query-for-dates + :param check_suite_id: int + + :rtype: :class:`PaginatedList` of :class:`github.WorkflowRun.WorkflowRun` + """ + assert is_optional(actor, (github.NamedUser.NamedUser, str)), actor + assert is_optional(branch, (github.Branch.Branch, str)), branch + assert is_optional(event, str), event + assert is_optional(status, str), status + assert is_optional(exclude_pull_requests, bool), exclude_pull_requests + assert is_optional(head_sha, str), head_sha + assert is_optional(created, str), created + assert is_optional(check_suite_id, int), check_suite_id + + url_parameters: dict[str, Any] = {} + if is_defined(actor): + if isinstance(actor, github.NamedUser.NamedUser): + url_parameters["actor"] = actor._identity + else: + url_parameters["actor"] = actor + if is_defined(branch): + if isinstance(branch, github.Branch.Branch): + url_parameters["branch"] = branch.name + else: + url_parameters["branch"] = branch + if is_defined(event): + url_parameters["event"] = event + if is_defined(status): + url_parameters["status"] = status + if is_defined(exclude_pull_requests) and exclude_pull_requests: + url_parameters["exclude_pull_requests"] = 1 + if is_defined(head_sha): + url_parameters["head_sha"] = head_sha + if is_defined(created): + url_parameters["created"] = created + if is_defined(check_suite_id): + url_parameters["check_suite_id"] = check_suite_id + + return PaginatedList( + github.WorkflowRun.WorkflowRun, + self._requester, + f"{self.url}/actions/runs", + url_parameters, + list_item="workflow_runs", + ) + + def get_workflow_run(self, id_: int) -> WorkflowRun: + """ + :calls: `GET /repos/{owner}/{repo}/actions/runs/{run_id} `_ + :param id_: int + :rtype: :class:`github.WorkflowRun.WorkflowRun` + """ + assert isinstance(id_, int) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/actions/runs/{id_}") + return github.WorkflowRun.WorkflowRun(self._requester, headers, data, completed=True) + + def has_in_assignees(self, assignee: str | NamedUser) -> bool: + """ + :calls: `GET /repos/{owner}/{repo}/assignees/{assignee} `_ + :param assignee: string or :class:`github.NamedUser.NamedUser` + :rtype: bool + """ + assert isinstance(assignee, github.NamedUser.NamedUser) or isinstance(assignee, str), assignee + + if isinstance(assignee, github.NamedUser.NamedUser): + assignee = assignee._identity + else: + assignee = urllib.parse.quote(assignee) + + status, headers, data = self._requester.requestJson("GET", f"{self.url}/assignees/{assignee}") + return status == 204 + + def has_in_collaborators(self, collaborator: str | NamedUser) -> bool: + """ + :calls: `GET /repos/{owner}/{repo}/collaborators/{user} `_ + :param collaborator: string or :class:`github.NamedUser.NamedUser` + :rtype: bool + """ + assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, str), collaborator + + if isinstance(collaborator, github.NamedUser.NamedUser): + collaborator = collaborator._identity + else: + collaborator = urllib.parse.quote(collaborator) + + status, headers, data = self._requester.requestJson("GET", f"{self.url}/collaborators/{collaborator}") + return status == 204 + + def _legacy_convert_issue(self, attributes: dict[str, Any]) -> dict[str, Any]: + convertedAttributes = { + "number": attributes["number"], + "url": f"/repos{urllib.parse.urlparse(attributes['html_url']).path}", + "user": { + "login": attributes["user"], + "url": f"/users/{attributes['user']}", + }, + } + if "labels" in attributes: # pragma no branch + convertedAttributes["labels"] = [{"name": label} for label in attributes["labels"]] + for attr in ("title", "created_at", "comments", "body", "updated_at", "state"): + if attr in attributes: # pragma no branch + convertedAttributes[attr] = attributes[attr] + return convertedAttributes + + def legacy_search_issues(self, state: str, keyword: str) -> list[Issue]: + """ + :calls: `GET /legacy/issues/search/{owner}/{repository}/{state}/{keyword} `_ + :param state: "open" or "closed" + :param keyword: string + :rtype: List of :class:`github.Issue.Issue` + """ + assert state in ["open", "closed"], state + assert isinstance(keyword, str), keyword + headers, data = self._requester.requestJsonAndCheck( + "GET", + f"/legacy/issues/search/{self.owner.login}/{self.name}/{state}/{urllib.parse.quote(keyword)}", + ) + return [ + github.Issue.Issue( + self._requester, + headers, + self._legacy_convert_issue(element), + completed=False, + ) + for element in data["issues"] + ] + + def get_notifications( + self, + all: Opt[bool] = NotSet, + participating: Opt[bool] = NotSet, + since: Opt[datetime] = NotSet, + before: Opt[datetime] = NotSet, + ) -> PaginatedList[Notification]: + """ + :calls: `GET /repos/{owner}/{repo}/notifications `_ + :param all: bool + :param participating: bool + :param since: datetime + :param before: datetime + :rtype: :class:`PaginatedList` of :class:`github.Notification.Notification` + """ + + assert is_optional(all, bool), all + assert is_optional(participating, bool), participating + assert is_optional(since, datetime), since + assert is_optional(before, datetime), before + + params = NotSet.remove_unset_items({"all": all, "participating": participating}) + if is_defined(since): + params["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ") + if is_defined(before): + params["before"] = before.strftime("%Y-%m-%dT%H:%M:%SZ") + + return PaginatedList( + github.Notification.Notification, + self._requester, + f"{self.url}/notifications", + params, + ) + + def mark_notifications_as_read(self, last_read_at: datetime = datetime.now(timezone.utc)) -> None: + """ + :calls: `PUT /repos/{owner}/{repo}/notifications `_ + :param last_read_at: datetime + """ + assert isinstance(last_read_at, datetime) + put_parameters = {"last_read_at": last_read_at.strftime("%Y-%m-%dT%H:%M:%SZ")} + + headers, data = self._requester.requestJsonAndCheck("PUT", f"{self.url}/notifications", input=put_parameters) + + def merge(self, base: str, head: str, commit_message: Opt[str] = NotSet) -> Commit | None: + """ + :calls: `POST /repos/{owner}/{repo}/merges `_ + :param base: string + :param head: string + :param commit_message: string + :rtype: :class:`github.Commit.Commit` + """ + assert isinstance(base, str), base + assert isinstance(head, str), head + assert is_optional(commit_message, str), commit_message + post_parameters = { + "base": base, + "head": head, + } + if is_defined(commit_message): + post_parameters["commit_message"] = commit_message + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/merges", input=post_parameters) + if data is None: + return None + else: + return github.Commit.Commit(self._requester, headers, data, completed=True) + + def merge_upstream(self, branch: str) -> MergedUpstream: + """ + :calls: `POST /repos/{owner}/{repo}/merge-upstream `_ + :param branch: string + :rtype: :class:`github.MergedUpstream.MergedUpstream` + :raises: :class:`GithubException` for error status codes + """ + assert isinstance(branch, str), branch + post_parameters = {"branch": branch} + headers, data = self._requester.requestJsonAndCheck("POST", f"{self.url}/merge-upstream", input=post_parameters) + return github.MergedUpstream.MergedUpstream(self._requester, headers, data) + + def replace_topics(self, topics: list[str]) -> None: + """ + :calls: `PUT /repos/{owner}/{repo}/topics `_ + :param topics: list of strings + :rtype: None + """ + post_parameters = {"names": topics} + headers, data = self._requester.requestJsonAndCheck( + "PUT", + f"{self.url}/topics", + headers={"Accept": Consts.mediaTypeTopicsPreview}, + input=post_parameters, + ) + + def get_vulnerability_alert(self) -> bool: + """ + :calls: `GET /repos/{owner}/{repo}/vulnerability-alerts `_ + :rtype: bool + """ + status, _, _ = self._requester.requestJson( + "GET", + f"{self.url}/vulnerability-alerts", + headers={"Accept": Consts.vulnerabilityAlertsPreview}, + ) + return status == 204 + + def enable_vulnerability_alert(self) -> bool: + """ + :calls: `PUT /repos/{owner}/{repo}/vulnerability-alerts `_ + :rtype: bool + """ + status, _, _ = self._requester.requestJson( + "PUT", + f"{self.url}/vulnerability-alerts", + headers={"Accept": Consts.vulnerabilityAlertsPreview}, + ) + return status == 204 + + def disable_vulnerability_alert(self) -> bool: + """ + :calls: `DELETE /repos/{owner}/{repo}/vulnerability-alerts `_ + :rtype: bool + """ + status, _, _ = self._requester.requestJson( + "DELETE", + f"{self.url}/vulnerability-alerts", + headers={"Accept": Consts.vulnerabilityAlertsPreview}, + ) + return status == 204 + + def enable_automated_security_fixes(self) -> bool: + """ + :calls: `PUT /repos/{owner}/{repo}/automated-security-fixes `_ + :rtype: bool + """ + status, _, _ = self._requester.requestJson( + "PUT", + f"{self.url}/automated-security-fixes", + headers={"Accept": Consts.automatedSecurityFixes}, + ) + return status == 204 + + def disable_automated_security_fixes(self) -> bool: + """ + :calls: `DELETE /repos/{owner}/{repo}/automated-security-fixes `_ + :rtype: bool + """ + status, _, _ = self._requester.requestJson( + "DELETE", + f"{self.url}/automated-security-fixes", + headers={"Accept": Consts.automatedSecurityFixes}, + ) + return status == 204 + + def remove_from_collaborators(self, collaborator: str | NamedUser) -> None: + """ + :calls: `DELETE /repos/{owner}/{repo}/collaborators/{user} `_ + :param collaborator: string or :class:`github.NamedUser.NamedUser` + :rtype: None + """ + assert isinstance(collaborator, github.NamedUser.NamedUser) or isinstance(collaborator, str), collaborator + + if isinstance(collaborator, github.NamedUser.NamedUser): + collaborator = collaborator._identity + else: + collaborator = urllib.parse.quote(collaborator) + + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.url}/collaborators/{collaborator}") + + def remove_self_hosted_runner(self, runner: SelfHostedActionsRunner | int) -> bool: + """ + :calls: `DELETE /repos/{owner}/{repo}/actions/runners/{runner_id} `_ + :param runner: int or :class:`github.SelfHostedActionsRunner.SelfHostedActionsRunner` + :rtype: bool + """ + assert isinstance(runner, github.SelfHostedActionsRunner.SelfHostedActionsRunner) or isinstance( + runner, int + ), runner + + if isinstance(runner, github.SelfHostedActionsRunner.SelfHostedActionsRunner): + runner = runner.id + + status, _, _ = self._requester.requestJson("DELETE", f"{self.url}/actions/runners/{runner}") + return status == 204 + + def remove_autolink(self, autolink: Autolink | int) -> bool: + """ + :calls: `DELETE /repos/{owner}/{repo}/autolinks/{id} `_ + :param autolink: int or :class:`github.Autolink.Autolink` + :rtype: None + """ + is_autolink = isinstance(autolink, github.Autolink.Autolink) + assert is_autolink or isinstance(autolink, int), autolink + + status, _, _ = self._requester.requestJson( + "DELETE", f"{self.url}/autolinks/{autolink.id if is_autolink else autolink}" # type: ignore + ) + return status == 204 + + def subscribe_to_hub(self, event: str, callback: str, secret: Opt[str] = NotSet) -> None: + """ + :calls: `POST /hub `_ + :param event: string + :param callback: string + :param secret: string + :rtype: None + """ + return self._hub("subscribe", event, callback, secret) + + def unsubscribe_from_hub(self, event: str, callback: str) -> None: + """ + :calls: `POST /hub `_ + :param event: string + :param callback: string + :param secret: string + :rtype: None + """ + return self._hub("unsubscribe", event, callback, NotSet) + + def create_check_suite(self, head_sha: str) -> CheckSuite: + """ + :calls: `POST /repos/{owner}/{repo}/check-suites `_ + :param head_sha: string + :rtype: :class:`github.CheckSuite.CheckSuite` + """ + assert isinstance(head_sha, str), head_sha + headers, data = self._requester.requestJsonAndCheck( + "POST", + f"{self.url}/check-suites", + input={"head_sha": head_sha}, + ) + return github.CheckSuite.CheckSuite(self._requester, headers, data, completed=True) + + def get_check_suite(self, check_suite_id: int) -> CheckSuite: + """ + :calls: `GET /repos/{owner}/{repo}/check-suites/{check_suite_id} `_ + :param check_suite_id: int + :rtype: :class:`github.CheckSuite.CheckSuite` + """ + assert isinstance(check_suite_id, int), check_suite_id + requestHeaders = {"Accept": "application/vnd.github.v3+json"} + headers, data = self._requester.requestJsonAndCheck( + "GET", + f"{self.url}/check-suites/{check_suite_id}", + headers=requestHeaders, + ) + return github.CheckSuite.CheckSuite(self._requester, headers, data) + + def update_check_suites_preferences( + self, auto_trigger_checks: list[dict[str, bool | int]] + ) -> RepositoryPreferences: + """ + :calls: `PATCH /repos/{owner}/{repo}/check-suites/preferences `_ + :param auto_trigger_checks: list of dict + :rtype: :class:`github.RepositoryPreferences.RepositoryPreferences` + """ + assert all(isinstance(element, dict) for element in auto_trigger_checks), auto_trigger_checks + headers, data = self._requester.requestJsonAndCheck( + "PATCH", + f"{self.url}/check-suites/preferences", + input={"auto_trigger_checks": auto_trigger_checks}, + ) + return github.RepositoryPreferences.RepositoryPreferences(self._requester, headers, data) + + def _hub(self, mode: str, event: str, callback: str, secret: Opt[str]) -> None: + assert isinstance(mode, str), mode + assert isinstance(event, str), event + assert isinstance(callback, str), callback + assert is_optional(secret, str), secret + event = urllib.parse.quote(event) + + post_parameters = collections.OrderedDict() + post_parameters["hub.callback"] = callback + post_parameters["hub.topic"] = f"https://github.com/{self.full_name}/events/{event}" + post_parameters["hub.mode"] = mode + if is_defined(secret): + post_parameters["hub.secret"] = secret + + headers, output = self._requester.requestMultipartAndCheck("POST", "/hub", input=post_parameters) + + def get_release_asset(self, id: int) -> GitReleaseAsset: + assert isinstance(id, (int)), id + resp_headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/releases/assets/{id}") + return github.GitReleaseAsset.GitReleaseAsset(self._requester, resp_headers, data, completed=True) + + def create_check_run( + self, + name: str, + head_sha: str, + details_url: Opt[str] = NotSet, + external_id: Opt[str] = NotSet, + status: Opt[str] = NotSet, + started_at: Opt[datetime] = NotSet, + conclusion: Opt[str] = NotSet, + completed_at: Opt[datetime] = NotSet, + output: Opt[dict[str, str | list[dict[str, str | int]]]] = NotSet, + actions: Opt[list[dict[str, str]]] = NotSet, + ) -> CheckRun: + """ + :calls: `POST /repos/{owner}/{repo}/check-runs `_ + :param name: string + :param head_sha: string + :param details_url: string + :param external_id: string + :param status: string + :param started_at: datetime + :param conclusion: string + :param completed_at: datetime + :param output: dict + :param actions: list of dict + :rtype: :class:`github.CheckRun.CheckRun` + """ + assert isinstance(name, str), name + assert isinstance(head_sha, str), head_sha + assert is_optional(details_url, str), details_url + assert is_optional(external_id, str), external_id + assert is_optional(status, str), status + assert is_optional(started_at, datetime), started_at + assert is_optional(conclusion, str), conclusion + assert is_optional(completed_at, datetime), completed_at + assert is_optional(output, dict), output + assert is_optional_list(actions, dict), actions + + post_parameters = NotSet.remove_unset_items( + { + "name": name, + "head_sha": head_sha, + "details_url": details_url, + "external_id": external_id, + "status": status, + "conclusion": conclusion, + "output": output, + "actions": actions, + } + ) + + if is_defined(started_at): + post_parameters["started_at"] = started_at.strftime("%Y-%m-%dT%H:%M:%SZ") + if is_defined(completed_at): + post_parameters["completed_at"] = completed_at.strftime("%Y-%m-%dT%H:%M:%SZ") + + headers, data = self._requester.requestJsonAndCheck( + "POST", + f"{self.url}/check-runs", + input=post_parameters, + ) + return github.CheckRun.CheckRun(self._requester, headers, data, completed=True) + + def get_check_run(self, check_run_id: int) -> CheckRun: + """ + :calls: `GET /repos/{owner}/{repo}/check-runs/{check_run_id} `_ + :param check_run_id: int + :rtype: :class:`github.CheckRun.CheckRun` + """ + assert isinstance(check_run_id, int), check_run_id + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/check-runs/{check_run_id}") + return github.CheckRun.CheckRun(self._requester, headers, data, completed=True) + + def get_artifacts(self, name: Opt[str] = NotSet) -> PaginatedList[Artifact]: + """ + :calls: `GET /repos/{owner}/{repo}/actions/artifacts `_ + :param name: str + :rtype: :class:`PaginatedList` of :class:`github.Artifact.Artifact` + """ + + assert is_optional(name, str), name + + param = {key: value for key, value in {"name": name}.items() if is_defined(value)} + + return PaginatedList( + github.Artifact.Artifact, + self._requester, + f"{self.url}/actions/artifacts", + firstParams=param, + list_item="artifacts", + ) + + def get_artifact(self, artifact_id: int) -> Artifact: + """ + :calls: `GET /repos/{owner}/{repo}/actions/artifacts/{artifact_id} `_ + :param artifact_id: int + :rtype: :class:`github.Artifact.Artifact` + """ + assert isinstance(artifact_id, int), artifact_id + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/actions/artifacts/{artifact_id}") + return github.Artifact.Artifact(self._requester, headers, data) + + def get_codescan_alerts(self) -> PaginatedList[CodeScanAlert]: + """ + :calls: `GET https://api.github.com/repos/{owner}/{repo}/code-scanning/alerts `_ + :rtype: :class:`PaginatedList` of :class:`github.CodeScanAlert.CodeScanAlert` + """ + return PaginatedList( + github.CodeScanAlert.CodeScanAlert, + self._requester, + f"{self.url}/code-scanning/alerts", + None, + ) + + def get_environments(self) -> PaginatedList[Environment]: + """ + :calls: `GET /repositories/{self._repository.id}/environments/{self.environment_name}/environments `_ + :rtype: :class:`PaginatedList` of :class:`github.Environment.Environment` + """ + return PaginatedList( + Environment, + self._requester, + f"{self.url}/environments", + None, + attributesTransformer=PaginatedList.override_attributes( + {"environments_url": f"/repositories/{self.id}/environments"} + ), + list_item="environments", + ) + + def get_environment(self, environment_name: str) -> Environment: + """ + :calls: `GET /repositories/{self._repository.id}/environments/{self.environment_name}/environments/{environment_name} `_ + :rtype: :class:`github.Environment.Environment` + """ + assert isinstance(environment_name, str), environment_name + environment_name = urllib.parse.quote(environment_name) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/environments/{environment_name}") + data["environments_url"] = f"/repositories/{self.id}/environments" + return Environment(self._requester, headers, data, completed=True) + + def create_environment( + self, + environment_name: str, + wait_timer: int = 0, + reviewers: list[ReviewerParams] = [], + deployment_branch_policy: EnvironmentDeploymentBranchPolicyParams | None = None, + ) -> Environment: + """ + :calls: `PUT /repositories/{self._repository.id}/environments/{self.environment_name}/environments/{environment_name} `_ + :param environment_name: string + :param wait_timer: int + :param reviews: List[:class:github.EnvironmentDeploymentBranchPolicy.EnvironmentDeploymentBranchPolicyParams] + :param deployment_branch_policy: Optional[:class:github.EnvironmentDeploymentBranchPolicy.EnvironmentDeploymentBranchPolicyParams`] + :rtype: :class:`github.Environment.Environment` + """ + assert isinstance(environment_name, str), environment_name + assert isinstance(wait_timer, int) + assert isinstance(reviewers, list) + assert all( + [isinstance(reviewer, github.EnvironmentProtectionRuleReviewer.ReviewerParams) for reviewer in reviewers] + ) + assert ( + isinstance( + deployment_branch_policy, + github.EnvironmentDeploymentBranchPolicy.EnvironmentDeploymentBranchPolicyParams, + ) + or deployment_branch_policy is None + ) + environment_name = urllib.parse.quote(environment_name) + + put_parameters = { + "wait_timer": wait_timer, + "reviewers": [reviewer._asdict() for reviewer in reviewers], + "deployment_branch_policy": deployment_branch_policy._asdict() if deployment_branch_policy else None, + } + + headers, data = self._requester.requestJsonAndCheck( + "PUT", f"{self.url}/environments/{environment_name}", input=put_parameters + ) + data["environments_url"] = f"/repositories/{self.id}/environments" + return Environment(self._requester, headers, data, completed=True) + + def delete_environment(self, environment_name: str) -> None: + """ + :calls: `DELETE /repositories/{self._repository.id}/environments/{self.environment_name}/environments/{environment_name} `_ + :param environment_name: string + :rtype: None + """ + assert isinstance(environment_name, str), environment_name + environment_name = urllib.parse.quote(environment_name) + + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.url}/environments/{environment_name}") + + def get_dependabot_alerts( + self, + state: Opt[str] = NotSet, + severity: Opt[str] = NotSet, + ecosystem: Opt[str] = NotSet, + package: Opt[str] = NotSet, + manifest: Opt[str] = NotSet, + scope: Opt[str] = NotSet, + sort: Opt[str] = NotSet, + direction: Opt[str] = NotSet, + ) -> PaginatedList[DependabotAlert]: + """ + :calls: `GET /repos/{owner}/{repo}/dependabot/alerts `_ + :param state: Optional string + :param severity: Optional string + :param ecosystem: Optional string + :param package: Optional string + :param manifest: Optional string + :param scope: Optional string + :param sort: Optional string + :param direction: Optional string + :rtype: :class:`PaginatedList` of :class:`github.DependabotAlert.DependabotAlert` + """ + allowed_states = ["auto_dismissed", "dismissed", "fixed", "open"] + allowed_severities = ["low", "medium", "high", "critical"] + allowed_ecosystems = ["composer", "go", "maven", "npm", "nuget", "pip", "pub", "rubygems", "rust"] + allowed_scopes = ["development", "runtime"] + allowed_sorts = ["created", "updated"] + allowed_directions = ["asc", "desc"] + assert state in allowed_states + [NotSet], f"State can be one of {', '.join(allowed_states)}" + assert severity in allowed_severities + [NotSet], f"Severity can be one of {', '.join(allowed_severities)}" + assert ecosystem in allowed_ecosystems + [NotSet], f"Ecosystem can be one of {', '.join(allowed_ecosystems)}" + assert scope in allowed_scopes + [NotSet], f"Scope can be one of {', '.join(allowed_scopes)}" + assert sort in allowed_sorts + [NotSet], f"Sort can be one of {', '.join(allowed_sorts)}" + assert direction in allowed_directions + [NotSet], f"Direction can be one of {', '.join(allowed_directions)}" + url_parameters = NotSet.remove_unset_items( + { + "state": state, + "severity": severity, + "ecosystem": ecosystem, + "package": package, + "manifest": manifest, + "scope": scope, + "sort": sort, + "direction": direction, + } + ) + return PaginatedList( + github.DependabotAlert.DependabotAlert, + self._requester, + f"{self.url}/dependabot/alerts", + url_parameters, + ) + + def get_dependabot_alert(self, number: int) -> DependabotAlert: + """ + :calls: `GET /repos/{owner}/{repo}/dependabot/alerts/{alert_number} `_ + :param number: int + :rtype: :class:`github.DependabotAlert.DependabotAlert` + """ + assert isinstance(number, int), number + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/dependabot/alerts/{number}") + return github.DependabotAlert.DependabotAlert(self._requester, headers, data) + + def update_dependabot_alert( + self, number: int, state: str, dismissed_reason: Opt[str] = NotSet, dismissed_comment: Opt[str] = NotSet + ) -> DependabotAlert: + """ + :calls: `PATCH /repos/{owner}/{repo}/dependabot/alerts/{alert_number} `_ + :param number: int + :param state: string + :param dismissed_reason: Optional string + :param dismissed_comment: Optional string + :rtype: :class:`github.DependabotAlert.DependabotAlert` + """ + assert isinstance(number, int), number + assert isinstance(state, str), state + assert state in ["dismissed", "open"], "State can be one of ['dismissed', 'open']" + if state == "dismissed": + assert is_defined(dismissed_reason) + assert dismissed_reason in [ + "fix_started", + "inaccurate", + "no_bandwidth", + "not_used", + "tolerable_risk", + ], "Dismissed reason can be one of ['fix_started', 'inaccurate', 'no_bandwidth', 'not_used', 'tolerable_risk']" + assert is_optional(dismissed_comment, str), dismissed_comment + headers, data = self._requester.requestJsonAndCheck( + "PATCH", + f"{self.url}/dependabot/alerts/{number}", + input=NotSet.remove_unset_items( + {"state": state, "dismissed_reason": dismissed_reason, "dismissed_comment": dismissed_comment} + ), + ) + return github.DependabotAlert.DependabotAlert(self._requester, headers, data) + + def get_custom_properties(self) -> dict[str, None | str | list]: + """ + :calls: `GET /repos/{owner}/{repo}/properties/values `_ + :rtype: dict[str, None | str | list] + """ + url = f"{self.url}/properties/values" + _, data = self._requester.requestJsonAndCheck("GET", url) + custom_properties = {p["property_name"]: p["value"] for p in data} + self._custom_properties = self._makeDictAttribute(custom_properties) + return custom_properties + + def update_custom_properties(self, properties: dict[str, None | str | list]) -> None: + """ + :calls: `PATCH /repos/{owner}/{repo}/properties/values `_ + :rtype: None + """ + assert all(isinstance(v, (type(None), str, list)) for v in properties.values()), properties + url = f"{self.url}/properties/values" + patch_parameters: dict[str, list] = { + "properties": [{"property_name": k, "value": v} for k, v in properties.items()] + } + self._requester.requestJsonAndCheck("PATCH", url, input=patch_parameters) + + def attach_security_config(self, id: int) -> None: + """ + :calls: `POST /orgs/{org}/code-security/configurations/{configuration_id}/attach `_ + """ + self.organization.attach_security_config_to_repositories( + id=id, scope="selected", selected_repository_ids=[self.id] + ) + + def detach_security_config(self) -> None: + """ + :calls: `DELETE /orgs/{org}/code-security/configurations/detach `_ + """ + self.organization.detach_security_config_from_repositories(selected_repository_ids=[self.id]) + + def get_security_config(self) -> RepoCodeSecurityConfig | None: + """ + :calls: `GET /repos/{owner}/{repo}/code-security-configuration `_ + :rtype: RepoCodeSecurityConfig | None + """ + #### TODO(napier): this is actually a special type not CodeSecurityConfig + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/code-security-configuration") + if data is None: + return None + return github.RepoCodeSecurityConfig.RepoCodeSecurityConfig(self._requester, headers, data) + + def transfer_ownership(self, new_owner: str, new_name: Opt[str] = NotSet, teams: Opt[list[int]] = NotSet) -> bool: + """ + :calls: `POST /repos/{owner}/{repo}/transfer `_ + :param new_owner: string + :param new_name: Optional string + :param teams: Optional list of int + :rtype: bool + """ + assert isinstance(new_owner, str), new_owner + assert is_optional(new_name, str), new_name + assert is_optional_list(teams, int), teams + + post_parameters = NotSet.remove_unset_items({"new_owner": new_owner, "new_name": new_name, "team_ids": teams}) + + _, _ = self._requester.requestJsonAndCheck("POST", f"{self.url}/transfer", input=post_parameters) + + return True + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "allow_auto_merge" in attributes: # pragma no branch + self._allow_auto_merge = self._makeBoolAttribute(attributes["allow_auto_merge"]) + if "allow_forking" in attributes: # pragma no branch + self._allow_forking = self._makeBoolAttribute(attributes["allow_forking"]) + if "allow_merge_commit" in attributes: # pragma no branch + self._allow_merge_commit = self._makeBoolAttribute(attributes["allow_merge_commit"]) + if "allow_rebase_merge" in attributes: # pragma no branch + self._allow_rebase_merge = self._makeBoolAttribute(attributes["allow_rebase_merge"]) + if "allow_squash_merge" in attributes: # pragma no branch + self._allow_squash_merge = self._makeBoolAttribute(attributes["allow_squash_merge"]) + if "allow_update_branch" in attributes: # pragma no branch + self._allow_update_branch = self._makeBoolAttribute(attributes["allow_update_branch"]) + if "anonymous_access_enabled" in attributes: # pragma no branch + self._anonymous_access_enabled = self._makeBoolAttribute(attributes["anonymous_access_enabled"]) + if "archive_url" in attributes: # pragma no branch + self._archive_url = self._makeStringAttribute(attributes["archive_url"]) + if "archived" in attributes: # pragma no branch + self._archived = self._makeBoolAttribute(attributes["archived"]) + if "assignees_url" in attributes: # pragma no branch + self._assignees_url = self._makeStringAttribute(attributes["assignees_url"]) + if "blobs_url" in attributes: # pragma no branch + self._blobs_url = self._makeStringAttribute(attributes["blobs_url"]) + if "branches_url" in attributes: # pragma no branch + self._branches_url = self._makeStringAttribute(attributes["branches_url"]) + if "clone_url" in attributes: # pragma no branch + self._clone_url = self._makeStringAttribute(attributes["clone_url"]) + if "code_of_conduct" in attributes: # pragma no branch + self._code_of_conduct = self._makeDictAttribute(attributes["code_of_conduct"]) + if "collaborators_url" in attributes: # pragma no branch + self._collaborators_url = self._makeStringAttribute(attributes["collaborators_url"]) + if "comments_url" in attributes: # pragma no branch + self._comments_url = self._makeStringAttribute(attributes["comments_url"]) + if "commits_url" in attributes: # pragma no branch + self._commits_url = self._makeStringAttribute(attributes["commits_url"]) + if "compare_url" in attributes: # pragma no branch + self._compare_url = self._makeStringAttribute(attributes["compare_url"]) + if "contents_url" in attributes: # pragma no branch + self._contents_url = self._makeStringAttribute(attributes["contents_url"]) + if "contributors_url" in attributes: # pragma no branch + self._contributors_url = self._makeStringAttribute(attributes["contributors_url"]) + if "created_at" in attributes: # pragma no branch + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) + if "custom_properties" in attributes: # pragma no branch + self._custom_properties = self._makeDictAttribute(attributes["custom_properties"]) + if "default_branch" in attributes: # pragma no branch + self._default_branch = self._makeStringAttribute(attributes["default_branch"]) + if "delete_branch_on_merge" in attributes: # pragma no branch + self._delete_branch_on_merge = self._makeBoolAttribute(attributes["delete_branch_on_merge"]) + if "deployments_url" in attributes: # pragma no branch + self._deployments_url = self._makeStringAttribute(attributes["deployments_url"]) + if "description" in attributes: # pragma no branch + self._description = self._makeStringAttribute(attributes["description"]) + if "disabled" in attributes: # pragma no branch + self._disabled = self._makeBoolAttribute(attributes["disabled"]) + if "downloads_url" in attributes: # pragma no branch + self._downloads_url = self._makeStringAttribute(attributes["downloads_url"]) + if "events_url" in attributes: # pragma no branch + self._events_url = self._makeStringAttribute(attributes["events_url"]) + if "fork" in attributes: # pragma no branch + self._fork = self._makeBoolAttribute(attributes["fork"]) + if "forks" in attributes: # pragma no branch + self._forks = self._makeIntAttribute(attributes["forks"]) + if "forks_count" in attributes: # pragma no branch + self._forks_count = self._makeIntAttribute(attributes["forks_count"]) + if "forks_url" in attributes: # pragma no branch + self._forks_url = self._makeStringAttribute(attributes["forks_url"]) + if "full_name" in attributes: # pragma no branch + self._full_name = self._makeStringAttribute(attributes["full_name"]) + if "git_commits_url" in attributes: # pragma no branch + self._git_commits_url = self._makeStringAttribute(attributes["git_commits_url"]) + if "git_refs_url" in attributes: # pragma no branch + self._git_refs_url = self._makeStringAttribute(attributes["git_refs_url"]) + if "git_tags_url" in attributes: # pragma no branch + self._git_tags_url = self._makeStringAttribute(attributes["git_tags_url"]) + if "git_url" in attributes: # pragma no branch + self._git_url = self._makeStringAttribute(attributes["git_url"]) + if "has_discussions" in attributes: # pragma no branch + self._has_discussions = self._makeBoolAttribute(attributes["has_discussions"]) + if "has_downloads" in attributes: # pragma no branch + self._has_downloads = self._makeBoolAttribute(attributes["has_downloads"]) + if "has_issues" in attributes: # pragma no branch + self._has_issues = self._makeBoolAttribute(attributes["has_issues"]) + if "has_pages" in attributes: # pragma no branch + self._has_pages = self._makeBoolAttribute(attributes["has_pages"]) + if "has_projects" in attributes: # pragma no branch + self._has_projects = self._makeBoolAttribute(attributes["has_projects"]) + if "has_wiki" in attributes: # pragma no branch + self._has_wiki = self._makeBoolAttribute(attributes["has_wiki"]) + if "homepage" in attributes: # pragma no branch + self._homepage = self._makeStringAttribute(attributes["homepage"]) + if "hooks_url" in attributes: # pragma no branch + self._hooks_url = self._makeStringAttribute(attributes["hooks_url"]) + if "html_url" in attributes: # pragma no branch + self._html_url = self._makeStringAttribute(attributes["html_url"]) + if "id" in attributes: # pragma no branch + self._id = self._makeIntAttribute(attributes["id"]) + if "is_template" in attributes: # pragma no branch + self._is_template = self._makeBoolAttribute(attributes["is_template"]) + if "issue_comment_url" in attributes: # pragma no branch + self._issue_comment_url = self._makeStringAttribute(attributes["issue_comment_url"]) + if "issue_events_url" in attributes: # pragma no branch + self._issue_events_url = self._makeStringAttribute(attributes["issue_events_url"]) + if "issues_url" in attributes: # pragma no branch + self._issues_url = self._makeStringAttribute(attributes["issues_url"]) + if "keys_url" in attributes: # pragma no branch + self._keys_url = self._makeStringAttribute(attributes["keys_url"]) + if "labels_url" in attributes: # pragma no branch + self._labels_url = self._makeStringAttribute(attributes["labels_url"]) + if "language" in attributes: # pragma no branch + self._language = self._makeStringAttribute(attributes["language"]) + if "languages_url" in attributes: # pragma no branch + self._languages_url = self._makeStringAttribute(attributes["languages_url"]) + if "license" in attributes: # pragma no branch + self._license = self._makeClassAttribute(github.License.License, attributes["license"]) + if "master_branch" in attributes: # pragma no branch + self._master_branch = self._makeStringAttribute(attributes["master_branch"]) + if "merge_commit_message" in attributes: # pragma no branch + self._merge_commit_message = self._makeStringAttribute(attributes["merge_commit_message"]) + if "merge_commit_title" in attributes: # pragma no branch + self._merge_commit_title = self._makeStringAttribute(attributes["merge_commit_title"]) + if "merges_url" in attributes: # pragma no branch + self._merges_url = self._makeStringAttribute(attributes["merges_url"]) + if "milestones_url" in attributes: # pragma no branch + self._milestones_url = self._makeStringAttribute(attributes["milestones_url"]) + if "mirror_url" in attributes: # pragma no branch + self._mirror_url = self._makeStringAttribute(attributes["mirror_url"]) + if "name" in attributes: # pragma no branch + self._name = self._makeStringAttribute(attributes["name"]) + if "network_count" in attributes: # pragma no branch + self._network_count = self._makeIntAttribute(attributes["network_count"]) + if "node_id" in attributes: # pragma no branch + self._node_id = self._makeStringAttribute(attributes["node_id"]) + if "notifications_url" in attributes: # pragma no branch + self._notifications_url = self._makeStringAttribute(attributes["notifications_url"]) + if "open_issues" in attributes: # pragma no branch + self._open_issues = self._makeIntAttribute(attributes["open_issues"]) + if "open_issues_count" in attributes: # pragma no branch + self._open_issues_count = self._makeIntAttribute(attributes["open_issues_count"]) + if "organization" in attributes: # pragma no branch + self._organization = self._makeClassAttribute(github.Organization.Organization, attributes["organization"]) + if "owner" in attributes: # pragma no branch + self._owner = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["owner"]) + if "parent" in attributes: # pragma no branch + self._parent = self._makeClassAttribute(Repository, attributes["parent"]) + if "permissions" in attributes: # pragma no branch + self._permissions = self._makeClassAttribute(github.Permissions.Permissions, attributes["permissions"]) + if "private" in attributes: # pragma no branch + self._private = self._makeBoolAttribute(attributes["private"]) + if "pulls_url" in attributes: # pragma no branch + self._pulls_url = self._makeStringAttribute(attributes["pulls_url"]) + if "pushed_at" in attributes: # pragma no branch + self._pushed_at = self._makeDatetimeAttribute(attributes["pushed_at"]) + if "releases_url" in attributes: # pragma no branch + self._releases_url = self._makeStringAttribute(attributes["releases_url"]) + if "role_name" in attributes: # pragma no branch + self._role_name = self._makeStringAttribute(attributes["role_name"]) + if "security_and_analysis" in attributes: # pragma no branch + self._security_and_analysis = self._makeClassAttribute( + github.SecurityAndAnalysis.SecurityAndAnalysis, attributes["security_and_analysis"] + ) + if "size" in attributes: # pragma no branch + self._size = self._makeIntAttribute(attributes["size"]) + if "source" in attributes: # pragma no branch + self._source = self._makeClassAttribute(Repository, attributes["source"]) + if "squash_merge_commit_message" in attributes: # pragma no branch + self._squash_merge_commit_message = self._makeStringAttribute(attributes["squash_merge_commit_message"]) + if "squash_merge_commit_title" in attributes: # pragma no branch + self._squash_merge_commit_title = self._makeStringAttribute(attributes["squash_merge_commit_title"]) + if "ssh_url" in attributes: # pragma no branch + self._ssh_url = self._makeStringAttribute(attributes["ssh_url"]) + if "stargazers_count" in attributes: # pragma no branch + self._stargazers_count = self._makeIntAttribute(attributes["stargazers_count"]) + if "stargazers_url" in attributes: # pragma no branch + self._stargazers_url = self._makeStringAttribute(attributes["stargazers_url"]) + if "starred_at" in attributes: # pragma no branch + self._starred_at = self._makeStringAttribute(attributes["starred_at"]) + if "statuses_url" in attributes: # pragma no branch + self._statuses_url = self._makeStringAttribute(attributes["statuses_url"]) + if "subscribers_count" in attributes: # pragma no branch + self._subscribers_count = self._makeIntAttribute(attributes["subscribers_count"]) + if "subscribers_url" in attributes: # pragma no branch + self._subscribers_url = self._makeStringAttribute(attributes["subscribers_url"]) + if "subscription_url" in attributes: # pragma no branch + self._subscription_url = self._makeStringAttribute(attributes["subscription_url"]) + if "svn_url" in attributes: # pragma no branch + self._svn_url = self._makeStringAttribute(attributes["svn_url"]) + if "tags_url" in attributes: # pragma no branch + self._tags_url = self._makeStringAttribute(attributes["tags_url"]) + if "teams_url" in attributes: # pragma no branch + self._teams_url = self._makeStringAttribute(attributes["teams_url"]) + if "temp_clone_token" in attributes: # pragma no branch + self._temp_clone_token = self._makeStringAttribute(attributes["temp_clone_token"]) + if "template_repository" in attributes: # pragma no branch + self._template_repository = self._makeClassAttribute( + github.Repository.Repository, attributes["template_repository"] + ) + if "topics" in attributes: # pragma no branch + self._topics = self._makeListOfStringsAttribute(attributes["topics"]) + if "trees_url" in attributes: # pragma no branch + self._trees_url = self._makeStringAttribute(attributes["trees_url"]) + if "updated_at" in attributes: # pragma no branch + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) + if "url" in attributes: # pragma no branch + self._url = self._makeStringAttribute(attributes["url"]) + if "use_squash_pr_title_as_default" in attributes: # pragma no branch + self._use_squash_pr_title_as_default = self._makeBoolAttribute(attributes["use_squash_pr_title_as_default"]) + if "visibility" in attributes: # pragma no branch + self._visibility = self._makeStringAttribute(attributes["visibility"]) + if "watchers" in attributes: # pragma no branch + self._watchers = self._makeIntAttribute(attributes["watchers"]) + if "watchers_count" in attributes: # pragma no branch + self._watchers_count = self._makeIntAttribute(attributes["watchers_count"]) + if "web_commit_signoff_required" in attributes: # pragma no branch + self._web_commit_signoff_required = self._makeBoolAttribute(attributes["web_commit_signoff_required"]) diff --git a/venv/lib/python3.10/site-packages/github/RepositoryAdvisory.py b/venv/lib/python3.10/site-packages/github/RepositoryAdvisory.py new file mode 100644 index 0000000000000000000000000000000000000000..4b98e3753b7dba5dc2515137f4d43af4f5f0f84d --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/RepositoryAdvisory.py @@ -0,0 +1,424 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Jonathan Leitschuh # +# Copyright 2023 Joseph Henrich # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2024 Thomas Cooper # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from datetime import datetime +from typing import TYPE_CHECKING, Any, Iterable + +import github.AdvisoryCredit +import github.AdvisoryCreditDetailed +import github.AdvisoryVulnerability +import github.NamedUser +import github.Repository +import github.Team +from github.AdvisoryBase import AdvisoryBase +from github.GithubObject import Attribute, NotSet, Opt + +if TYPE_CHECKING: + from github.AdvisoryCredit import AdvisoryCredit, Credit + from github.AdvisoryCreditDetailed import AdvisoryCreditDetailed + from github.AdvisoryVulnerability import AdvisoryVulnerability, AdvisoryVulnerabilityInput + from github.NamedUser import NamedUser + from github.Repository import Repository + from github.Team import Team + + +class RepositoryAdvisory(AdvisoryBase): + """ + This class represents a RepositoryAdvisory. + + The reference can be found here + https://docs.github.com/en/rest/security-advisories/repository-advisories + + The OpenAPI schema can be found at + - /components/schemas/repository-advisory + + """ + + def _initAttributes(self) -> None: + super()._initAttributes() + self._author: Attribute[NamedUser] = NotSet + self._closed_at: Attribute[datetime] = NotSet + self._collaborating_teams: Attribute[list[Team]] = NotSet + self._collaborating_users: Attribute[list[NamedUser]] = NotSet + self._created_at: Attribute[datetime] = NotSet + self._credits: Attribute[list[AdvisoryCredit]] = NotSet + self._credits_detailed: Attribute[list[AdvisoryCreditDetailed]] = NotSet + self._cwe_ids: Attribute[list[str]] = NotSet + self._private_fork: Attribute[Repository] = NotSet + self._publisher: Attribute[NamedUser] = NotSet + self._state: Attribute[str] = NotSet + self._submission: Attribute[dict[str, Any]] = NotSet + self._vulnerabilities: Attribute[list[AdvisoryVulnerability]] = NotSet + super()._initAttributes() + + @property + def author(self) -> NamedUser: + return self._author.value + + @property + def closed_at(self) -> datetime: + return self._closed_at.value + + @property + def collaborating_teams(self) -> list[Team]: + return self._collaborating_teams.value + + @property + def collaborating_users(self) -> list[NamedUser]: + return self._collaborating_users.value + + @property + def created_at(self) -> datetime: + return self._created_at.value + + @property + def credits( + self, + ) -> list[AdvisoryCredit]: + return self._credits.value + + @property + def credits_detailed( + self, + ) -> list[AdvisoryCreditDetailed]: + return self._credits_detailed.value + + @property + def cwe_ids(self) -> list[str]: + return self._cwe_ids.value + + @property + def private_fork(self) -> Repository: + return self._private_fork.value + + @property + def publisher(self) -> NamedUser: + return self._publisher.value + + @property + def state(self) -> str: + return self._state.value + + @property + def submission(self) -> dict[str, Any]: + return self._submission.value + + @property + def vulnerabilities(self) -> list[AdvisoryVulnerability]: + return self._vulnerabilities.value + + def add_vulnerability( + self, + ecosystem: str, + package_name: str | None = None, + vulnerable_version_range: str | None = None, + patched_versions: str | None = None, + vulnerable_functions: list[str] | None = None, + ) -> None: + """ + :calls: `PATCH /repos/{owner}/{repo}/security-advisories/:advisory_id `\ + """ + return self.add_vulnerabilities( + [ + { + "package": { + "ecosystem": ecosystem, + "name": package_name, + }, + "vulnerable_version_range": vulnerable_version_range, + "patched_versions": patched_versions, + "vulnerable_functions": vulnerable_functions, + } + ] + ) + + def add_vulnerabilities(self, vulnerabilities: Iterable[AdvisoryVulnerabilityInput]) -> None: + """ + :calls: `PATCH /repos/{owner}/{repo}/security-advisories/:advisory_id ` + """ + assert isinstance(vulnerabilities, Iterable), vulnerabilities + for vulnerability in vulnerabilities: + github.AdvisoryVulnerability.AdvisoryVulnerability._validate_vulnerability(vulnerability) + + post_parameters = { + "vulnerabilities": [ + github.AdvisoryVulnerability.AdvisoryVulnerability._to_github_dict(vulnerability) + for vulnerability in (self.vulnerabilities + list(vulnerabilities)) + ] + } + headers, data = self._requester.requestJsonAndCheck( + "PATCH", + self.url, + input=post_parameters, + ) + self._useAttributes(data) + + def offer_credit( + self, + login_or_user: str | github.NamedUser.NamedUser, + credit_type: str, + ) -> None: + """ + Offers credit to a user for a vulnerability in a repository. + + Unless you are giving credit to yourself, the user having credit offered will need to explicitly accept the credit. + :calls: `PATCH /repos/{owner}/{repo}/security-advisories/:advisory_id ` + + """ + self.offer_credits([{"login": login_or_user, "type": credit_type}]) + + def offer_credits( + self, + credited: Iterable[Credit], + ) -> None: + """ + Offers credit to a list of users for a vulnerability in a repository. + + Unless you are giving credit to yourself, the user having credit offered will need to explicitly accept the credit. + :calls: `PATCH /repos/{owner}/{repo}/security-advisories/:advisory_id ` + :param credited: iterable of dict with keys "login" and "type" + + """ + assert isinstance(credited, Iterable), credited + for credit in credited: + github.AdvisoryCredit.AdvisoryCredit._validate_credit(credit) + + patch_parameters = { + "credits": [ + github.AdvisoryCredit.AdvisoryCredit._to_github_dict(credit) + for credit in (self.credits + list(credited)) + ] + } + headers, data = self._requester.requestJsonAndCheck( + "PATCH", + self.url, + input=patch_parameters, + ) + self._useAttributes(data) + + def revoke_credit(self, login_or_user: str | github.NamedUser.NamedUser) -> None: + """ + :calls: `PATCH /repos/{owner}/{repo}/security-advisories/:advisory_id `_ + """ + assert isinstance(login_or_user, (str, github.NamedUser.NamedUser)), login_or_user + if isinstance(login_or_user, github.NamedUser.NamedUser): + login_or_user = login_or_user.login + patch_parameters = { + "credits": [ + dict(login=credit.login, type=credit.type) for credit in self.credits if credit.login != login_or_user + ] + } + headers, data = self._requester.requestJsonAndCheck( + "PATCH", + self.url, + input=patch_parameters, + ) + self._useAttributes(data) + + def clear_credits(self) -> None: + """ + :calls: `PATCH /repos/{owner}/{repo}/security-advisories/:advisory_id `_ + """ + patch_parameters: dict[str, Any] = {"credits": []} + headers, data = self._requester.requestJsonAndCheck( + "PATCH", + self.url, + input=patch_parameters, + ) + self._useAttributes(data) + + def edit( + self, + summary: Opt[str] = NotSet, + description: Opt[str] = NotSet, + severity_or_cvss_vector_string: Opt[str] = NotSet, + cve_id: Opt[str] = NotSet, + vulnerabilities: Opt[Iterable[AdvisoryVulnerabilityInput]] = NotSet, + cwe_ids: Opt[Iterable[str]] = NotSet, + credits: Opt[Iterable[Credit]] = NotSet, + state: Opt[str] = NotSet, + ) -> RepositoryAdvisory: + """ + :calls: `PATCH /repos/{owner}/{repo}/security-advisories/:advisory_id `_ + """ + assert summary is NotSet or isinstance(summary, str), summary + assert description is NotSet or isinstance(description, str), description + assert severity_or_cvss_vector_string is NotSet or isinstance( + severity_or_cvss_vector_string, str + ), severity_or_cvss_vector_string + assert cve_id is NotSet or isinstance(cve_id, str), cve_id + assert vulnerabilities is NotSet or isinstance(vulnerabilities, Iterable), vulnerabilities + if isinstance(vulnerabilities, Iterable): + for vulnerability in vulnerabilities: + github.AdvisoryVulnerability.AdvisoryVulnerability._validate_vulnerability(vulnerability) + assert cwe_ids is NotSet or ( + isinstance(cwe_ids, Iterable) and all(isinstance(element, str) for element in cwe_ids) + ), cwe_ids + if isinstance(credits, Iterable): + for credit in credits: + github.AdvisoryCredit.AdvisoryCredit._validate_credit(credit) + assert state is NotSet or isinstance(state, str), state + patch_parameters: dict[str, Any] = {} + if summary is not NotSet: + patch_parameters["summary"] = summary + if description is not NotSet: + patch_parameters["description"] = description + if isinstance(severity_or_cvss_vector_string, str): + if severity_or_cvss_vector_string.startswith("CVSS:"): + patch_parameters["cvss_vector_string"] = severity_or_cvss_vector_string + else: + patch_parameters["severity"] = severity_or_cvss_vector_string + if cve_id is not NotSet: + patch_parameters["cve_id"] = cve_id + if isinstance(vulnerabilities, Iterable): + patch_parameters["vulnerabilities"] = [ + github.AdvisoryVulnerability.AdvisoryVulnerability._to_github_dict(vulnerability) + for vulnerability in vulnerabilities + ] + if isinstance(cwe_ids, Iterable): + patch_parameters["cwe_ids"] = list(cwe_ids) + if isinstance(credits, Iterable): + patch_parameters["credits"] = [ + github.AdvisoryCredit.AdvisoryCredit._to_github_dict(credit) for credit in credits + ] + if state is not NotSet: + patch_parameters["state"] = state + headers, data = self._requester.requestJsonAndCheck( + "PATCH", + self.url, + input=patch_parameters, + ) + self._useAttributes(data) + return self + + def accept_report(self) -> None: + """ + Accepts the advisory reported from an external reporter via private vulnerability reporting. + + :calls: `PATCH /repos/{owner}/{repo}/security-advisories/:advisory_id ` + + """ + patch_parameters = {"state": "draft"} + headers, data = self._requester.requestJsonAndCheck( + "PATCH", + self.url, + input=patch_parameters, + ) + self._useAttributes(data) + + def publish(self) -> None: + """ + Publishes the advisory. + + :calls: `PATCH /repos/{owner}/{repo}/security-advisories/:advisory_id ` + + """ + patch_parameters = {"state": "published"} + headers, data = self._requester.requestJsonAndCheck( + "PATCH", + self.url, + input=patch_parameters, + ) + self._useAttributes(data) + + def request_cve(self) -> None: + """ + Requests a CVE for the advisory. + + :calls: `POST /repos/{owner}/{repo}/security-advisories/{ghsa_id}/cve `_ + + """ + self._requester.requestJsonAndCheck( + "POST", + self.url + "/cve", + ) + + def close(self) -> None: + """ + Closes the advisory. + + :calls: `PATCH /repos/{owner}/{repo}/security-advisories/:advisory_id ` + + """ + patch_parameters = {"state": "closed"} + headers, data = self._requester.requestJsonAndCheck( + "PATCH", + self.url, + input=patch_parameters, + ) + self._useAttributes(data) + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "author" in attributes: # pragma no branch + self._author = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["author"]) + if "closed_at" in attributes: # pragma no branch + assert attributes["closed_at"] is None or isinstance(attributes["closed_at"], str), attributes["closed_at"] + self._closed_at = self._makeDatetimeAttribute(attributes["closed_at"]) + if "collaborating_teams" in attributes: # pragma no branch + self._collaborating_teams = self._makeListOfClassesAttribute( + github.Team.Team, attributes["collaborating_teams"] + ) + if "collaborating_users" in attributes: # pragma no branch + self._collaborating_users = self._makeListOfClassesAttribute( + github.NamedUser.NamedUser, attributes["collaborating_users"] + ) + if "created_at" in attributes: # pragma no branch + assert attributes["created_at"] is None or isinstance(attributes["created_at"], str), attributes[ + "created_at" + ] + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) + if "credits" in attributes: # pragma no branch + self._credits = self._makeListOfClassesAttribute( + github.AdvisoryCredit.AdvisoryCredit, + attributes["credits"], + ) + if "credits_detailed" in attributes: # pragma no branch + self._credits_detailed = self._makeListOfClassesAttribute( + github.AdvisoryCreditDetailed.AdvisoryCreditDetailed, + attributes["credits_detailed"], + ) + if "cwe_ids" in attributes: # pragma no branch + self._cwe_ids = self._makeListOfStringsAttribute(attributes["cwe_ids"]) + if "private_fork" in attributes: # pragma no branch + self._private_fork = self._makeClassAttribute(github.Repository.Repository, attributes["private_fork"]) + if "publisher" in attributes: # pragma no branch + self._publisher = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["publisher"]) + if "state" in attributes: # pragma no branch + self._state = self._makeStringAttribute(attributes["state"]) + if "submission" in attributes: # pragma no branch + self._submission = self._makeDictAttribute(attributes["submission"]) + if "vulnerabilities" in attributes: + self._vulnerabilities = self._makeListOfClassesAttribute( + github.AdvisoryVulnerability.AdvisoryVulnerability, + attributes["vulnerabilities"], + ) + super()._useAttributes(attributes) diff --git a/venv/lib/python3.10/site-packages/github/RepositoryDiscussion.py b/venv/lib/python3.10/site-packages/github/RepositoryDiscussion.py new file mode 100644 index 0000000000000000000000000000000000000000..5c7624f869edb227ebb93d7d619d1b82d53b5dce --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/RepositoryDiscussion.py @@ -0,0 +1,213 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2024 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from typing import TYPE_CHECKING, Any + +import github +import github.Label +import github.NamedUser +import github.Reaction +import github.Repository +import github.RepositoryDiscussionCategory +import github.RepositoryDiscussionComment +from github.DiscussionBase import DiscussionBase +from github.GithubObject import ( + Attribute, + GraphQlObject, + NotSet, + as_rest_api_attributes, + as_rest_api_attributes_list, + is_undefined, +) +from github.PaginatedList import PaginatedList + +if TYPE_CHECKING: + from github.Label import Label + from github.NamedUser import NamedUser + from github.Reaction import Reaction + from github.Repository import Repository + from github.RepositoryDiscussionCategory import RepositoryDiscussionCategory + from github.RepositoryDiscussionComment import RepositoryDiscussionComment + + +class RepositoryDiscussion(GraphQlObject, DiscussionBase): + """ + This class represents GraphQL Discussion. + + The reference can be found here + https://docs.github.com/en/graphql/reference/objects#discussion + + """ + + def _initAttributes(self) -> None: + super()._initAttributes() + self._answer: Attribute[RepositoryDiscussionComment | None] = NotSet + self._body_text: Attribute[str] = NotSet + self._category: Attribute[RepositoryDiscussionCategory] = NotSet + self._comments_page = None + self._database_id: Attribute[int] = NotSet + self._editor: Attribute[NamedUser] = NotSet + self._id: Attribute[str] = NotSet + self._labels_page = None + self._reactions_page = None + self._repository: Attribute[Repository] = NotSet + + @property + def answer(self) -> RepositoryDiscussionComment | None: + return self._answer.value + + @property + def body_text(self) -> str: + return self._body_text.value + + @property + def category(self) -> RepositoryDiscussionCategory: + return self._category.value + + @property + def database_id(self) -> int: + return self._database_id.value + + @property + def editor(self) -> NamedUser: + return self._editor.value + + @property + def id(self) -> str: + return self._id.value + + @property + def node_id(self) -> str: + return self.id + + @property + def repository(self) -> Repository: + return self._repository.value + + def get_comments(self, comment_graphql_schema: str) -> PaginatedList[RepositoryDiscussionComment]: + if self._comments_page is not None: + return PaginatedList( + github.RepositoryDiscussionComment.RepositoryDiscussionComment, + self._requester, + firstData=self._comments_page, + firstHeaders={}, + ) + + if is_undefined(self._id): + raise RuntimeError("Retrieving discussion comments requires the discussion field 'id'") + if not comment_graphql_schema.startswith("\n"): + comment_graphql_schema = f" {comment_graphql_schema} " + + query = ( + """ + query Q($discussionId: ID!, $first: Int, $last: Int, $before: String, $after: String) { + node(id: $discussionId) { + ... on Discussion { + comments(first: $first, last: $last, before: $before, after: $after) { + totalCount + pageInfo { + startCursor + endCursor + hasNextPage + hasPreviousPage + } + nodes {""" + + comment_graphql_schema + + """} + } + } + } + }""" + ) + variables = {"discussionId": self.node_id} + return PaginatedList( + github.RepositoryDiscussionComment.RepositoryDiscussionComment, + self._requester, + graphql_query=query, + graphql_variables=variables, + list_item=["node", "comments"], + ) + + def get_labels(self) -> PaginatedList[Label]: + if self._labels_page is None: + raise RuntimeError("Fetching labels not implemented") + return PaginatedList(github.Label.Label, self._requester, firstData=self._labels_page, firstHeaders={}) + + def get_reactions(self) -> PaginatedList[Reaction]: + if self._reactions_page is None: + raise RuntimeError("Fetching reactions not implemented") + return PaginatedList(github.Reaction.Reaction, self._requester, firstData=self._reactions_page, firstHeaders={}) + + def add_comment( + self, body: str, reply_to: RepositoryDiscussionComment | str | None = None, output_schema: str = "id" + ) -> RepositoryDiscussionComment: + reply_to_id = ( + reply_to.id + if isinstance(reply_to, github.RepositoryDiscussionComment.RepositoryDiscussionComment) + else reply_to + ) + if not output_schema.startswith("\n"): + output_schema = f" {output_schema} " + + variables = {"body": body, "discussionId": self.id, "replyToId": reply_to_id} + return self._requester.graphql_named_mutation_class( + "addDiscussionComment", + NotSet.remove_unset_items(variables), + f"comment {{{output_schema}}}", + "comment", + github.RepositoryDiscussionComment.RepositoryDiscussionComment, + ) + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + # super class is a REST API GithubObject, attributes are coming from GraphQL + super()._useAttributes(as_rest_api_attributes(attributes)) + if "answer" in attributes: # pragma no branch + self._answer = self._makeClassAttribute( + github.RepositoryDiscussionComment.RepositoryDiscussionComment, attributes["answer"] + ) + if "bodyText" in attributes: # pragma no branch + self._body_text = self._makeStringAttribute(attributes["bodyText"]) + if "category" in attributes: # pragma no branch + self._category = self._makeClassAttribute( + github.RepositoryDiscussionCategory.RepositoryDiscussionCategory, attributes["category"] + ) + if "comments" in attributes: # pragma no branch + # comments are GraphQL API objects + self._comments_page = attributes["comments"]["nodes"] + if "databaseId" in attributes: # pragma no branch + self._database_id = self._makeIntAttribute(attributes["databaseId"]) + if "editor" in attributes: # pragma no branch + self._editor = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["editor"]) + if "id" in attributes: # pragma no branch + self._id = self._makeStringAttribute(attributes["id"]) + if "labels" in attributes: # pragma no branch + # labels are REST API objects + self._labels_page = as_rest_api_attributes_list(attributes["labels"]["nodes"]) # type: ignore + if "reactions" in attributes: # pragma no branch + # reactions are REST API objects + self._reactions_page = as_rest_api_attributes_list(attributes["reactions"]["nodes"]) # type: ignore + if "repository" in attributes: # pragma no branch + self._repository = self._makeClassAttribute( + github.Repository.Repository, as_rest_api_attributes(attributes["repository"]) + ) diff --git a/venv/lib/python3.10/site-packages/github/RepositoryDiscussionCategory.py b/venv/lib/python3.10/site-packages/github/RepositoryDiscussionCategory.py new file mode 100644 index 0000000000000000000000000000000000000000..0a832134037f31a83c46fb4d5ee98246032d8628 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/RepositoryDiscussionCategory.py @@ -0,0 +1,142 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2020 Victor Zeng # +# Copyright 2022 Eric Nieuwland # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from datetime import datetime +from typing import TYPE_CHECKING, Any + +import github.Reaction +from github.GithubObject import Attribute, GraphQlObject, NonCompletableGithubObject, NotSet, as_rest_api_attributes + +if TYPE_CHECKING: + from github.Repository import Repository + + +class RepositoryDiscussionCategory(GraphQlObject, NonCompletableGithubObject): + """ + This class represents GraphQL DiscussionCategory. + + The reference can be found here + https://docs.github.com/en/graphql/reference/objects#discussioncategory + + """ + + def _initAttributes(self) -> None: + self._created_at: Attribute[datetime] = NotSet + self._description: Attribute[str] = NotSet + self._emoji: Attribute[str] = NotSet + self._emoji_html: Attribute[str] = NotSet + self._id: Attribute[str] = NotSet + self._is_answerable: Attribute[bool] = NotSet + self._name: Attribute[str] = NotSet + self._repository: Attribute[Repository] = NotSet + self._slug: Attribute[str] = NotSet + self._updated_at: Attribute[datetime] = NotSet + + @property + def created_at(self) -> datetime: + return self._created_at.value + + @property + def description(self) -> str: + return self._description.value + + @property + def emoji(self) -> str: + return self._emoji.value + + @property + def emoji_html(self) -> str: + return self._emoji_html.value + + @property + def id(self) -> str: + return self._id.value + + @property + def is_answerable(self) -> bool: + return self._is_answerable.value + + @property + def name(self) -> str: + return self._name.value + + @property + def node_id(self) -> str: + return self.id + + @property + def repository(self) -> Repository: + return self._repository.value + + @property + def slug(self) -> str: + return self._slug.value + + @property + def updated_at(self) -> datetime: + return self._updated_at.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "createdAt" in attributes: # pragma no branch + self._created_at = self._makeDatetimeAttribute(attributes["createdAt"]) + if "description" in attributes: # pragma no branch + self._description = self._makeStringAttribute(attributes["description"]) + if "emoji" in attributes: # pragma no branch + self._emoji = self._makeStringAttribute(attributes["emoji"]) + if "emojiHTML" in attributes: # pragma no branch + self._emoji_html = self._makeStringAttribute(attributes["emojiHTML"]) + if "id" in attributes: # pragma no branch + self._id = self._makeStringAttribute(attributes["id"]) + if "isAnswerable" in attributes: # pragma no branch + self._is_answerable = self._makeBoolAttribute(attributes["isAnswerable"]) + if "name" in attributes: # pragma no branch + self._name = self._makeStringAttribute(attributes["name"]) + if "repository" in attributes: # pragma no branch + # repository is a REST API object + self._repository = self._makeClassAttribute( + github.Repository.Repository, as_rest_api_attributes(attributes["repository"]) + ) + if "slug" in attributes: # pragma no branch + self._slug = self._makeStringAttribute(attributes["slug"]) + if "updatedAt" in attributes: # pragma no branch + self._updated_at = self._makeDatetimeAttribute(attributes["updatedAt"]) diff --git a/venv/lib/python3.10/site-packages/github/RepositoryDiscussionComment.py b/venv/lib/python3.10/site-packages/github/RepositoryDiscussionComment.py new file mode 100644 index 0000000000000000000000000000000000000000..ef33a5abdab1642d2d5fba9ca3f00c08fc0f406b --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/RepositoryDiscussionComment.py @@ -0,0 +1,149 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2024 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from typing import TYPE_CHECKING, Any + +import github.NamedUser +import github.Reaction +from github.DiscussionCommentBase import DiscussionCommentBase +from github.GithubObject import ( + Attribute, + GraphQlObject, + NotSet, + as_rest_api_attributes, + as_rest_api_attributes_list, + is_defined, +) +from github.PaginatedList import PaginatedList + +if TYPE_CHECKING: + from github.NamedUser import NamedUser + from github.Reaction import Reaction + from github.RepositoryDiscussion import RepositoryDiscussion + + +class RepositoryDiscussionComment(GraphQlObject, DiscussionCommentBase): + """ + This class represents GraphQL DiscussionComment. + + The reference can be found here + https://docs.github.com/en/graphql/reference/objects#discussioncomment + + """ + + def _initAttributes(self) -> None: + super()._initAttributes() + self._body_text: Attribute[str] = NotSet + self._database_id: Attribute[int] = NotSet + self._discussion: Attribute[RepositoryDiscussion] + self._editor: Attribute[NamedUser] = NotSet + self._id: Attribute[str] = NotSet + self._reactions_page = None + self._replies_page = None + + @property + def body_text(self) -> str: + return self._body_text.value + + @property + def database_id(self) -> int: + return self._database_id.value + + @property + def discussion(self) -> RepositoryDiscussion: + return self._discussion.value + + @property + def editor(self) -> NamedUser: + return self._editor.value + + @property + def id(self) -> str: + return self._id.value + + @property + def node_id(self) -> str: + if is_defined(self._node_id): + return super().node_id + return self.id + + def get_reactions(self) -> PaginatedList[Reaction]: + if self._reactions_page is None: + raise RuntimeError("Fetching reactions not implemented") + return PaginatedList(github.Reaction.Reaction, self._requester, firstData=self._reactions_page, firstHeaders={}) + + def get_replies(self) -> PaginatedList[RepositoryDiscussionComment]: + if self._replies_page is None: + raise RuntimeError("Fetching replies not implemented") + return PaginatedList( + RepositoryDiscussionComment, self._requester, firstData=self._replies_page, firstHeaders={} + ) + + def edit(self, body: str, output_schema: str = "id") -> RepositoryDiscussionComment: + if not output_schema.startswith("\n"): + output_schema = f" {output_schema} " + return self._requester.graphql_named_mutation_class( + "updateDiscussionComment", + {"commentId": self.node_id, "body": body}, + f"comment {{{output_schema}}}", + "comment", + github.RepositoryDiscussionComment.RepositoryDiscussionComment, + ) + + def delete(self, output_schema: str = "id") -> RepositoryDiscussionComment: + if not output_schema.startswith("\n"): + output_schema = f" {output_schema} " + return self._requester.graphql_named_mutation_class( + "deleteDiscussionComment", + {"id": self.id}, + f"comment {{{output_schema}}}", + "comment", + github.RepositoryDiscussionComment.RepositoryDiscussionComment, + ) + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + # super class is a REST API GithubObject, attributes are coming from GraphQL + super()._useAttributes(as_rest_api_attributes(attributes)) + if "bodyText" in attributes: # pragma no branch + self._body_text = self._makeStringAttribute(attributes["bodyText"]) + if "databaseId" in attributes: # pragma no branch + self._database_id = self._makeIntAttribute(attributes["databaseId"]) + if "discussion" in attributes: # pragma no branch + # RepositoryDiscussion is a GraphQL API object + self._discussion = self._makeClassAttribute( + github.RepositoryDiscussion.RepositoryDiscussion, attributes["discussion"] + ) + if "editor" in attributes: # pragma no branch + # NamedUser is a REST API object + self._editor = self._makeClassAttribute( + github.NamedUser.NamedUser, as_rest_api_attributes(attributes["editor"]) + ) + if "id" in attributes: # pragma no branch + self._id = self._makeStringAttribute(attributes["id"]) + if "reactions" in attributes: # pragma no branch + # reactions are REST API objects + self._reactions_page = as_rest_api_attributes_list(attributes["reactions"]["nodes"]) # type: ignore + if "replies" in attributes: # pragma no branch + # replies are GraphQL API objects + self._replies_page = attributes["replies"]["nodes"] diff --git a/venv/lib/python3.10/site-packages/github/RepositoryKey.py b/venv/lib/python3.10/site-packages/github/RepositoryKey.py new file mode 100644 index 0000000000000000000000000000000000000000..84dec926b3f8976ecc8ac0022d3808453ab8e912 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/RepositoryKey.py @@ -0,0 +1,152 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Srijan Choudhary # +# Copyright 2013 Vincent Jacques # +# Copyright 2013 martinqt # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2017 Jimmy Zelinskie # +# Copyright 2017 Simon # +# Copyright 2018 Laurent Raufaste # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Floyd Hightower # +# Copyright 2021 Mark Walker # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2024 Ramiro Morales # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from datetime import datetime +from typing import Any + +from github.GithubObject import Attribute, CompletableGithubObject, NotSet + + +class RepositoryKey(CompletableGithubObject): + """ + This class represents RepositoryKeys. + + The reference can be found here + https://docs.github.com/en/rest/reference/repos#deploy-keys + + The OpenAPI schema can be found at + - /components/schemas/deploy-key + + """ + + def _initAttributes(self) -> None: + self._added_by: Attribute[str] = NotSet + self._created_at: Attribute[datetime] = NotSet + self._id: Attribute[int] = NotSet + self._key: Attribute[str] = NotSet + self._last_used: Attribute[datetime] = NotSet + self._read_only: Attribute[bool] = NotSet + self._title: Attribute[str] = NotSet + self._url: Attribute[str] = NotSet + self._verified: Attribute[bool] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"id": self._id.value, "title": self._title.value}) + + @property + def added_by(self) -> str: + self._completeIfNotSet(self._added_by) + return self._added_by.value + + @property + def created_at(self) -> datetime: + self._completeIfNotSet(self._created_at) + return self._created_at.value + + @property + def id(self) -> int: + self._completeIfNotSet(self._id) + return self._id.value + + @property + def key(self) -> str: + self._completeIfNotSet(self._key) + return self._key.value + + @property + def last_used(self) -> datetime: + self._completeIfNotSet(self._last_used) + return self._last_used.value + + @property + def read_only(self) -> bool: + self._completeIfNotSet(self._read_only) + return self._read_only.value + + @property + def title(self) -> str: + self._completeIfNotSet(self._title) + return self._title.value + + @property + def url(self) -> str: + self._completeIfNotSet(self._url) + return self._url.value + + @property + def verified(self) -> bool: + self._completeIfNotSet(self._verified) + return self._verified.value + + def delete(self) -> None: + """ + :calls: `DELETE /repos/{owner}/{repo}/keys/{id} `_ + """ + headers, data = self._requester.requestJsonAndCheck("DELETE", self.url) + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "added_by" in attributes: # pragma no branch + self._added_by = self._makeStringAttribute(attributes["added_by"]) + if "created_at" in attributes: # pragma no branch + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) + if "id" in attributes: # pragma no branch + self._id = self._makeIntAttribute(attributes["id"]) + if "key" in attributes: # pragma no branch + self._key = self._makeStringAttribute(attributes["key"]) + if "last_used" in attributes: # pragma no branch + assert attributes["last_used"] is None or isinstance(attributes["last_used"], str), attributes["last_used"] + self._last_used = self._makeDatetimeAttribute(attributes["last_used"]) + if "read_only" in attributes: # pragma no branch + self._read_only = self._makeBoolAttribute(attributes["read_only"]) + if "title" in attributes: # pragma no branch + self._title = self._makeStringAttribute(attributes["title"]) + if "url" in attributes: # pragma no branch + self._url = self._makeStringAttribute(attributes["url"]) + if "verified" in attributes: # pragma no branch + self._verified = self._makeBoolAttribute(attributes["verified"]) diff --git a/venv/lib/python3.10/site-packages/github/RepositoryPreferences.py b/venv/lib/python3.10/site-packages/github/RepositoryPreferences.py new file mode 100644 index 0000000000000000000000000000000000000000..426329abdf225e55f2f15d01150dd505dddb907b --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/RepositoryPreferences.py @@ -0,0 +1,80 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Adam Baratz # +# Copyright 2019 Nick Campbell # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Dhruv Manilawala # +# Copyright 2020 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from typing import TYPE_CHECKING, Any + +import github.Repository +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + +if TYPE_CHECKING: + from github.Repository import Repository + + +class RepositoryPreferences(NonCompletableGithubObject): + """ + This class represents repository preferences. + + The reference can be found here + https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#update-repository-preferences-for-check-suites + + The OpenAPI schema can be found at + - /components/schemas/check-suite-preference + + """ + + def _initAttributes(self) -> None: + self._preferences: Attribute[dict[str, list[dict[str, bool | int]]]] = NotSet + self._repository: Attribute[Repository] = NotSet + + @property + def preferences(self) -> dict[str, list[dict[str, bool | int]]]: + return self._preferences.value + + @property + def repository(self) -> Repository: + return self._repository.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "preferences" in attributes: # pragma no branch + self._preferences = self._makeDictAttribute(attributes["preferences"]) + if "repository" in attributes: # pragma no branch + self._repository = self._makeClassAttribute(github.Repository.Repository, attributes["repository"]) diff --git a/venv/lib/python3.10/site-packages/github/Requester.py b/venv/lib/python3.10/site-packages/github/Requester.py new file mode 100644 index 0000000000000000000000000000000000000000..b3e5eb554c0b588b6648a31424e97267f0d98ff7 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/Requester.py @@ -0,0 +1,1317 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Andrew Bettison # +# Copyright 2012 Dima Kukushkin # +# Copyright 2012 Michael Woodworth # +# Copyright 2012 Petteri Muilu # +# Copyright 2012 Steve English # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Cameron White # +# Copyright 2013 Ed Jackson # +# Copyright 2013 Jonathan J Hunt # +# Copyright 2013 Mark Roddy # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Jimmy Zelinskie # +# Copyright 2014 Vincent Jacques # +# Copyright 2015 Brian Eugley # +# Copyright 2015 Daniel Pocock # +# Copyright 2016 Denis K # +# Copyright 2016 Jared K. Smith # +# Copyright 2016 Mathieu Mitchell # +# Copyright 2016 Peter Buckley # +# Copyright 2017 Chris McBride # +# Copyright 2017 Hugo # +# Copyright 2017 Simon # +# Copyright 2018 Arda Kuyumcu # +# Copyright 2018 Dylan # +# Copyright 2018 Maarten Fonville # +# Copyright 2018 Mike Miller # +# Copyright 2018 R1kk3r # +# Copyright 2018 Shubham Singh <41840111+singh811@users.noreply.github.com> # +# Copyright 2018 Steve Kowalik # +# Copyright 2018 Tuuu Nya # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Isac Souza # +# Copyright 2019 Rigas Papathanasopoulos # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Jesse Li # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Amador Pahim # +# Copyright 2021 Mark Walker # +# Copyright 2021 Steve Kowalik # +# Copyright 2022 Liuyang Wan # +# Copyright 2023 Denis Blanchette # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Heitor Polidoro # +# Copyright 2023 Hemslo Wang # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Phillip Tran # +# Copyright 2023 Trim21 # +# Copyright 2023 adosibalo <94008816+adosibalo@users.noreply.github.com> # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2024 Jonathan Kliem # +# Copyright 2024 Kobbi Gal <85439776+kgal-pan@users.noreply.github.com> # +# Copyright 2024 Min RK # +# Copyright 2025 Enrico Minack # +# Copyright 2025 Neel Malik <41765022+neel-m@users.noreply.github.com> # +# Copyright 2025 Timothy Klopotoski # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +import io +import json +import logging +import mimetypes +import os +import re +import threading +import time +import urllib +import urllib.parse +from collections import deque +from datetime import datetime, timezone +from io import IOBase +from typing import ( + TYPE_CHECKING, + Any, + BinaryIO, + Callable, + Deque, + Dict, + Generic, + ItemsView, + Iterator, + List, + Optional, + Tuple, + Type, + TypeVar, + Union, +) + +import requests +import requests.adapters +from urllib3 import Retry + +import github.Consts as Consts +import github.GithubException +import github.GithubException as GithubException +from github.GithubObject import as_rest_api_attributes + +if TYPE_CHECKING: + from .AppAuthentication import AppAuthentication + from .Auth import Auth + from .GithubObject import GithubObject + from .InstallationAuthorization import InstallationAuthorization + +T = TypeVar("T") +T_gh = TypeVar("T_gh", bound="GithubObject") + +# For App authentication, time remaining before token expiration to request a new one +ACCESS_TOKEN_REFRESH_THRESHOLD_SECONDS = 20 + + +class RequestsResponse: + # mimic the httplib response object + def __init__(self, r: requests.Response): + self.status = r.status_code + self.headers = r.headers + self.response = r + + def getheaders(self) -> ItemsView[str, str]: + return self.headers.items() + + def read(self) -> str: + return self.response.text + + def iter_content(self, chunk_size: Union[int, None] = 1) -> Iterator: + return self.response.iter_content(chunk_size=chunk_size) + + def raise_for_status(self) -> None: + self.response.raise_for_status() + + +class HTTPSRequestsConnectionClass: + retry: Union[int, Retry] + + # mimic the httplib connection object + def __init__( + self, + host: str, + port: Optional[int] = None, + strict: bool = False, + timeout: Optional[int] = None, + retry: Optional[Union[int, Retry]] = None, + pool_size: Optional[int] = None, + **kwargs: Any, + ) -> None: + self.port = port if port else 443 + self.host = host + self.protocol = "https" + self.timeout = timeout + self.verify = kwargs.get("verify", True) + self.session = requests.Session() + # having Session.auth set something other than None disables falling back to .netrc file + # https://github.com/psf/requests/blob/d63e94f552ebf77ccf45d97e5863ac46500fa2c7/src/requests/sessions.py#L480-L481 + # see https://github.com/PyGithub/PyGithub/pull/2703 + self.session.auth = Requester.noopAuth + + if retry is None: + self.retry = requests.adapters.DEFAULT_RETRIES + else: + self.retry = retry + + if pool_size is None: + self.pool_size = requests.adapters.DEFAULT_POOLSIZE + else: + self.pool_size = pool_size + + self.adapter = requests.adapters.HTTPAdapter( + max_retries=self.retry, + pool_connections=self.pool_size, + pool_maxsize=self.pool_size, + ) + self.session.mount("https://", self.adapter) + + def request( + self, + verb: str, + url: str, + input: Optional[Union[str, io.BufferedReader]], + headers: Dict[str, str], + stream: bool = False, + ) -> None: + self.verb = verb + self.url = url + self.input = input + self.headers = headers + self.stream = stream + + def getresponse(self) -> RequestsResponse: + verb = getattr(self.session, self.verb.lower()) + url = f"{self.protocol}://{self.host}:{self.port}{self.url}" + r = verb( + url, + headers=self.headers, + data=self.input, + timeout=self.timeout, + verify=self.verify, + allow_redirects=False, + ) + return RequestsResponse(r) + + def close(self) -> None: + self.session.close() + + +class HTTPRequestsConnectionClass: + # mimic the httplib connection object + def __init__( + self, + host: str, + port: Optional[int] = None, + strict: bool = False, + timeout: Optional[int] = None, + retry: Optional[Union[int, Retry]] = None, + pool_size: Optional[int] = None, + **kwargs: Any, + ): + self.port = port if port else 80 + self.host = host + self.protocol = "http" + self.timeout = timeout + self.verify = kwargs.get("verify", True) + self.session = requests.Session() + # having Session.auth set something other than None disables falling back to .netrc file + # https://github.com/psf/requests/blob/d63e94f552ebf77ccf45d97e5863ac46500fa2c7/src/requests/sessions.py#L480-L481 + # see https://github.com/PyGithub/PyGithub/pull/2703 + self.session.auth = Requester.noopAuth + + if retry is None: + self.retry = requests.adapters.DEFAULT_RETRIES + else: + self.retry = retry # type: ignore + + if pool_size is None: + self.pool_size = requests.adapters.DEFAULT_POOLSIZE + else: + self.pool_size = pool_size + + self.adapter = requests.adapters.HTTPAdapter( + max_retries=self.retry, + pool_connections=self.pool_size, + pool_maxsize=self.pool_size, + ) + self.session.mount("http://", self.adapter) + + def request(self, verb: str, url: str, input: None, headers: Dict[str, str], stream: bool = False) -> None: + self.verb = verb + self.url = url + self.input = input + self.headers = headers + self.stream = stream + + def getresponse(self) -> RequestsResponse: + verb = getattr(self.session, self.verb.lower()) + url = f"{self.protocol}://{self.host}:{self.port}{self.url}" + r = verb( + url, + headers=self.headers, + data=self.input, + timeout=self.timeout, + verify=self.verify, + allow_redirects=False, + ) + return RequestsResponse(r) + + def close(self) -> None: + self.session.close() + + +class Requester: + __installation_authorization: Optional["InstallationAuthorization"] + __app_auth: Optional["AppAuthentication"] + + __httpConnectionClass = HTTPRequestsConnectionClass + __httpsConnectionClass = HTTPSRequestsConnectionClass + __persist = True + __logger: Optional[logging.Logger] = None + + _frameBuffer: List[Any] + + @staticmethod + def noopAuth(request: requests.models.PreparedRequest) -> requests.models.PreparedRequest: + return request + + @classmethod + def injectConnectionClasses( + cls, + httpConnectionClass: Type[HTTPRequestsConnectionClass], + httpsConnectionClass: Type[HTTPSRequestsConnectionClass], + ) -> None: + cls.__persist = False + cls.__httpConnectionClass = httpConnectionClass + cls.__httpsConnectionClass = httpsConnectionClass + + @classmethod + def resetConnectionClasses(cls) -> None: + cls.__persist = True + cls.__httpConnectionClass = HTTPRequestsConnectionClass + cls.__httpsConnectionClass = HTTPSRequestsConnectionClass + + @classmethod + def injectLogger(cls, logger: logging.Logger) -> None: + cls.__logger = logger + + @classmethod + def resetLogger(cls) -> None: + cls.__logger = None + + ############################################################# + # For Debug + @classmethod + def setDebugFlag(cls, flag: bool) -> None: + cls.DEBUG_FLAG = flag + + @classmethod + def setOnCheckMe(cls, onCheckMe: Callable) -> None: + cls.ON_CHECK_ME = onCheckMe + + DEBUG_FLAG = False + + DEBUG_FRAME_BUFFER_SIZE = 1024 + + DEBUG_HEADER_KEY = "DEBUG_FRAME" + + ON_CHECK_ME: Optional[Callable] = None + + def NEW_DEBUG_FRAME(self, requestHeader: Dict[str, str]) -> None: + """ + Initialize a debug frame with requestHeader + Frame count is updated and will be attached to respond header + The structure of a frame: [requestHeader, statusCode, responseHeader, raw_data] + Some of them may be None + """ + if self.DEBUG_FLAG: # pragma no branch (Flag always set in tests) + new_frame = [requestHeader, None, None, None] + if self._frameCount < self.DEBUG_FRAME_BUFFER_SIZE - 1: # pragma no branch (Should be covered) + self._frameBuffer.append(new_frame) + else: + self._frameBuffer[0] = new_frame # pragma no cover (Should be covered) + + self._frameCount = len(self._frameBuffer) - 1 + + def DEBUG_ON_RESPONSE(self, statusCode: int, responseHeader: Dict[str, Union[str, int]], data: str) -> None: + """ + Update current frame with response Current frame index will be attached to responseHeader. + """ + if self.DEBUG_FLAG: # pragma no branch (Flag always set in tests) + self._frameBuffer[self._frameCount][1:4] = [ + statusCode, + responseHeader, + data, + ] + responseHeader[self.DEBUG_HEADER_KEY] = self._frameCount + + def check_me(self, obj: "GithubObject") -> None: + if self.DEBUG_FLAG and self.ON_CHECK_ME is not None: # pragma no branch (Flag always set in tests) + frame = None + if self.DEBUG_HEADER_KEY in obj._headers: + frame_index = obj._headers[self.DEBUG_HEADER_KEY] + frame = self._frameBuffer[frame_index] # type: ignore + self.ON_CHECK_ME(obj, frame) + + def _initializeDebugFeature(self) -> None: + self._frameCount = 0 + self._frameBuffer = [] + + ############################################################# + + _frameCount: int + __connectionClass: Union[Type[HTTPRequestsConnectionClass], Type[HTTPSRequestsConnectionClass]] + __hostname: str + __authorizationHeader: Optional[str] + __seconds_between_requests: Optional[float] + __seconds_between_writes: Optional[float] + + # keep arguments in-sync with github.MainClass and GithubIntegration + def __init__( + self, + auth: Optional["Auth"], + base_url: str, + timeout: int, + user_agent: str, + per_page: int, + verify: Union[bool, str], + retry: Optional[Union[int, Retry]], + pool_size: Optional[int], + seconds_between_requests: Optional[float] = None, + seconds_between_writes: Optional[float] = None, + lazy: bool = False, + ): + self._initializeDebugFeature() + + self.__auth = auth + self.__base_url = base_url + + o = urllib.parse.urlparse(base_url) + self.__graphql_prefix = self.get_graphql_prefix(o.path) + self.__graphql_url = urllib.parse.urlunparse(o._replace(path=self.__graphql_prefix)) + self.__hostname = o.hostname # type: ignore + self.__port = o.port + self.__prefix = o.path + self.__timeout = timeout + self.__retry = retry # NOTE: retry can be either int or an urllib3 Retry object + self.__pool_size = pool_size + self.__seconds_between_requests = seconds_between_requests + self.__seconds_between_writes = seconds_between_writes + self.__last_requests: Dict[str, float] = dict() + self.__scheme = o.scheme + if o.scheme == "https": + self.__connectionClass = self.__httpsConnectionClass + elif o.scheme == "http": + self.__connectionClass = self.__httpConnectionClass + else: + assert False, "Unknown URL scheme" + self.__connection: Optional[Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass]] = None + self.__connection_lock = threading.Lock() + self.__custom_connections: Deque[Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass]] = deque() + self.rate_limiting = (-1, -1) + self.rate_limiting_resettime = 0 + self.FIX_REPO_GET_GIT_REF = True + self.per_page = per_page + + self.oauth_scopes = None + + assert user_agent is not None, ( + "github now requires a user-agent. " + "See https://docs.github.com/en/rest/overview/resources-in-the-rest-api#user-agent-required" + ) + self.__userAgent = user_agent + self.__verify = verify + self.__lazy = lazy + + self.__installation_authorization = None + + # provide auth implementations that require a requester with this requester + if isinstance(self.__auth, WithRequester): + self.__auth.withRequester(self) + + def __getstate__(self) -> Dict[str, Any]: + state = self.__dict__.copy() + # __connection_lock is not picklable + del state["_Requester__connection_lock"] + # __connection is not usable on remote, so ignore it + del state["_Requester__connection"] + # __custom_connections is not usable on remote, so ignore it + del state["_Requester__custom_connections"] + return state + + def __setstate__(self, state: Dict[str, Any]) -> None: + self.__dict__.update(state) + self.__connection_lock = threading.Lock() + self.__connection = None + self.__custom_connections = deque() + + @staticmethod + # replace with str.removesuffix once support for Python 3.8 is dropped + def remove_suffix(string: str, suffix: str) -> str: + if string.endswith(suffix): + return string[: -len(suffix)] + return string + + @staticmethod + def get_graphql_prefix(path: Optional[str]) -> str: + if path is None or path in ["", "/"]: + path = "" + if path.endswith(("/v3", "/v3/")): + path = Requester.remove_suffix(path, "/") + path = Requester.remove_suffix(path, "/v3") + return path + "/graphql" + + @staticmethod + def get_parameters_of_url(url: str) -> Dict[str, list]: + query = urllib.parse.urlparse(url)[4] + return urllib.parse.parse_qs(query) + + @staticmethod + def add_parameters_to_url( + url: str, + parameters: Dict[str, Any], + ) -> str: + scheme, netloc, url, params, query, fragment = urllib.parse.urlparse(url) + url_params = urllib.parse.parse_qs(query) + # union parameters in url with given parameters, the latter have precedence + url_params.update(**{k: v if isinstance(v, list) else [v] for k, v in parameters.items()}) + parameter_list = [(key, value) for key, values in url_params.items() for value in values] + # remove query from url + url = urllib.parse.urlunparse((scheme, netloc, url, params, "", fragment)) + + if len(parameter_list) == 0: + return url + else: + return f"{url}?{urllib.parse.urlencode(parameter_list)}" + + def close(self) -> None: + """ + Close the connection to the server. + """ + with self.__connection_lock: + if self.__connection is not None: + self.__connection.close() + self.__connection = None + while self.__custom_connections: + self.__custom_connections.popleft().close() + + @property + def kwargs(self) -> Dict[str, Any]: + """ + Returns arguments required to recreate this Requester with Requester.__init__, as well as with + MainClass.__init__ and GithubIntegration.__init__. + """ + return dict( + auth=self.__auth, + base_url=self.__base_url, + timeout=self.__timeout, + user_agent=self.__userAgent, + per_page=self.per_page, + verify=self.__verify, + retry=self.__retry, + pool_size=self.__pool_size, + seconds_between_requests=self.__seconds_between_requests, + seconds_between_writes=self.__seconds_between_writes, + lazy=self.__lazy, + ) + + @property + def base_url(self) -> str: + return self.__base_url + + @property + def graphql_url(self) -> str: + return self.__graphql_url + + @property + def scheme(self) -> str: + return self.__scheme + + @property + def hostname(self) -> str: + return self.__hostname + + @property + def hostname_and_port(self) -> str: + if self.__port is None: + return self.hostname + return f"{self.hostname}:{self.__port}" + + @property + def auth(self) -> Optional["Auth"]: + return self.__auth + + def withAuth(self, auth: Optional["Auth"]) -> "Requester": + """ + Create a new requester instance with identical configuration but the given authentication method. + + :param auth: authentication method + :return: new Requester instance + + """ + kwargs = self.kwargs + kwargs.update(auth=auth) + return Requester(**kwargs) + + @property + def is_lazy(self) -> bool: + return self.__lazy + + @property + def is_not_lazy(self) -> bool: + return not self.__lazy + + def withLazy(self, lazy: bool) -> "Requester": + """ + Create a new requester instance with identical configuration but the given lazy setting. + + :param lazy: completable objects created from this instance are lazy, as well as completable objects created + from those, and so on + :return: new Requester instance + + """ + kwargs = self.kwargs + kwargs.update(lazy=lazy) + return Requester(**kwargs) + + def requestJsonAndCheck( + self, + verb: str, + url: str, + parameters: Optional[Dict[str, Any]] = None, + headers: Optional[Dict[str, str]] = None, + input: Optional[Any] = None, + follow_302_redirect: bool = False, + ) -> Tuple[Dict[str, Any], Any]: + """ + Send a request with JSON body. + + :param input: request body, serialized to JSON if specified + + :return: ``(headers: dict, JSON Response: Any)`` + :raises: :class:`GithubException` for error status codes + + """ + return self.__check( + *self.requestJson( + verb, + url, + parameters, + headers, + input, + self.__customConnection(url), + follow_302_redirect=follow_302_redirect, + ) + ) + + def requestMultipartAndCheck( + self, + verb: str, + url: str, + parameters: Optional[Dict[str, Any]] = None, + headers: Optional[Dict[str, Any]] = None, + input: Optional[Dict[str, str]] = None, + ) -> Tuple[Dict[str, Any], Optional[Dict[str, Any]]]: + """ + Send a request with multi-part-encoded body. + + :param input: request body, will be multi-part encoded if specified + + :return: ``(headers: dict, JSON Response: Any)`` + :raises: :class:`GithubException` for error status codes + + """ + return self.__check(*self.requestMultipart(verb, url, parameters, headers, input, self.__customConnection(url))) + + def requestBlobAndCheck( + self, + verb: str, + url: str, + parameters: Optional[Dict[str, str]] = None, + headers: Optional[Dict[str, str]] = None, + input: Optional[str] = None, + cnx: Optional[Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass]] = None, + ) -> Tuple[Dict[str, Any], Dict[str, Any]]: + """ + Send a request with a file for the body. + + :param input: path to a file to use for the request body + + :return: ``(headers: dict, JSON Response: Any)`` + :raises: :class:`GithubException` for error status codes + + """ + return self.__check(*self.requestBlob(verb, url, parameters, headers, input, self.__customConnection(url))) + + def graphql_query(self, query: str, variables: Dict[str, Any]) -> Tuple[Dict[str, Any], Dict[str, Any]]: + """ + :calls: `POST /graphql `_ + """ + input_ = {"query": query, "variables": variables} + + response_headers, data = self.requestJsonAndCheck("POST", self.graphql_url, input=input_) + if "errors" in data: + if len(data["errors"]) == 1: + error = data["errors"][0] + if error.get("type") == "NOT_FOUND": + raise github.UnknownObjectException(404, data, response_headers, error.get("message")) + raise self.createException(400, response_headers, data) + return response_headers, data + + @classmethod + def paths_of_dict(cls, d: dict) -> dict: + return {key: cls.paths_of_dict(val) if isinstance(val, dict) else None for key, val in d.items()} + + def data_as_class( + self, headers: Dict[str, Any], data: Dict[str, Any], data_path: List[str], klass: Type[T_gh] + ) -> T_gh: + for item in data_path: + if item not in data: + raise RuntimeError(f"GraphQL path {data_path} not found in data: {self.paths_of_dict(data)}") + data = data[item] + if klass.is_rest(): + data = as_rest_api_attributes(data) + return klass(self, headers, data) + + def graphql_node(self, node_id: str, graphql_schema: str, node_type: str) -> Tuple[Dict[str, Any], Dict[str, Any]]: + """ + :calls: `POST /graphql `_ + """ + if not graphql_schema.startswith("\n"): + graphql_schema = f" {graphql_schema} " + query = ( + """ + query Q($id: ID!) { + node(id: $id) { + __typename + ... on """ + + f"{node_type} {{{graphql_schema}}}" + + """ + } + } + """ + ) + + headers, data = self.graphql_query(query, {"id": node_id}) + actual_node_type = data.get("data", {}).get("node", {}).get("__typename", node_type) + if actual_node_type != node_type: + raise github.GithubException( + 400, + data, + message=f"Retrieved {node_type} object is of different type: {actual_node_type}", + ) + return headers, data + + def graphql_node_class( + self, node_id: str, graphql_schema: str, klass: Type[T_gh], node_type: Optional[str] = None + ) -> T_gh: + """ + :calls: `POST /graphql `_ + """ + if node_type is None: + node_type = klass.__name__ + + headers, data = self.graphql_node(node_id, graphql_schema, node_type) + return self.data_as_class(headers, data, ["data", "node"], klass) + + def graphql_query_class( + self, query: str, variables: Dict[str, Any], data_path: List[str], klass: Type[T_gh] + ) -> T_gh: + """ + :calls: `POST /graphql `_ + """ + headers, data = self.graphql_query(query, variables) + return self.data_as_class(headers, data, ["data"] + data_path, klass) + + def graphql_named_mutation( + self, mutation_name: str, mutation_input: Dict[str, Any], output_schema: str + ) -> Tuple[Dict[str, Any], Dict[str, Any]]: + """ + Create a mutation in the format: + mutation Mutation($input: MutationNameInput!) { + mutationName(input: $input) { } + } + and call the self.graphql_query method. + + Returns the response data according to given output schema. + """ + mutation_input_name = mutation_name[:1].upper() + mutation_name[1:] + "Input!" + query = f"mutation Mutation($input: {mutation_input_name}) {{ {mutation_name}(input: $input) {{ {output_schema} }} }}" + headers, data = self.graphql_query(query, {"input": mutation_input}) + return headers, data.get("data", {}).get(mutation_name, {}) + + def graphql_named_mutation_class( + self, mutation_name: str, mutation_input: Dict[str, Any], output_schema: str, item: str, klass: Type[T_gh] + ) -> T_gh: + """ + Executes a mutation and returns the output object as the given GithubObject. + + See {@link graphql_named_mutation}. + + """ + headers, data = self.graphql_named_mutation(mutation_name, mutation_input, output_schema) + return self.data_as_class(headers, data, [item], klass) + + def __check( + self, + status: int, + responseHeaders: Dict[str, Any], + output: str, + ) -> Tuple[Dict[str, Any], Any]: + data = self.__structuredFromJson(output) + if status >= 400: + raise self.createException(status, responseHeaders, data) + return responseHeaders, data + + def __customConnection( + self, url: str + ) -> Optional[Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass]]: + cnx: Optional[Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass]] = None + if not url.startswith("/"): + o = urllib.parse.urlparse(url) + if ( + o.hostname != self.__hostname + or (o.port and o.port != self.__port) + or (o.scheme != self.__scheme and not (o.scheme == "https" and self.__scheme == "http")) + ): # issue80 + if o.scheme == "http": + cnx = self.__httpConnectionClass( + o.hostname, # type: ignore + o.port, + retry=self.__retry, + pool_size=self.__pool_size, + ) + self.__custom_connections.append(cnx) + elif o.scheme == "https": + cnx = self.__httpsConnectionClass( + o.hostname, # type: ignore + o.port, + retry=self.__retry, + pool_size=self.__pool_size, + ) + self.__custom_connections.append(cnx) + return cnx + + @classmethod + def createException( + cls, + status: int, + headers: Dict[str, Any], + output: Dict[str, Any], + ) -> GithubException.GithubException: + message = output.get("message") if output else None + lc_message = message.lower() if message else "" + + msg = None + exc = GithubException.GithubException + if status == 401 and lc_message == "bad credentials": + exc = GithubException.BadCredentialsException + elif status == 401 and Consts.headerOTP in headers and re.match(r".*required.*", headers[Consts.headerOTP]): + exc = GithubException.TwoFactorException + elif status == 403 and lc_message.startswith("missing or invalid user agent string"): + exc = GithubException.BadUserAgentException + elif status == 403 and cls.isRateLimitError(lc_message): + exc = GithubException.RateLimitExceededException + elif status == 404 and (lc_message == "not found" or "no object found" in lc_message): + exc = GithubException.UnknownObjectException + else: + # for general GithubException, provide the actual message + msg = message + + return exc(status, output, headers, msg) + + @classmethod + def isRateLimitError(cls, message: str) -> bool: + return cls.isPrimaryRateLimitError(message) or cls.isSecondaryRateLimitError(message) + + @classmethod + def isPrimaryRateLimitError(cls, message: str) -> bool: + if not message: + return False + + message = message.lower() + return message.startswith("api rate limit exceeded") + + @classmethod + def isSecondaryRateLimitError(cls, message: str) -> bool: + if not message: + return False + + message = message.lower() + return ( + message.startswith("you have exceeded a secondary rate limit") + or message.endswith("please retry your request again later.") + or message.endswith("please wait a few minutes before you try again.") + ) + + def __structuredFromJson(self, data: str) -> Any: + if len(data) == 0: + return None + else: + if isinstance(data, bytes): + data = data.decode("utf-8") + try: + return json.loads(data) + except ValueError: + if data.startswith("{") or data.startswith("["): + raise + return {"data": data} + + def getFile( + self, + url: str, + path: str, + parameters: Optional[Dict[str, Any]] = None, + headers: Optional[Dict[str, str]] = None, + cnx: Optional[Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass]] = None, + chunk_size: Optional[Union[int, None]] = 1, + ) -> None: + """ + GET a file from the server and save it to the given path, which includes the filename. + """ + _, _, stream_chunk_iterator = self.getStream(url, parameters, headers, cnx, chunk_size=chunk_size) + with open(path, "wb") as f: + for chunk in stream_chunk_iterator: + if chunk: + f.write(chunk) + + def getStream( + self, + url: str, + parameters: Optional[Dict[str, Any]] = None, + headers: Optional[Dict[str, str]] = None, + cnx: Optional[Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass]] = None, + chunk_size: Optional[Union[int, None]] = 1, + ) -> Tuple[int, Dict[str, Any], Iterator]: + """ + GET a stream from the server. + + :returns:``(status, headers, stream_chunk_iterator)`` + + """ + if headers is None: + headers = {} + headers["Accept"] = "application/octet-stream" + + def encode(_: Any) -> Tuple[str, str]: + return "", "" + + status, responseHeaders, output = self.__requestEncode( + cnx, "GET", url, parameters, headers, None, encode, stream=True, follow_302_redirect=True + ) + if isinstance(output, RequestsResponse) or ( + hasattr(output, "iter_content") and hasattr(output, "raise_for_status") + ): + output.raise_for_status() + return status, responseHeaders, output.iter_content(chunk_size=chunk_size) + raise TypeError(f"Expected a RequestsResponse object: {type(output)}") + + def requestJson( + self, + verb: str, + url: str, + parameters: Optional[Dict[str, Any]] = None, + headers: Optional[Dict[str, Any]] = None, + input: Optional[Any] = None, + cnx: Optional[Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass]] = None, + follow_302_redirect: bool = False, + ) -> Tuple[int, Dict[str, Any], str]: + """ + Send a request with JSON input. + + :param input: request body, will be serialized as JSON + :returns:``(status, headers, body)`` + + """ + + def encode(input: Any) -> Tuple[str, str]: + return "application/json", json.dumps(input) + + status, responseHeaders, output = self.__requestEncode( + cnx, verb, url, parameters, headers, input, encode, follow_302_redirect=follow_302_redirect + ) + if isinstance(output, str): + return status, responseHeaders, output + raise ValueError("requestJson() Expected a str, should never happen") + + def requestMultipart( + self, + verb: str, + url: str, + parameters: Optional[Dict[str, Any]] = None, + headers: Optional[Dict[str, Any]] = None, + input: Optional[Dict[str, str]] = None, + cnx: Optional[Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass]] = None, + ) -> Tuple[int, Dict[str, Any], str]: + """ + Send a request with multi-part encoding. + + :param input: request body, will be serialized as multipart form data + :returns:``(status, headers, body)`` + + """ + + def encode(input: Dict[str, Any]) -> Tuple[str, str]: + boundary = "----------------------------3c3ba8b523b2" + eol = "\r\n" + + encoded_input = "" + for name, value in input.items(): + encoded_input += f"--{boundary}{eol}" + encoded_input += f'Content-Disposition: form-data; name="{name}"{eol}' + encoded_input += eol + encoded_input += value + eol + encoded_input += f"--{boundary}--{eol}" + return f"multipart/form-data; boundary={boundary}", encoded_input + + status, responseHeaders, output = self.__requestEncode(cnx, verb, url, parameters, headers, input, encode) + if isinstance(output, str): + return status, responseHeaders, output + raise ValueError("requestMultipart() Expected a str, should never happen") + + def requestBlob( + self, + verb: str, + url: str, + parameters: Optional[Dict[str, str]] = None, + headers: Optional[Dict[str, str]] = None, + input: Optional[str] = None, + cnx: Optional[Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass]] = None, + ) -> Tuple[int, Dict[str, Any], str]: + """ + Send a request with a file as request body. + + :param input: path to a local file to use for request body + :returns:``(status, headers, body)`` + + """ + if headers is None: + headers = {} + + def encode(local_path: str) -> Tuple[str, Any]: + if "Content-Type" in headers: # type: ignore + mime_type = headers["Content-Type"] # type: ignore + else: + guessed_type = mimetypes.guess_type(local_path) + mime_type = guessed_type[0] if guessed_type[0] is not None else Consts.defaultMediaType + f = open(local_path, "rb") + return mime_type, f + + if input: + headers["Content-Length"] = str(os.path.getsize(input)) + + status, responseHeaders, output = self.__requestEncode(cnx, verb, url, parameters, headers, input, encode) + if isinstance(output, str): + return status, responseHeaders, output + raise ValueError("requestBlob() Expected a str, should never happen") + + def requestMemoryBlobAndCheck( + self, + verb: str, + url: str, + parameters: Any, + headers: Dict[str, Any], + file_like: BinaryIO, + cnx: Optional[Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass]] = None, + ) -> Tuple[Dict[str, Any], Any]: + """ + Send a request with a binary file-like for the body. + + :param file_like: file-like object to use for the request body + :return: ``(headers: dict, JSON Response: Any)`` + :raises: :class:`GithubException` for error status codes + + """ + + # The expected signature of encode means that the argument is ignored. + def encode(_: Any) -> Tuple[str, Any]: + return headers["Content-Type"], file_like + + if not cnx: + cnx = self.__customConnection(url) + + status, responseHeaders, output = self.__requestEncode(cnx, verb, url, parameters, headers, file_like, encode) + if isinstance(output, str): + return self.__check(status, responseHeaders, output) + raise ValueError("requestMemoryBlobAndCheck() Expected a str, should never happen") + + def __requestEncode( + self, + cnx: Optional[Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass]], + verb: str, + url: str, + parameters: Optional[Dict[str, str]], + requestHeaders: Optional[Dict[str, str]], + input: Optional[T], + encode: Callable[[T], Tuple[str, Any]], + stream: bool = False, + follow_302_redirect: bool = False, + ) -> Tuple[int, Dict[str, Any], Union[str, object]]: + assert verb in ["HEAD", "GET", "POST", "PATCH", "PUT", "DELETE"] + if parameters is None: + parameters = {} + if requestHeaders is None: + requestHeaders = {} + + if self.__auth is not None: + self.__auth.authentication(requestHeaders) + requestHeaders["User-Agent"] = self.__userAgent + + url = self.__makeAbsoluteUrl(url) + url = Requester.add_parameters_to_url(url, parameters) + + encoded_input = None + if input is not None: + requestHeaders["Content-Type"], encoded_input = encode(input) + + self.NEW_DEBUG_FRAME(requestHeaders) + + status, responseHeaders, output = self.__requestRaw( + cnx, verb, url, requestHeaders, encoded_input, stream=stream, follow_302_redirect=follow_302_redirect + ) + + if Consts.headerRateRemaining in responseHeaders and Consts.headerRateLimit in responseHeaders: + self.rate_limiting = ( + # ints expected but sometimes floats returned: https://github.com/PyGithub/PyGithub/pull/2697 + int(float(responseHeaders[Consts.headerRateRemaining])), + int(float(responseHeaders[Consts.headerRateLimit])), + ) + if Consts.headerRateReset in responseHeaders: + # ints expected but sometimes floats returned: https://github.com/PyGithub/PyGithub/pull/2697 + self.rate_limiting_resettime = int(float(responseHeaders[Consts.headerRateReset])) + + if Consts.headerOAuthScopes in responseHeaders: + self.oauth_scopes = responseHeaders[Consts.headerOAuthScopes].split(", ") + + self.DEBUG_ON_RESPONSE(status, responseHeaders, output if isinstance(output, str) else "stream") + + return status, responseHeaders, output + + def __requestRaw( + self, + cnx: Optional[Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass]], + verb: str, + url: str, + requestHeaders: Dict[str, str], + input: Optional[Any], + stream: bool = False, + follow_302_redirect: bool = False, + ) -> Tuple[int, Dict[str, Any], Union[str, object]]: + self.__deferRequest(verb) + + try: + original_cnx = cnx + if cnx is None: + cnx = self.__createConnection() + cnx.request(verb, url, input, requestHeaders, stream) + response = cnx.getresponse() + output = response if stream else response.read() + status = response.status + responseHeaders = {k.lower(): v for k, v in response.getheaders()} + + if input: + if isinstance(input, IOBase): + input.close() + + self.__log(verb, url, requestHeaders, input, status, responseHeaders, output) + + if status == 202 and ( + verb == "GET" or verb == "HEAD" + ): # only for requests that are considered 'safe' in RFC 2616 + time.sleep(Consts.PROCESSING_202_WAIT_TIME) + return self.__requestRaw(original_cnx, verb, url, requestHeaders, input, stream=stream) + + if status == 301 and "location" in responseHeaders: + location = responseHeaders["location"] + o = urllib.parse.urlparse(location) + if o.scheme != self.__scheme: + raise RuntimeError( + f"Github server redirected from {self.__scheme} protocol to {o.scheme}, " + f"please correct your Github server URL via base_url: Github(base_url=...)" + ) + if o.hostname != self.__hostname: + raise RuntimeError( + f"Github server redirected from host {self.__hostname} to {o.hostname}, " + f"please correct your Github server URL via base_url: Github(base_url=...)" + ) + if o.path == url: + port = ":" + str(self.__port) if self.__port is not None else "" + requested_location = f"{self.__scheme}://{self.__hostname}{port}{url}" + raise RuntimeError( + f"Requested {requested_location} but server redirected to {location}, " + f"you may need to correct your Github server URL " + f"via base_url: Github(base_url=...)" + ) + if self._logger.isEnabledFor(logging.INFO): + self._logger.info(f"Following Github server redirection from {url} to {o.path}") + return self.__requestRaw(original_cnx, verb, o.path, requestHeaders, input, stream=stream) + if status == 302 and follow_302_redirect and "location" in responseHeaders: + location = responseHeaders["location"] + o = urllib.parse.urlparse(location) + cnx = self.__customConnection(location) + path = self.__makeAbsoluteUrl(location) + if self._logger.isEnabledFor(logging.DEBUG): + self._logger.debug(f"Following Github server redirection (302) from {url} to {o.path}") + # remove auth to not leak authentication to redirection location + if o.hostname != self.__hostname: + del requestHeaders["Authorization"] + return self.__requestRaw( + cnx, verb, path, requestHeaders, input, stream=stream, follow_302_redirect=True + ) + return status, responseHeaders, output + finally: + # we record the time of this request after it finished + # to defer next request starting from this request's end, not start + self.__recordRequestTime(verb) + + def __deferRequest(self, verb: str) -> None: + # Ensures at least self.__seconds_between_requests seconds have passed since any last request + # and self.__seconds_between_writes seconds have passed since last write request (if verb refers to a write). + # Uses self.__last_requests. + requests = self.__last_requests.values() + writes = [l for v, l in self.__last_requests.items() if v != "GET"] + + last_request = max(requests) if requests else 0 + last_write = max(writes) if writes else 0 + + next_request = (last_request + self.__seconds_between_requests) if self.__seconds_between_requests else 0 + next_write = (last_write + self.__seconds_between_writes) if self.__seconds_between_writes else 0 + + next = next_request if verb == "GET" else max(next_request, next_write) + defer = max(next - datetime.now(timezone.utc).timestamp(), 0) + if defer > 0: + if self.__logger is None: + self.__logger = logging.getLogger(__name__) + self.__logger.debug(f"sleeping {defer}s before next GitHub request") + time.sleep(defer) + + def __recordRequestTime(self, verb: str) -> None: + # Updates self.__last_requests with current timestamp for given verb + self.__last_requests[verb] = datetime.now(timezone.utc).timestamp() + + def __makeAbsoluteUrl(self, url: str) -> str: + # URLs generated locally will be relative to __base_url + # URLs returned from the server will start with __base_url + if url.startswith("/"): + url = f"{self.__prefix}{url}" + else: + o = urllib.parse.urlparse(url) + assert o.hostname in [ + self.__hostname, + "uploads.github.com", + "status.github.com", + "github.com", + "objects.githubusercontent.com", + ], o.hostname + assert o.path.startswith((self.__prefix, self.__graphql_prefix, "/api/", "/login/oauth")), o.path + assert o.port == self.__port, o.port + url = o.path + if o.query != "": + url += f"?{o.query}" + return url + + def __createConnection( + self, hostname: Optional[str] = None + ) -> Union[HTTPRequestsConnectionClass, HTTPSRequestsConnectionClass]: + if self.__persist and self.__connection is not None and hostname is not None and hostname == self.__hostname: + return self.__connection + + with self.__connection_lock: + if self.__connection is not None and hostname is not None and hostname == self.__hostname: + if self.__persist: + return self.__connection + if self.__connection is not None: + self.__connection.close() + self.__connection = None + self.__connection = self.__connectionClass( + hostname if hostname is not None else self.__hostname, + self.__port, + retry=self.__retry, + pool_size=self.__pool_size, + timeout=self.__timeout, + verify=self.__verify, + ) + + return self.__connection + + @property + def _logger(self) -> logging.Logger: + if self.__logger is None: + self.__logger = logging.getLogger(__name__) + return self.__logger + + def __log( + self, + verb: str, + url: str, + requestHeaders: Dict[str, str], + input: Optional[Any], + status: Optional[int], + responseHeaders: Dict[str, Any], + output: Optional[Union[str, object]], + ) -> None: + if self._logger.isEnabledFor(logging.DEBUG): + headersForRequest = requestHeaders.copy() + if self.__auth: + self.__auth.mask_authentication(headersForRequest) + self._logger.debug( + "%s %s://%s%s %s %s ==> %i %s %s", + verb, + self.__scheme, + self.__hostname, + url, + headersForRequest, + input, + status, + responseHeaders, + output if isinstance(output, str) else "stream", + ) + + +class WithRequester(Generic[T]): + """ + Mixin class that allows to set a requester. + """ + + __requester: Requester + + def __init__(self) -> None: + self.__requester: Optional[Requester] = None # type: ignore + + @property + def requester(self) -> Requester: + return self.__requester + + def withRequester(self, requester: Requester) -> "WithRequester[T]": + assert isinstance(requester, Requester), requester + self.__requester = requester + return self diff --git a/venv/lib/python3.10/site-packages/github/RequiredPullRequestReviews.py b/venv/lib/python3.10/site-packages/github/RequiredPullRequestReviews.py new file mode 100644 index 0000000000000000000000000000000000000000..410e0e745c7cc2b1d8258c86fd690445533abdf9 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/RequiredPullRequestReviews.py @@ -0,0 +1,146 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2017 Jannis Gebauer # +# Copyright 2017 Simon # +# Copyright 2018 Steve Kowalik # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Mark Walker # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2024 Benjamin K <53038537+treee111@users.noreply.github.com> # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from typing import TYPE_CHECKING, Any + +import github.NamedUser +import github.Team +from github.GithubObject import Attribute, CompletableGithubObject, NotSet + +if TYPE_CHECKING: + from github.NamedUser import NamedUser + from github.Team import Team + + +class RequiredPullRequestReviews(CompletableGithubObject): + """ + This class represents Required Pull Request Reviews. + + The reference can be found here + https://docs.github.com/en/rest/reference/repos#get-pull-request-review-protection + + The OpenAPI schema can be found at + - /components/schemas/protected-branch-pull-request-review + - /components/schemas/protected-branch/properties/required_pull_request_reviews + + """ + + def _initAttributes(self) -> None: + self._dismiss_stale_reviews: Attribute[bool] = NotSet + self._require_code_owner_reviews: Attribute[bool] = NotSet + self._require_last_push_approval: Attribute[bool] = NotSet + self._required_approving_review_count: Attribute[int] = NotSet + self._teams: Attribute[list[Team]] = NotSet + self._users: Attribute[list[NamedUser]] = NotSet + + def __repr__(self) -> str: + return self.get__repr__( + { + "url": self._url.value, + "dismiss_stale_reviews": self._dismiss_stale_reviews.value, + "require_code_owner_reviews": self._require_code_owner_reviews.value, + "require_last_push_approval": self._require_last_push_approval.value, + } + ) + + @property + def dismiss_stale_reviews(self) -> bool: + self._completeIfNotSet(self._dismiss_stale_reviews) + return self._dismiss_stale_reviews.value + + @property + def dismissal_teams(self) -> list[Team]: + self._completeIfNotSet(self._teams) + return self._teams.value + + @property + def dismissal_users(self) -> list[NamedUser]: + self._completeIfNotSet(self._users) + return self._users.value + + @property + def require_code_owner_reviews(self) -> bool: + self._completeIfNotSet(self._require_code_owner_reviews) + return self._require_code_owner_reviews.value + + @property + def require_last_push_approval(self) -> bool: + self._completeIfNotSet(self._require_last_push_approval) + return self._require_last_push_approval.value + + @property + def required_approving_review_count(self) -> int: + self._completeIfNotSet(self._required_approving_review_count) + return self._required_approving_review_count.value + + @property + def url(self) -> str: + self._completeIfNotSet(self._url) + return self._url.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "dismiss_stale_reviews" in attributes: # pragma no branch + self._dismiss_stale_reviews = self._makeBoolAttribute(attributes["dismiss_stale_reviews"]) + if "dismissal_restrictions" in attributes: # pragma no branch + if "users" in attributes["dismissal_restrictions"]: + self._users = self._makeListOfClassesAttribute( + github.NamedUser.NamedUser, + attributes["dismissal_restrictions"]["users"], + ) + if "teams" in attributes["dismissal_restrictions"]: # pragma no branch + self._teams = self._makeListOfClassesAttribute( + github.Team.Team, attributes["dismissal_restrictions"]["teams"] + ) + if "require_code_owner_reviews" in attributes: # pragma no branch + self._require_code_owner_reviews = self._makeBoolAttribute(attributes["require_code_owner_reviews"]) + if "require_last_push_approval" in attributes: # pragma no branch + self._require_last_push_approval = self._makeBoolAttribute(attributes["require_last_push_approval"]) + if "required_approving_review_count" in attributes: # pragma no branch + self._required_approving_review_count = self._makeIntAttribute( + attributes["required_approving_review_count"] + ) + if "url" in attributes: # pragma no branch + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/venv/lib/python3.10/site-packages/github/RequiredStatusChecks.py b/venv/lib/python3.10/site-packages/github/RequiredStatusChecks.py new file mode 100644 index 0000000000000000000000000000000000000000..13bd5d962b40f4e727e9dbb41c736a89cf51c8c0 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/RequiredStatusChecks.py @@ -0,0 +1,92 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Steve Kowalik # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Mark Walker # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from typing import Any + +from github.GithubObject import Attribute, CompletableGithubObject, NotSet + + +class RequiredStatusChecks(CompletableGithubObject): + """ + This class represents Required Status Checks. + + The reference can be found here + https://docs.github.com/en/rest/reference/repos#get-status-checks-protection + + The OpenAPI schema can be found at + - /components/schemas/protected-branch-pull-request-review + - /components/schemas/protected-branch-required-status-check + - /components/schemas/status-check-policy + + """ + + def _initAttributes(self) -> None: + self._contexts: Attribute[list[str]] = NotSet + self._strict: Attribute[bool] = NotSet + self._url: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"strict": self._strict.value, "url": self._url.value}) + + @property + def contexts(self) -> list[str]: + self._completeIfNotSet(self._contexts) + return self._contexts.value + + @property + def strict(self) -> bool: + self._completeIfNotSet(self._strict) + return self._strict.value + + @property + def url(self) -> str: + self._completeIfNotSet(self._url) + return self._url.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "contexts" in attributes: # pragma no branch + self._contexts = self._makeListOfStringsAttribute(attributes["contexts"]) + if "strict" in attributes: # pragma no branch + self._strict = self._makeBoolAttribute(attributes["strict"]) + if "url" in attributes: # pragma no branch + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/venv/lib/python3.10/site-packages/github/Secret.py b/venv/lib/python3.10/site-packages/github/Secret.py new file mode 100644 index 0000000000000000000000000000000000000000..82901aa4f494199537a291d869421d19964f1b76 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/Secret.py @@ -0,0 +1,124 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2023 Andrew Dawes <53574062+AndrewJDawes@users.noreply.github.com> # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Mauricio Alejandro Martínez Pacheco # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from datetime import datetime +from typing import Any, Dict + +from github.GithubObject import Attribute, CompletableGithubObject, NotSet + + +class Secret(CompletableGithubObject): + """ + This class represents a GitHub secret. + + The reference can be found here + https://docs.github.com/en/rest/actions/secrets + + """ + + def _initAttributes(self) -> None: + self._created_at: Attribute[datetime] = NotSet + self._name: Attribute[str] = NotSet + self._secrets_url: Attribute[str] = NotSet + self._updated_at: Attribute[datetime] = NotSet + self._url: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"name": self.name}) + + @property + def created_at(self) -> datetime: + """ + :type: datetime.datetime + """ + self._completeIfNotSet(self._created_at) + return self._created_at.value + + @property + def name(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._name) + return self._name.value + + @property + def secrets_url(self) -> str: + """ + :type: string + """ + return self._secrets_url.value + + @property + def updated_at(self) -> datetime: + """ + :type: datetime.datetime + """ + self._completeIfNotSet(self._updated_at) + return self._updated_at.value + + @property + def url(self) -> str: + """ + :type: string + """ + # Construct url from secrets_url and name, if self._url. is not set + if self._url is NotSet: + self._url = self._makeStringAttribute(self.secrets_url + "/" + self.name) + return self._url.value + + def delete(self) -> None: + """ + :calls: `DELETE {secret_url} `_ + :rtype: None + """ + self._requester.requestJsonAndCheck("DELETE", self.url) + + def _useAttributes(self, attributes: Dict[str, Any]) -> None: + if "created_at" in attributes: + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) + if "name" in attributes: + self._name = self._makeStringAttribute(attributes["name"]) + if "secrets_url" in attributes: + self._secrets_url = self._makeStringAttribute(attributes["secrets_url"]) + if "updated_at" in attributes: + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) + if "url" in attributes: + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/venv/lib/python3.10/site-packages/github/SecurityAndAnalysis.py b/venv/lib/python3.10/site-packages/github/SecurityAndAnalysis.py new file mode 100644 index 0000000000000000000000000000000000000000..00fae0702562b2f2c06954b5d19533fe2ca877d0 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/SecurityAndAnalysis.py @@ -0,0 +1,141 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Mark Walker # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Nikolay Yurin # +# Copyright 2023 Trim21 # +# Copyright 2024 Caleb McCombs # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from typing import Any + +import github.SecurityAndAnalysisFeature +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + + +class SecurityAndAnalysis(NonCompletableGithubObject): + """ + This class represents Security and Analysis Settings. + + The OpenAPI schema can be found at + - /components/schemas/security-and-analysis + + """ + + def _initAttributes(self) -> None: + self._advanced_security: Attribute[github.SecurityAndAnalysisFeature.SecurityAndAnalysisFeature] = NotSet + self._dependabot_security_updates: Attribute[ + github.SecurityAndAnalysisFeature.SecurityAndAnalysisFeature + ] = NotSet + self._secret_scanning: Attribute[github.SecurityAndAnalysisFeature.SecurityAndAnalysisFeature] = NotSet + self._secret_scanning_ai_detection: Attribute[str] = NotSet + self._secret_scanning_non_provider_patterns: Attribute[ + github.SecurityAndAnalysisFeature.SecurityAndAnalysisFeature + ] = NotSet + self._secret_scanning_push_protection: Attribute[ + github.SecurityAndAnalysisFeature.SecurityAndAnalysisFeature + ] = NotSet + self._secret_scanning_validity_checks: Attribute[ + github.SecurityAndAnalysisFeature.SecurityAndAnalysisFeature + ] = NotSet + + def __repr__(self) -> str: + repr_attributes = { + "advanced_security": repr(self._advanced_security.value), + "dependabot_security_updates": repr(self._dependabot_security_updates.value), + "secret_scanning": repr(self._secret_scanning.value), + "secret_scanning_non_provider_patterns": repr(self._secret_scanning_non_provider_patterns.value), + "secret_scanning_push_protection": repr(self._secret_scanning_push_protection.value), + "secret_scanning_validity_checks": repr(self._secret_scanning_validity_checks.value), + } + + return self.get__repr__(repr_attributes) + + @property + def advanced_security(self) -> github.SecurityAndAnalysisFeature.SecurityAndAnalysisFeature: + return self._advanced_security.value + + @property + def dependabot_security_updates(self) -> github.SecurityAndAnalysisFeature.SecurityAndAnalysisFeature: + return self._dependabot_security_updates.value + + @property + def secret_scanning(self) -> github.SecurityAndAnalysisFeature.SecurityAndAnalysisFeature: + return self._secret_scanning.value + + @property + def secret_scanning_ai_detection(self) -> str: + return self._secret_scanning_ai_detection.value + + @property + def secret_scanning_non_provider_patterns(self) -> github.SecurityAndAnalysisFeature.SecurityAndAnalysisFeature: + return self._secret_scanning_non_provider_patterns.value + + @property + def secret_scanning_push_protection(self) -> github.SecurityAndAnalysisFeature.SecurityAndAnalysisFeature: + return self._secret_scanning_push_protection.value + + @property + def secret_scanning_validity_checks(self) -> github.SecurityAndAnalysisFeature.SecurityAndAnalysisFeature: + return self._secret_scanning_validity_checks.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "advanced_security" in attributes: # pragma no branch + self._advanced_security = self._makeClassAttribute( + github.SecurityAndAnalysisFeature.SecurityAndAnalysisFeature, attributes["advanced_security"] + ) + if "dependabot_security_updates" in attributes: # pragma no branch + self._dependabot_security_updates = self._makeClassAttribute( + github.SecurityAndAnalysisFeature.SecurityAndAnalysisFeature, attributes["dependabot_security_updates"] + ) + if "secret_scanning" in attributes: # pragma no branch + self._secret_scanning = self._makeClassAttribute( + github.SecurityAndAnalysisFeature.SecurityAndAnalysisFeature, attributes["secret_scanning"] + ) + if "secret_scanning_ai_detection" in attributes: # pragma no branch + self._secret_scanning_ai_detection = self._makeStringAttribute(attributes["secret_scanning_ai_detection"]) + if "secret_scanning_non_provider_patterns" in attributes: # pragma no branch + self._secret_scanning_non_provider_patterns = self._makeClassAttribute( + github.SecurityAndAnalysisFeature.SecurityAndAnalysisFeature, + attributes["secret_scanning_non_provider_patterns"], + ) + if "secret_scanning_push_protection" in attributes: # pragma no branch + self._secret_scanning_push_protection = self._makeClassAttribute( + github.SecurityAndAnalysisFeature.SecurityAndAnalysisFeature, + attributes["secret_scanning_push_protection"], + ) diff --git a/venv/lib/python3.10/site-packages/github/SecurityAndAnalysisFeature.py b/venv/lib/python3.10/site-packages/github/SecurityAndAnalysisFeature.py new file mode 100644 index 0000000000000000000000000000000000000000..6ca84191a3f18bd65e776d1db7787b58cca61855 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/SecurityAndAnalysisFeature.py @@ -0,0 +1,70 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Trim21 # +# Copyright 2024 Caleb McCombs # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from typing import Any, Dict + +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + + +class SecurityAndAnalysisFeature(NonCompletableGithubObject): + """ + This class represents a Security and Analysis feature status. + + The OpenAPI schema can be found at + - /components/schemas/security-and-analysis/properties/advanced_security + - /components/schemas/security-and-analysis/properties/dependabot_security_updates + - /components/schemas/security-and-analysis/properties/secret_scanning + - /components/schemas/security-and-analysis/properties/secret_scanning_non_provider_patterns + - /components/schemas/security-and-analysis/properties/secret_scanning_push_protection + + """ + + def _initAttributes(self) -> None: + self._status: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"status": self._status.value}) + + @property + def status(self) -> str: + return self._status.value + + def _useAttributes(self, attributes: Dict[str, Any]) -> None: + if "status" in attributes: # pragma no branch + self._status = self._makeStringAttribute(attributes["status"]) diff --git a/venv/lib/python3.10/site-packages/github/SelfHostedActionsRunner.py b/venv/lib/python3.10/site-packages/github/SelfHostedActionsRunner.py new file mode 100644 index 0000000000000000000000000000000000000000..134b1c50486bd1892d7a2ed811a84e02c86b787d --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/SelfHostedActionsRunner.py @@ -0,0 +1,113 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2020 Victor Zeng # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from typing import Any + +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + + +class SelfHostedActionsRunner(NonCompletableGithubObject): + """ + This class represents Self-hosted GitHub Actions Runners. + + The reference can be found at + https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#self-hosted-runners + + The OpenAPI schema can be found at + - /components/schemas/runner + + """ + + def _initAttributes(self) -> None: + self._busy: Attribute[bool] = NotSet + self._id: Attribute[int] = NotSet + self._labels: Attribute[list[dict[str, int | str]]] = NotSet + self._name: Attribute[str] = NotSet + self._os: Attribute[str] = NotSet + self._runner_group_id: Attribute[int] = NotSet + self._status: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"name": self._name.value}) + + @property + def busy(self) -> bool: + return self._busy.value + + @property + def id(self) -> int: + return self._id.value + + @property + def labels(self) -> list[dict[str, int | str]]: + return self._labels.value + + @property + def name(self) -> str: + return self._name.value + + @property + def os(self) -> str: + return self._os.value + + @property + def runner_group_id(self) -> int: + return self._runner_group_id.value + + @property + def status(self) -> str: + return self._status.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "busy" in attributes: + self._busy = self._makeBoolAttribute(attributes["busy"]) + if "id" in attributes: # pragma no branch + self._id = self._makeIntAttribute(attributes["id"]) + if "labels" in attributes: + self._labels = self._makeListOfDictsAttribute(attributes["labels"]) + if "name" in attributes: # pragma no branch + self._name = self._makeStringAttribute(attributes["name"]) + if "os" in attributes: # pragma no branch + self._os = self._makeStringAttribute(attributes["os"]) + if "runner_group_id" in attributes: # pragma no branch + self._runner_group_id = self._makeIntAttribute(attributes["runner_group_id"]) + if "status" in attributes: # pragma no branch + self._status = self._makeStringAttribute(attributes["status"]) diff --git a/venv/lib/python3.10/site-packages/github/SourceImport.py b/venv/lib/python3.10/site-packages/github/SourceImport.py new file mode 100644 index 0000000000000000000000000000000000000000..6c73bd5b649c0b9e2c588b88c48cdb1c856a65b5 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/SourceImport.py @@ -0,0 +1,255 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2018 Hayden Fuss # +# Copyright 2018 Wan Liuyang # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Mark Walker # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from typing import Any + +from github import Consts +from github.GithubObject import Attribute, CompletableGithubObject, NotSet + + +class SourceImport(CompletableGithubObject): + """ + This class represents SourceImports. + + The reference can be found here + https://docs.github.com/en/rest/reference/migrations#source-imports + + The OpenAPI schema can be found at + - /components/schemas/import + + """ + + def _initAttributes(self) -> None: + self._authors_count: Attribute[int] = NotSet + self._authors_url: Attribute[str] = NotSet + self._commit_count: Attribute[int] = NotSet + self._error_message: Attribute[str] = NotSet + self._failed_step: Attribute[str] = NotSet + self._has_large_files: Attribute[bool] = NotSet + self._html_url: Attribute[str] = NotSet + self._import_percent: Attribute[int] = NotSet + self._large_files_count: Attribute[int] = NotSet + self._large_files_size: Attribute[int] = NotSet + self._message: Attribute[str] = NotSet + self._project_choices: Attribute[list[dict[str, Any]]] = NotSet + self._push_percent: Attribute[int] = NotSet + self._repository_url: Attribute[str] = NotSet + self._status: Attribute[str] = NotSet + self._status_text: Attribute[str] = NotSet + self._svc_root: Attribute[str] = NotSet + self._svn_root: Attribute[str] = NotSet + self._tfvc_project: Attribute[str] = NotSet + self._url: Attribute[str] = NotSet + self._use_lfs: Attribute[str] = NotSet + self._vcs: Attribute[str] = NotSet + self._vcs_url: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__( + { + "vcs_url": self._vcs_url.value, + "repository_url": self._repository_url.value, + "status": self._status.value, + "url": self._url.value, + } + ) + + @property + def authors_count(self) -> int: + self._completeIfNotSet(self._authors_count) + return self._authors_count.value + + @property + def authors_url(self) -> str: + self._completeIfNotSet(self._authors_url) + return self._authors_url.value + + @property + def commit_count(self) -> int: + self._completeIfNotSet(self._commit_count) + return self._commit_count.value + + @property + def error_message(self) -> str: + self._completeIfNotSet(self._error_message) + return self._error_message.value + + @property + def failed_step(self) -> str: + self._completeIfNotSet(self._failed_step) + return self._failed_step.value + + @property + def has_large_files(self) -> bool: + self._completeIfNotSet(self._has_large_files) + return self._has_large_files.value + + @property + def html_url(self) -> str: + self._completeIfNotSet(self._html_url) + return self._html_url.value + + @property + def import_percent(self) -> int: + self._completeIfNotSet(self._import_percent) + return self._import_percent.value + + @property + def large_files_count(self) -> int: + self._completeIfNotSet(self._large_files_count) + return self._large_files_count.value + + @property + def large_files_size(self) -> int: + self._completeIfNotSet(self._large_files_size) + return self._large_files_size.value + + @property + def message(self) -> str: + self._completeIfNotSet(self._message) + return self._message.value + + @property + def project_choices(self) -> list[dict[str, Any]]: + self._completeIfNotSet(self._project_choices) + return self._project_choices.value + + @property + def push_percent(self) -> int: + self._completeIfNotSet(self._push_percent) + return self._push_percent.value + + @property + def repository_url(self) -> str: + self._completeIfNotSet(self._repository_url) + return self._repository_url.value + + @property + def status(self) -> str: + self._completeIfNotSet(self._status) + return self._status.value + + @property + def status_text(self) -> str: + self._completeIfNotSet(self._status_text) + return self._status_text.value + + @property + def svc_root(self) -> str: + self._completeIfNotSet(self._svc_root) + return self._svc_root.value + + @property + def svn_root(self) -> str: + self._completeIfNotSet(self._svn_root) + return self._svn_root.value + + @property + def tfvc_project(self) -> str: + self._completeIfNotSet(self._tfvc_project) + return self._tfvc_project.value + + @property + def url(self) -> str: + self._completeIfNotSet(self._url) + return self._url.value + + @property + def use_lfs(self) -> str: + self._completeIfNotSet(self._use_lfs) + return self._use_lfs.value + + @property + def vcs(self) -> str: + self._completeIfNotSet(self._vcs) + return self._vcs.value + + @property + def vcs_url(self) -> str: + self._completeIfNotSet(self._vcs_url) + return self._vcs_url.value + + def update(self, additional_headers: None | dict[str, Any] = None) -> bool: + import_header = {"Accept": Consts.mediaTypeImportPreview} + return super().update(additional_headers=import_header) + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "authors_count" in attributes: # pragma no branch + self._authors_count = self._makeIntAttribute(attributes["authors_count"]) + if "authors_url" in attributes: # pragma no branch + self._authors_url = self._makeStringAttribute(attributes["authors_url"]) + if "commit_count" in attributes: # pragma no branch + self._commit_count = self._makeIntAttribute(attributes["commit_count"]) + if "error_message" in attributes: # pragma no branch + self._error_message = self._makeStringAttribute(attributes["error_message"]) + if "failed_step" in attributes: # pragma no branch + self._failed_step = self._makeStringAttribute(attributes["failed_step"]) + if "has_large_files" in attributes: # pragma no branch + self._has_large_files = self._makeBoolAttribute(attributes["has_large_files"]) + if "html_url" in attributes: # pragma no branch + self._html_url = self._makeStringAttribute(attributes["html_url"]) + if "import_percent" in attributes: # pragma no branch + self._import_percent = self._makeIntAttribute(attributes["import_percent"]) + if "large_files_count" in attributes: # pragma no branch + self._large_files_count = self._makeIntAttribute(attributes["large_files_count"]) + if "large_files_size" in attributes: # pragma no branch + self._large_files_size = self._makeIntAttribute(attributes["large_files_size"]) + if "message" in attributes: # pragma no branch + self._message = self._makeStringAttribute(attributes["message"]) + if "project_choices" in attributes: # pragma no branch + self._project_choices = self._makeListOfDictsAttribute(attributes["project_choices"]) + if "push_percent" in attributes: # pragma no branch + self._push_percent = self._makeIntAttribute(attributes["push_percent"]) + if "repository_url" in attributes: # pragma no branch + self._repository_url = self._makeStringAttribute(attributes["repository_url"]) + if "status" in attributes: # pragma no branch + self._status = self._makeStringAttribute(attributes["status"]) + if "status_text" in attributes: # pragma no branch + self._status_text = self._makeStringAttribute(attributes["status_text"]) + if "svc_root" in attributes: # pragma no branch + self._svc_root = self._makeStringAttribute(attributes["svc_root"]) + if "svn_root" in attributes: # pragma no branch + self._svn_root = self._makeStringAttribute(attributes["svn_root"]) + if "tfvc_project" in attributes: # pragma no branch + self._tfvc_project = self._makeStringAttribute(attributes["tfvc_project"]) + if "url" in attributes: # pragma no branch + self._url = self._makeStringAttribute(attributes["url"]) + if "use_lfs" in attributes: # pragma no branch + self._use_lfs = self._makeStringAttribute(attributes["use_lfs"]) + if "vcs" in attributes: # pragma no branch + self._vcs = self._makeStringAttribute(attributes["vcs"]) + if "vcs_url" in attributes: # pragma no branch + self._vcs_url = self._makeStringAttribute(attributes["vcs_url"]) diff --git a/venv/lib/python3.10/site-packages/github/Stargazer.py b/venv/lib/python3.10/site-packages/github/Stargazer.py new file mode 100644 index 0000000000000000000000000000000000000000..d8d3fe7b623625ed9094c125e81cd06f6185e6fb --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/Stargazer.py @@ -0,0 +1,87 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2013 martinqt # +# Copyright 2014 Vincent Jacques # +# Copyright 2015 Dan Vanderkam # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Mark Walker # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from datetime import datetime +from typing import TYPE_CHECKING, Any + +import github.NamedUser +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + +if TYPE_CHECKING: + from github.NamedUser import NamedUser + + +class Stargazer(NonCompletableGithubObject): + """ + This class represents Stargazers. + + The reference can be found here + https://docs.github.com/en/rest/reference/activity#starring + + """ + + def _initAttributes(self) -> None: + self._starred_at: Attribute[datetime] = NotSet + self._url: Attribute[str] = NotSet + self._user: Attribute[NamedUser] = NotSet + + def __repr__(self) -> str: + # this is not a type error, just we didn't type `NamedUser` yet. + # enable type checker here after we typed attribute of `NamedUser` + return self.get__repr__({"user": self._user.value._login.value}) # type: ignore + + @property + def starred_at(self) -> datetime: + return self._starred_at.value + + @property + def user(self) -> NamedUser: + return self._user.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "starred_at" in attributes: + self._starred_at = self._makeDatetimeAttribute(attributes["starred_at"]) + if "user" in attributes: + self._user = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["user"]) diff --git a/venv/lib/python3.10/site-packages/github/StatsCodeFrequency.py b/venv/lib/python3.10/site-packages/github/StatsCodeFrequency.py new file mode 100644 index 0000000000000000000000000000000000000000..871317a4960de015e224a7813919b5910d673f27 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/StatsCodeFrequency.py @@ -0,0 +1,79 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Mark Walker # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from datetime import datetime + +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + + +class StatsCodeFrequency(NonCompletableGithubObject): + """ + This class represents statistics of StatsCodeFrequencies. + + The reference can be found here + https://docs.github.com/en/rest/metrics/statistics?apiVersion=2022-11-28#get-the-weekly-commit-activity + + The OpenAPI schema can be found at + - /components/schemas/code-frequency-stat + + """ + + def _initAttributes(self) -> None: + self._additions: Attribute[int] = NotSet + self._deletions: Attribute[int] = NotSet + self._week: Attribute[datetime] = NotSet + + @property + def additions(self) -> int: + return self._additions.value + + @property + def deletions(self) -> int: + return self._deletions.value + + @property + def week(self) -> datetime: + return self._week.value + + def _useAttributes(self, attributes: tuple[int, int, int]) -> None: + self._week = self._makeTimestampAttribute(attributes[0]) + self._additions = self._makeIntAttribute(attributes[1]) + self._deletions = self._makeIntAttribute(attributes[2]) diff --git a/venv/lib/python3.10/site-packages/github/StatsCommitActivity.py b/venv/lib/python3.10/site-packages/github/StatsCommitActivity.py new file mode 100644 index 0000000000000000000000000000000000000000..63ece53fb8d112bf635d15093dc041d2efedcf5a --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/StatsCommitActivity.py @@ -0,0 +1,82 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Mark Walker # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from datetime import datetime +from typing import Any, Dict + +import github.GithubObject +from github.GithubObject import Attribute + + +class StatsCommitActivity(github.GithubObject.NonCompletableGithubObject): + """ + This class represents StatsCommitActivities. + + The reference can be found here + https://docs.github.com/en/rest/reference/repos#get-the-last-year-of-commit-activity + + The OpenAPI schema can be found at + - /components/schemas/commit-activity + + """ + + def _initAttributes(self) -> None: + self._days: Attribute[int] = github.GithubObject.NotSet + self._total: Attribute[int] = github.GithubObject.NotSet + self._week: Attribute[datetime] = github.GithubObject.NotSet + + @property + def days(self) -> int: + return self._days.value + + @property + def total(self) -> int: + return self._total.value + + @property + def week(self) -> datetime: + return self._week.value + + def _useAttributes(self, attributes: Dict[str, Any]) -> None: + if "days" in attributes: # pragma no branch + self._days = self._makeListOfIntsAttribute(attributes["days"]) + if "total" in attributes: # pragma no branch + self._total = self._makeIntAttribute(attributes["total"]) + if "week" in attributes: # pragma no branch + self._week = self._makeTimestampAttribute(attributes["week"]) diff --git a/venv/lib/python3.10/site-packages/github/StatsContributor.py b/venv/lib/python3.10/site-packages/github/StatsContributor.py new file mode 100644 index 0000000000000000000000000000000000000000..76da7d745c0e1d183d59e5fd459d7870ba1d54ba --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/StatsContributor.py @@ -0,0 +1,124 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Mark Walker # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from datetime import datetime +from typing import Any + +import github.GithubObject +import github.NamedUser +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + + +class StatsContributor(NonCompletableGithubObject): + """ + This class represents StatsContributors. + + The reference can be found here + https://docs.github.com/en/rest/reference/repos#get-all-contributor-commit-activity + + The OpenAPI schema can be found at + - /components/schemas/contributor-activity + + """ + + class Week(NonCompletableGithubObject): + """ + This class represents weekly statistics of a contributor. + + The OpenAPI schema can be found at + - /components/schemas/contributor-activity/properties/weeks/items + + """ + + def _initAttributes(self) -> None: + self._a: Attribute[int] = NotSet + self._c: Attribute[int] = NotSet + self._d: Attribute[int] = NotSet + self._w: Attribute[datetime] = NotSet + + @property + def a(self) -> int: + return self._a.value + + @property + def c(self) -> int: + return self._c.value + + @property + def d(self) -> int: + return self._d.value + + @property + def w(self) -> datetime: + return self._w.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "a" in attributes: # pragma no branch + self._a = self._makeIntAttribute(attributes["a"]) + if "c" in attributes: # pragma no branch + self._c = self._makeIntAttribute(attributes["c"]) + if "d" in attributes: # pragma no branch + self._d = self._makeIntAttribute(attributes["d"]) + if "w" in attributes: # pragma no branch + self._w = self._makeTimestampAttribute(attributes["w"]) + + def _initAttributes(self) -> None: + self._author: Attribute[github.NamedUser.NamedUser] = NotSet + self._total: Attribute[int] = NotSet + self._weeks: Attribute[list[StatsContributor.Week]] = NotSet + + @property + def author(self) -> github.NamedUser.NamedUser: + return self._author.value + + @property + def total(self) -> int: + return self._total.value + + @property + def weeks(self) -> list[Week]: + return self._weeks.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "author" in attributes: # pragma no branch + self._author = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["author"]) + if "total" in attributes: # pragma no branch + self._total = self._makeIntAttribute(attributes["total"]) + if "weeks" in attributes: # pragma no branch + self._weeks = self._makeListOfClassesAttribute(self.Week, attributes["weeks"]) diff --git a/venv/lib/python3.10/site-packages/github/StatsParticipation.py b/venv/lib/python3.10/site-packages/github/StatsParticipation.py new file mode 100644 index 0000000000000000000000000000000000000000..1ddb1207a0b112b32e71f3278985302f9ad3eae5 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/StatsParticipation.py @@ -0,0 +1,76 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Adam Baratz # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Mark Walker # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from typing import Any + +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + + +class StatsParticipation(NonCompletableGithubObject): + """ + This class represents StatsParticipations. + + The reference can be found here + https://docs.github.com/en/rest/reference/repos#get-the-weekly-commit-count + + The OpenAPI schema can be found at + - /components/schemas/participation-stats + + """ + + def _initAttributes(self) -> None: + self._all: Attribute[list[int]] = NotSet + self._owner: Attribute[list[int]] = NotSet + + @property + def all(self) -> list[int]: + return self._all.value + + @property + def owner(self) -> list[int]: + return self._owner.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "all" in attributes: # pragma no branch + self._all = self._makeListOfIntsAttribute(attributes["all"]) + if "owner" in attributes: # pragma no branch + self._owner = self._makeListOfIntsAttribute(attributes["owner"]) diff --git a/venv/lib/python3.10/site-packages/github/StatsPunchCard.py b/venv/lib/python3.10/site-packages/github/StatsPunchCard.py new file mode 100644 index 0000000000000000000000000000000000000000..97f0fe9069dae5b6b0f2ab81db9cda5b01331b2a --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/StatsPunchCard.py @@ -0,0 +1,72 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Adam Baratz # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Dominic Davis-Foster # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Mark Walker # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from typing import Any, Dict, Tuple + +import github.GithubObject +import github.NamedUser # TODO remove unused + + +class StatsPunchCard(github.GithubObject.NonCompletableGithubObject): + """ + This class represents StatsPunchCards. + + The reference can be found here + https://docs.github.com/en/rest/reference/repos#get-the-hourly-commit-count-for-each-day + + The OpenAPI schema can be found at + - /components/schemas/code-frequency-stat + + """ + + _dict: Dict[Tuple[int, int], int] + + def _initAttributes(self) -> None: + self._dict = {} + + def get(self, day: int, hour: int) -> int: + """ + Get a specific element. + """ + return self._dict[(day, hour)] + + def _useAttributes(self, attributes: Any) -> None: + for day, hour, commits in attributes: + self._dict[(day, hour)] = commits diff --git a/venv/lib/python3.10/site-packages/github/Tag.py b/venv/lib/python3.10/site-packages/github/Tag.py new file mode 100644 index 0000000000000000000000000000000000000000..c37a828318e98c28d01dec3b75895434e2362665 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/Tag.py @@ -0,0 +1,106 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2013 martinqt # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Mark Walker # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from typing import TYPE_CHECKING, Any + +import github.Commit +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + +if TYPE_CHECKING: + from github.Commit import Commit + + +class Tag(NonCompletableGithubObject): + """ + This class represents Tags. + + The reference can be found here + https://docs.github.com/en/rest/reference/repos#list-repository-tags + + The OpenAPI schema can be found at + - /components/schemas/tag + + """ + + def _initAttributes(self) -> None: + self._commit: Attribute[Commit] = NotSet + self._name: Attribute[str] = NotSet + self._node_id: Attribute[str] = NotSet + self._tarball_url: Attribute[str] = NotSet + self._zipball_url: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"name": self._name.value, "commit": self._commit.value}) + + @property + def commit(self) -> Commit: + return self._commit.value + + @property + def name(self) -> str: + return self._name.value + + @property + def node_id(self) -> str: + return self._node_id.value + + @property + def tarball_url(self) -> str: + return self._tarball_url.value + + @property + def zipball_url(self) -> str: + return self._zipball_url.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "commit" in attributes: # pragma no branch + self._commit = self._makeClassAttribute(github.Commit.Commit, attributes["commit"]) + if "name" in attributes: # pragma no branch + self._name = self._makeStringAttribute(attributes["name"]) + if "node_id" in attributes: # pragma no branch + self._node_id = self._makeStringAttribute(attributes["node_id"]) + if "tarball_url" in attributes: # pragma no branch + self._tarball_url = self._makeStringAttribute(attributes["tarball_url"]) + if "zipball_url" in attributes: # pragma no branch + self._zipball_url = self._makeStringAttribute(attributes["zipball_url"]) diff --git a/venv/lib/python3.10/site-packages/github/Team.py b/venv/lib/python3.10/site-packages/github/Team.py new file mode 100644 index 0000000000000000000000000000000000000000..6e32e9d6e7f1142e621c7700cba32d5df54d1940 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/Team.py @@ -0,0 +1,521 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2013 martinqt # +# Copyright 2014 Jan Orel # +# Copyright 2014 Vincent Jacques # +# Copyright 2015 Aron Culotta # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2016 mattjmorrison # +# Copyright 2018 Isuru Fernando # +# Copyright 2018 Jacopo Notarstefano # +# Copyright 2018 James D'Amato # +# Copyright 2018 Maarten Fonville # +# Copyright 2018 Manu Hortet # +# Copyright 2018 Michał Górny # +# Copyright 2018 Steve Kowalik # +# Copyright 2018 Tim Boring # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Adam Baratz # +# Copyright 2019 Shibasis Patel # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Adrian Bridgett <58699309+tl-adrian-bridgett@users.noreply.github.com># +# Copyright 2020 Andy Grunwald # +# Copyright 2020 Gilad Shefer # +# Copyright 2020 Steve Kowalik # +# Copyright 2020 Tal Machani <12785464+talmachani@users.noreply.github.com> # +# Copyright 2021 Mark Walker # +# Copyright 2021 Steve Kowalik # +# Copyright 2021 秋葉 # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Kevin Grandjean # +# Copyright 2023 Mark Amery # +# Copyright 2023 Trim21 # +# Copyright 2024 Andrii Kezikov # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +import urllib.parse +from datetime import datetime +from typing import TYPE_CHECKING, Any + +from deprecated import deprecated + +import github.NamedUser +import github.Organization +import github.PaginatedList +import github.Permissions +import github.Repository +import github.TeamDiscussion +from github import Consts +from github.GithubException import UnknownObjectException +from github.GithubObject import Attribute, CompletableGithubObject, NotSet, Opt + +if TYPE_CHECKING: + from github.Membership import Membership + from github.NamedUser import NamedUser + from github.Organization import Organization + from github.PaginatedList import PaginatedList + from github.Permissions import Permissions + from github.Repository import Repository + from github.TeamDiscussion import TeamDiscussion + + +class Team(CompletableGithubObject): + """ + This class represents Teams. + + The reference can be found here + https://docs.github.com/en/rest/reference/teams + + The OpenAPI schema can be found at + - /components/schemas/nullable-team-simple + - /components/schemas/team + - /components/schemas/team-full + - /components/schemas/team-simple + + """ + + def _initAttributes(self) -> None: + self._created_at: Attribute[datetime] = NotSet + self._description: Attribute[str] = NotSet + self._html_url: Attribute[str] = NotSet + self._id: Attribute[int] = NotSet + self._ldap_dn: Attribute[str] = NotSet + self._members_count: Attribute[int] = NotSet + self._members_url: Attribute[str] = NotSet + self._name: Attribute[str] = NotSet + self._node_id: Attribute[str] = NotSet + self._notification_setting: Attribute[str] = NotSet + self._organization: Attribute[Organization] = NotSet + self._parent: Attribute[github.Team.Team] = NotSet + self._permission: Attribute[str] = NotSet + self._permissions: Attribute[Permissions] = NotSet + self._privacy: Attribute[str] = NotSet + self._repos_count: Attribute[int] = NotSet + self._repositories_url: Attribute[str] = NotSet + self._slug: Attribute[str] = NotSet + self._updated_at: Attribute[datetime] = NotSet + self._url: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"id": self._id.value, "name": self._name.value}) + + @property + def _identity(self) -> int: + return self.id + + @property + def created_at(self) -> datetime: + self._completeIfNotSet(self._created_at) + return self._created_at.value + + @property + def description(self) -> str: + self._completeIfNotSet(self._description) + return self._description.value + + @property + def html_url(self) -> str: + self._completeIfNotSet(self._html_url) + return self._html_url.value + + @property + def id(self) -> int: + self._completeIfNotSet(self._id) + return self._id.value + + @property + def ldap_dn(self) -> str: + self._completeIfNotSet(self._ldap_dn) + return self._ldap_dn.value + + @property + def members_count(self) -> int: + self._completeIfNotSet(self._members_count) + return self._members_count.value + + @property + def members_url(self) -> str: + self._completeIfNotSet(self._members_url) + return self._members_url.value + + @property + def name(self) -> str: + self._completeIfNotSet(self._name) + return self._name.value + + @property + def node_id(self) -> str: + self._completeIfNotSet(self._node_id) + return self._node_id.value + + @property + def notification_setting(self) -> str: + self._completeIfNotSet(self._notification_setting) + return self._notification_setting.value + + @property + def organization(self) -> Organization: + self._completeIfNotSet(self._organization) + return self._organization.value + + @property + def parent(self) -> Team: + self._completeIfNotSet(self._parent) + return self._parent.value + + @property + def permission(self) -> str: + self._completeIfNotSet(self._permission) + return self._permission.value + + @property + def permissions(self) -> Permissions: + self._completeIfNotSet(self._permissions) + return self._permissions.value + + @property + def privacy(self) -> str: + self._completeIfNotSet(self._privacy) + return self._privacy.value + + @property + def repos_count(self) -> int: + self._completeIfNotSet(self._repos_count) + return self._repos_count.value + + @property + def repositories_url(self) -> str: + self._completeIfNotSet(self._repositories_url) + return self._repositories_url.value + + @property + def slug(self) -> str: + self._completeIfNotSet(self._slug) + return self._slug.value + + @property + def updated_at(self) -> datetime: + self._completeIfNotSet(self._updated_at) + return self._updated_at.value + + @property + def url(self) -> str: + self._completeIfNotSet(self._url) + return self._url.value + + def add_to_members(self, member: NamedUser) -> None: + """ + This API call is deprecated. Use `add_membership` instead. + https://docs.github.com/en/rest/reference/teams#add-or-update-team-membership-for-a-user-legacy + + :calls: `PUT /teams/{id}/members/{user} `_ + """ + assert isinstance(member, github.NamedUser.NamedUser), member + headers, data = self._requester.requestJsonAndCheck("PUT", f"{self.url}/members/{member._identity}") + + def add_membership(self, member: NamedUser, role: Opt[str] = NotSet) -> None: + """ + :calls: `PUT /teams/{id}/memberships/{user} `_ + """ + assert isinstance(member, github.NamedUser.NamedUser), member + assert role is NotSet or isinstance(role, str), role + if role is not NotSet: + assert role in ["member", "maintainer"] + put_parameters = { + "role": role, + } + else: + put_parameters = { + "role": "member", + } + headers, data = self._requester.requestJsonAndCheck( + "PUT", f"{self.url}/memberships/{member._identity}", input=put_parameters + ) + + def get_team_membership(self, member: str | NamedUser) -> Membership: + """ + :calls: `GET /orgs/{org}/memberships/team/{team_id}/{username} `_ + """ + assert isinstance(member, str) or isinstance(member, github.NamedUser.NamedUser), member + if isinstance(member, github.NamedUser.NamedUser): + member = member._identity + else: + member = urllib.parse.quote(member) + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/memberships/{member}") + return github.Membership.Membership(self._requester, headers, data, completed=True) + + def add_to_repos(self, repo: Repository) -> None: + """ + :calls: `PUT /teams/{id}/repos/{org}/{repo} `_ + """ + assert isinstance(repo, github.Repository.Repository), repo + headers, data = self._requester.requestJsonAndCheck("PUT", f"{self.url}/repos/{repo._identity}") + + def get_repo_permission(self, repo: Repository) -> Permissions | None: + """ + :calls: `GET /teams/{id}/repos/{org}/{repo} `_ + """ + assert isinstance(repo, github.Repository.Repository) or isinstance(repo, str), repo + if isinstance(repo, github.Repository.Repository): + repo = repo._identity # type: ignore + else: + repo = urllib.parse.quote(repo) + try: + headers, data = self._requester.requestJsonAndCheck( + "GET", + f"{self.url}/repos/{repo}", + headers={"Accept": Consts.teamRepositoryPermissions}, + ) + return github.Permissions.Permissions(self._requester, headers, data["permissions"]) + except UnknownObjectException: + return None + + @deprecated( + reason=""" + Team.set_repo_permission() is deprecated, use Team.update_team_repository() instead. + """ + ) + def set_repo_permission(self, repo: Repository, permission: str) -> None: + """ + :calls: `PUT /teams/{id}/repos/{org}/{repo} `_ + :param repo: :class:`github.Repository.Repository` + :param permission: string + :rtype: None + """ + + assert isinstance(repo, github.Repository.Repository), repo + put_parameters = { + "permission": permission, + } + headers, data = self._requester.requestJsonAndCheck( + "PUT", f"{self.url}/repos/{repo._identity}", input=put_parameters + ) + + def update_team_repository(self, repo: Repository, permission: str) -> bool: + """ + :calls: `PUT /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo} `_ + """ + assert isinstance(repo, github.Repository.Repository) or isinstance(repo, str), repo + assert isinstance(permission, str), permission + if isinstance(repo, github.Repository.Repository): + repo_url_param = repo._identity + else: + repo_url_param = urllib.parse.quote(repo) + put_parameters = { + "permission": permission, + } + status, _, _ = self._requester.requestJson( + "PUT", + f"{self.organization.url}/teams/{self.slug}/repos/{repo_url_param}", + input=put_parameters, + ) + return status == 204 + + def delete(self) -> None: + """ + :calls: `DELETE /teams/{id} `_ + """ + headers, data = self._requester.requestJsonAndCheck("DELETE", self.url) + + def edit( + self, + name: str, + description: Opt[str] = NotSet, + permission: Opt[str] = NotSet, + privacy: Opt[str] = NotSet, + parent_team_id: Opt[int] = NotSet, + notification_setting: Opt[str] = NotSet, + ) -> None: + """ + :calls: `PATCH /teams/{id} `_ + """ + assert isinstance(name, str), name + assert description is NotSet or isinstance(description, str), description + assert permission is NotSet or isinstance(permission, str), permission + assert privacy is NotSet or isinstance(privacy, str), privacy + assert parent_team_id is NotSet or isinstance(parent_team_id, (int, type(None))), parent_team_id + assert notification_setting in ["notifications_enabled", "notifications_disabled", NotSet], notification_setting + post_parameters = NotSet.remove_unset_items( + { + "name": name, + "description": description, + "permission": permission, + "privacy": privacy, + "parent_team_id": parent_team_id, + "notification_setting": notification_setting, + } + ) + + headers, data = self._requester.requestJsonAndCheck("PATCH", self.url, input=post_parameters) + self._useAttributes(data) + + def get_teams(self) -> PaginatedList[Team]: + """ + :calls: `GET /teams/{id}/teams `_ + """ + return github.PaginatedList.PaginatedList( + github.Team.Team, + self._requester, + f"{self.url}/teams", + None, + ) + + def get_discussions(self) -> PaginatedList[TeamDiscussion]: + """ + :calls: `GET /teams/{id}/discussions `_ + """ + return github.PaginatedList.PaginatedList( + github.TeamDiscussion.TeamDiscussion, + self._requester, + f"{self.url}/discussions", + None, + headers={"Accept": Consts.mediaTypeTeamDiscussionsPreview}, + ) + + def get_members(self, role: Opt[str] = NotSet) -> PaginatedList[NamedUser]: + """ + :calls: `GET /teams/{id}/members `_ + """ + assert role is NotSet or isinstance(role, str), role + url_parameters: dict[str, Any] = {} + if role is not NotSet: + assert role in ["member", "maintainer", "all"] + url_parameters["role"] = role + return github.PaginatedList.PaginatedList( + github.NamedUser.NamedUser, + self._requester, + f"{self.url}/members", + url_parameters, + ) + + def get_repos(self) -> PaginatedList[Repository]: + """ + :calls: `GET /teams/{id}/repos `_ + """ + return github.PaginatedList.PaginatedList( + github.Repository.Repository, self._requester, f"{self.url}/repos", None + ) + + def invitations(self) -> PaginatedList[NamedUser]: + """ + :calls: `GET /teams/{id}/invitations `_ + """ + return github.PaginatedList.PaginatedList( + github.NamedUser.NamedUser, + self._requester, + f"{self.url}/invitations", + None, + headers={"Accept": Consts.mediaTypeOrganizationInvitationPreview}, + ) + + def has_in_members(self, member: NamedUser) -> bool: + """ + :calls: `GET /teams/{id}/members/{user} `_ + """ + assert isinstance(member, github.NamedUser.NamedUser), member + status, headers, data = self._requester.requestJson("GET", f"{self.url}/members/{member._identity}") + return status == 204 + + def has_in_repos(self, repo: Repository) -> bool: + """ + :calls: `GET /teams/{id}/repos/{owner}/{repo} `_ + """ + assert isinstance(repo, github.Repository.Repository), repo + status, headers, data = self._requester.requestJson("GET", f"{self.url}/repos/{repo._identity}") + return status == 204 + + def remove_membership(self, member: NamedUser) -> None: + """ + :calls: `DELETE /teams/{team_id}/memberships/{username} `_ + """ + assert isinstance(member, github.NamedUser.NamedUser), member + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.url}/memberships/{member._identity}") + + def remove_from_members(self, member: NamedUser) -> None: + """ + This API call is deprecated. Use `remove_membership` instead: + https://docs.github.com/en/rest/reference/teams#add-or-update-team-membership-for-a-user-legacy + + :calls: `DELETE /teams/{id}/members/{user} `_ + """ + assert isinstance(member, github.NamedUser.NamedUser), member + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.url}/members/{member._identity}") + + def remove_from_repos(self, repo: Repository) -> None: + """ + :calls: `DELETE /teams/{id}/repos/{owner}/{repo} `_ + """ + assert isinstance(repo, github.Repository.Repository), repo + headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.url}/repos/{repo._identity}") + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "created_at" in attributes: # pragma no branch + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) + if "description" in attributes: # pragma no branch + self._description = self._makeStringAttribute(attributes["description"]) + if "html_url" in attributes: + self._html_url = self._makeStringAttribute(attributes["html_url"]) + if "id" in attributes: # pragma no branch + self._id = self._makeIntAttribute(attributes["id"]) + if "ldap_dn" in attributes: # pragma no branch + self._ldap_dn = self._makeStringAttribute(attributes["ldap_dn"]) + if "members_count" in attributes: # pragma no branch + self._members_count = self._makeIntAttribute(attributes["members_count"]) + if "members_url" in attributes: # pragma no branch + self._members_url = self._makeStringAttribute(attributes["members_url"]) + if "name" in attributes: # pragma no branch + self._name = self._makeStringAttribute(attributes["name"]) + if "node_id" in attributes: # pragma no branch + self._node_id = self._makeStringAttribute(attributes["node_id"]) + if "notification_setting" in attributes: # pragma no branch + self._notification_setting = self._makeStringAttribute(attributes["notification_setting"]) + if "organization" in attributes: # pragma no branch + self._organization = self._makeClassAttribute(github.Organization.Organization, attributes["organization"]) + if "parent" in attributes: # pragma no branch + self._parent = self._makeClassAttribute(github.Team.Team, attributes["parent"]) + if "permission" in attributes: # pragma no branch + self._permission = self._makeStringAttribute(attributes["permission"]) + if "permissions" in attributes: # pragma no branch + self._permissions = self._makeClassAttribute(github.Permissions.Permissions, attributes["permissions"]) + if "privacy" in attributes: # pragma no branch + self._privacy = self._makeStringAttribute(attributes["privacy"]) + if "repos_count" in attributes: # pragma no branch + self._repos_count = self._makeIntAttribute(attributes["repos_count"]) + if "repositories_url" in attributes: # pragma no branch + self._repositories_url = self._makeStringAttribute(attributes["repositories_url"]) + if "slug" in attributes: # pragma no branch + self._slug = self._makeStringAttribute(attributes["slug"]) + if "updated_at" in attributes: # pragma no branch + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) + if "url" in attributes: # pragma no branch + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/venv/lib/python3.10/site-packages/github/TeamDiscussion.py b/venv/lib/python3.10/site-packages/github/TeamDiscussion.py new file mode 100644 index 0000000000000000000000000000000000000000..b3e0ca5ca4539d03c08c9f12f73322f226cc2613 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/TeamDiscussion.py @@ -0,0 +1,130 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2017 Chris McBride # +# Copyright 2017 Simon # +# Copyright 2018 Benoit Latinier # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 Yossarian King # +# Copyright 2018 sfdye # +# Copyright 2019 Adam Baratz # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from typing import Any + +from github.DiscussionBase import DiscussionBase +from github.GithubObject import Attribute, NotSet + + +class TeamDiscussion(DiscussionBase): + """ + This class represents TeamDiscussions. + + The reference can be found here + https://docs.github.com/en/rest/reference/teams#discussions + + """ + + def _initAttributes(self) -> None: + super()._initAttributes() + self._body_version: Attribute[str] = NotSet + self._comments_count: Attribute[int] = NotSet + self._comments_url: Attribute[str] = NotSet + self._html_url: Attribute[str] = NotSet + self._node_id: Attribute[str] = NotSet + self._pinned: Attribute[bool] = NotSet + self._private: Attribute[bool] = NotSet + self._team_url: Attribute[str] = NotSet + + @property + def body_version(self) -> str: + self._completeIfNotSet(self._body_version) + return self._body_version.value + + @property + def comments_count(self) -> int: + self._completeIfNotSet(self._comments_count) + return self._comments_count.value + + @property + def comments_url(self) -> str: + self._completeIfNotSet(self._comments_url) + return self._comments_url.value + + @property + def html_url(self) -> str: + self._completeIfNotSet(self._html_url) + return self._html_url.value + + @property + def node_id(self) -> str: + self._completeIfNotSet(self._node_id) + return self._node_id.value + + @property + def pinned(self) -> bool: + self._completeIfNotSet(self._pinned) + return self._pinned.value + + @property + def private(self) -> bool: + self._completeIfNotSet(self._private) + return self._private.value + + @property + def team_url(self) -> str: + self._completeIfNotSet(self._team_url) + return self._team_url.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + super()._useAttributes(attributes) + if "body_version" in attributes: # pragma no branch + self._body_version = self._makeStringAttribute(attributes["body_version"]) + if "comments_count" in attributes: # pragma no branch + self._comments_count = self._makeIntAttribute(attributes["comments_count"]) + if "comments_url" in attributes: # pragma no branch + self._comments_url = self._makeStringAttribute(attributes["comments_url"]) + if "html_url" in attributes: # pragma no branch + self._html_url = self._makeStringAttribute(attributes["html_url"]) + if "node_id" in attributes: # pragma no branch + self._node_id = self._makeStringAttribute(attributes["node_id"]) + if "pinned" in attributes: # pragma no branch + self._pinned = self._makeBoolAttribute(attributes["pinned"]) + if "private" in attributes: # pragma no branch + self._private = self._makeBoolAttribute(attributes["private"]) + if "team_url" in attributes: # pragma no branch + self._team_url = self._makeStringAttribute(attributes["team_url"]) diff --git a/venv/lib/python3.10/site-packages/github/TimelineEvent.py b/venv/lib/python3.10/site-packages/github/TimelineEvent.py new file mode 100644 index 0000000000000000000000000000000000000000..8d22cb765e03e1d9621b926908538728eb372795 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/TimelineEvent.py @@ -0,0 +1,154 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2017 Aaron Levine # +# Copyright 2017 Mike Miller # +# Copyright 2018 Darragh Bailey # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Nick Campbell # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from datetime import datetime +from typing import Any + +import github.GithubObject +import github.NamedUser +import github.TimelineEventSource +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + + +class TimelineEvent(NonCompletableGithubObject): + """ + This class represents IssueTimelineEvents. + + The reference can be found here + https://docs.github.com/en/rest/reference/issues#timeline + + """ + + def _initAttributes(self) -> None: + self._actor: Attribute[github.NamedUser.NamedUser] = NotSet + self._commit_id: Attribute[str] = NotSet + self._commit_url: Attribute[str] = NotSet + self._created_at: Attribute[datetime] = NotSet + self._event: Attribute[str] = NotSet + self._id: Attribute[int] = NotSet + self._node_id: Attribute[str] = NotSet + self._source: Attribute[github.TimelineEventSource.TimelineEventSource] = NotSet + self._url: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"id": self._id.value}) + + @property + def actor(self) -> github.NamedUser.NamedUser: + return self._actor.value + + @property + def author_association(self) -> str | None: + if self.event == "commented" and self._author_association is not NotSet: + return self._author_association.value + return None + + @property + def body(self) -> str | None: + if self.event == "commented" and self._body is not NotSet: + return self._body.value + return None + + @property + def commit_id(self) -> str: + return self._commit_id.value + + @property + def commit_url(self) -> str: + return self._commit_url.value + + @property + def created_at(self) -> datetime: + return self._created_at.value + + @property + def event(self) -> str: + return self._event.value + + @property + def id(self) -> int: + return self._id.value + + @property + def node_id(self) -> str: + return self._node_id.value + + @property + def source(self) -> github.TimelineEventSource.TimelineEventSource | None: + # only available on `cross-referenced` events. + if self.event == "cross-referenced" and self._source is not NotSet: + return self._source.value + return None + + @property + def url(self) -> str: + return self._url.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "actor" in attributes: # pragma no branch + self._actor = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["actor"]) + if "author_association" in attributes: # pragma no branch + self._author_association = self._makeStringAttribute(attributes["author_association"]) + if "body" in attributes: # pragma no branch + self._body = self._makeStringAttribute(attributes["body"]) + if "commit_id" in attributes: # pragma no branch + self._commit_id = self._makeStringAttribute(attributes["commit_id"]) + if "commit_url" in attributes: # pragma no branch + self._commit_url = self._makeStringAttribute(attributes["commit_url"]) + if "created_at" in attributes: # pragma no branch + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) + if "event" in attributes: # pragma no branch + self._event = self._makeStringAttribute(attributes["event"]) + if "id" in attributes: # pragma no branch + self._id = self._makeIntAttribute(attributes["id"]) + if "node_id" in attributes: # pragma no branch + self._node_id = self._makeStringAttribute(attributes["node_id"]) + if "source" in attributes: # pragma no branch + self._source = self._makeClassAttribute( + github.TimelineEventSource.TimelineEventSource, attributes["source"] + ) + if "url" in attributes: # pragma no branch + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/venv/lib/python3.10/site-packages/github/TimelineEventSource.py b/venv/lib/python3.10/site-packages/github/TimelineEventSource.py new file mode 100644 index 0000000000000000000000000000000000000000..9e76b5bfe25ebe12649ee3b5a779af160d94be8b --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/TimelineEventSource.py @@ -0,0 +1,80 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Adam Baratz # +# Copyright 2019 Nick Campbell # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from typing import TYPE_CHECKING, Any + +import github.Issue +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + +if TYPE_CHECKING: + from github.Issue import Issue + + +class TimelineEventSource(NonCompletableGithubObject): + """ + This class represents IssueTimelineEventSource. + + The reference can be found here + https://docs.github.com/en/rest/reference/issues#timeline + + """ + + def _initAttributes(self) -> None: + self._issue: Attribute[Issue] = NotSet + self._type: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"type": self._type.value}) + + @property + def issue(self) -> Issue: + return self._issue.value + + @property + def type(self) -> str: + return self._type.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "issue" in attributes: # pragma no branch + self._issue = self._makeClassAttribute(github.Issue.Issue, attributes["issue"]) + if "type" in attributes: # pragma no branch + self._type = self._makeStringAttribute(attributes["type"]) diff --git a/venv/lib/python3.10/site-packages/github/Topic.py b/venv/lib/python3.10/site-packages/github/Topic.py new file mode 100644 index 0000000000000000000000000000000000000000..2a07a5316290f5e60b20f1a36dde6c9fa0b24138 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/Topic.py @@ -0,0 +1,175 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Steve Kowalik # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Adam Baratz # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from datetime import datetime +from typing import Any + +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + + +class Topic(NonCompletableGithubObject): + """ + This class represents topics as used by https://github.com/topics. The object reference can be found here https://docs.github.com/en/rest/reference/search#search-topics + + The OpenAPI schema can be found at + - /components/schemas/topic-search-result-item + + """ + + def _initAttributes(self) -> None: + self._aliases: Attribute[list[dict[str, Any]]] = NotSet + self._created_at: Attribute[datetime] = NotSet + self._created_by: Attribute[str] = NotSet + self._curated: Attribute[bool] = NotSet + self._description: Attribute[str] = NotSet + self._display_name: Attribute[str] = NotSet + self._featured: Attribute[bool] = NotSet + self._logo_url: Attribute[str] = NotSet + self._name: Attribute[str] = NotSet + self._related: Attribute[list[dict[str, Any]]] = NotSet + self._released: Attribute[str] = NotSet + self._repository_count: Attribute[int] = NotSet + self._score: Attribute[float] = NotSet + self._short_description: Attribute[str] = NotSet + self._text_matches: Attribute[dict[str, Any]] = NotSet + self._updated_at: Attribute[datetime] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"name": self._name.value}) + + @property + def aliases(self) -> list[dict[str, Any]]: + return self._aliases.value + + @property + def created_at(self) -> datetime: + return self._created_at.value + + @property + def created_by(self) -> str: + return self._created_by.value + + @property + def curated(self) -> bool: + return self._curated.value + + @property + def description(self) -> str: + return self._description.value + + @property + def display_name(self) -> str: + return self._display_name.value + + @property + def featured(self) -> bool: + return self._featured.value + + @property + def logo_url(self) -> str: + return self._logo_url.value + + @property + def name(self) -> str: + return self._name.value + + @property + def related(self) -> list[dict[str, Any]]: + return self._related.value + + @property + def released(self) -> str: + return self._released.value + + @property + def repository_count(self) -> int: + return self._repository_count.value + + @property + def score(self) -> float: + return self._score.value + + @property + def short_description(self) -> str: + return self._short_description.value + + @property + def text_matches(self) -> dict[str, Any]: + return self._text_matches.value + + @property + def updated_at(self) -> datetime: + return self._updated_at.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "aliases" in attributes: # pragma no branch + self._aliases = self._makeListOfDictsAttribute(attributes["aliases"]) + if "created_at" in attributes: # pragma no branch + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) + if "created_by" in attributes: # pragma no branch + self._created_by = self._makeStringAttribute(attributes["created_by"]) + if "curated" in attributes: # pragma no branch + self._curated = self._makeBoolAttribute(attributes["curated"]) + if "description" in attributes: # pragma no branch + self._description = self._makeStringAttribute(attributes["description"]) + if "display_name" in attributes: # pragma no branch + self._display_name = self._makeStringAttribute(attributes["display_name"]) + if "featured" in attributes: # pragma no branch + self._featured = self._makeBoolAttribute(attributes["featured"]) + if "logo_url" in attributes: # pragma no branch + self._logo_url = self._makeStringAttribute(attributes["logo_url"]) + if "name" in attributes: # pragma no branch + self._name = self._makeStringAttribute(attributes["name"]) + if "related" in attributes: # pragma no branch + self._related = self._makeListOfDictsAttribute(attributes["related"]) + if "released" in attributes: # pragma no branch + self._released = self._makeStringAttribute(attributes["released"]) + if "repository_count" in attributes: # pragma no branch + self._repository_count = self._makeIntAttribute(attributes["repository_count"]) + if "score" in attributes: # pragma no branch + self._score = self._makeFloatAttribute(attributes["score"]) + if "short_description" in attributes: # pragma no branch + self._short_description = self._makeStringAttribute(attributes["short_description"]) + if "text_matches" in attributes: # pragma no branch + self._text_matches = self._makeDictAttribute(attributes["text_matches"]) + if "updated_at" in attributes: # pragma no branch + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) diff --git a/venv/lib/python3.10/site-packages/github/Traffic.py b/venv/lib/python3.10/site-packages/github/Traffic.py new file mode 100644 index 0000000000000000000000000000000000000000..629933ff55a08f8b93791be0e7b3ae0f48424e90 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/Traffic.py @@ -0,0 +1,93 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Justin Kufro # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from datetime import datetime +from typing import Any + +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + + +class Traffic(NonCompletableGithubObject): + """ + This class represents traffic information at a specific point in time. + + The reference can be found here + https://docs.github.com/en/rest/metrics/traffic + + The OpenAPI schema can be found at + - /components/schemas/traffic + + """ + + def _initAttributes(self) -> None: + self._count: Attribute[int] = NotSet + self._timestamp: Attribute[datetime] = NotSet + self._uniques: Attribute[int] = NotSet + + def __repr__(self) -> str: + return self.get__repr__( + { + "timestamp": self._timestamp.value, + "count": self._count.value, + "uniques": self._uniques.value, + } + ) + + @property + def count(self) -> int: + return self._count.value + + @property + def timestamp(self) -> datetime: + return self._timestamp.value + + @property + def uniques(self) -> int: + return self._uniques.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "count" in attributes: # pragma no branch + self._count = self._makeIntAttribute(attributes["count"]) + if "timestamp" in attributes: # pragma no branch + self._timestamp = self._makeDatetimeAttribute(attributes["timestamp"]) + if "uniques" in attributes: # pragma no branch + self._uniques = self._makeIntAttribute(attributes["uniques"]) diff --git a/venv/lib/python3.10/site-packages/github/UserKey.py b/venv/lib/python3.10/site-packages/github/UserKey.py new file mode 100644 index 0000000000000000000000000000000000000000..a5a878fabbc4f205e5e87484a4a4ef1ce941b371 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/UserKey.py @@ -0,0 +1,130 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2013 martinqt # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Mark Walker # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from datetime import datetime +from typing import Any + +from github.GithubObject import Attribute, CompletableGithubObject, NotSet + + +class UserKey(CompletableGithubObject): + """ + This class represents UserKeys. + + The reference can be found here + https://docs.github.com/en/rest/reference/users#keys + + The OpenAPI schema can be found at + - /components/schemas/key + + """ + + def _initAttributes(self) -> None: + self._created_at: Attribute[datetime] = NotSet + self._id: Attribute[int] = NotSet + self._key: Attribute[str] = NotSet + self._read_only: Attribute[bool] = NotSet + self._title: Attribute[str] = NotSet + self._url: Attribute[str] = NotSet + self._verified: Attribute[bool] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"id": self._id.value, "title": self._title.value}) + + @property + def created_at(self) -> datetime: + self._completeIfNotSet(self._created_at) + return self._created_at.value + + @property + def id(self) -> int: + self._completeIfNotSet(self._id) + return self._id.value + + @property + def key(self) -> str: + self._completeIfNotSet(self._key) + return self._key.value + + @property + def read_only(self) -> bool: + self._completeIfNotSet(self._read_only) + return self._read_only.value + + @property + def title(self) -> str: + self._completeIfNotSet(self._title) + return self._title.value + + @property + def url(self) -> str: + self._completeIfNotSet(self._url) + return self._url.value + + @property + def verified(self) -> bool: + self._completeIfNotSet(self._verified) + return self._verified.value + + def delete(self) -> None: + """ + :calls: `DELETE /user/keys/{id} `_ + :rtype: None + """ + headers, data = self._requester.requestJsonAndCheck("DELETE", self.url) + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "created_at" in attributes: # pragma no branch + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) + if "id" in attributes: # pragma no branch + self._id = self._makeIntAttribute(attributes["id"]) + if "key" in attributes: # pragma no branch + self._key = self._makeStringAttribute(attributes["key"]) + if "read_only" in attributes: # pragma no branch + self._read_only = self._makeBoolAttribute(attributes["read_only"]) + if "title" in attributes: # pragma no branch + self._title = self._makeStringAttribute(attributes["title"]) + if "url" in attributes: # pragma no branch + self._url = self._makeStringAttribute(attributes["url"]) + if "verified" in attributes: # pragma no branch + self._verified = self._makeBoolAttribute(attributes["verified"]) diff --git a/venv/lib/python3.10/site-packages/github/Variable.py b/venv/lib/python3.10/site-packages/github/Variable.py new file mode 100644 index 0000000000000000000000000000000000000000..6d69d268d3df2ec4c8402bf124c4549e3b72e790 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/Variable.py @@ -0,0 +1,143 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2023 Andrew Dawes <53574062+AndrewJDawes@users.noreply.github.com> # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Mauricio Alejandro Martínez Pacheco # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from datetime import datetime +from typing import Any + +from github.GithubObject import Attribute, CompletableGithubObject, NotSet + + +class Variable(CompletableGithubObject): + """ + This class represents a GitHub variable. + + The reference can be found here + https://docs.github.com/en/rest/actions/variables + + """ + + def _initAttributes(self) -> None: + self._created_at: Attribute[datetime] = NotSet + self._name: Attribute[str] = NotSet + self._updated_at: Attribute[datetime] = NotSet + self._url: Attribute[str] = NotSet + self._value: Attribute[str] = NotSet + self._variables_url: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"name": self.name}) + + @property + def created_at(self) -> datetime: + """ + :type: datetime.datetime + """ + self._completeIfNotSet(self._created_at) + return self._created_at.value + + @property + def name(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._name) + return self._name.value + + @property + def updated_at(self) -> datetime: + """ + :type: datetime.datetime + """ + self._completeIfNotSet(self._updated_at) + return self._updated_at.value + + @property + def url(self) -> str: + """ + :type: string + """ + # Construct url from variables_url and name, if self._url. is not set + if self._url is NotSet: + self._url = self._makeStringAttribute(self.variables_url + "/" + self.name) + return self._url.value + + @property + def value(self) -> str: + """ + :type: string + """ + self._completeIfNotSet(self._value) + return self._value.value + + @property + def variables_url(self) -> str: + """ + :type: string + """ + return self._variables_url.value + + def edit(self, value: str) -> bool: + """ + :calls: `PATCH /repos/{owner}/{repo}/actions/variables/{variable_name} `_ + :param variable_name: string + :param value: string + :rtype: bool + """ + assert isinstance(value, str), value + patch_parameters = { + "name": self.name, + "value": value, + } + status, _, _ = self._requester.requestJson( + "PATCH", + self.url, + input=patch_parameters, + ) + return status == 204 + + def delete(self) -> None: + """ + :calls: `DELETE {variable_url} `_ + :rtype: None + """ + self._requester.requestJsonAndCheck("DELETE", self.url) + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "created_at" in attributes: + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) + if "name" in attributes: + self._name = self._makeStringAttribute(attributes["name"]) + if "updated_at" in attributes: + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) + if "url" in attributes: + self._url = self._makeStringAttribute(attributes["url"]) + if "value" in attributes: + self._value = self._makeStringAttribute(attributes["value"]) + if "variables_url" in attributes: + self._variables_url = self._makeStringAttribute(attributes["variables_url"]) diff --git a/venv/lib/python3.10/site-packages/github/View.py b/venv/lib/python3.10/site-packages/github/View.py new file mode 100644 index 0000000000000000000000000000000000000000..133dfb1c963b2e4c144d016c32f6d523cbd0da02 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/View.py @@ -0,0 +1,95 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2018 Justin Kufro # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from typing import TYPE_CHECKING, Any + +import github.Traffic +from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet + +if TYPE_CHECKING: + from github.Traffic import Traffic + + +class View(NonCompletableGithubObject): + """ + This class represents the total number of views and breakdown per day or week for a GitHub repository. + + The reference can be found here + https://docs.github.com/en/rest/metrics/traffic#get-page-views + + The OpenAPI schema can be found at + - /components/schemas/view-traffic + + """ + + def _initAttributes(self) -> None: + self._count: Attribute[int] = NotSet + self._uniques: Attribute[int] = NotSet + self._views: Attribute[list[Traffic]] = NotSet + + def __repr__(self) -> str: + return self.get__repr__( + { + "count": self._count.value, + "uniques": self._uniques.value, + } + ) + + @property + def count(self) -> int: + return self._count.value + + @property + def uniques(self) -> int: + return self._uniques.value + + @property + def views(self) -> list[Traffic]: + return self._views.value + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "count" in attributes: # pragma no branch + self._count = self._makeIntAttribute(attributes["count"]) + if "uniques" in attributes: # pragma no branch + self._uniques = self._makeIntAttribute(attributes["uniques"]) + if "views" in attributes: # pragma no branch + self._views = self._makeListOfClassesAttribute(github.Traffic.Traffic, attributes["views"]) diff --git a/venv/lib/python3.10/site-packages/github/Workflow.py b/venv/lib/python3.10/site-packages/github/Workflow.py new file mode 100644 index 0000000000000000000000000000000000000000..280c98550ca79b51aa97511bc7edfeb725f2c1df --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/Workflow.py @@ -0,0 +1,257 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 AKFish # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2017 Jannis Gebauer # +# Copyright 2017 Simon # +# Copyright 2018 sfdye # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Mahesh Raju # +# Copyright 2020 Steve Kowalik # +# Copyright 2021 Steve Kowalik # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Thomas Burghout # +# Copyright 2023 Trim21 # +# Copyright 2023 sd-kialo <138505487+sd-kialo@users.noreply.github.com> # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# Copyright 2025 Nick McClorey <32378821+nickrmcclorey@users.noreply.github.com># +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from datetime import datetime +from typing import Any + +import github.Branch +import github.Commit +import github.GithubObject +import github.NamedUser +import github.Tag +import github.WorkflowRun +from github.GithubObject import Attribute, CompletableGithubObject, NotSet, Opt +from github.PaginatedList import PaginatedList + + +class Workflow(CompletableGithubObject): + """ + This class represents Workflows. + + The reference can be found here + https://docs.github.com/en/rest/reference/actions#workflows + + The OpenAPI schema can be found at + - /components/schemas/workflow + + """ + + def _initAttributes(self) -> None: + self._badge_url: Attribute[str] = NotSet + self._created_at: Attribute[datetime] = NotSet + self._deleted_at: Attribute[datetime] = NotSet + self._html_url: Attribute[str] = NotSet + self._id: Attribute[int] = NotSet + self._name: Attribute[str] = NotSet + self._node_id: Attribute[str] = NotSet + self._path: Attribute[str] = NotSet + self._state: Attribute[str] = NotSet + self._updated_at: Attribute[datetime] = NotSet + self._url: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"name": self._name.value, "url": self._url.value}) + + @property + def badge_url(self) -> str: + self._completeIfNotSet(self._badge_url) + return self._badge_url.value + + @property + def created_at(self) -> datetime: + self._completeIfNotSet(self._created_at) + return self._created_at.value + + @property + def deleted_at(self) -> datetime: + self._completeIfNotSet(self._deleted_at) + return self._deleted_at.value + + @property + def html_url(self) -> str: + self._completeIfNotSet(self._html_url) + return self._html_url.value + + @property + def id(self) -> int: + self._completeIfNotSet(self._id) + return self._id.value + + @property + def name(self) -> str: + self._completeIfNotSet(self._name) + return self._name.value + + @property + def node_id(self) -> str: + self._completeIfNotSet(self._node_id) + return self._node_id.value + + @property + def path(self) -> str: + self._completeIfNotSet(self._path) + return self._path.value + + @property + def state(self) -> str: + self._completeIfNotSet(self._state) + return self._state.value + + @property + def updated_at(self) -> datetime: + self._completeIfNotSet(self._updated_at) + return self._updated_at.value + + @property + def url(self) -> str: + self._completeIfNotSet(self._url) + return self._url.value + + def create_dispatch( + self, ref: github.Branch.Branch | github.Tag.Tag | github.Commit.Commit | str, inputs: Opt[dict] = NotSet + ) -> bool: + """ + :calls: `POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches `_ + """ + assert ( + isinstance(ref, github.Branch.Branch) + or isinstance(ref, github.Tag.Tag) + or isinstance(ref, github.Commit.Commit) + or isinstance(ref, str) + ), ref + assert inputs is NotSet or isinstance(inputs, dict), inputs + if isinstance(ref, github.Branch.Branch): + ref = ref.name + elif isinstance(ref, github.Commit.Commit): + ref = ref.sha + elif isinstance(ref, github.Tag.Tag): + ref = ref.name + if inputs is NotSet: + inputs = {} + status, _, _ = self._requester.requestJson( + "POST", f"{self.url}/dispatches", input={"ref": ref, "inputs": inputs} + ) + return status == 204 + + def get_runs( + self, + actor: Opt[github.NamedUser.NamedUser | str] = NotSet, + branch: Opt[github.Branch.Branch | str] = NotSet, + event: Opt[str] = NotSet, + status: Opt[str] = NotSet, + created: Opt[str] = NotSet, + exclude_pull_requests: Opt[bool] = NotSet, + check_suite_id: Opt[int] = NotSet, + head_sha: Opt[str] = NotSet, + ) -> PaginatedList[github.WorkflowRun.WorkflowRun]: + """ + :calls: `GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs `_ + """ + assert actor is NotSet or isinstance(actor, github.NamedUser.NamedUser) or isinstance(actor, str), actor + assert branch is NotSet or isinstance(branch, github.Branch.Branch) or isinstance(branch, str), branch + assert event is NotSet or isinstance(event, str), event + assert status is NotSet or isinstance(status, str), status + assert created is NotSet or isinstance(created, str), created + assert exclude_pull_requests is NotSet or isinstance(exclude_pull_requests, bool), exclude_pull_requests + assert check_suite_id is NotSet or isinstance(check_suite_id, int), check_suite_id + assert head_sha is NotSet or isinstance(head_sha, str), head_sha + url_parameters: dict[str, Any] = dict() + if actor is not NotSet: + url_parameters["actor"] = actor._identity if isinstance(actor, github.NamedUser.NamedUser) else actor + if branch is not NotSet: + url_parameters["branch"] = branch.name if isinstance(branch, github.Branch.Branch) else branch + if event is not NotSet: + url_parameters["event"] = event + if status is not NotSet: + url_parameters["status"] = status + if created is not NotSet: + url_parameters["created"] = created + if exclude_pull_requests is not NotSet: + url_parameters["exclude_pull_requests"] = exclude_pull_requests + if check_suite_id is not NotSet: + url_parameters["check_suite_id"] = check_suite_id + if head_sha is not NotSet: + url_parameters["head_sha"] = head_sha + + return PaginatedList( + github.WorkflowRun.WorkflowRun, + self._requester, + f"{self.url}/runs", + url_parameters, + headers=None, + list_item="workflow_runs", + ) + + def disable(self) -> bool: + """ + :calls: `PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/disable `_ + :rtype: bool + """ + status, _, _ = self._requester.requestJson("PUT", f"{self.url}/disable") + return status == 204 + + def enable(self) -> bool: + """ + :calls: `PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/enable `_ + :rtype: bool + """ + status, _, _ = self._requester.requestJson("PUT", f"{self.url}/enable") + return status == 204 + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "badge_url" in attributes: # pragma no branch + self._badge_url = self._makeStringAttribute(attributes["badge_url"]) + if "created_at" in attributes: # pragma no branch + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) + if "deleted_at" in attributes: # pragma no branch + self._deleted_at = self._makeDatetimeAttribute(attributes["deleted_at"]) + if "html_url" in attributes: # pragma no branch + self._html_url = self._makeStringAttribute(attributes["html_url"]) + if "id" in attributes: # pragma no branch + self._id = self._makeIntAttribute(attributes["id"]) + if "name" in attributes: # pragma no branch + self._name = self._makeStringAttribute(attributes["name"]) + if "node_id" in attributes: # pragma no branch + self._node_id = self._makeStringAttribute(attributes["node_id"]) + if "path" in attributes: # pragma no branch + self._path = self._makeStringAttribute(attributes["path"]) + if "state" in attributes: # pragma no branch + self._state = self._makeStringAttribute(attributes["state"]) + if "updated_at" in attributes: # pragma no branch + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) + if "url" in attributes: # pragma no branch + self._url = self._makeStringAttribute(attributes["url"]) diff --git a/venv/lib/python3.10/site-packages/github/WorkflowJob.py b/venv/lib/python3.10/site-packages/github/WorkflowJob.py new file mode 100644 index 0000000000000000000000000000000000000000..4d979ed9115ec5cbfab9e3242074249d15d26401 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/WorkflowJob.py @@ -0,0 +1,243 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jeppe Fihl-Pearson # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2024 Xavi Vega # +# Copyright 2025 Enrico Minack # +# Copyright 2025 Yossi Rozantsev <54272821+Apakottur@users.noreply.github.com> # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from datetime import datetime +from typing import Any + +import github.GithubObject +import github.WorkflowStep +from github.GithubObject import Attribute, CompletableGithubObject, NotSet + + +class WorkflowJob(CompletableGithubObject): + """ + This class represents Workflow Jobs. + + The reference can be found here + https://docs.github.com/en/rest/reference/actions#workflow-jobs + + """ + + def _initAttributes(self) -> None: + self._check_run_url: Attribute[str] = NotSet + self._completed_at: Attribute[datetime] = NotSet + self._conclusion: Attribute[str | None] = NotSet + self._created_at: Attribute[datetime] = NotSet + self._head_branch: Attribute[str] = NotSet + self._head_sha: Attribute[str] = NotSet + self._html_url: Attribute[str] = NotSet + self._id: Attribute[int] = NotSet + self._labels: Attribute[list[str]] = NotSet + self._name: Attribute[str] = NotSet + self._node_id: Attribute[str] = NotSet + self._run_attempt: Attribute[int] = NotSet + self._run_id: Attribute[int] = NotSet + self._run_url: Attribute[str] = NotSet + self._runner_group_id: Attribute[int] = NotSet + self._runner_group_name: Attribute[str] = NotSet + self._runner_id: Attribute[int] = NotSet + self._runner_name: Attribute[str] = NotSet + self._started_at: Attribute[datetime] = NotSet + self._status: Attribute[str] = NotSet + self._steps: Attribute[list[github.WorkflowStep.WorkflowStep]] = NotSet + self._url: Attribute[str] = NotSet + self._workflow_name: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"id": self._id.value, "url": self._url.value}) + + @property + def check_run_url(self) -> str: + self._completeIfNotSet(self._check_run_url) + return self._check_run_url.value + + @property + def completed_at(self) -> datetime: + self._completeIfNotSet(self._completed_at) + return self._completed_at.value + + @property + def conclusion(self) -> str | None: + self._completeIfNotSet(self._conclusion) + return self._conclusion.value + + @property + def created_at(self) -> datetime: + self._completeIfNotSet(self._created_at) + return self._created_at.value + + @property + def head_branch(self) -> str: + self._completeIfNotSet(self._head_branch) + return self._head_branch.value + + @property + def head_sha(self) -> str: + self._completeIfNotSet(self._head_sha) + return self._head_sha.value + + @property + def html_url(self) -> str: + self._completeIfNotSet(self._html_url) + return self._html_url.value + + @property + def id(self) -> int: + self._completeIfNotSet(self._id) + return self._id.value + + @property + def labels(self) -> list[str]: + self._completeIfNotSet(self._labels) + return self._labels.value + + @property + def name(self) -> str: + self._completeIfNotSet(self._name) + return self._name.value + + @property + def node_id(self) -> str: + self._completeIfNotSet(self._node_id) + return self._node_id.value + + @property + def run_attempt(self) -> int: + self._completeIfNotSet(self._run_attempt) + return self._run_attempt.value + + @property + def run_id(self) -> int: + self._completeIfNotSet(self._run_id) + return self._run_id.value + + @property + def run_url(self) -> str: + self._completeIfNotSet(self._run_url) + return self._run_url.value + + @property + def runner_group_id(self) -> int: + self._completeIfNotSet(self._runner_group_id) + return self._runner_group_id.value + + @property + def runner_group_name(self) -> str: + self._completeIfNotSet(self._runner_group_name) + return self._runner_group_name.value + + @property + def runner_id(self) -> int: + self._completeIfNotSet(self._runner_id) + return self._runner_id.value + + @property + def runner_name(self) -> str: + self._completeIfNotSet(self._runner_name) + return self._runner_name.value + + @property + def started_at(self) -> datetime: + self._completeIfNotSet(self._started_at) + return self._started_at.value + + @property + def status(self) -> str: + self._completeIfNotSet(self._status) + return self._status.value + + @property + def steps(self) -> list[github.WorkflowStep.WorkflowStep]: + self._completeIfNotSet(self._steps) + return self._steps.value + + @property + def url(self) -> str: + self._completeIfNotSet(self._url) + return self._url.value + + @property + def workflow_name(self) -> str: + self._completeIfNotSet(self._workflow_name) + return self._workflow_name.value + + def logs_url(self) -> str: + headers, _ = self._requester.requestBlobAndCheck("GET", f"{self.url}/logs") + return headers["location"] + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "check_run_url" in attributes: # pragma no branch + self._check_run_url = self._makeStringAttribute(attributes["check_run_url"]) + if "completed_at" in attributes: # pragma no branch + self._completed_at = self._makeDatetimeAttribute(attributes["completed_at"]) + if "conclusion" in attributes: # pragma no branch + self._conclusion = self._makeStringAttribute(attributes["conclusion"]) + if "created_at" in attributes: # pragma no branch + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) + if "head_branch" in attributes: # pragma no branch + self._head_branch = self._makeStringAttribute(attributes["head_branch"]) + if "head_sha" in attributes: # pragma no branch + self._head_sha = self._makeStringAttribute(attributes["head_sha"]) + if "html_url" in attributes: # pragma no branch + self._html_url = self._makeStringAttribute(attributes["html_url"]) + if "id" in attributes: # pragma no branch + self._id = self._makeIntAttribute(attributes["id"]) + if "labels" in attributes: # pragma no branch + self._labels = self._makeListOfStringsAttribute(attributes["labels"]) + if "name" in attributes: # pragma no branch + self._name = self._makeStringAttribute(attributes["name"]) + if "node_id" in attributes: # pragma no branch + self._node_id = self._makeStringAttribute(attributes["node_id"]) + if "run_attempt" in attributes: # pragma no branch + self._run_attempt = self._makeIntAttribute(attributes["run_attempt"]) + if "run_id" in attributes: # pragma no branch + self._run_id = self._makeIntAttribute(attributes["run_id"]) + if "run_url" in attributes: # pragma no branch + self._run_url = self._makeStringAttribute(attributes["run_url"]) + if "runner_group_id" in attributes: # pragma no branch + self._runner_group_id = self._makeIntAttribute(attributes["runner_group_id"]) + if "runner_group_name" in attributes: # pragma no branch + self._runner_group_name = self._makeStringAttribute(attributes["runner_group_name"]) + if "runner_id" in attributes: # pragma no branch + self._runner_id = self._makeIntAttribute(attributes["runner_id"]) + if "runner_name" in attributes: # pragma no branch + self._runner_name = self._makeStringAttribute(attributes["runner_name"]) + if "started_at" in attributes: # pragma no branch + self._started_at = self._makeDatetimeAttribute(attributes["started_at"]) + if "status" in attributes: # pragma no branch + self._status = self._makeStringAttribute(attributes["status"]) + if "steps" in attributes: # pragma no branch + self._steps = self._makeListOfClassesAttribute(github.WorkflowStep.WorkflowStep, attributes["steps"]) + if "url" in attributes: # pragma no branch + self._url = self._makeStringAttribute(attributes["url"]) + if "workflow_name" in attributes: # pragma no branch + self._workflow_name = self._makeStringAttribute(attributes["workflow_name"]) diff --git a/venv/lib/python3.10/site-packages/github/WorkflowRun.py b/venv/lib/python3.10/site-packages/github/WorkflowRun.py new file mode 100644 index 0000000000000000000000000000000000000000..928b930fcfb7648282aa609919671c9201312a28 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/WorkflowRun.py @@ -0,0 +1,448 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2020 Steve Kowalik # +# Copyright 2020 Yannick Jadoul # +# Copyright 2021 Steve Kowalik # +# Copyright 2022 Aleksei Fedotov # +# Copyright 2022 Gabriele Oliaro # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Jeppe Fihl-Pearson # +# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2023 Sasha Chung <50770626+nuang-ee@users.noreply.github.com> # +# Copyright 2023 Trim21 # +# Copyright 2024 Chris Gavin # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Geoffrey # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ + +from __future__ import annotations + +from datetime import datetime +from typing import TYPE_CHECKING, Any, NamedTuple + +import github.GitCommit +import github.NamedUser +import github.PullRequest +import github.Repository +import github.WorkflowJob +from github.GithubObject import Attribute, CompletableGithubObject, NotSet, Opt, is_optional +from github.PaginatedList import PaginatedList + +if TYPE_CHECKING: + from github.Artifact import Artifact + from github.GitCommit import GitCommit + from github.NamedUser import NamedUser + from github.PullRequest import PullRequest + from github.Repository import Repository + from github.WorkflowJob import WorkflowJob + + +class TimingData(NamedTuple): + billable: dict[str, dict[str, int]] + run_duration_ms: int + + +class WorkflowRun(CompletableGithubObject): + """ + This class represents Workflow Runs. + + The reference can be found here + https://docs.github.com/en/rest/reference/actions#workflow-runs + + The OpenAPI schema can be found at + - /components/schemas/artifact/properties/workflow_run + - /components/schemas/workflow-run + + """ + + def _initAttributes(self) -> None: + self._actor: Attribute[NamedUser] = NotSet + self._artifacts_url: Attribute[str] = NotSet + self._cancel_url: Attribute[str] = NotSet + self._check_suite_id: Attribute[int] = NotSet + self._check_suite_node_id: Attribute[str] = NotSet + self._check_suite_url: Attribute[str] = NotSet + self._conclusion: Attribute[str] = NotSet + self._created_at: Attribute[datetime] = NotSet + self._display_title: Attribute[str] = NotSet + self._event: Attribute[str] = NotSet + self._head_branch: Attribute[str] = NotSet + self._head_commit: Attribute[GitCommit] = NotSet + self._head_repository: Attribute[Repository] = NotSet + self._head_repository_id: Attribute[int] = NotSet + self._head_sha: Attribute[str] = NotSet + self._html_url: Attribute[str] = NotSet + self._id: Attribute[int] = NotSet + self._jobs_url: Attribute[str] = NotSet + self._logs_url: Attribute[str] = NotSet + self._name: Attribute[str] = NotSet + self._node_id: Attribute[str] = NotSet + self._path: Attribute[str] = NotSet + self._previous_attempt_url: Attribute[str] = NotSet + self._pull_requests: Attribute[list[PullRequest]] = NotSet + self._referenced_workflows: Attribute[list[dict[str, Any]]] = NotSet + self._repository: Attribute[Repository] = NotSet + self._repository_id: Attribute[int] = NotSet + self._rerun_url: Attribute[str] = NotSet + self._run_attempt: Attribute[int] = NotSet + self._run_number: Attribute[int] = NotSet + self._run_started_at: Attribute[datetime] = NotSet + self._status: Attribute[str] = NotSet + self._triggering_actor: Attribute[NamedUser] = NotSet + self._updated_at: Attribute[datetime] = NotSet + self._url: Attribute[str] = NotSet + self._workflow_id: Attribute[int] = NotSet + self._workflow_url: Attribute[str] = NotSet + + def __repr__(self) -> str: + return self.get__repr__({"id": self._id.value, "url": self._url.value}) + + @property + def actor(self) -> NamedUser: + self._completeIfNotSet(self._actor) + return self._actor.value + + @property + def artifacts_url(self) -> str: + self._completeIfNotSet(self._artifacts_url) + return self._artifacts_url.value + + @property + def cancel_url(self) -> str: + self._completeIfNotSet(self._cancel_url) + return self._cancel_url.value + + @property + def check_suite_id(self) -> int: + self._completeIfNotSet(self._check_suite_id) + return self._check_suite_id.value + + @property + def check_suite_node_id(self) -> str: + self._completeIfNotSet(self._check_suite_node_id) + return self._check_suite_node_id.value + + @property + def check_suite_url(self) -> str: + self._completeIfNotSet(self._check_suite_url) + return self._check_suite_url.value + + @property + def conclusion(self) -> str: + self._completeIfNotSet(self._conclusion) + return self._conclusion.value + + @property + def created_at(self) -> datetime: + self._completeIfNotSet(self._created_at) + return self._created_at.value + + @property + def display_title(self) -> str: + self._completeIfNotSet(self._display_title) + return self._display_title.value + + @property + def event(self) -> str: + self._completeIfNotSet(self._event) + return self._event.value + + @property + def head_branch(self) -> str: + self._completeIfNotSet(self._head_branch) + return self._head_branch.value + + @property + def head_commit(self) -> GitCommit: + self._completeIfNotSet(self._head_commit) + return self._head_commit.value + + @property + def head_repository(self) -> Repository: + self._completeIfNotSet(self._head_repository) + return self._head_repository.value + + @property + def head_repository_id(self) -> int: + self._completeIfNotSet(self._head_repository_id) + return self._head_repository_id.value + + @property + def head_sha(self) -> str: + self._completeIfNotSet(self._head_sha) + return self._head_sha.value + + @property + def html_url(self) -> str: + self._completeIfNotSet(self._html_url) + return self._html_url.value + + @property + def id(self) -> int: + self._completeIfNotSet(self._id) + return self._id.value + + @property + def jobs_url(self) -> str: + self._completeIfNotSet(self._jobs_url) + return self._jobs_url.value + + @property + def logs_url(self) -> str: + self._completeIfNotSet(self._logs_url) + return self._logs_url.value + + @property + def name(self) -> str: + self._completeIfNotSet(self._name) + return self._name.value + + @property + def node_id(self) -> str: + self._completeIfNotSet(self._node_id) + return self._node_id.value + + @property + def path(self) -> str: + self._completeIfNotSet(self._path) + return self._path.value + + @property + def previous_attempt_url(self) -> str: + self._completeIfNotSet(self._previous_attempt_url) + return self._previous_attempt_url.value + + @property + def pull_requests(self) -> list[PullRequest]: + self._completeIfNotSet(self._pull_requests) + return self._pull_requests.value + + @property + def referenced_workflows(self) -> list[dict[str, Any]]: + self._completeIfNotSet(self._referenced_workflows) + return self._referenced_workflows.value + + @property + def repository(self) -> Repository: + self._completeIfNotSet(self._repository) + return self._repository.value + + @property + def repository_id(self) -> int: + self._completeIfNotSet(self._repository_id) + return self._repository_id.value + + @property + def rerun_url(self) -> str: + self._completeIfNotSet(self._rerun_url) + return self._rerun_url.value + + @property + def run_attempt(self) -> int: + self._completeIfNotSet(self._run_attempt) + return self._run_attempt.value + + @property + def run_number(self) -> int: + self._completeIfNotSet(self._run_number) + return self._run_number.value + + @property + def run_started_at(self) -> datetime: + self._completeIfNotSet(self._run_started_at) + return self._run_started_at.value + + @property + def status(self) -> str: + self._completeIfNotSet(self._status) + return self._status.value + + @property + def triggering_actor(self) -> github.NamedUser.NamedUser: + self._completeIfNotSet(self._triggering_actor) + return self._triggering_actor.value + + @property + def updated_at(self) -> datetime: + self._completeIfNotSet(self._updated_at) + return self._updated_at.value + + @property + def url(self) -> str: + self._completeIfNotSet(self._url) + return self._url.value + + @property + def workflow_id(self) -> int: + self._completeIfNotSet(self._workflow_id) + return self._workflow_id.value + + @property + def workflow_url(self) -> str: + self._completeIfNotSet(self._workflow_url) + return self._workflow_url.value + + def get_artifacts(self) -> PaginatedList[Artifact]: + return PaginatedList( + github.Artifact.Artifact, + self._requester, + self._artifacts_url.value, + None, + list_item="artifacts", + ) + + def cancel(self) -> bool: + """ + :calls: `POST /repos/{owner}/{repo}/actions/runs/{run_id}/cancel `_ + """ + status, _, _ = self._requester.requestJson("POST", self.cancel_url) + return status == 202 + + def rerun(self) -> bool: + """ + :calls: `POST /repos/{owner}/{repo}/actions/runs/{run_id}/rerun `_ + """ + status, _, _ = self._requester.requestJson("POST", self.rerun_url) + return status == 201 + + def rerun_failed_jobs(self) -> bool: + """ + :calls: `POST /repos/{owner}/{repo}/actions/runs/{run_id}/rerun-failed-jobs `_ + """ + status, _, _ = self._requester.requestJson("POST", f"{self.url}/rerun-failed-jobs") + return status == 201 + + def timing(self) -> TimingData: + """ + :calls: `GET /repos/{owner}/{repo}/actions/runs/{run_id}/timing `_ + """ + headers, data = self._requester.requestJsonAndCheck("GET", f"{self.url}/timing") + return TimingData(billable=data["billable"], run_duration_ms=data["run_duration_ms"]) # type: ignore + + def delete(self) -> bool: + """ + :calls: `DELETE /repos/{owner}/{repo}/actions/runs/{run_id} `_ + """ + status, _, _ = self._requester.requestJson("DELETE", self.url) + return status == 204 + + def jobs(self, _filter: Opt[str] = NotSet) -> PaginatedList[WorkflowJob]: + """ + :calls "`GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs `_ + :param _filter: string `latest`, or `all` + """ + assert is_optional(_filter, str), _filter + + url_parameters = NotSet.remove_unset_items({"filter": _filter}) + + return PaginatedList( + github.WorkflowJob.WorkflowJob, + self._requester, + self.jobs_url, + url_parameters, + list_item="jobs", + ) + + def _useAttributes(self, attributes: dict[str, Any]) -> None: + if "actor" in attributes: # pragma no branch + self._actor = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["actor"]) + if "artifacts_url" in attributes: # pragma no branch + self._artifacts_url = self._makeStringAttribute(attributes["artifacts_url"]) + if "cancel_url" in attributes: # pragma no branch + self._cancel_url = self._makeStringAttribute(attributes["cancel_url"]) + if "check_suite_id" in attributes: # pragma no branch + self._check_suite_id = self._makeIntAttribute(attributes["check_suite_id"]) + if "check_suite_node_id" in attributes: # pragma no branch + self._check_suite_node_id = self._makeStringAttribute(attributes["check_suite_node_id"]) + if "check_suite_url" in attributes: # pragma no branch + self._check_suite_url = self._makeStringAttribute(attributes["check_suite_url"]) + if "conclusion" in attributes: # pragma no branch + self._conclusion = self._makeStringAttribute(attributes["conclusion"]) + if "created_at" in attributes: # pragma no branch + self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) + if "display_title" in attributes: # pragma no branch + self._display_title = self._makeStringAttribute(attributes["display_title"]) + if "event" in attributes: # pragma no branch + self._event = self._makeStringAttribute(attributes["event"]) + if "head_branch" in attributes: # pragma no branch + self._head_branch = self._makeStringAttribute(attributes["head_branch"]) + if "head_commit" in attributes: # pragma no branch + self._head_commit = self._makeClassAttribute(github.GitCommit.GitCommit, attributes["head_commit"]) + if "head_repository" in attributes: # pragma no branch + self._head_repository = self._makeClassAttribute( + github.Repository.Repository, attributes["head_repository"] + ) + if "head_repository_id" in attributes: # pragma no branch + self._head_repository_id = self._makeIntAttribute(attributes["head_repository_id"]) + if "head_sha" in attributes: # pragma no branch + self._head_sha = self._makeStringAttribute(attributes["head_sha"]) + if "html_url" in attributes: # pragma no branch + self._html_url = self._makeStringAttribute(attributes["html_url"]) + if "id" in attributes: # pragma no branch + self._id = self._makeIntAttribute(attributes["id"]) + if "jobs_url" in attributes: # pragma no branch + self._jobs_url = self._makeStringAttribute(attributes["jobs_url"]) + if "logs_url" in attributes: # pragma no branch + self._logs_url = self._makeStringAttribute(attributes["logs_url"]) + if "name" in attributes: # pragma no branch + self._name = self._makeStringAttribute(attributes["name"]) + if "node_id" in attributes: # pragma no branch + self._node_id = self._makeStringAttribute(attributes["node_id"]) + if "path" in attributes: # pragma no branch + self._path = self._makeStringAttribute(attributes["path"]) + if "previous_attempt_url" in attributes: # pragma no branch + self._previous_attempt_url = self._makeStringAttribute(attributes["previous_attempt_url"]) + if "pull_requests" in attributes: # pragma no branch + self._pull_requests = self._makeListOfClassesAttribute( + github.PullRequest.PullRequest, attributes["pull_requests"] + ) + if "referenced_workflows" in attributes: # pragma no branch + self._referenced_workflows = self._makeListOfDictsAttribute(attributes["referenced_workflows"]) + if "repository" in attributes: # pragma no branch + self._repository = self._makeClassAttribute(github.Repository.Repository, attributes["repository"]) + if "repository_id" in attributes: # pragma no branch + self._repository_id = self._makeIntAttribute(attributes["repository_id"]) + if "rerun_url" in attributes: # pragma no branch + self._rerun_url = self._makeStringAttribute(attributes["rerun_url"]) + if "run_attempt" in attributes: # pragma no branch + self._run_attempt = self._makeIntAttribute(attributes["run_attempt"]) + if "run_number" in attributes: # pragma no branch + self._run_number = self._makeIntAttribute(attributes["run_number"]) + if "run_started_at" in attributes: # pragma no branch + assert attributes["run_started_at"] is None or isinstance(attributes["run_started_at"], str), attributes[ + "run_started_at" + ] + self._run_started_at = self._makeDatetimeAttribute(attributes["run_started_at"]) + if "status" in attributes: # pragma no branch + self._status = self._makeStringAttribute(attributes["status"]) + if "triggering_actor" in attributes: # pragma no branch + self._triggering_actor = self._makeClassAttribute( + github.NamedUser.NamedUser, attributes["triggering_actor"] + ) + if "updated_at" in attributes: # pragma no branch + self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) + if "url" in attributes: # pragma no branch + self._url = self._makeStringAttribute(attributes["url"]) + if "workflow_id" in attributes: # pragma no branch + self._workflow_id = self._makeIntAttribute(attributes["workflow_id"]) + if "workflow_url" in attributes: # pragma no branch + self._workflow_url = self._makeStringAttribute(attributes["workflow_url"]) diff --git a/venv/lib/python3.10/site-packages/github/__init__.py b/venv/lib/python3.10/site-packages/github/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..d8d05c18c4a9d982b86111dd2931cc0b4860dc93 --- /dev/null +++ b/venv/lib/python3.10/site-packages/github/__init__.py @@ -0,0 +1,112 @@ +############################ Copyrights and license ############################ +# # +# Copyright 2012 Vincent Jacques # +# Copyright 2012 Zearin # +# Copyright 2013 Vincent Jacques # +# Copyright 2014 Vincent Jacques # +# Copyright 2016 Jannis Gebauer # +# Copyright 2016 Peter Buckley # +# Copyright 2017 sharkykh # +# Copyright 2018 Wan Liuyang # +# Copyright 2018 sfdye # +# Copyright 2019 Adam Baratz # +# Copyright 2019 Steve Kowalik # +# Copyright 2019 Wan Liuyang # +# Copyright 2020 Alice GIRARD # +# Copyright 2020 Emily # +# Copyright 2020 Liuyang Wan # +# Copyright 2020 Steve Kowalik # +# Copyright 2023 Denis Blanchette # +# Copyright 2023 Enrico Minack # +# Copyright 2023 Trim21 # +# Copyright 2024 Enrico Minack # +# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> # +# Copyright 2025 Enrico Minack # +# # +# This file is part of PyGithub. # +# http://pygithub.readthedocs.io/ # +# # +# PyGithub is free software: you can redistribute it and/or modify it under # +# the terms of the GNU Lesser General Public License as published by the Free # +# Software Foundation, either version 3 of the License, or (at your option) # +# any later version. # +# # +# PyGithub 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 Lesser General Public License for more # +# details. # +# # +# You should have received a copy of the GNU Lesser General Public License # +# along with PyGithub. If not, see . # +# # +################################################################################ +""" +The primary class you will instantiate is :class:`github.MainClass.Github`. From its ``get_``, ``create_`` methods, you +will obtain instances of all Github objects like :class:`github.NamedUser.NamedUser` or +:class:`github.Repository.Repository`. + +All classes inherit from :class:`github.GithubObject.GithubObject`. + +""" + +import logging + +from . import Auth +from .AppAuthentication import AppAuthentication +from .GithubException import ( + BadAttributeException, + BadCredentialsException, + BadUserAgentException, + GithubException, + IncompletableObject, + RateLimitExceededException, + TwoFactorException, + UnknownObjectException, +) +from .GithubIntegration import GithubIntegration +from .GithubRetry import GithubRetry +from .InputFileContent import InputFileContent +from .InputGitAuthor import InputGitAuthor +from .InputGitTreeElement import InputGitTreeElement +from .MainClass import Github + +# set log level to INFO for github +logger = logging.getLogger("github") +logger.setLevel(logging.INFO) +logger.addHandler(logging.StreamHandler()) + + +def set_log_level(level: int) -> None: + """ + Set the log level of the github logger, e.g. set_log_level(logging.WARNING) :param level: log level. + """ + logger.setLevel(level) + + +def enable_console_debug_logging() -> None: # pragma no cover (Function useful only outside test environment) + """ + This function sets up a very simple logging configuration (log everything on standard output) that is useful for + troubleshooting. + """ + set_log_level(logging.DEBUG) + + +__all__ = [ + "Auth", + "AppAuthentication", + "BadAttributeException", + "BadCredentialsException", + "BadUserAgentException", + "enable_console_debug_logging", + "Github", + "GithubException", + "GithubIntegration", + "GithubRetry", + "IncompletableObject", + "InputFileContent", + "InputGitAuthor", + "InputGitTreeElement", + "RateLimitExceededException", + "TwoFactorException", + "UnknownObjectException", +] diff --git a/venv/lib/python3.10/site-packages/github/__pycache__/Traffic.cpython-310.pyc b/venv/lib/python3.10/site-packages/github/__pycache__/Traffic.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..27a6378beb66db576dec8493ba197e62da4e7263 Binary files /dev/null and b/venv/lib/python3.10/site-packages/github/__pycache__/Traffic.cpython-310.pyc differ diff --git a/venv/lib/python3.10/site-packages/github/__pycache__/UserKey.cpython-310.pyc b/venv/lib/python3.10/site-packages/github/__pycache__/UserKey.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f6fb18aa56f7cfdd7bd365f3b1ceac581769c100 Binary files /dev/null and b/venv/lib/python3.10/site-packages/github/__pycache__/UserKey.cpython-310.pyc differ diff --git a/venv/lib/python3.10/site-packages/github/__pycache__/Variable.cpython-310.pyc b/venv/lib/python3.10/site-packages/github/__pycache__/Variable.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ab59563ff40d7fde27eec5f057e5914cd368cde7 Binary files /dev/null and b/venv/lib/python3.10/site-packages/github/__pycache__/Variable.cpython-310.pyc differ diff --git a/venv/lib/python3.10/site-packages/github/__pycache__/View.cpython-310.pyc b/venv/lib/python3.10/site-packages/github/__pycache__/View.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e8f125bcf10c14469dc16e7c9093bbeb05b3b511 Binary files /dev/null and b/venv/lib/python3.10/site-packages/github/__pycache__/View.cpython-310.pyc differ diff --git a/venv/lib/python3.10/site-packages/github/__pycache__/Workflow.cpython-310.pyc b/venv/lib/python3.10/site-packages/github/__pycache__/Workflow.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9b5680368f0c2f6e150befd146ed00ffb5571eb0 Binary files /dev/null and b/venv/lib/python3.10/site-packages/github/__pycache__/Workflow.cpython-310.pyc differ diff --git a/venv/lib/python3.10/site-packages/github/__pycache__/WorkflowJob.cpython-310.pyc b/venv/lib/python3.10/site-packages/github/__pycache__/WorkflowJob.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1d88edd32896a978f0f03ff7db2c16a3b12b6436 Binary files /dev/null and b/venv/lib/python3.10/site-packages/github/__pycache__/WorkflowJob.cpython-310.pyc differ diff --git a/venv/lib/python3.10/site-packages/github/__pycache__/WorkflowRun.cpython-310.pyc b/venv/lib/python3.10/site-packages/github/__pycache__/WorkflowRun.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..be298dd884105635140258c321c1bbc819d21a23 Binary files /dev/null and b/venv/lib/python3.10/site-packages/github/__pycache__/WorkflowRun.cpython-310.pyc differ diff --git a/venv/lib/python3.10/site-packages/github/__pycache__/WorkflowStep.cpython-310.pyc b/venv/lib/python3.10/site-packages/github/__pycache__/WorkflowStep.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0680003e37a8ccd9cdaaa9b5c7ad95c03dd5063e Binary files /dev/null and b/venv/lib/python3.10/site-packages/github/__pycache__/WorkflowStep.cpython-310.pyc differ diff --git a/venv/lib/python3.10/site-packages/github/__pycache__/__init__.cpython-310.pyc b/venv/lib/python3.10/site-packages/github/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b0112ec9416a4d3a52f888d022b67c82995be13f Binary files /dev/null and b/venv/lib/python3.10/site-packages/github/__pycache__/__init__.cpython-310.pyc differ diff --git a/venv/lib/python3.10/site-packages/github/py.typed b/venv/lib/python3.10/site-packages/github/py.typed new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391