%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/bamboohr.pyc

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddl	m
Z
ddlmZ
eje�Zd�Zd�Zdd	�Zdd
�Zdddd�Zdd�Zd
�Zdddddd�ZdS(u�
Support for BambooHR

.. versionadded:: 2015.8.0

Requires a ``subdomain`` and an ``apikey`` in ``/etc/salt/minion``:

.. code-block: yaml

    bamboohr:
      apikey: 012345678901234567890
      subdomain: mycompany
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(tElementTreecC@st�r
tStdfS(u5
    Only load the module if apache is installed
    uKThe API key was not specified. Please specify it using the "apikey" config.(t_apikeytTruetFalse(((s9/usr/lib/python2.7/site-packages/salt/modules/bamboohr.pyt__virtual__s	cC@stjdi�jdd�S(u
    Get the API key
    ubamboohruapikeyN(t__opts__tgettNone(((s9/usr/lib/python2.7/site-packages/salt/modules/bamboohr.pyR&suidcC@s�i}tdddd�\}}tj|�}|j�}x�|D]�}|jdkr^qCnxo|D]g}|j�dd}i|d6}	x/|j�D]!}
|
j|	|
j�dd<q�W|	||	|<qeWqCW|S(u�
    Show all employees for this company.

    CLI Example:

        salt myminion bamboohr.list_employees

    By default, the return data will be keyed by ID. However, it can be ordered
    by any other field. Keep in mind that if the field that is chosen contains
    duplicate values (i.e., location is used, for a company which only has one
    location), then each duplicate value will be overwritten by the previous.
    Therefore, it is advisable to only sort by fields that are guaranteed to be
    unique.

    CLI Examples:

        salt myminion bamboohr.list_employees order_by=id
        salt myminion bamboohr.list_employees order_by=displayName
        salt myminion bamboohr.list_employees order_by=workEmail
    tactionu	employeestcommandu	directoryiiuid(t_querytETt
fromstringtgetchildrenttagtitemsttext(torder_bytrettstatustresulttroott	directorytcattitemtemp_idtemp_rettdetails((s9/usr/lib/python2.7/site-packages/salt/modules/bamboohr.pytlist_employees-s


cC@s�i}|dkr$djd�}ntddd|di|d6�\}}tj|�}|j�}i|d6}x)|D]!}|j||j�dd<q{W|S(u4
    Show all employees for this company.

    CLI Example:

        salt myminion bamboohr.show_employee 1138

    By default, the fields normally returned from bamboohr.list_employees are
    returned. These fields are:

        - canUploadPhoto
        - department
        - displayName
        - firstName
        - id
        - jobTitle
        - lastName
        - location
        - mobilePhone
        - nickname
        - photoUploaded
        - photoUrl
        - workEmail
        - workPhone
        - workPhoneExtension

    If needed, a different set of fields may be specified, separated by commas:

    CLI Example:

        salt myminion bamboohr.show_employee 1138 displayName,dateOfBirth

    A list of available fields can be found at
    http://www.bamboohr.com/api/documentation/employees.php
    u,ucanUploadPhotou
departmentudisplayNameu	firstNameuidujobTitleulastNameulocationumobilePhoneunicknameu
photoUploadeduphotoUrlu	workEmailu	workPhoneuworkPhoneExtensionRu	employeesR
targsufieldsiiN(ucanUploadPhotou
departmentudisplayNameu	firstNameuidujobTitleulastNameulocationumobilePhoneunicknameu
photoUploadeduphotoUrlu	workEmailu	workPhoneuworkPhoneExtension(RtjoinRRRRRR(RtfieldsRRRRRR((s9/usr/lib/python2.7/site-packages/salt/modules/bamboohr.pyt
show_employeeRs8$

c
C@s�|d
kr?|d
ks$|d
kr/idd6Si||6}n*t|tj�ritjjj|�}nd}x(|D] }|dj|||�7}qvWdj|�}t	ddd|d	|d
d�\}}t
|dj|j���S(u�
    Update one or more items for this employee. Specifying an empty value will
    clear it for that employee.

    CLI Examples:

        salt myminion bamboohr.update_employee 1138 nickname Curly
        salt myminion bamboohr.update_employee 1138 nickname ''
        salt myminion bamboohr.update_employee 1138 items='{"nickname": "Curly"}
        salt myminion bamboohr.update_employee 1138 items='{"nickname": ""}
    u'At least one key/value pair is requireduErroruu<field id="{0}">{1}</field>u<employee>{0}</employee>Ru	employeesR
tdatatmethoduPOSTu,N(
Rt
isinstanceRtstring_typestsalttutilstyamlt	safe_loadtformatRR$R"tkeys(RtkeytvalueRt	xml_itemstpairRR((s9/usr/lib/python2.7/site-packages/salt/modules/bamboohr.pytupdate_employee�s 
c
C@s�i}tdddd�\}}tj|�}|j�}x�|D]�}d}i}xC|j�D]5}	|	d||	d<|	ddkrb|	d}qbqbWx$|j�D]}	|	j||	j<q�W||||<qCW|S(	u�
    Show all users for this company.

    CLI Example:

        salt myminion bamboohr.list_users

    By default, the return data will be keyed by ID. However, it can be ordered
    by any other field. Keep in mind that if the field that is chosen contains
    duplicate values (i.e., location is used, for a company which only has one
    location), then each duplicate value will be overwritten by the previous.
    Therefore, it is advisable to only sort by fields that are guaranteed to be
    unique.

    CLI Examples:

        salt myminion bamboohr.list_users order_by=id
        salt myminion bamboohr.list_users order_by=email
    RumetaR
uusersiiuidN(RRRRRRRR(
RRRRRtuserstusertuser_idtuser_retR((s9/usr/lib/python2.7/site-packages/salt/modules/bamboohr.pyt
list_users�s
c	C@s�i}tdddd�\}}tj|�}|j�}xt|D]l}d	}i|jd6}xC|j�D]5}|d||d<|ddkrl|d}qlqlW|||<qCW|S(
ux
    Show all meta data fields for this company.

    CLI Example:

        salt myminion bamboohr.list_meta_fields
    RumetaR
ufieldsunameiiuidN(RRRRRRR(	RRRRR#tfieldtfield_idt	field_retR((s9/usr/lib/python2.7/site-packages/salt/modules/bamboohr.pytlist_meta_fields�s
uGETc	C@s�tjdi�jdd�}dj|�}|r@||7}n|r\|dj|�7}ntjd|�t|t�s�i}nd}tj	j
j||dt�ddd	|d
|dt
dtd
tdt�}tjd|d�|d|dgS(ug
    Make a web call to BambooHR

    The password can be any random text, so we chose Salty text.
    ubamboohru	subdomainu0https://api.bamboohr.com/api/gateway.php/{0}/v1/u/{0}uBambooHR URL: %stusernametpasswordu	saltyporktparamsR%tdecodeRRtoptsu!BambooHR Response Status Code: %sustatusutextN(R	R
RR-tlogtdebugR'tdictR)R*thttptqueryRRR(	RR
R!R&R%t	subdomaintpathtreturn_contentR((s9/usr/lib/python2.7/site-packages/salt/modules/bamboohr.pyR�s0
	
			(t__doc__t
__future__RRRtloggingtsalt.utils.httpR)tsalt.utils.yamltsalt.extRtsalt._compatRRt	getLoggert__name__RBRRR RR$R3R8R<R(((s9/usr/lib/python2.7/site-packages/salt/modules/bamboohr.pyt<module>s&			%G"%	

Zerion Mini Shell 1.0