%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/thread-self/root/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //proc/thread-self/root/lib/python2.7/site-packages/salt/modules/github.pyo

�
���^c@@stdZddlmZmZmZddlZddlmZddlm	Z	ddl
ZeZ
y>ddlZddlZddlZddlmZeZ
Wnek
r�nXeje�ZdZd�Zd	�Zd
�Zdd�Zded�Zded
�Zded�Z dd�Z!dd�Z"dddd�Z#ddddd�Z$dddddddddddddd�
Z%dddddddd�Z&dddddd�Z'd�Z(ded�Z)dd�Z*dd�Z+dd �Z,dd!�Z-ddddddddddd"�
Z.dddddddd#�Z/dd$�Z0dd%�Z1dddddd&�Z2ddddd'�Z3dd(�Z4ded)�Z5ddd*�Z6dd+�Z7ded,�Z8ded-�Z9dd.�Z:dd/�Z;dd0�Z<ded1�Z=dddddddddd2�	Z>d3�Z?d4�Z@dddd5ddd6dd7�ZAdS(8u
Module for interacting with the GitHub v3 API.

.. versionadded:: 2016.3.0

:depends: PyGithub python module

Configuration
-------------

Configure this module by specifying the name of a configuration
profile in the minion config, minion pillar, or master config. The module
will use the 'github' key by default, if defined.

For example:

.. code-block:: yaml

    github:
      token: abc1234
      org_name: my_organization

      # optional: some functions require a repo_name, which
      # can be set in the config file, or passed in at the CLI.
      repo_name: my_repo

      # optional: it can be dangerous to change the privacy of a repository
      # in an automated way. set this to True to allow privacy modifications
      allow_repo_privacy_changes: False
