Re: [google-appengine] Re: Firestore and Cloud task api not callable from app engine flexible

2021-03-22 Thread 'wokmou' via Google App Engine


>From the description above you are facing issues using Cloud Tasks API with 
app engine as well as using Firestore API.

This page [1] provides you with a tutorial on how to Create tasks from App 
Engine app Using Cloud Tasks to trigger Cloud Functions.

Also, this Cloud Firestore Android Codelab [2] allows you to emulate and 
experiment with Firestore APIs and sample code.

If the issue you are experiencing is related to a malfunction of one of the 
Google platform services please refer to this page[3] so that a support 
agent can have a look at your project.

[1]https://cloud.google.com/tasks/docs/samples/cloud-tasks-app

[2]https://firebase.google.com/codelabs/firestore-android#0

[3]https://cloud.google.com/support/docs/issue-trackers


On Monday, March 22, 2021 at 1:13:53 AM UTC-4 ashikr...@gmail.com wrote:

> Can anyone help me with how to resolve the above issues?
>
> On Thursday, March 18, 2021 at 7:17:18 PM UTC+5:30 ASHIK RANJAN wrote:
>
>> I am using the flask application on the google app engine flexible 
>> environment.
>>
>> 1. I want to create a task whenever some URL has been hit by a user and 
>> queues should hit the google app engine endpoint for executing the task. 
>> For example, I am appending the code here
>> The same code is working fine and creating a task if executed from 
>> another server
>>
>> import json
>> import datetime
>> from google.cloud import tasks_v2beta3
>> from google.protobuf import timestamp_pb2
>>
>> import json
>> import datetime
>> from google.cloud import tasks_v2beta3
>> from google.protobuf import timestamp_pb2
>>
>>
>> class CloudTaskManager:
>> def __init__(self):
>> self.client = tasks_v2beta3.CloudTasksClient()
>>
>> def create_task(self, project, queue, location, payload=None, 
>> in_seconds=5):
>> parent = self.client.queue_path(project, location, queue)
>>
>> task = {
>> 'app_engine_http_request': {
>> 'http_method': tasks_v2beta3.HttpMethod.POST 
>> ,
>> 'relative_uri': '/api/v1/rating/cloud_task_handler',
>> 'headers': {
>> 'Content-Type': 'application/json',
>> 'Org_Name': 'organization1'
>> },
>> 'body': json.dumps(payload).encode()
>> }
>> }
>>
>> if in_seconds is not None:
>> d = datetime.datetime.utcnow() + 
>> datetime.timedelta(seconds=in_seconds)
>> timestamp = timestamp_pb2.Timestamp()
>> timestamp.FromDatetime(d)
>> task['schedule_time'] = timestamp
>>
>> response = self.client.create_task(parent=parent, task=task)
>> return response
>>
>> 2. Another case is that I want to use cloud firestore API that is in 
>> native mode and the code snippet are as below.
>>cred = credentials.Certificate('name.json')  
>> # cred = credentials.ApplicationDefault()
>> if not firebase_admin._apps:
>> firebase_admin.initialize_app(cred, {
>>   'projectId': 'project-id',
>> })
>> db = firestore.client()
>> collection_refs = db.collection('collection-name')
>> documents = collection_refs.stream()
>> for doc in documents:
>> return doc.to_dict()
>>
>> On Wed, Mar 17, 2021 at 8:34 PM 'Elliott (Cloud Platform Support)' via 
>> Google App Engine  wrote:
>>
>>>
>>> Hello,
>>>
>>> I understand that you want to use the Cloud Tasks API to create a task 
>>> and push in a queue from the app engine flexible environment but it doesn't 
>>> work. Also you are not able to use the Firestore API in native mode.
>>>
>>> You’ve also mentioned that an API is working fine from outside of google 
>>> cloud using the same service account credentials.
>>>
>>> In addition, you asked for some help with settings.
>>>
>>> To determine a common issue, can you please tell me more about your code 
>>> and where you get stuck? Are there error messages? Google Groups is meant 
>>> for general discussions about Google products and if a scenario is 
>>> determined to be a common issue, an Issue Tracker may be created. Right 
>>> now, I do not have enough information to decide the next steps.
>>>
>>> Would you provide this information for the benefit of the community and 
>>> if it is common, others the groups may be able to recognize it.
>>>
>>> I hope that after getting your details, some advice will be offered.
>>>
>>> I will wait for your response.
>>>
>>> On Wednesday, March 17, 2021 at 9:43:01 AM UTC-4 ashikr...@gmail.com 
>>> wrote:
>>>
 I want to use cloud task api to create task and push in the queue from 
 the app engine flexible environment but it doesn't work and also not able 
 to use firestore api in native mode.

 Same API is working fine from the server outside of google cloud using 
 the same service account credentials.

 Can you please help if we can use both the api from the app engine or I 

