I would like to ask how can I extend CKAN's API by writing my own extension for CKAN. I could not find anything in the documentation.
Could you give some simple example please?
In the OP's defence, the documentation does seem to be a bit opaque. I've been looking at this in an attempt to get a custom API action for supplying JSON news feed to work, and finally came up with this:
import ckan.plugins as plugins
import ckan.plugins.toolkit as toolkit
# Required so that GET requests work
#toolkit.side_effect_free
def get_news(context,data_dict=None):
# The actual custom API method
return {"hello":"world"}
class CustomAPIPlugin(plugins.SingletonPlugin):
plugins.implements(plugins.interfaces.IActions)
def get_actions(self):
# Registers the custom API method defined above
return {'get_news': get_news}
The tutorial which describes creating an authentication plugin is here:
http://docs.ckan.org/en/latest/extensions/tutorial.html#creating-a-new-extension
What I've done is to plagiarise that, but using IActions rather than IAuthFunctions:
http://docs.ckan.org/en/latest/extensions/plugin-interfaces.html
It's working on an installation of CKAN 2.2.1.
Related
Is it possible to have VSCode show a Python method's online documentation upon mouse-over/hover?
For example, PyTorch API Docs are hosted online and the method hierarchy is simple to navigate. When I hover of a method from the PyTorch library, I'd like to see the API documentation from that URL, not just the various method signatures.
This feature is available to Java Developer using Eclipse: The user can configure Eclipse to pull API documentation from a URL (e.g., the List API JavaDocs) on a project-by-project basis. Here's an example of the popup that shows up in Eclipse for the List.of() method:
Notice that along with the method signature is a short description of the method ("returns an unmodifiable list...") along with additional helpful information (e.g., Type parameters, Parameters, and Returns)
To clarify: I'm not only looking for a popup showing the method signature(s), but also the associated documentation. For example: VSCode only displays the method signatures for torch.rand(), but the PyTorch API documentation includes the full description.
Looking through the API documentation it seems that there's currently no way to access a custom report via the API. If this is, in fact, the case, is there a workaround to make this possible?
The goal is to get a modified version of this report shown on the web interface:
No, you need to build the report yourself and call it with the API unfortunately.
Depending on how complex the report is, it can be done pretty quickly. You can quickly generate the GAQL needed for your APU query using this tool: https://developers.google.com/google-ads/api/fields/v7/overview_query_builder
This will save you typing out all the resources manually, and will even validate it for you.
If you're stuck, let us know what report you're trying to generate and we can help with the GAQL.
I have written API documentation using Open API 3 standards (using stoplight.io). Now I'm implementing the API in Python 3.7, and I don't want to rewrite all of the schemas, not to mention I'd like my API to be coupled with my documentation to prevent discrepancies.
I've found tools like pydantic and openapi-schema-validator that seem relevant, but don't fit my use case. For example, pydantic wants me to create the pythonic objects first and then export to json_schema and openapi-schema-validator wants just the json schema while I have an Open API yaml.
This seems like a standard question, but I haven't found a good answer. Thanks!
You could use openapi-core or connexion which both support request and response validation..
I am new in Splunk - as well as in Python and start working on Splunk Custom Module and I have taken reference from Splunk Site Custom Module. When I have created Same file structure using Visual Studio 2017 -> Python3 then its give me an error
import controllers.module not found
import splunk not found
import splunk.search not found
import splunk.util not found
import splunk.entity not found
import json from splunk.appserver.mrsparkle.lib not found
import lib.util as util not found
Note: I have already imported Splunk SDK using "pip install splunk-sdk" Still, I can't find any package in the project.
Please, anyone, guide me how to resolve above custom module package error.
If there is any readymade samples are available then please suggest a link.
Thanks in advance
You may be wasting your time. Splunk Modules have been deprecated for over a year and may become unsupported at any time.
The packages you are looking for should be part of Splunk. Have you installed it?
I believe Splunk does not support Python 3. Try 2.7.
Have you tried taking a look to simple_xml_exaples app for sourcecodeviewer implementation. I think it is a good approach for adding custom HTML + CCS + third party.js.
Furthermore it can be implemented in a custom dashboard.js
edit
Download Simple xml examples APP; in every example dashboard it can be seen that it has a custom component called sourceviewer, that is injected after the load time in every dashboard page.
For that a custom
dashboard.js
is created and inserted in APP/appserver/static so this will override the original
so then you can insert in every dashboard page the new needed components without even afecting the dashboard xml part and its functionalities as pdf generator.
I used that way in order to implement custom Nav as a SideBar.
I'm sorry but I'm having some trouble implementing Oauth within my app engine python project.
I've been working from http://github.com/tav/tweetapp, but I don't think I have a strong enough grasp on this platform to understand how to implement this class within my main.py I'm building the rest of my app in.
This maybe a feeble attempt, but here is what I have so far:
twa = twitter_auth
client = twa.OAuthClient('twitter')
I've created a source folder within my project called "twitter_auth" and that contains a file within it called "twitter_auth.py" which contains the above linked library, and a file called __ init__.py (no space) which is completely empty.
I really have no idea what to do from here :/
Let me recommend taking a look at the tweepy library and some example tweepy apps. Specifically here: http://github.com/wasauce/tweepy-examples
This shows how to use oauth to authenticate a user: http://github.com/wasauce/tweepy-examples/tree/master/appengine/oauth_example/
As Hagge said, it sounds like your issue is more with the tweetapp library than with App Engine. However, if you would like to know more about OAuth on App Engine and if I may be allowed to link to myself, my two articles on the topic seem to be reasonably popular.
The tweetapp library was a an early prototype for Twitter OAuth on twitter. Tav did the heavy lifting and I deployed the site http://twitteroauth.appspot.com , using some of the tweetapp library. The actual source of that site is here (I need to update the site to point here): http://github.com/ryanwi/twitteroauth
I am still using it in production, but, it has aged and does not work for all API calls. I'd recommend trying a different, more up to date and maintained library as others have mentioned.
But, take a look at the twitteroauth source if you want to try to get a first attempt working.
These two are on Twitter's list
http://github.com/brosner/python-oauth2
http://code.google.com/p/oauth-python-twitter2/
I'm not familiar with that library, but after a quick look and seeing the warning that it is not maintained I'd search for something better. I implemented a simple Twitter connection based on Tornado's auth: see an example of how to make Twitter API calls here (and an authentication example here). In case you don't want to use tipfy, I recommend implementing the python-twitter library in your framework of choice.