def updateInputs(srv, prt, usr, pwd, outLst):
    try:
        # GeoEvent admin URL
        geeUrl = 'https://{}:{}/geoevent/admin'.format(srv, prt)
        # Get GeoEvent token to access admin API
        sh = AGSTokenSecurityHandler(username=usr,
                                    password=pwd,
                                    org_url=geeUrl,
                                    token_url='https://{}:6443/arcgis/tokens/'.format(srv),  # token URL for AGS
                                    proxy_url=None,
                                    proxy_port=None)
        sh.referer_url = geeUrl  # need to set the referrer to generate token correctly

        if sh.token is not None:
            # Instantiate the AGS admin object
            ags = AGSAdministration(url=geeUrl,
                                    securityHandler=sh,
                                    proxy_url=None,
                                    proxy_port=None)

            for output in outLst:
                getInputsUrl = 'https://{}:{}/geoevent/admin/output/{}/stop'.format(srv, prt, output)
                ags._get(url=getInputsUrl, securityHandler=sh)  # _get method uses the stop URL and the token to stop the output
                print "{} Stopped successfully".format(output)
            del ags, sh
        else:
            print "Unable to get token, check username, password and token url"
            del sh
            sys.exit(1)

    except Exception:
        line, filename, synerror = trace()
        print "error on line: %s" % line
        print "error in file name: %s" % filename
        print "with error message: %s" % synerror
def startOutputs(srv, prt, usr, pwd, outLst):
    try:
        # GeoEvent admin URL
        geeUrl = 'https://{}:{}/geoevent/admin'.format(srv, prt)
        # Get the AGS token to pass to GEE
        sh = AGSTokenSecurityHandler(username=usr,
                                    password=pwd,
                                    org_url=geeUrl,
                                    token_url='https://{}:6443/arcgis/tokens/'.format(srv),
                                    proxy_url=None,
                                    proxy_port=None)

        if sh.token is not None:
            # Build the AGS admin object
            ags = AGSAdministration(url=geeUrl,
                                    securityHandler=sh,
                                    proxy_url=None,
                                    proxy_port=None)

            for output in outLst:
                startUrl = 'https://{}:{}/geoevent/admin/output/{}/start/'.format(srv, prt, output)
                ags._get(url=startUrl, securityHandler=sh)  # _get method uses the start URL and the token to start the output
                print "{} Started successfully".format(output)
            del ags, sh
        else:
            print "Unable to get token, check username, password and token url"
            del sh
            sys.exit(1)

    except Exception:
        line, filename, synerror = trace()
        print "error on line: %s" % line
        print "error in file name: %s" % filename
        print "with error message: %s" % synerror
Exemplo n.º 3
0
def Main():
    # Get GeoEvent token to access admin API
    sh = AGSTokenSecurityHandler(
        username=username,
        password=password,
        org_url=AGS_URL_TOKEN,
        token_url=AGS_URL_TOKEN,  # token URL for AGS
        proxy_url=None,
        proxy_port=None)
    sh.referer_url = GES_URL_ADMIN  # need to set the referrer to generate token correctly

    if sh.token is not None:
        # Instantiate the AGS admin object
        ags = AGSAdministrationPut(url=GES_URL_ADMIN,
                                   securityHandler=sh,
                                   proxy_url=None,
                                   proxy_port=None)

        # use a get() method to get the requested component json
        componentList = ags._get(url=GES_URL_INPUTS, securityHandler=sh)
        for component in componentList:
            if len(geeTargetInputList) > 0 and not any(
                    component[NAME] in s for s in geeTargetInputList):
                # we arn't interested in this item so
                continue
            else:
                # geeTargetInputList is either empty or we care about this input
                if paramType == CLIENT_PARAMETERS:
                    updatedInput = updateInputClientParameter(component)
                elif paramType == HEADERS:
                    updatedInput = updateInputHeader(component)

                ags._put(url=GES_URL_INPUT,
                         securityHandler=sh,
                         param_dict=updatedInput)
                try:
                    print "Updated {} '{}' parameter on input named {}".format(
                        CLIENT_PARAMETERS, paramName, component[NAME])
                except:
                    print "Failed to update input"
        del ags, sh, componentList
    else:
        print "Unable to get token, check username, password, referer url and token url"
        del sh
        sys.exit(1)
Exemplo n.º 4
0
from arcrest.security.security import AGSTokenSecurityHandler
from arcrest.manageags import AGSAdministration

if __name__ == "__main__":
    username = ""
    password = ""
    url = ""

    sh = AGSTokenSecurityHandler(username=username,
                                 password=password,
                                 token_url=url + '/tokens/',
                                 proxy_url=None,
                                 proxy_port=None)

    ags = AGSAdministration(url=url,
                            securityHandler=sh,
                            proxy_url=None,
                            proxy_port=None)

    security_cfg = ags.security.securityConfig
    print(security_cfg)

    if 'sslEnabled' in security_cfg:
        security_cfg['sslEnabled'] = False

    if 'httpEnabled' in security_cfg:
        security_cfg['httpEnabled'] = True

    res = ags.security.updateSecurityConfig(security_cfg)
    print(res)
Exemplo n.º 5
0
    # Get Python syntax error
    #
    synerror = traceback.format_exc().splitlines()[-1]
    return line, filename, synerror


if __name__ == "__main__":
    username = ""
    password = ""
    url = "https://arcrestdev1.esri.com/arcgis/admin/"

    try:
        sh = AGSTokenSecurityHandler(
            username=username,
            password=password,
            org_url="http://arcrestdev1.esri.com/arcgis",
            token_url=None,
            proxy_url=None,
            proxy_port=None)
        print sh.token
        ags = AGSAdministration(url=url,
                                securityHandler=sh,
                                proxy_url=None,
                                proxy_port=None)
        print ags.data

    except:
        line, filename, synerror = trace()
        print "error on line: %s" % line
        print "error in file name: %s" % filename
        print "with error message: %s" % synerror