Return the application URL from the app info page on the Spark master.
        Due to a bug, we need to parse the HTML manually because we cannot
        fetch JSON data from HTTP interface.
327169
def _get_standalone_app_url(self, app_id, spark_master_address, requests_config, tags):
        
        app_page = self._rest_request(
            spark_master_address,
            SPARK_MASTER_APP_PATH,
            SPARK_STANDALONE_SERVICE_CHECK,
            requests_config,
            tags,
            appId=app_id,
        )

        dom = BeautifulSoup(app_page.text, 'html.parser')
        app_detail_ui_links = dom.find_all('a', string='Application Detail UI')

        if app_detail_ui_links and len(app_detail_ui_links) == 1:
            return app_detail_ui_links[0].attrs['href']
857310
def get_redirect(self):
        
        index_url = self.appbuilder.get_url_for_index
        page_history = Stack(session.get("page_history", []))

        if page_history.pop() is None:
            return index_url
        session["page_history"] = page_history.to_json()
        url = page_history.pop() or index_url
        return url
880760
def _parse_application_info(self, info_container):
        
        m = applications_regex.search(info_container.text)
        if m:
            self.open_applications = m.group(1) == "opened"
52619
def show(cls, app_id):
        
        conn = Qubole.agent()
        return conn.get(cls.element_path(app_id))
1117992
def _spark_streaming_statistics_metrics(self, instance, running_apps, addl_tags, requests_config):
        
        for app_id, (app_name, tracking_url) in iteritems(running_apps):
            try:
                base_url = self._get_request_url(instance, tracking_url)
                response = self._rest_request_to_json(
                    base_url,
                    SPARK_APPS_PATH,
                    SPARK_SERVICE_CHECK,
                    requests_config,
                    addl_tags,
                    app_id,
                    'streaming/statistics',
                )
                self.log.debug('streaming/statistics: %s', response)
                tags = ['app_name:%s' % str(app_name)]
                tags.extend(addl_tags)

                # NOTE: response is a dict
                self._set_metrics_from_json(tags, response, SPARK_STREAMING_STATISTICS_METRICS)
            except HTTPError as e:
                # NOTE: If api call returns response 404
                # then it means that the application is not a streaming application, we should skip metric submission
                if e.response.status_code != 404:
                    raise
133445
def _app(self):
        
        if self.app is not None:
            return self.app

        ctx = _request_ctx_stack.top
        if ctx is not None:
            return ctx.app

        try:
            from flask import _app_ctx_stack
            app_ctx = _app_ctx_stack.top
            if app_ctx is not None:
                return app_ctx.app
        except ImportError:
            pass

        raise RuntimeError('assets instance not bound to an application, '+
                            'and no application in current context')
1109519
public String buildAppUrl(LibertyServer theServer, String root, String app) throws Exception {

        return SecurityFatHttpUtils.getServerUrlBase(theServer) + root + "/rest/" + app + "/" + MpJwtFatConstants.MPJWT_GENERIC_APP_NAME;

    }
36956
public Optional<Application> show(long applicationId)
    {
        return HTTP.GET(String.format("/v2/applications/%d.json", applicationId), APPLICATION);
    }
570023
private ApplicationDefinition getApplication(String uri, Tenant tenant) {
        if (uri.length() < 2 || uri.startsWith("/_")) {
            return null;    // Non-application request
        }
        String[] pathNodes = uri.substring(1).split("/");
        String appName = Utils.urlDecode(pathNodes[0]);
        ApplicationDefinition appDef = SchemaService.instance().getApplication(tenant, appName);
        if (appDef == null) {
            throw new NotFoundException("Unknown application: " + appName);
        }
        return appDef;
    }
639505
def get_view_url(self, webapp: str = "oc", **kwargs):
        
        # build wbeapp URL depending on choosen webapp
        if webapp in self.WEBAPPS:
            webapp_args = self.WEBAPPS.get(webapp).get("args")
            # check kwargs parameters
            if set(webapp_args) <= set(kwargs):
                # construct and return url
                url = self.WEBAPPS.get(webapp).get("url")

                return url.format(**kwargs)
            else:
                raise TypeError(
                    "'{}' webapp expects {} argument(s): {}."
                    " Args passed: {}".format(
                        webapp, len(webapp_args), webapp_args, kwargs
                    )
                )
        else:
            raise ValueError(
                "'{}' is not a recognized webapp among: {}."
                " Try to register it.".format(self.WEBAPPS.keys(), webapp)
            )