i(tabsolute_importtunicode_literalstprint_functionN(tCommandExecutionError(tsix(tUnknownObjectExceptionugithubcC@str
tStdfS(uH
    Only load this module if PyGithub is installed on this minion.
    uPThe github execution module cannot be loaded: PyGithub library is not installed.(tHAS_LIBSt__virtualname__tFalse(((s7/usr/lib/python2.7/site-packages/salt/modules/github.pyt__virtual__;scC@shtd|�}|s.tdj|���n|j|�}|dkrdtdj||���n|S(u!
    Helper function that returns a profile's configuration value based on
    the supplied configuration name.

    profile
        The profile name that contains configuration information.

    config_name
        The configuration item's name to use to return configuration values.
    u
config.optionuDAuthentication information could not be found for the '{0}' profile.u7The '{0}' parameter was not found in the '{1}' profile.N(t__salt__RtformattgettNone(tprofiletconfig_nametconfigtconfig_value((s7/usr/lib/python2.7/site-packages/salt/modules/github.pyt_get_config_valueEscC@sZt|d�}dj|t|d��}|tkrRtj|dd�t|<nt|S(uK
    Return the GitHub client, cached into __context__ for performance
    utokenugithub.{0}:{1}uorg_nametper_pageid(RRt__context__tgithubtGithub(Rttokentkey((s7/usr/lib/python2.7/site-packages/salt/modules/github.pyt_get_clientdscC@s)tjjtjj|j|jd|�S(Nu/members(Rt
PaginatedListt	NamedUsert
_requesterturl(torganizationtparams((s7/usr/lib/python2.7/site-packages/salt/modules/github.pyt_get_membersvs
		
cC@st|d�}dj|�}|tks<|s<|dk	r�t|d�}t|�}|j|�}tjjtjj|j	|j
d|�}|dk	r�|Sg}xF|D]>}	|j|	�dj||	jj
��}
t|	�t|
<q�W|t|<nt|S(Nuorg_nameugithub.{0}:reposu/reposugithub.{0}:{1}:repo_info(RRRR
Rtget_organizationRRt
RepositoryRRtappendtnametlowert
_repo_to_dict(RRtignore_cachetorg_nameRtclientRtresulttnext_resulttrepotrepo_key((s7/usr/lib/python2.7/site-packages/salt/modules/github.pyt
_get_reposs(		
	


cC@st|d�}dj|�}|tks0|rwt|�}|j|�}gt|d�D]}|j^q[t|<nt|S(u�
    List all users within the organization.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    ignore_cache
        Bypasses the use of cached users.

        .. versionadded:: 2016.11.0

    CLI Example:

    .. code-block:: bash

        salt myminion github.list_users
        salt myminion github.list_users profile='my-github-profile'
    uorg_nameugithub.{0}:usersN(RRRRR!R R
tlogin(RR'R(RR)Rtmember((s7/usr/lib/python2.7/site-packages/salt/modules/github.pyt
list_users�s	,c	C@sq|r|t|�krtSi}t|�}|jt|d��}y|j|�}Wntk
r{tjd�t	SX|j
|d<|j|d<|j|d<|j
|d<|j|d<|j|d<|j|d	<|j|d
<|j|d<y-|jjd|jd
|j�\}}Wn&tk
rFd|d<t	|d<|SX|j|�|d<|jd�|d<|S(u�
    Get a GitHub user by name.

    name
        The user for which to obtain information.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    user_details
        Prints user information details. Defaults to ``False``. If the user is
        already in the organization and user_details is set to False, the
        get_user function returns ``True``. If the user is not already present
        in the organization, user details will be printed by default.

    CLI Example:

    .. code-block:: bash

        salt myminion github.get_user github-handle
        salt myminion github.get_user github-handle user_details=true

    uorg_nameuResource not founducompanyu
created_atuemailuhtml_urluiduloginunameutypeuurluGETu
/memberships/unonexistentumembership_stateuin_orgustate(R1tTrueRR!Rtget_userRtlogt	exceptionRtcompanyt
created_attemailthtml_urltidR/R$ttypeRRtrequestJsonAndCheckt	_identitythas_in_membersR(	R$Rtuser_detailstresponseR)Rtusertheaderstdata((s7/usr/lib/python2.7/site-packages/salt/modules/github.pyR3�s>










	!


cC@s�t|�}|jt|d��}y|j|�}Wntk
rXtjd�tSX|jj	d|j
d|j�\}}|jd�dkS(u
    Add a GitHub user.

    name
        The user for which to obtain information.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    CLI Example:

    .. code-block:: bash

        salt myminion github.add_user github-handle
    uorg_nameuResource not founduPUTu
/memberships/ustateupending(
RR!RR3RR4R5RRR<RR=R(R$RR)Rtgithub_named_userRBRC((s7/usr/lib/python2.7/site-packages/salt/modules/github.pytadd_users

	cC@s�t|�}|jt|d��}y|j|�}Wntk
rXtjd�tSX|j|�rx|j	|�n|j|�S(u"
    Remove a Github user by name.

    name
        The user for which to obtain information.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    CLI Example:

    .. code-block:: bash

        salt myminion github.remove_user github-handle
    uorg_nameuResource not found(
RR!RR3RR4R5RR>tremove_from_members(R$RR)Rtgit_user((s7/usr/lib/python2.7/site-packages/salt/modules/github.pytremove_user's

uminc
C@s�t|d�}|d
kr-t|d�}ndjd||g�}dtj|�}i}t|d|d|�}|jd�}	|d	kr�|||	<nt|�||	<|S(uU
    Return information about a single issue in a named repository.

    .. versionadded:: 2016.11.0

    issue_number
        The number of the issue to retrieve.

    repo_name
        The name of the repository from which to get the issue. This argument is
        required, either passed via the CLI, or defined in the configured
        profile. A ``repo_name`` passed as a CLI argument will override the
        repo_name defined in the configured profile, if provided.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    output
        The amount of data returned by each issue. Defaults to ``min``. Change
        to ``full`` to see all issue output.

    CLI Example:

    .. code-block:: bash

        salt myminion github.get_issue 514
        salt myminion github.get_issue 514 repo_name=salt
    uorg_nameu	repo_nameu/ureposuissues/tactiontcommanduidufullN(RR
tjoinRt	text_typet_queryRt
_format_issue(
tissue_numbert	repo_nameRtoutputR(RIRJtrett
issue_datatissue_id((s7/usr/lib/python2.7/site-packages/salt/modules/github.pyt	get_issueIs
c
C@s3t|d�}|dkr-t|d�}ndjd||g�}djdtj|�dg�}i}|r||d<nt|d|d	|d
|�}	i}
x�|	D]�}|jd�}|dkr�||
|<q�i|jd�d6|jd
�d
6|jd�d6|jd�jd�d6|
|<q�W|
S(u
    Return information about the comments for a given issue in a named repository.

    .. versionadded:: 2016.11.0

    issue_number
        The number of the issue for which to retrieve comments.

    repo_name
        The name of the repository to which the issue belongs. This argument is
        required, either passed via the CLI, or defined in the configured
        profile. A ``repo_name`` passed as a CLI argument will override the
        repo_name defined in the configured profile, if provided.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    since
        Only comments updated at or after this time are returned. This is a
        timestamp in ISO 8601 format: ``YYYY-MM-DDTHH:MM:SSZ``.

    output
        The amount of data returned by each issue. Defaults to ``min``. Change
        to ``full`` to see all issue output.

    CLI Example:

    .. code-block:: bash

        salt myminion github.get_issue_comments 514
        salt myminion github.get_issue 514 repo_name=salt
    uorg_nameu	repo_nameu/ureposuissuesucommentsusinceRIRJtargsuidufullu
created_atu
updated_atuuseruloginu
user_loginN(RR
RKRRLRMR(
RORPRtsinceRQR(RIRJRVtcommentsRRtcommentt
comment_id((s7/usr/lib/python2.7/site-packages/salt/modules/github.pytget_issue_commentsys&%!


$uopenucreatedudescc
C@s�t|d�}
|dkr-t|d�}ndjd|
|g�}i}|r^||d<n|rq||d<n|r�||d<n|r�||d<n|r�||d	<n|
r�|
|d
<n|r�||d<n|r�|dkr�||d
<n|r|dkr||d<n|	r-|	dkr-|	|d<ni}t|d|ddd|�}x[|D]S}|jd�rsqXn|jd�}|dkr�|||<qXt|�||<qXW|S(u+	
    Returns information for all issues in a given repository, based on the search options.

    .. versionadded:: 2016.11.0

    repo_name
        The name of the repository for which to list issues. This argument is
        required, either passed via the CLI, or defined in the configured
        profile. A ``repo_name`` passed as a CLI argument will override the
        repo_name defined in the configured profile, if provided.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    milestone
        The number of a GitHub milestone, or a string of either ``*`` or
        ``none``.

        If a number is passed, it should refer to a milestone by its number
        field. Use the ``github.get_milestone`` function to obtain a milestone's
        number.

        If the string ``*`` is passed, issues with any milestone are
        accepted. If the string ``none`` is passed, issues without milestones
        are returned.

    state
        Indicates the state of the issues to return. Can be either ``open``,
        ``closed``, or ``all``. Default is ``open``.

    assignee
        Can be the name of a user. Pass in ``none`` (as a string) for issues
        with no assigned user or ``*`` for issues assigned to any user.

    creator
        The user that created the issue.

    mentioned
        A user that's mentioned in the issue.

    labels
        A string of comma separated label names. For example, ``bug,ui,@high``.

    sort
        What to sort results by. Can be either ``created``, ``updated``, or
        ``comments``. Default is ``created``.

    direction
        The direction of the sort. Can be either ``asc`` or ``desc``. Default
        is ``desc``.

    since
        Only issues updated at or after this time are returned. This is a
        timestamp in ISO 8601 format: ``YYYY-MM-DDTHH:MM:SSZ``.

    output
        The amount of data returned by each issue. Defaults to ``min``. Change
        to ``full`` to see all issue output.

    per_page
        GitHub paginates data in their API calls. Use this value to increase or
        decrease the number of issues gathered from GitHub, per page. If not set,
        GitHub defaults are used. Maximum is 100.

    CLI Example:

    .. code-block:: bash

        salt myminion github.get_issues my-github-repo
    uorg_nameu	repo_nameu/ureposu	milestoneuassigneeucreatoru	mentionedulabelsusinceuper_pageuopenustateucreatedusortudescu	directionRIRJuissuesRVupull_requestuidufullN(RR
RKRMRRN(RPRt	milestonetstatetassigneetcreatort	mentionedtlabelstsortt	directionRWRQRR(RIRVRRtissuestissueRT((s7/usr/lib/python2.7/site-packages/salt/modules/github.pyt
get_issues�sFS











udue_onuasccC@sMt|d�}|dkr-t|d�}ndjd||g�}i}	|r^||	d<n|r}|dkr}||	d<n|r�|dkr�||	d	<n|r�|d
kr�||	d<ni}
t|d|d
dd|	�}xg|D]_}|jd�}
|dkr||
|
<q�|jd�|jd�|jd�||
|
<q�W|
S(u�
    Return information about milestones for a given repository.

    .. versionadded:: 2016.11.0

    repo_name
        The name of the repository for which to list issues. This argument is
        required, either passed via the CLI, or defined in the configured
        profile. A ``repo_name`` passed as a CLI argument will override the
        repo_name defined in the configured profile, if provided.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    state
        The state of the milestone. Either ``open``, ``closed``, or ``all``.
        Default is ``open``.

    sort
        What to sort results by. Either ``due_on`` or ``completeness``. Default
        is ``due_on``.

    direction
        The direction of the sort. Either ``asc`` or ``desc``. Default is ``asc``.

    output
        The amount of data returned by each issue. Defaults to ``min``. Change
        to ``full`` to see all issue output.

    per_page
        GitHub paginates data in their API calls. Use this value to increase or
        decrease the number of issues gathered from GitHub, per page. If not set,
        GitHub defaults are used.

    CLI Example:

    .. code-block:: bash

        salt myminion github.get_milestones

    uorg_nameu	repo_nameu/ureposuper_pageuopenustateudue_onusortuascu	directionRIRJu
milestonesRVuidufullucreatoruhtml_urlu
labels_urlN(RR
RKRMRtpop(RPRR]RbRcRQRR(RIRVRRt
milestonesR\tmilestone_id((s7/usr/lib/python2.7/site-packages/salt/modules/github.pytget_milestones;s00








cC@s\i}t||g�s'td��nt|d�}|dkrTt|d�}ndjd||g�}|r�dtj|�}t|d|d|�}	|	jd	�}
|d
kr�|	||
<n1|	j	d�|	j	d�|	j	d
�|	||
<|St
d|d|d|�}x@tj|�D]/\}}
|
jd�|kr%|
||<|Sq%W|S(u�
    Return information about a single milestone in a named repository.

    .. versionadded:: 2016.11.0

    number
        The number of the milestone to retrieve. If provided, this option
        will be favored over ``name``.

    name
        The name of the milestone to retrieve.

    repo_name
        The name of the repository for which to list issues. This argument is
        required, either passed via the CLI, or defined in the configured
        profile. A ``repo_name`` passed as a CLI argument will override the
        repo_name defined in the configured profile, if provided.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    output
        The amount of data returned by each issue. Defaults to ``min``. Change
        to ``full`` to see all issue output.

    CLI Example:

    .. code-block:: bash

        salt myminion github.get_milestone 72
        salt myminion github.get_milestone name=my_milestone

    u7Either a milestone 'name' or 'number' must be provided.uorg_nameu	repo_nameu/ureposumilestones/RIRJuidufullucreatoruhtml_urlu
labels_urlRPRRQutitleN(tanyRRR
RKRRLRMRRgRjt	iteritems(tnumberR$RPRRQRRR(RIRJtmilestone_dataRiRhRtval((s7/usr/lib/python2.7/site-packages/salt/modules/github.pyt
get_milestone�s2&





cC@si}|j|d<|j|d<|j|d<|jj|d<|j|d<|j|d<|j|d<|j|d<|j	|d	<|j
|d
<|j|d<|j|d<|j
|d
<|j|d<|j|d<|j|d<|j|d<|j|d<|j|d<|j|d<|j|d<|S(Nuidunameu	full_nameuowneruprivateuhtml_urludescriptionuforkuhomepageusizeustargazers_countuwatchers_countulanguageuopen_issues_countuforksuopen_issuesuwatchersudefault_branchu
has_issuesuhas_wikiu
has_downloads(R:R$t	full_nametownerR/tprivateR9tdescriptiontforkthomepagetsizetstargazers_counttwatchers_counttlanguagetopen_issues_counttforkstopen_issuestwatcherstdefault_brancht
has_issuesthas_wikit
has_downloads(R,RR((s7/usr/lib/python2.7/site-packages/salt/modules/github.pyR&�s.



















cC@s�t|d�}djt|d�|j��}|tksB|r�t|�}yB|jdj||g��}|syiSt|�}|t|<Wq�tj	k
r�t
dj||���q�Xnt|S(u�
    Return information for a given repo.

    .. versionadded:: 2016.11.0

    repo_name
        The name of the repository.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    CLI Example:

    .. code-block:: bash

        salt myminion github.get_repo_info salt
        salt myminion github.get_repo_info salt profile='my-github-profile'
    uorg_nameugithub.{0}:{1}:repo_infou/uEThe '{0}' repository under the '{1}' organization could not be found.(RRR%RRtget_repoRKR&RRR(RPRR'R(RR)R,RR((s7/usr/lib/python2.7/site-packages/salt/modules/github.pyt
get_repo_info�s$cC@s�g}t|d�}t|�}y"|jdj||g��}Wn,tjk
rqtdj||���nXyL|j�}x9|D]1}|j	i|j
d6|jd6|jd6�q�WWn,tjk
r�tdj||���nX|S(u�
    Return teams belonging to a repository.

    .. versionadded:: 2017.7.0

    repo_name
        The name of the repository from which to retrieve teams.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    CLI Example:

    .. code-block:: bash

        salt myminion github.get_repo_teams salt
        salt myminion github.get_repo_teams salt profile='my-github-profile'
    uorg_nameu/uEThe '{0}' repository under the '{1}' organization could not be found.uidunameu
permissionuKUnable to retrieve teams for repository '{0}' under the '{1}' organization.(
RRR�RKRRRRt	get_teamsR#R:R$t
permission(RPRRRR(R)R,tteamstteam((s7/usr/lib/python2.7/site-packages/salt/modules/github.pytget_repo_teams#s*"
	

cC@s gt|�D]}|j^q
S(u�
    List all repositories within the organization. Includes public and private
    repositories within the organization Dependent upon the access rights of
    the profile token.

    .. versionadded:: 2016.11.0

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    CLI Example:

    .. code-block:: bash

        salt myminion github.list_repos
        salt myminion github.list_repos profile='my-github-profile'
    (R.R$(RR,((s7/usr/lib/python2.7/site-packages/salt/modules/github.pyt
list_reposQscC@sCg}x6t|�D](}|jtkr|j|j�qqW|S(u�
    List private repositories within the organization. Dependent upon the access
    rights of the profile token.

    .. versionadded:: 2016.11.0

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    CLI Example:

    .. code-block:: bash

        salt myminion github.list_private_repos
        salt myminion github.list_private_repos profile='my-github-profile'
    (R.RsR2R#R$(RtreposR,((s7/usr/lib/python2.7/site-packages/salt/modules/github.pytlist_private_reposfs
cC@sCg}x6t|�D](}|jtkr|j|j�qqW|S(u^
    List public repositories within the organization.

    .. versionadded:: 2016.11.0

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    CLI Example:

    .. code-block:: bash

        salt myminion github.list_public_repos
        salt myminion github.list_public_repos profile='my-github-profile'
    (R.RsRR#R$(RR�R,((s7/usr/lib/python2.7/site-packages/salt/modules/github.pytlist_public_repos~s
cC@sy�t|
�}|jt|
d��}i	|d6|d6|d6|d6|d6|d6|d6|d	6|	d
6}
i|d6}x6tj|
�D]%\}}|dk	r�|||<q�q�W|jjd|jd
d|�t	SWn"t
jk
r�tj
d�tSXdS(u$
    Create a new github repository.

    name
        The name of the team to be created.

    description
        The description of the repository.

    homepage
        The URL with more information about the repository.

    private
        The visiblity of the repository. Note that private repositories require
        a paid GitHub account.

    has_issues
        Whether to enable issues for this repository.

    has_wiki
        Whether to enable the wiki for this repository.

    has_downloads
        Whether to enable downloads for this repository.

    auto_init
        Whether to create an initial commit with an empty README.

    gitignore_template
        The desired language or platform for a .gitignore, e.g "Haskell".

    license_template
        The desired LICENSE template to apply, e.g "mit" or "mozilla".

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    CLI Example:

    .. code-block:: bash

        salt myminion github.add_repo 'repo_name'

    .. versionadded:: 2016.11.0
    uorg_nameudescriptionuhomepageuprivateu
has_issuesuhas_wikiu
has_downloadsu	auto_initugitignore_templateulicense_templateunameuPOSTu/repostinputuError creating a repoN(RR!RRRlR
RR<RR2RtGithubExceptionR4R5R(R$RtRvRsR�R�R�t	auto_inittgitignore_templatetlicense_templateRR)Rtgiven_paramst
parameterst
param_nametparam_value((s7/usr/lib/python2.7/site-packages/salt/modules/github.pytadd_repo�s48

	

cC@sdyt|d�}Wntk
r,t}nX|dk	rX|rXtdj|���ny�t|�}	|	jt|d��}
|
j|�}i|d6|d6|d6|d6|d6|d	6}i|d
6}
x6tj	|�D]%\}}|dk	r�||
|<q�q�W|
j
jd|jd|
�t
|d
|dt�tSWn"tjk
r_tjd�tSXdS(u
    Updates an existing Github repository.

    name
        The name of the team to be created.

    description
        The description of the repository.

    homepage
        The URL with more information about the repository.

    private
        The visiblity of the repository. Note that private repositories require
        a paid GitHub account.

    has_issues
        Whether to enable issues for this repository.

    has_wiki
        Whether to enable the wiki for this repository.

    has_downloads
        Whether to enable downloads for this repository.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    CLI Example:

    .. code-block:: bash

        salt myminion github.add_repo 'repo_name'

    .. versionadded:: 2016.11.0
    uallow_repo_privacy_changesubThe private field is set to be changed for repo {0} but allow_repo_privacy_changes disallows this.uorg_nameudescriptionuhomepageuprivateu
has_issuesuhas_wikiu
has_downloadsunameuPATCHR�RR'uError editing a repoN(RRRR
RRR!R�RRlRR<RR�R2RR�R4R5(R$RtRvRsR�R�R�Rtallow_private_changeR)RR,R�R�R�R�((s7/usr/lib/python2.7/site-packages/salt/modules/github.pyt	edit_repo�s@-

	

		
cC@s�t|d|�}|s,tjd|�tSyXt|�}|jt|d��}|j|�}|j�t	d|dt
�t
SWn"tjk
r�tj
d�tSXdS(u=
    Remove a Github repository.

    name
        The name of the repository to be removed.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    CLI Example:

    .. code-block:: bash

        salt myminion github.remove_repo 'my-repo'

    .. versionadded:: 2016.11.0
    Ru%Repo %s to be removed does not exist.uorg_nameR'uError deleting a repoN(R�R4terrorRRR!RR�tdeleteR.R2RR�R5(R$Rt	repo_infoR)RR,((s7/usr/lib/python2.7/site-packages/salt/modules/github.pytremove_repoDs

cC@st|�j|�S(uZ
    Returns the team details if a team with the given name exists, or None
    otherwise.

    name
        The team name for which to obtain information.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    CLI Example:

    .. code-block:: bash

        salt myminion github.get_team 'team_name'
    (t
list_teamsR(R$R((s7/usr/lib/python2.7/site-packages/salt/modules/github.pytget_teamhsc	C@s�y�t|�}|jt|d��}i}||d<|dk	rP||d<n|dk	ri||d<n|dk	r�||d<n|dk	r�||d<n|jjd|jdd	|�td
t�tSWn"t	j
k
r�tjd�t
SXdS(
u�
    Create a new Github team within an organization.

    name
        The name of the team to be created.

    description
        The description of the team.

    repo_names
        The names of repositories to add the team to.

    privacy
        The level of privacy for the team, can be 'secret' or 'closed'.

    permission
        The default permission for new repositories added to the team, can be
        'pull', 'push' or 'admin'.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    CLI Example:

    .. code-block:: bash

        salt myminion github.add_team 'team_name'

    .. versionadded:: 2016.11.0
    uorg_nameunameudescriptionu
repo_namesu
permissionuprivacyuPOSTu/teamsR�R'uError creating a teamN(RR!RR
RR<RR�R2RR�R4R5R(	R$Rtt
repo_namestprivacyR�RR)RR�((s7/usr/lib/python2.7/site-packages/salt/modules/github.pytadd_team|s.$




	


c	C@st|d|�}|s,tjd|�tSy�t|�}|jt|d��}|j|d�}i}|dk	r�||d<n|dk	r�||d<n|dk	r�||d<n|dk	r�||d<n|jj	d	|j
d
|�tSWntk
rtj
d�tSXdS(
uf
    Updates an existing Github team.

    name
        The name of the team to be edited.

    description
        The description of the team.

    privacy
        The level of privacy for the team, can be 'secret' or 'closed'.

    permission
        The default permission for new repositories added to the team, can be
        'pull', 'push' or 'admin'.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    CLI Example:

    .. code-block:: bash

        salt myminion github.edit_team 'team_name' description='Team description'

    .. versionadded:: 2016.11.0
    RuTeam %s does not existuorg_nameuidunameudescriptionuprivacyu
permissionuPATCHR�uResource not foundN(R�R4R�RRR!RR
RR<RR2RR5(	R$RtR�R�RR�R)RR�((s7/usr/lib/python2.7/site-packages/salt/modules/github.pyt	edit_team�s4 



		

cC@s�t|d|�}|s,tjd|�tSygt|�}|jt|d��}|j|d�}|j�tdt	d|�j
|�dkSWn"tj
k
r�tjd�tSXdS(u3
    Remove a github team.

    name
        The name of the team to be removed.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    CLI Example:

    .. code-block:: bash

        salt myminion github.remove_team 'team_name'

    .. versionadded:: 2016.11.0
    Ru%Team %s to be removed does not exist.uorg_nameuidR'uError deleting a teamN(R�R4R�RRR!RR�R�R2RR
RR�R5(R$Rt	team_infoR)RR�((s7/usr/lib/python2.7/site-packages/salt/modules/github.pytremove_team�s
&
c
C@sXt|d|�}|s,tjd|�tS|jd�rO|rO|jd�Sy;t|�}|jt|d��}|j|d�}Wn%tk
r�tj	d|d�nXyyi}x^|j
�D]P}d}	|jjr�d}	n|jj
r�d	}	ni|	d
6||jj�<q�W||d<|SWn&tk
rStj	d|d�gSXdS(u�
    Gets the repo details for a given team as a dict from repo_name to repo details.
    Note that repo names are always in lower case.

    team_name
        The name of the team from which to list repos.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    ignore_cache
        Bypasses the use of cached team repos.

    CLI Example:

    .. code-block:: bash

        salt myminion github.list_team_repos 'team_name'

    .. versionadded:: 2016.11.0
    RuTeam %s does not exist.ureposuorg_nameuiduResource not found: %supulluadminupushu
permissionN(R�R4R�RRRR!RRR5t	get_repostpermissionstadmintpushR$R%(
t	team_nameRR'tcached_teamR)RR�R�R,R�((s7/usr/lib/python2.7/site-packages/salt/modules/github.pytlist_team_repos s8

		

cC@s
t|d|�}|s,tjd|�tSyJt|�}|jt|d��}|j|d�}|j|�}Wn&tk
r�tj	d|d�tSXd}|dk	r�i|d6}n|jjd|j
d|jd	|�\}	}
t|d|d
t�tS(u�
    Adds a repository to a team with team_name.

    repo_name
        The name of the repository to add.

    team_name
        The name of the team of which to add the repository.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    permission
        The permission for team members within the repository, can be 'pull',
        'push' or 'admin'. If not specified, the default permission specified on
        the team will be used.

        .. versionadded:: 2017.7.0

    CLI Example:

    .. code-block:: bash

        salt myminion github.add_team_repo 'my_repo' 'team_name'

    .. versionadded:: 2016.11.0
    RuTeam %s does not existuorg_nameuiduResource not found: %su
permissionuPUTu/repos/R�R'N(R�R4R�RRR!RR�RR5R
RR<RR=R�R2(RPR�RR�R�R)RR,RRBRC((s7/usr/lib/python2.7/site-packages/salt/modules/github.pyt
add_team_repoZs,
	cC@s�t|d|�}|s,tjd|�tSyJt|�}|jt|d��}|j|d�}|j|�}Wn&tk
