API endpoint of this source site to export a part of the page tree
    rooted at page_id

    Requests are made by a destination site's import_from_api view.
338384
def export(request, page_id, export_unpublished=False):
    
    try:
        if export_unpublished:
            root_page = Page.objects.get(id=page_id)
        else:
            root_page = Page.objects.get(id=page_id, live=True)
    except Page.DoesNotExist:
        return JsonResponse({'error': _('page not found')})

    payload = export_pages(root_page, export_unpublished=export_unpublished)

    return JsonResponse(payload)
858624
def _get_request(url_root,api_key,path,response_type,params, ssl_verify):
    
    url = _url_builder(url_root,api_key,path,params)
    content = _fetch(url, ssl_verify)
    response = _dispatch(response_type)(content)
    return response
411325
def bookmark_create(endpoint_plus_path, bookmark_name):
    
    endpoint_id, path = endpoint_plus_path
    client = get_client()

    submit_data = {"endpoint_id": str(endpoint_id), "path": path, "name": bookmark_name}

    res = client.create_bookmark(submit_data)
    formatted_print(res, simple_text="Bookmark ID: {}".format(res["id"]))
1337012
def _url_builder(url_root,api_key,path,params):
    
    params['api_key'] = api_key
    url_end = urlencode(params)
    url = "%s%s%s" % (url_root,path,url_end)
    return url
1027324
private static List<String[]> exportQueryPageCommentsAsCsv(ReplierExportStrategy replierExportStrategy, QueryPage queryPage, ReportPageCommentProcessor processor) {
    QueryQuestionCommentDAO queryQuestionCommentDAO = new QueryQuestionCommentDAO();
    List<String[]> rows = new ArrayList<>();

    processor.processComments();
    List<QueryQuestionComment> rootComments = processor.getRootComments();
    
    if (rootComments != null && !rootComments.isEmpty()) {
      Map<Long, List<QueryQuestionComment>> childCommentMap = queryQuestionCommentDAO.listTreesByQueryPage(queryPage);
      
      for (QueryQuestionComment rootComment : rootComments) {
        String rootUser = getReplierExportStrategyValue(replierExportStrategy, rootComment.getQueryReply());
        String rootLabel = processor.getCommentLabel(rootComment.getId());
        rows.add(new String[] { rootUser, rootLabel, rootComment.getComment(), "" });
        List<QueryQuestionComment> childComments = childCommentMap.get(rootComment.getId());
        if (childComments != null) {
          childComments.forEach(childComment -> {
            String childUser = getReplierExportStrategyValue(replierExportStrategy, childComment.getQueryReply());
            rows.add(new String[] { childUser, "", "", childComment.getComment() });
          });
        }
      }
    }
    
    return rows;
  }
1243489
def _build_and_attach_node(endpoint_class, method_name=nil)
      # Create the new endpoint
      endpoint_instance = endpoint_class.new(@requester, method_name, self)
      # Attach the endpoint as an instance variable and method
      method_name ||= endpoint_class.name.demodulize.underscore
      self.instance_variable_set("@#{method_name}", endpoint_instance)
      self.define_singleton_method(method_name.to_s) { endpoint_instance }
      endpoint_instance
    end
616050
def connection_id_to_endpoint(self, connection_id):
        
        with self._connections_lock:
            try:
                connection_info = self._connections[connection_id]
                return connection_info.uri
            except KeyError:
                return None
281864
def get_page_by_id(self, page_id, expand=None):
        
        url = 'rest/api/content/{page_id}?expand={expand}'.format(page_id=page_id, expand=expand)
        return self.get(url)
354915
def generate_page_object(page_name, url):
    ""

    # Attempt to extract partial URL for verification.
    url_with_path = u('^.*//[^/]+([^?]+)?|$')
    try:
        match = re.match(url_with_path, url)
        partial_url = match.group(1)
        print("Using partial URL for location verification. ", partial_url)
    except:
        # use full url since we couldn't extract a partial.
        partial_url = url
        print("Could not find usable partial url, using full url.", url)

    # Attempt to map input objects.
    print("Processing page source...")
    response = urllib2.urlopen(url)
    html = response.read()
    input_tags_expr = u('<\s*input[^>]*>')
    input_tag_iter = re.finditer(input_tags_expr, html, re.IGNORECASE)

    objectmap = ""
    print("Creating object map for <input> tags...")
    for input_tag_match in input_tag_iter:
        if not "hidden" in input_tag_match.group(0):
            try:
                print("processing", input_tag_match.group(0))
                obj_map_entry = _process_input_tag(input_tag_match.group(0))
                objectmap += u("    ") + obj_map_entry + "\n"
            except Exception as e:
                print(e)
                # we failed to process it, nothing more we can do.
                pass

    return _page_object_template_.contents.format(date=datetime.now(),
                                                  url=url,
                                                  pagename=page_name,
                                                  partialurl=partial_url,
                                                  objectmap=objectmap)
