Attaching an existing Evernote resource to a new Evernote note - evernote

According to the Evernote docs, a resource is created along with a note that contains and references it.
Say I have a note with a resource, and I want to create a new note with exactly the same resource.
Is there a way to create the new note and use the existing resource, instead of creating a new duplicate resource?
Reasons for that:
I get the existing note with resources using getNote API call, and I have no reason to pass with_resource_data=True, which will consume bandwidth.
I don't want to consume extra quota by uploading the resource data again with the new note.
I'm using the Python Evernote SDK.

No. There's no way to do that.
A resource is linked to a specific note and can't be shared amongst notes.
That's why there's a noteGuid attribute in the Resource object.
So you'll have to get the resource with the note, attach it to the new note and upload the new note.
It's not optimal but it's the only way...

Related

How to properly mock API results for testing with NextJS and MSW?

First of all, if I should ask this question elsewhere please let me know, as I'm not sure where it belongs.
I have a working application with NextJS and MSW, where I can capture the server-side API requests with MSW and return mocked JSON results.
The issue I have is that there are probably about 15 API calls that I need to mock in order to test my application properly
While I could just call each one of these manually, copy and paste the results into a file and then just return that data from the file when I capture the API call, this not a very scalable solution, especially if the back-end API changes.
Question: What are your best methods for automating the generation of these results?
In the past I have created JSON files that have all of the URL paths and query parameters explicitely listed, and I would parse through this file and query every endpoint, and then I had template files which would be used to re-populate my fixtures directory with all of the mocked responses, however this was also very cumbersome.
(For reference, the API has a somewhat similar structure to this one: https://api.gouv.fr/documentation/api-geo, where there are multiple endpoints for fetching data, and each endpoint supports a number of different query parameters to tweak the call.)

Axon stores events as XML instead of JSON

I'm new on Axon framework and i want to configure Axon in order to store events as JSON.
I'm using Spring-Boot and, as per documentation, i set some key/value in a .properties file
I expected to see events stored as JSON but i keep seeing XML in the serializedPayload of the MongoDB event store.
I think I have configured the serilializers correctly but obviously I'm doing something wrong
Please note that debugging the application it seems that JacksonSerializer class is never invocated and instead XStreamSerializer class is called even my key/value configuration.
So i need to understand why my jackson configuraton is not calling the right serializer
You have to configure the MongoEventStorageEngine to use the Serializer you want.
Looking at it's Builder (specially the javadoc), you can see it offers a snapshotSerializer and a eventSerializer methods while the javadoc states that both of them defaults to XStreamSerializer.
If you need help configuring it, I can point you to the mongo-axon-example where you can see a project configured and running.
The example is not using Jackson but it should be an easy addition to configure it here.
Even if the documentation doesn't seem to mention it, it is not enough to add the key/value in the .properties file. You need also to add the JacksonSerializer to the MongoEventStorageEngine as following:

Azure Api Management append api to existing api with arm

I wonder how you can append a second api to an already registered api in Azure api management via an ARM deploy?
If I use the same value for the name property in my Microsoft.ApiManagement/service/apis resource. It overwrites the whole api instead of appending it. I don't find a property in the arm reference docs to specify I want to append the api instead of overwriting it: https://learn.microsoft.com/en-us/azure/templates/microsoft.apimanagement/2019-01-01/service/apis
I want to accomplish the same result via arm, like I am able todo via the Azure portal import menu
This is also described in the docs: https://learn.microsoft.com/en-us/azure/api-management/add-api-manually#append-other-apis
That is easily not possible at the moment. "Append" logic is implemented in UI, but it does rely only on publicly available ARM calls. You could inspect calls it makes to ARM to append one API to another and try to reproduce it "by hand".

Spring Boot Rest service changing attributes

I have been asked in an interview below question:
I have a rest service developed using spring boot and this service is running in production and consumed by 500 other services. I want to change some attributes in this service for new consumers. How do I achieve this one without impacting existing 500 consumers.
Just add a new method with the new attributes for the new customer and leave the old one as it is.
Add a new version of your webservice (by using URL encoded versioning) and give the new customer the new version URL.
REST versioning
You can do this in two ways.
You must have given API documentation to the customers i-e confluence or any other document. Update the document and share with customers the updated one.
You can also do it using API definition scripts called YAML. If you add new attribute, you need to update the YAML configuration of the API and share it with all the customers.

Is it correct aspnetcore way? Service & Dependency Injection

so i want to create some service that accesses external API, and i want to cache common requests from the API inside of that service, it depends on 3 other services, but i want to give it its own instance of cache, MemoryDistributedCache might later be changed for something else
services.AddSingleton<ISomeApi, SomeApi>(provider => new SomeApi(
Configuration.Get<Options>(),
new MemoryDistributedCache(new MemoryCache(new MemoryCacheOptions())),
provider.GetService<ILogger<SomeApi>>()
));
now from my Controllers i can access the api via DI, it works nicely but im not sure if its some sort of an anti-pattern or if there are better ways of doing it
i mean the real problem is separating the internal cache, requesting
IDistributedMemory from one service would give me the same object as if i request it from another service, they must be separated
This sounds like something you could use a proxy or decorator pattern for. The basic problem is that you have a service that does some data access, and another service responsible for caching the results of the first service. I realize you're not using a repository per se, but nonetheless the CachedRepository pattern should work for your needs. See here:
http://ardalis.com/introducing-the-cachedrepository-pattern
and
http://ardalis.com/building-a-cachedrepository-via-strategy-pattern
You can write your cached implementation such that it takes in the actual SomeApi type in its constructor if you don't need that part of the design to be flexible.

Resources