r�tj	d|d�tSX|j
|�|t|d|dt�kS(u�
    Removes a repository from a team with team_name.

    repo_name
        The name of the repository to remove.

    team_name
        The name of the team of which to remove the repository.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    CLI Example:

    .. code-block:: bash

        salt myminion github.remove_team_repo 'my_repo' 'team_name'

    .. versionadded:: 2016.11.0
    RuTeam %s does not existuorg_nameuiduResource not found: %sR'(
R�R4R�RRR!RR�RR5tremove_from_reposR�R2(RPR�RR�R)RR,((s7/usr/lib/python2.7/site-packages/salt/modules/github.pytremove_team_repo�s

cC@st|d|�}|s,tjd|�tS|jd�rO|rO|jd�Sy;t|�}|jt|d��}|j|d�}Wn%tk
r�tj	d|d�nXy8g|j
�D]}|jj�^q�|d<|dSWn&tk
rtj	d|d�gSXdS(u�
    Gets the names of team members in lower case.

    team_name
        The name of the team from which to list members.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    ignore_cache
        Bypasses the use of cached team members.

    CLI Example:

    .. code-block:: bash

        salt myminion github.list_team_members 'team_name'

    .. versionadded:: 2016.11.0
    RuTeam %s does not exist.umembersuorg_nameuiduResource not found: %sN(
R�R4R�RRRR!RRR5tget_membersR/R%(R�RR'R�R)RR�R0((s7/usr/lib/python2.7/site-packages/salt/modules/github.pytlist_team_members�s(

)
cC@s�djt|d��}|tks*|r�t|�}|jt|d��}d}ttjjd�rrd}ngt|id|6�D]}|j	j
�^q�t|<nt|S(ua
    List all members (in lower case) without MFA turned on.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    ignore_cache
        Bypasses the use of cached team repos.

    CLI Example:

    .. code-block:: bash

        salt myminion github.list_members_without_mfa

    .. versionadded:: 2016.11.0
    ugithub.{0}:non_mfa_usersuorg_nameufilteru
membershipufilter_u2fa_disabled(RRRRR!thasattrRtTeamR R/R%(RR'RR)Rt
filter_keytm((s7/usr/lib/python2.7/site-packages/salt/modules/github.pytlist_members_without_mfa�s	6cC@s|j�t|d|�kS(u�
    Returns True if the github user is in the team with team_name, or False
    otherwise.

    name
        The name of the user whose membership to check.

    team_name
        The name of the team to check membership in.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    CLI Example:

    .. code-block:: bash

        salt myminion github.is_team_member 'user_name' 'team_name'

    .. versionadded:: 2016.11.0
    R(R%R�(R$R�R((s7/usr/lib/python2.7/site-packages/salt/modules/github.pytis_team_membersc		C@st|d|�}|s,tjd|�tSyJt|�}|jt|d��}|j|d�}|j|�}Wn&tk
r�tj	d|d�tSXyG|j
jd|jd|j
did	d
6did	d
6�\}}Wn"tjk
r
tj	d�tSXtS(
u�
    Adds a team member to a team with team_name.

    name
        The name of the team member to add.

    team_name
        The name of the team of which to add the user.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    CLI Example:

    .. code-block:: bash

        salt myminion github.add_team_member 'user_name' 'team_name'

    .. versionadded:: 2016.11.0
    RuTeam %s does not existuorg_nameuiduResource not found: %suPUTu
/memberships/R�umemberuroleR�u"Error in adding a member to a team(R�R4R�RRR!RR3RR5RR<RR=RR�R2(	R$R�RR�R)RR0RBRC((s7/usr/lib/python2.7/site-packages/salt/modules/github.pytadd_team_member's.
	

cC@s�t|d|�}|s,tjd|�tSyJt|�}|jt|d��}|j|d�}|j|�}Wn&tk
r�tj	d|d�tSXt
|d�s�tdfS|j|�|j|�S(u�
    Removes a team member from a team with team_name.

    name
        The name of the team member to remove.

    team_name
        The name of the team from which to remove the user.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    CLI Example:

    .. code-block:: bash

        salt myminion github.remove_team_member 'user_name' 'team_name'

    .. versionadded:: 2016.11.0
    RuTeam %s does not existuorg_nameuiduResource not found: %suremove_from_membersuKPyGithub 1.26.0 or greater is required for team management, please upgrade.(
R�R4R�RRR!RR3RR5R�RFR>(R$R�RR�R)RR0((s7/usr/lib/python2.7/site-packages/salt/modules/github.pytremove_team_memberZs"


cC@s�djt|d��}|tks*|r�t|�}|jt|d��}|j�}i}xU|D]M}i|jd6|jd6|jdd6|j	d6|jdd6||j
<qgW|t|<nt|S(u=
    Lists all teams with the organization.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    ignore_cache
        Bypasses the use of cached teams.

    CLI Example:

    .. code-block:: bash

        salt myminion github.list_teams

    .. versionadded:: 2016.11.0
    ugithub.{0}:teamsuorg_nameuiduslugudescriptionu
permissionuprivacy(RRRRR!R�R:tslugt_rawDataR�R$(RR'RR)Rt
teams_dataR�R�((s7/usr/lib/python2.7/site-packages/salt/modules/github.pyR��s"




c	C@sRt|d�}	|dkr-t|d�}ndjd|	|g�}
i}|r^||d<n|rq||d<n|r�||d<n|r�|dkr�||d	<n|r�|d
kr�||d<n|r�|dkr�||d
<ni}t|d|
ddd|�}
xF|
D]>}|jd�}|dkr:|||<qt|�||<qW|S(uN
    Returns information for all pull requests in a given repository, based on
    the search options provided.

    .. versionadded:: 2017.7.0

    repo_name
        The name of the repository for which to list pull requests. This
        argument is required, either passed via the CLI, or defined in the
        configured profile. A ``repo_name`` passed as a CLI argument will
        override the ``repo_name`` defined in the configured profile, if
        provided.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    state
        Indicates the state of the pull requests to return. Can be either
        ``open``, ``closed``, or ``all``. Default is ``open``.

    head
        Filter pull requests by head user and branch name in the format of
        ``user:ref-name``. Example: ``'github:new-script-format'``. Default
        is ``None``.

    base
        Filter pulls by base branch name. Example: ``gh-pages``. Default is
        ``None``.

    sort
        What to sort results by. Can be either ``created``, ``updated``,
        ``popularity`` (comment count), or ``long-running`` (age, filtering
        by pull requests updated within the last month). Default is ``created``.

    direction
        The direction of the sort. Can be either ``asc`` or ``desc``. Default
        is ``desc``.

    output
        The amount of data returned by each pull request. Defaults to ``min``.
        Change to ``full`` to see all pull request output.

    per_page
        GitHub paginates data in their API calls. Use this value to increase or
        decrease the number of pull requests gathered from GitHub, per page. If
        not set, GitHub defaults are used. Maximum is 100.

    CLI Example:

    .. code-block:: bash

        salt myminion github.get_prs
        salt myminion github.get_prs base=2016.11
    uorg_nameu	repo_nameu/ureposuheadubaseuper_pageuopenustateucreatedusortudescu	directionRIRJupullsRVuidufullN(RR
RKRMRt
_format_pr(RPRR]theadtbaseRbRcRQRR(RIRVRRtprstpr_tpr_id((s7/usr/lib/python2.7/site-packages/salt/modules/github.pytget_prs�s2?







cC@s�i|jd�d6|jd�d6|jd�d6|jd�d6|jd�jd�d6|jd�d6|jd	�jd
�d6}|S(u�
    Helper function to format API return information into a more manageable
    and useful dictionary for pull request information.

    pr_
        The pull request to format.
    uidunumberu	pr_numberustateutitleuuseruloginuhtml_urlubaseurefubase_branch(R(R�RR((s7/usr/lib/python2.7/site-packages/salt/modules/github.pyR�scC@si|jd�d6|jd�d6|jd�d6|jd�d6|jd�jd�d6|jd�d6}|jd	�}|r�|jd�}n|jd
�}g}x$|D]}|j|jd��q�W|jd�}|r�|jd�}n||d	<||d
<||d<|S(
u�
    Helper function to format API return information into a more manageable
    and useful dictionary for issue information.

    issue
        The issue to format.
    uidunumberuissue_numberustateutitleuuseruloginuhtml_urluassigneeulabelsunameu	milestone(RR#(ReRRR^Ratlabel_namestlabelR\((s7/usr/lib/python2.7/site-packages/salt/modules/github.pyRN+s(



uGETuhttps://api.github.com/c	C@sit|t�si}n|r+||7}n|rG|dj|�7}ntjd|�d|j�krt|d�|d<n|r�d|j�kr�||d<n|d%kr�i}n|dkr�d|d<nt}	|d	kr�t	}	ng}
t}d
}xc|tkrd|r!||d<nt
jjj
||d|d
|d|d|	dddtdtdtddgdt�
}
tjd|
d�|
ddkr�t|
dt�r�|
dS|
|
d}
ntdj|
jd����y)|
jd�jd�jd�d }Wntk
r+t	}qnXd!|kr[|jd"�d jd#�d$}qt	}qW|
S(&uL
    Make a web call to the GitHub API and deal with paginated results.
    u/{0}uGitHub URL: %suaccess_tokenutokenuper_pageuPOSTuapplication/jsonuAcceptuDELETEuupageRRCtheader_dicttdecodetdecode_typeujsonRBtstatusttextthide_fieldstoptsuGitHub Response Status Code: %sustatusi�udictuGitHub Response Error: {0}uerroruheadersuLinku,iunextu>u&page=iN(t
isinstancetdictRR4tdebugtkeysRR
R2Rtsalttutilsthttptqueryt__opts__RRtsplittAttributeError(RRIRJRVtmethodR�RCRRR�tcomplete_resultt	next_pagetpage_numberR*t	link_info((s7/usr/lib/python2.7/site-packages/salt/modules/github.pyRMNsj	

	
	
			)
#
(Bt__doc__t
__future__RRRtloggingtsalt.exceptionsRtsalt.extRtsalt.utils.httpR�RRRtgithub.PaginatedListtgithub.NamedUsertgithub.GithubExceptionRR2tImportErrort	getLoggert__name__R4RR	RRR
R R.R1R3RERHRUR[RfRjRpR&R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�RNRM(((s7/usr/lib/python2.7/site-packages/salt/modules/github.pyt<module>s�

	
			#C$"1;wLE	3.OP$=<#:8'.'3-.[		$

Zerion Mini Shell 1.0