1183839
def copy_page_and_children(self, foreign_id, parent_id, depth=0):
        '''
        
        '''
        url = "{}/api/v2/pages/{}/".format(self.base_url, foreign_id)

        self.log(ACTION, "Requesting Data", {"url": url}, depth)
        try:
            # TODO: create a robust wrapper around this functionality
            response = requests.get(url)
            content = json.loads(response.content)
        except Exception as e:
            self.log(ERROR, "Requesting Data - abandoning copy",
                     {"url": url, "exception": e}, depth)
            return None

        parent = Page.objects.get(id=parent_id).specific
        page = None
        try:
            self.log(ACTION, "Create Page", {"url": url}, depth)
            page = self.attach_page(parent, content)
            if page:
                self.log(SUCCESS, "Create Page",
                         {"url": url,
                          "page title": page.title.encode('utf-8')},
                         depth)
        except PageNotImportable as e:
            message = e.message.pop("message")
            self.log(WARNING, message, e.message.pop("message"), depth)
            return None

        if page:
            # create translations
            if content["meta"]["translations"]:
                for translation_obj in content["meta"]["translations"]:
                    _url = "{}/api/v2/pages/{}/".format(self.base_url,
                                                        translation_obj["id"])
                    # TODO: create a robust wrapper around this functionality
                    _response = requests.get(_url)
                    self.log(
                        ACTION,
                        "Getting translated content",
                        {"url": _url}, depth)
                    if _response.content:
                        _content = json.loads(_response.content)

                        if ("locale" in translation_obj and
                                translation_obj["locale"]):
                            self.attach_translated_content(
                                page, _content, translation_obj["locale"])
                        else:
                            self.log(
                                ERROR,
                                "locale is null",
                                {"url": _url, }, depth)
                    else:
                        self.log(
                            ERROR,
                            "Getting translated content",
                            {"url": _url}, depth)

            main_language_child_ids = content["meta"]["main_language_children"]

            # recursively iterate through child nodes
            if main_language_child_ids:
                for main_language_child_id in main_language_child_ids:
                    try:
                        self.copy_page_and_children(
                            foreign_id=main_language_child_id,
                            parent_id=page.id, depth=depth + 1)
                    except Exception as e:
                        self.log(ERROR, "Copying Children",
                                 {"url": url, "exception": e})
29487
def download(self):
		'''  '''

		self.page = requests.get(self.url)
		self.tree = html.fromstring(self.page.text)
1240217
def loadTopicPageFromER(self, uri):
        
        params = {
            "action": "getTopicPageJson",
            "includeConceptDescription": True,
            "includeTopicPageDefinition": True,
            "includeTopicPageOwner": True,
            "uri": uri
        }
        self.topicPage = self._createEmptyTopicPage()
        self.concept = self.eventRegistry.jsonRequest("/json/topicPage", params)
        self.topicPage.update(self.concept.get("topicPage", {}))
387223
protected void initHtmlImportObject() {

        Object o;
        String uri = getJsp().getRequestContext().getUri();
        if ((uri == null) || uri.endsWith(IMPORT_STANDARD_PATH)) {
            m_dialogMode = MODE_STANDARD;
        } else if (uri.endsWith(IMPORT_DEFAULT_PATH)) {
            m_dialogMode = MODE_DEFAULT;
        } else {
            m_dialogMode = MODE_ADVANCED;
        }
        if (CmsStringUtil.isEmpty(getParamAction())) {
            o = new CmsHtmlImport(getJsp().getCmsObject());
        } else {
            // this is not the initial call, get the job object from session
            o = getDialogObject();
        }

        if (!(o instanceof CmsHtmlImport)) {
            // create a new HTML import handler object
            m_htmlimport = new CmsHtmlImport(getJsp().getCmsObject());
        } else {
            // reuse HTML import handler object stored in session
            m_htmlimport = (CmsHtmlImport)o;
            // this is needed, because the user can switch between the sites, now get the current
            m_htmlimport.setCmsObject(getJsp().getCmsObject());
        }

        // gets the data from the configuration file
        fillHtmlImport();
    }
170496
def endpoint(self):
        
        if self.endpoint_ref and self.tunnel_interface_ref:
            return InternalEndpoint(href=self.endpoint_ref)
        return Element.from_href(self.endpoint_ref)
1194935
def build_tree(requester)
      root_node = build_root_node(requester)
      # Search out the implementations directory structure for endpoints
      if defined?(self.implementation_root)
        # For each endpoints directory, recurse down it to load the modules
        endpoints_directories.each do |endpoints_directories|
          Dir["#{endpoints_directories}/**/*.rb"].each { |f| require(f) }
        end
        build_node_children(self.endpoints_module, root_node, requester)
      end
      root_node
    end
1319744
def page_from_static_file(static_file)
      base = static_file.instance_variable_get("@base")
      dir  = static_file.instance_variable_get("@dir")
      name = static_file.instance_variable_get("@name")
      Jekyll::Page.new(site, base, dir, name)
    end
73826
function createUrlFromEndpointAndOptions (endpoint, options) {
  const query = qs.stringify(options);
  const baseURL = `${host}${endpoint}`;
  return query ? `${baseURL}?${query}` : baseURL;
}