"""
   Adminstration.py allows users to control ArcGIS Server 10.1+
   through the Administration REST API

"""
from .._abstract.abstract import BaseAGSServer
from ..security import OAuthSecurityHandler, NTLMSecurityHandler, PKISecurityHandler, \
    PortalServerSecurityHandler, PortalTokenSecurityHandler, \
    ArcGISTokenSecurityHandler,AGOLTokenSecurityHandler, \
    LDAPSecurityHandler, AGSTokenSecurityHandler

from datetime import datetime
import csv
import os
import json
import _machines, _clusters
import _data, _info
import _kml, _logs
import _security, _services
import _system
import _uploads, _usagereports

########################################################################
class AGSAdministration(BaseAGSServer):
    """
    Wrapper for the ArcGIS Server REST API

    Inputs:
       url - Administration REST URL
       securityHandler - security handler object for ArcGIS Server
       proxy_url - optional URL of a proxy
       proxy_port - optional port of a proxy
       initialize - default is false.  False means the object does not make
                    any REST calls until the object is actually needed,
                    whereas True means the object's properties are
                    initialized at creation.
    """
    _url = None
    _securityHandler = None
    _proxy_url = None
    _proxy_port = None
    _json = None
    _acceptLanguage = None
    _currentVersion = None
    _resources = None
    _fullVersion = None
    #----------------------------------------------------------------------
    def __init__(self, url, securityHandler,
                 proxy_url=None, proxy_port=None,
                 initialize=False):
        """Constructor"""
        if url.lower().endswith('/admin') == False: