Batch create documents in firestore (with direct api) - google-api

I'm trying to update an existing firestore google apps script library to also allow for batch create documents. Now, I understand the existing library as explained very well here. I'm testing with postman and am able to create documents.
Now I would like to create multiple document with a batch write.
But I find the Google Documentation quite hard to read. So I was looking for a simple example how the body request looks of a batch write, could someone provide this for me?
I read a comment by LaughDonor here that it should be using these endpoints:
Begin Transaction - I have this working and received a transaction token
Commit Transaction - could someone provide me with an example of what a Write object would look?
Rollback Transaction

Related

How can I wrap an existing REST API into graphQL API using AWS appsync?

I am trying to convert my REST API into graphql using AWS app sync, the problem is I am unable to fine the right method or documentation on how to do it.
I have successfully created a schema, I am trying to give a resolver for it, but I am not sure what is the right way to do it.
The problem was the creation of a pipeline, I changed actions > update runtime > Unit Resolver (VTL only). and then selecting the HTTP request as a data source was open for me to use. the document does not seem to have this information, anyways if you play with it for some time, you can get it (quite frustrating, ngl).

Add multiple events in Google Calendar using batch request

I want to add multiple events in google calendar using google calendar API. I am thinking of using batch request for the same but unfortunately, I couldn't find any helpful pkg or article to help me send batch request using golang.
can anyone please explain me how to send batch request to google calendar to insert event using golang.
Thank you!
The first thing you need to consider is why you want to bother with batching
Batching is not going to save you quota, in some case it will increase the likly hood that you will get a flooding error. All batching saves you is the number of HTTP calls.
You're limited to 50 calls in a single batch request and they must all be to the same authorized user. So unless you are planning on inserting a large number of events to a single users calendar there is really no reason to work out batching.
That being said from what i can see the google-apis-go-client does not support batching and they dont intend to add it. Which would mean that if you do in fact want to add batching you will need to check the first link i posted and code this manually yourself.

What architecture is best for multiple users editing the same database record?

I have a Django REST Application that has POST and GET endpoints for a record in database. It allows multiple users to POST data to it and GET from it. I can implement locking to make sure the records don't get overwritten and I can make sure the front-end pulls latest record first before users starts to write.
The problem comes when two users are editing the same thing simultaneously, I am looking for a solution as robust as Miro or Google Docs, where you can see the name of the user editing a line while you are also editing the same line.
Currently, its a simple Django REST app but is there anything out there that can help me make it more like Google Doc editing, as robust and truly realtime as it?
How are they managing such a thing in their architecture? What am I missing here?

How to work in Laravel app with external api?

in my Laravel 5.7/mysql app I need to make external api to read some data from external
app with get request and to write some data to my db with post request.
Which tools/scripts are there for this and how to make these requests safe?
MODIFIED :
Thanks for feedbacks, but looks like I badly put my question
The external app(I do not know what is it written with) need to read data from my app
and write data to my Laravel 5 app.
And how have I to test these requests while on development locally ?
Looks like I have to use Guzzle as in provided link?
Which steps have I to take for safety on my side?
Thanks!
These three libraries are popular for your use-case:
Guzzle
Curl
zttp
If the database is local you can use Eloquent, If not, remote connection to that database may help. otherwise, if you only have API access you should consume eighter of above libraries or any alternative options to make an HTTP request your application might require.
Security-wise, as long as you are only making a request to a remote server, the Suggested way is to store any key or secret string related to authorizing your request (if applicable) in your .env to prevent it from committed to your version control systems. Needless to say to always handle any possible HTTP error your remote API might throw in order to prevent any unwanted error on your application side.
And as Abir Adak mentioned in the comment check this thread for further details.
Updated Answer: On the case of MODIFIED part, generally you have 3 popular options,
REST API
This blog post is a detailed walkthrough written for Laravel
This one from Stack Overflow can help you with designing you API
This last one can help you to develop a widely accepted API response and endpoints by following its specifications.
GraphQL
Can save some time for developing your API, but I suggest to make sure that the consumers of your API are happy to use this option.
GraphQ
Laravel Package for GraphQL
If using Laravel isn't a must, and you are using PostgreSQL, you might want to look at Hasura as well.
SOAP
Have little knowledge on this option for Laravel, just know folks coding using C# and .net are happier to expose their API with this protocol. read more about it on WikiPedia
Postman is a great tool for testing your API or any other API.

Creating a time-driven trigger using REST API

I was thinking to write some Java code for installing a time driven trigger (to run a google apps script periodically) for an user. But could not find REST API for manipulating triggers. Wanted to know whether it is possible yet. Thank you.
Sanjay
There is no REST API to manipulate triggers. However, you can write a doPost function in your script, publish it as a web app and do a POST from your Java code.
Of course, inside your doPost() function you have to set up a trigger using the ScriptApp API.

Resources