Re: [google-appengine] Re: Firestore and Cloud task api not callable from app engine flexible

2021-03-21 Thread ASHIK RANJAN
Can anyone help me with how to resolve the above issues?

On Thursday, March 18, 2021 at 7:17:18 PM UTC+5:30 ASHIK RANJAN wrote:

> I am using the flask application on the google app engine flexible 
> environment.
>
> 1. I want to create a task whenever some URL has been hit by a user and 
> queues should hit the google app engine endpoint for executing the task. 
> For example, I am appending the code here
> The same code is working fine and creating a task if executed from another 
> server
>
> import json
> import datetime
> from google.cloud import tasks_v2beta3
> from google.protobuf import timestamp_pb2
>
> import json
> import datetime
> from google.cloud import tasks_v2beta3
> from google.protobuf import timestamp_pb2
>
>
> class CloudTaskManager:
> def __init__(self):
> self.client = tasks_v2beta3.CloudTasksClient()
>
> def create_task(self, project, queue, location, payload=None, 
> in_seconds=5):
> parent = self.client.queue_path(project, location, queue)
>
> task = {
> 'app_engine_http_request': {
> 'http_method': tasks_v2beta3.HttpMethod.POST 
> ,
> 'relative_uri': '/api/v1/rating/cloud_task_handler',
> 'headers': {
> 'Content-Type': 'application/json',
> 'Org_Name': 'organization1'
> },
> 'body': json.dumps(payload).encode()
> }
> }
>
> if in_seconds is not None:
> d = datetime.datetime.utcnow() + 
> datetime.timedelta(seconds=in_seconds)
> timestamp = timestamp_pb2.Timestamp()
> timestamp.FromDatetime(d)
> task['schedule_time'] = timestamp
>
> response = self.client.create_task(parent=parent, task=task)
> return response
>
> 2. Another case is that I want to use cloud firestore API that is in 
> native mode and the code snippet are as below.
>cred = credentials.Certificate('name.json')  
> # cred = credentials.ApplicationDefault()
> if not firebase_admin._apps:
> firebase_admin.initialize_app(cred, {
>   'projectId': 'project-id',
> })
> db = firestore.client()
> collection_refs = db.collection('collection-name')
> documents = collection_refs.stream()
> for doc in documents:
> return doc.to_dict()
>
> On Wed, Mar 17, 2021 at 8:34 PM 'Elliott (Cloud Platform Support)' via 
> Google App Engine  wrote:
>
>>
>> Hello,
>>
>> I understand that you want to use the Cloud Tasks API to create a task 
>> and push in a queue from the app engine flexible environment but it doesn't 
>> work. Also you are not able to use the Firestore API in native mode.
>>
>> You’ve also mentioned that an API is working fine from outside of google 
>> cloud using the same service account credentials.
>>
>> In addition, you asked for some help with settings.
>>
>> To determine a common issue, can you please tell me more about your code 
>> and where you get stuck? Are there error messages? Google Groups is meant 
>> for general discussions about Google products and if a scenario is 
>> determined to be a common issue, an Issue Tracker may be created. Right 
>> now, I do not have enough information to decide the next steps.
>>
>> Would you provide this information for the benefit of the community and 
>> if it is common, others the groups may be able to recognize it.
>>
>> I hope that after getting your details, some advice will be offered.
>>
>> I will wait for your response.
>>
>> On Wednesday, March 17, 2021 at 9:43:01 AM UTC-4 ashikr...@gmail.com 
>> wrote:
>>
>>> I want to use cloud task api to create task and push in the queue from 
>>> the app engine flexible environment but it doesn't work and also not able 
>>> to use firestore api in native mode.
>>>
>>> Same API is working fine from the server outside of google cloud using 
>>> the same service account credentials.
>>>
>>> Can you please help if we can use both the api from the app engine or I 
>>> need to make some changes in the settings.
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Google App Engine" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to google-appengi...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/google-appengine/73e344f4-862e-465d-a1e6-857219e4fd28n%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appen

Re: [google-appengine] Re: Firestore and Cloud task api not callable from app engine flexible

2021-03-18 Thread ASHIK RANJAN
I am using the flask application on the google app engine flexible
environment.

1. I want to create a task whenever some URL has been hit by a user and
queues should hit the google app engine endpoint for executing the task.
For example, I am appending the code here
The same code is working fine and creating a task if executed from another
server

import json
import datetime
from google.cloud import tasks_v2beta3
from google.protobuf import timestamp_pb2

import json
import datetime
from google.cloud import tasks_v2beta3
from google.protobuf import timestamp_pb2


class CloudTaskManager:
def __init__(self):
self.client = tasks_v2beta3.CloudTasksClient()

def create_task(self, project, queue, location, payload=None,
in_seconds=5):
parent = self.client.queue_path(project, location, queue)

task = {
'app_engine_http_request': {
'http_method': tasks_v2beta3.HttpMethod.POST
,
'relative_uri': '/api/v1/rating/cloud_task_handler',
'headers': {
'Content-Type': 'application/json',
'Org_Name': 'organization1'
},
'body': json.dumps(payload).encode()
}
}

if in_seconds is not None:
d = datetime.datetime.utcnow() +
datetime.timedelta(seconds=in_seconds)
timestamp = timestamp_pb2.Timestamp()
timestamp.FromDatetime(d)
task['schedule_time'] = timestamp

response = self.client.create_task(parent=parent, task=task)
return response

2. Another case is that I want to use cloud firestore API that is in native
mode and the code snippet are as below.
   cred = credentials.Certificate('name.json')
# cred = credentials.ApplicationDefault()
if not firebase_admin._apps:
firebase_admin.initialize_app(cred, {
  'projectId': 'project-id',
})
db = firestore.client()
collection_refs = db.collection('collection-name')
documents = collection_refs.stream()
for doc in documents:
return doc.to_dict()

On Wed, Mar 17, 2021 at 8:34 PM 'Elliott (Cloud Platform Support)' via
Google App Engine  wrote:

>
> Hello,
>
> I understand that you want to use the Cloud Tasks API to create a task and
> push in a queue from the app engine flexible environment but it doesn't
> work. Also you are not able to use the Firestore API in native mode.
>
> You’ve also mentioned that an API is working fine from outside of google
> cloud using the same service account credentials.
>
> In addition, you asked for some help with settings.
>
> To determine a common issue, can you please tell me more about your code
> and where you get stuck? Are there error messages? Google Groups is meant
> for general discussions about Google products and if a scenario is
> determined to be a common issue, an Issue Tracker may be created. Right
> now, I do not have enough information to decide the next steps.
>
> Would you provide this information for the benefit of the community and if
> it is common, others the groups may be able to recognize it.
>
> I hope that after getting your details, some advice will be offered.
>
> I will wait for your response.
>
> On Wednesday, March 17, 2021 at 9:43:01 AM UTC-4 ashikr...@gmail.com
> wrote:
>
>> I want to use cloud task api to create task and push in the queue from
>> the app engine flexible environment but it doesn't work and also not able
>> to use firestore api in native mode.
>>
>> Same API is working fine from the server outside of google cloud using
>> the same service account credentials.
>>
>> Can you please help if we can use both the api from the app engine or I
>> need to make some changes in the settings.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to google-appengine+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-appengine/73e344f4-862e-465d-a1e6-857219e4fd28n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/CANtQv3cb5B4ty8sFXmgoU6dGVvs1hS%2Ba%2BPzmq%2BwmqkrPSnTvPw%40mail.gmail.com.


[google-appengine] Re: Firestore and Cloud task api not callable from app engine flexible

2021-03-17 Thread 'Elliott (Cloud Platform Support)' via Google App Engine


Hello,

I understand that you want to use the Cloud Tasks API to create a task and 
push in a queue from the app engine flexible environment but it doesn't 
work. Also you are not able to use the Firestore API in native mode.

You’ve also mentioned that an API is working fine from outside of google 
cloud using the same service account credentials.

In addition, you asked for some help with settings.

To determine a common issue, can you please tell me more about your code 
and where you get stuck? Are there error messages? Google Groups is meant 
for general discussions about Google products and if a scenario is 
determined to be a common issue, an Issue Tracker may be created. Right 
now, I do not have enough information to decide the next steps.

Would you provide this information for the benefit of the community and if 
it is common, others the groups may be able to recognize it.

I hope that after getting your details, some advice will be offered.

I will wait for your response.

On Wednesday, March 17, 2021 at 9:43:01 AM UTC-4 ashikr...@gmail.com wrote:

> I want to use cloud task api to create task and push in the queue from the 
> app engine flexible environment but it doesn't work and also not able to 
> use firestore api in native mode.
>
> Same API is working fine from the server outside of google cloud using the 
> same service account credentials.
>
> Can you please help if we can use both the api from the app engine or I 
> need to make some changes in the settings.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/73e344f4-862e-465d-a1e6-857219e4fd28n%40googlegroups.com.