this is one of the mikrotik api commandlines:
interface route add dst-address=0.0.0.0/0 gateway=36.95.238.111
/interface/route/add =dst-address=0.0.0.0/0 =gateway=36.95.238.111
but how to type :
interface bridge port set \[find interface=wlan1\] disabled=yes
I guessed:
/interface/bridge/port/set/find =interface=wlan1 =disabled=yes
but it's wrong.
and sorry for my English.
I hate to tell you.
The Mikrotik API does not have a "find" command.
You must get all the results and use the *.id field.
I do not think the API can make changes on multiple "objects" in a single command.
Related
I'm trying to figure out if FeathersJS suits my needs. I have looked at several examples and use cases. FeathersJS uses a set of request methods : find, get, create, update, patch and delete. No other methods let alone custom methods can be implemented and used, as confirmed on this other SO post..
Let's imagine this application where users can save their app settings. Careless of following method conventions, I would create an endpoint describing the action that is performed by the user. In this case, we could have, for instance: /saveSettings. Knowing there won't be any setting-finding, -creation, -updating (only some -patching) or -deleting. I might also need a /getSettings route.
My question is: can every action be reduced down to these request methods? To me, these actions are strongly bound to a specific collection/model. Sometimes, we need to create actions that are not bound to a single collection and could potentially interact with more than one collection/model.
For this example, I'm guessing it would be translated in FeathersJS with a service named Setting which would hold two methods: get() and a patch().
If that is the correct approach, it looks to me as if this solution is more server-oriented than client-oriented in the sense that we have to know, client-side, what underlying collection is going to get changed or affected. It feels like we are losing some level of freedom by not having some kind of routing between endpoints and services (like we have in vanilla ExpressJS).
Here's another example: I have a game character that can skill-up. When the user decides to skill-up a particular skill, a request is sent to the server. This endpoint can look like POST: /skillUp What would it be in FeathersJS? by implementing SkillUpService#create?
I hope you get the issue I'm trying to highlight here. Do you have some ideas to share or recommendations on how to organize the API in this particular framework?
I'm not an expert of featherJs, but if you build your database and models with a good logic,
these methods are all you need :
for the settings example, saveSettings corresponds to setting.patch({options}) so to the route settings/:id?options (method PATCH) since the user already has some default settings (created whith the user). getSetting would correspond to setting.find(query)
To create the user AND the settings, I guess you have a method to call setting.create({defaultOptions}) when the user CREATE route is called. This would be the right way.
for the skillUp route, depends on the conception of your database, but I guess it would be something like a table that gives you the level/skills/character, so you need a service for this specific table and to call skillLevel.patch({character, level})
In addition to the correct answer that #gui3 has already given, it is probably worth pointing out that Feathers is intentionally restricting in order to help you create RESTful APIs which focus on resources (data) and a known set of methods you can execute on them.
Aside from the answer you linked, this is also explained in more detail in the FAQ and an introduction to REST API design and why Feathers does what it does can be found in this article: Design patterns for modern web APIs. These are best practises that helped scale the internet (specifically the HTTP protocol) to what it is today and can work really well for creating APIs. If you still want to use the routes you are suggesting (which a not RESTful) then Feathers is not the right tool for the job.
One strategy you may want to consider is using a request parameter in a POST body such as { "action": "type" } and use a switch statement to conditionally perform the desired action. An example of this strategy is discussed in this tutorial.
How do I make an actual remote call?
I've followed the guide: https://codelabs.developers.google.com/codelabs/webrtc-web/#4
And gotten their example fully integrated in my application (Angular, TypeScript, multi webcam &etc).
How do I make the remote call actually remote? - I get the idea of a signalling server, but maybe someone can show with basic strings?
I found this, but it's not been updated in a while so I'm not sure what's still valid:
Found some nice sequence diagrams https://webrtc.org/native-code/native-apis/
Setup call
(source: webrtc.org)
Receive a Call
(source: webrtc.org)
Close Down a Call
(source: webrtc.org)
You can programmatically invoke services if you already know the name of the service. As best I understand, the Services menu is built by calling a validation method on each published Service.
Is there a way to access a list of installed Services without using the Services user dialog?
EDIT: I don't mean background processes. I am talking about the items in the Services menu in Finder. Overview of what they are here.
There is an API provided by Apple, documented here - https://developer.apple.com/documentation/coreservices/launch_services
Note that you need to have your service registered in system database and consuming code needs to know about its existence.
I hope this helps.
The somewhat supported (but poorly documented) approach is to call lsregister and parse the output. The output does not have a documented or guaranteed format, however.
You run it this way for the commandline:
LSREGISTER="/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister"
${LSREGISTER} -dump
(Yes, it's deeply buried and not in PATH.)
This dumps a ton of information. You just want services, which look like this:
--------------------------------------------------------------------------------
service id: FileMerge/Compare To Master (0x16f8)
menu: FileMerge/Compare To Master
port: FileMerge
message: diffVersusMasterService
timeout: -1
send types: "NSFilenamesPboardType"
The part you want is the "menu" tag:
$LSREGISTER -dump | grep ^menu: | cut -c 29-
Obviously you can parse this more directly in code, but the only way I know of that's even vaguely supported is to run lsregister.
OK, that's obnoxious. If you're willing to use private APIs, it's pretty straightforward. Define an interface for LSServiceRecord:
#interface LSServiceRecord
+ (id)enumerator;
- (NSString *)localizedMenuItemTitle;
#end
And then you can enumerate over them to get the menu titles:
id enumerator = [LSServiceRecord enumerator];
for (id item in enumerator) {
NSLog(#"%#", [item localizedMenuItemTitle]);
}
You might find the portName property helpful. It's the name of the application that registered the service. You might also find +[LSServiceRecord enumeratorForContentsOfPasteboard:] useful if you're trying to limit it to valid services.
If you want to explore more, I recommend Hopper, and looking in LaunchServices framework.
try launchctl list, see https://guide.macports.org/chunked/reference.startupitems.html for some more info,.
RESTAdapter has the possibility to specify a url for the backend:
DS.RESTAdapter.reopen({
url: 'https://api.example.com'
});
How can I access this property programmatically? I mean something like: DS.RESTAdapter.get('url') <-This doesn't work
You're setting the properties on the class not the instance, thats why you can't retrieve the values. There are two possible solutions.
You can get the values from the prototype
DS.RESTAdapter.prototype.url
or you can instantiate the class and get it from there
DS.RESTAdapter.create().url
Quick and dirty ...
NOTE: Please use only for debugging, this API is intern and will cenrtainly change in the future, so don't rely on it.
Assuming you have only one Store in your application:
App.__container__.lookup('store:main').get('adapter.url')
If you are using Chrome Dev Tools you can try to call this from the console, it should print out the url used by the default adapter used by the default Store.
But it's discouraged to be used for other then for debugging.
Hope it helps
Or
DS.defaultStore.adapter.url
I would like wxHtmlWindow to use libcurl instead of the internal wxHTTP class.
Is there an easy way to do this? If not, can I at least change the useragent wxHtmlWindow sends when it accesses pages?
I would create a class that manage my curl session. Setting a user agent, cookies, server to connect to etc.
Also I would make that class to be able to save the page I get from the internet to a file temp/web.htm
and then I would use something like:
htmlwin->LoadPage("temp/web.htm");
Where htmlwin is a wxHtmlWindow
This is the first thing that comes in my mind, maybe I can think to a better solution.
EDIT 1:
See this link so see a little example of wrapping curl in a C++ class