680390
def _standalone_init(self, spark_master_address, pre_20_mode, requests_config, tags):
        
        metrics_json = self._rest_request_to_json(
            spark_master_address, SPARK_MASTER_STATE_PATH, SPARK_STANDALONE_SERVICE_CHECK, requests_config, tags
        )

        running_apps = {}

        if metrics_json.get('activeapps'):
            for app in metrics_json['activeapps']:
                app_id = app.get('id')
                app_name = app.get('name')

                # Parse through the HTML to grab the application driver's link
                try:
                    app_url = self._get_standalone_app_url(app_id, spark_master_address, requests_config, tags)

                    if app_id and app_name and app_url:
                        if pre_20_mode:
                            self.log.debug('Getting application list in pre-20 mode')
                            applist = self._rest_request_to_json(
                                app_url, SPARK_APPS_PATH, SPARK_STANDALONE_SERVICE_CHECK, requests_config, tags
                            )
                            for appl in applist:
                                aid = appl.get('id')
                                aname = appl.get('name')
                                running_apps[aid] = (aname, app_url)
                        else:
                            running_apps[app_id] = (app_name, app_url)
                except Exception:
                    # it's possible for the requests to fail if the job
                    # completed since we got the list of apps.  Just continue
                    pass

        # Report success after gathering metrics from Spark master
        self.service_check(
            SPARK_STANDALONE_SERVICE_CHECK,
            AgentCheck.OK,
            tags=['url:%s' % spark_master_address] + tags,
            message='Connection to Spark master "%s" was successful' % spark_master_address,
        )
        self.log.info("Returning running apps %s" % running_apps)
        return running_apps
919527
@RequestMapping(value = "", method = RequestMethod.GET)
    public Resource<Info> info() {
        return Resource.of(
                infoService.getInfo(),
                uri(on(getClass()).info())
        )
                // API links
                .with("user", uri(on(UserController.class).getCurrentUser()))
                        // TODO Structure controller (--> projects, branches, etc.)
                        // Info message
                .with("_applicationInfo", uri(on(InfoController.class).applicationInfo()))
                ;
    }
570679
def url(self):
    '''
    '''
    path = '/web/itemdetails.html?id={}'.format(self.id)
    return self.connector.get_url(path, attach_api_key=False)
533668
def get_notebook_url(self):
        
        url = self._client._build_url('service_execution_notebook_url', service_execution_id=self.id)
        response = self._client._request('GET', url, params=dict(format='json'))

        if response.status_code != requests.codes.ok:
            raise APIError("Could not retrieve notebook url '{}': {}".format(self, response))

        data = response.json()
        url = data.get('results')[0].get('url')
        return url
1064489
def data_url(contents, domain=DEFAULT_DOMAIN):
    
    url = (domain + '#data=data:application/json,' +
           urllib.parse.quote(contents))
    return url
30989
@Override
	public Response loadZippedApplicationTemplate( String url ) {

		this.logger.fine( "Request: load application from URL " + url + "." );
		ResolvedFile resolvedFile = null;
		File extractionDir = null;
		Response response;

		// Retrieve the file as a local one
		if( Utils.isEmptyOrWhitespaces( url )) {
			response = handleError(
					Status.NOT_ACCEPTABLE,
					new RestError( REST_MNGMT_INVALID_URL, value( url )),
					lang( this.manager )).build();

		} else try {
			// Get a resolver...
			IUrlResolver resolver = this.mavenResolver != null ? new MavenUrlResolver( this.mavenResolver ) : new DefaultUrlResolver();
			resolvedFile = resolver.resolve( url );

			// Extract the ZIP content
			extractionDir = new File( System.getProperty( "java.io.tmpdir" ), "roboconf/" + UUID.randomUUID().toString());
			Utils.extractZipArchive( resolvedFile.getFile(), extractionDir );

			// Load the application template
			response = loadUnzippedApplicationTemplate( extractionDir.getAbsolutePath());

		} catch( IOException e ) {
			response = handleError(
					Status.UNAUTHORIZED,
					new RestError( REST_SAVE_ERROR, e ),
					lang( this.manager )).build();

		} finally {
			// We do not need the extracted application anymore.
			// In case of success, it was copied in the DM's configuration.
			Utils.deleteFilesRecursivelyAndQuietly( extractionDir );

			// If the resolved file did not exist before, delete it as we do not need it anymore
			if( resolvedFile != null && ! resolvedFile.existedBefore())
				Utils.deleteFilesRecursivelyAndQuietly( resolvedFile.getFile());
		}

		return response;
	}
1140754
def get_resource(url, headers):
    
    headers["Accept"] = "application/json"
    response = Catalyst_DAO().getURL(url, headers)

    if response.status != 200:
        raise DataFailureException(url, response.status, response.data)

    try:
        return json.loads(response.data)
    except ValueError as ex:
        raise DataFailureException(url, response.status, response.data)