gcloud deploy ... --trigger-resource for triggering on Firestore write 'CloudEvents' needs a bit of clarification - google-cloud-firestore

I read and followed the examples found on Google Cloud Firestore Triggers. I have been able to deploy these examples following.
gcloud functions deploy my-second-event \
--entry-point CloudEventFunction2.Function \
--runtime dotnet3 \
--trigger-event "providers/cloud.firestore/eventTypes/document.create" \
--trigger-resource "projects/my-projectId/databases/(default)/documents/messages/{pushId}" \
NOTE that the /documents/messages/{pushId} part of this resource aligns with the "Deploy your function" section.
HOWEVER a little further down --trigger-resource 'NAME' is described as...
The fully qualified database path to which the function will listen. This should conform to the following format: "projects/YOUR_PROJECT_ID/databases/(default)/documents/PATH" The {pushId} text is a wildcard parameter described above in Specifying the document path.*
Now we get to my confusion when we follow the link to "Specifying the document path". I believe I understand what is meant by "Functions only respond to document changes, and cannot monitor specific fields or collections.". HOWEVER if we look at the above /documents/messages/{pushId} - 'documents' is a collection and 'messages' is a document. Following from the above limitations about functions only responding to document changes, I would NOT expect the event to be triggered by the {pushId} event (because the pushId is EITHER a collection or a field (it sits directly on a document 'messages').
What seems to be to be indicated is that the {pushId} wild card be put directly under the collection 'documents'; resulting in...
--trigger-resource "projects/my-projectId/databases/(default)/documents/{pushId}"
Meaning that when a new message is pushed to the documents collection the cloud event is triggered.
However the above change yeilds below...
ERROR: (gcloud.functions.deploy) ResponseError: status=[400], code=[Ok], message=[
The request has errors
Problems:
event_trigger:
Expected value {pushId} to match regular expression [^/]+/[^/]+(/[^/]+/[^/]+)*
]
While I am sure I am doing something wrong, I am struggling to make sense out of the above observations, also my function is not being triggered.
I would really appreciate any hints as to how this is to be understood, and or at least how to get my function to trigger on create.
FYI; the 'Function' I am using is from the dotnet template provided by Visual Studio (2022).

I am late to the party, but if the collection in your database is literally named documents then your path is going to look like this:
--trigger-resource "projects/my-projectId/databases/(default)/documents/documents/{pushId}"
The second instance of documents is the literal name of the collection you are watching.

Related

VS Code Regex search to remove references based on containing text in string

I am attempting to remove all references of a managed package that is going to be uninstalled that spans throughout code base in VS Code
I have using a query to find the field permissions but am wondering if there is a way to search for the reference outside of specifying the exact field name compared to the field containing only "agf" since they are all using it.
Below is the search query:
<fieldPermissions>
<editable>false</editable>
<field>User.agf_Certified_Product_Owner__c</field>
<readable>false</readable>
</fieldPermissions>
In the field, I want to be able to find and delete the 5 associated lines from multiple files if they match "agf" in any combination. Something like the below:
<fieldPermissions>
<editable>false</editable>
<field>agf</field>
<readable>false</readable>
</fieldPermissions>
With any combination of agf in the field, delete all from any file it appears in.
Not an answer but too long for a comment
You don't have to? Profiles/perm sets don't block package's delete. Probably neither do reports.
You'd use your time better by searching for all instances of agf__ (that's with double underscore), should find fields, objects... used in classes, flows, page layouts etc. And search for agf. (with dot) should find all instances where your Apex code calls their classes marked as global.
Alternatively Apex / VF pages with dependencies on package will have it listed in their "meta.xml", for example
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>54.0</apiVersion>
<packageVersions>
<majorNumber>236</majorNumber>
<minorNumber>1</minorNumber>
<namespace>SBQQ</namespace>
</packageVersions>
<status>Active</status>
</ApexClass>
Last but not least - why not just spawn a dev sandbox and attempt the delete there? If it succeeds - great. If not - it'll list the dependencies that blocked the delete. It'll be "the real thing", it'll smite you even if your VSCode project doesn't contain all flows, layouts and thus could lull you into false sense of security. I'd seriously do it in sandbox and then run all tests for good measure, just in case there are some dynamic soql queries that don't count as hard, delete-blocking references.
After delete's done - fetch Profiles / Permsets from this org and the field references will be gone from the xml.

Unable to wait for VPC creation

I am trying to create a VPC with Pulumi crosswalk and then use the output's vpc_id to pass as argument to fetch security groups. However, being natively async, vpc object is supposedly being queried before creation causing it to throw an error:
Exception: invoke of aws:ec2/getSecurityGroup:getSecurityGroup failed: invocation of aws:ec2/getSecurityGroup:getSecurityGroup returned an error: invoking aws:ec2/getSecurityGroup:getSecurityGroup: 1 error occurred:
* multiple Security Groups matched; use additional constraints to reduce matches to a single Security Group
I am unable to figure out the following:
Why does it say there are multiple matches when there aren't?
Why does it throw an error in preview? Does preview also make an AWS call?
how to put a hold on the query until VPC is created, considering 'depends_on' won't work for get_security_group method? Is there a Pulumi way to handle this situation?
Following is the code snippet:
vpc = awsx.ec2.Vpc("pulumi-test",cidr_block='10.2.0.0/16',subnet_specs=[
awsx.ec2.SubnetSpecArgs(
type=awsx.ec2.SubnetType.PRIVATE,
cidr_mask=26,
),
awsx.ec2.SubnetSpecArgs(
type=awsx.ec2.SubnetType.PUBLIC,
cidr_mask=26,
)
], number_of_availability_zones=1)
security_group = aws.ec2.get_security_group(vpc_id=vpc.vpc_id)
1.
You should probably not make any assumptions about there being only a single security group. Use the get_security_groups function to get them all. Example:
security_groups = aws.ec2.get_security_groups(filters=[aws.ec2.GetSecurityGroupsFilterArgs(name='vpc-id', values=[vpc.vpc_id])])
2.
Yes, pulumi preview will execute functions if possible (get_security_group in your case). Even function calls that are Output-based (see 3. for clarification) can be executed during preview.
This can happen if the Output that this function uses belongs to a resource that already exists (was created in some of the preceding pulumi up).
For example:
You add the VPC code.
You execute pulumi up successfully (VPC is created and its Pulumi state is stored in the backend).
You add the code that uses one of the VPC outputs (get_security_group(vpc.vpc_id)).
You execute pulumi preview and the above function is executed with the real VPC id (vpc.vpc_id).
3.
There is no need for depends_on. Pulumi functions are different than resources. In Python, two invocation forms are available. The one you are using is Output-based.
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

Actions Builder checked list value for intent parameter returns no original value for match

I'm running into an issue with the Actions Builder that I think is a bug at Google's side of the Actions Builder platform, but not I'm not a hundred percent sure.
I'm building some sort of a shopping list app (that integrates with backend services). I have an intent to add one or more "generic names" (= product names) to a list.
When I configure the Intent with an InputType like this (notice the List being false),
The input I send to the intent gets parsed correctly, like this:
You see, "kokosolie" is resolved when my query was "add 'kokosnootolie' to the list". In this case, I get both the resolved and the original value of the InputType.
But in my use case, I want to receive multiple values for a "Generic name", so I turn on the "is list" checkbox.
The same query/voice command now results in this:
Only the resolved input type is returned here. While I need this one later in the app's logic, I also need the original values, but Google doesn't return them to me.
Is this a bug or a missing feature at Google's side of things or rather me, missing some configuration?

React hook form dynamic fields validations

My task is to implant a functionality that includes dynamically creation of fields and apply validation on those dynamically created fields.
I have found a prefect example that fits my use case which is here (https://stackblitz.com/edit/react-hook-form-dynamic-form-example) but the issue that I am facing is every time I try to download the example from stackblitz and run locally I get error below error:
{"tickets":{"message":"tickets must be a `array` type, but the final value was: `null` (cast from the value `{\n \"0name\": \"\\\"\\\"\",\n \"0email\": \"\\\"\\\"\",\n \"1name\": \"\\\"\\\"\",\n \"1email\": \"\\\"\\\"\"\n}`).\n If \"null\" is intended as an empty value be sure to mark the schema as `.nullable()`","type":"typeError"}}
I am wondering if someone could help me run this example locally, rest I can work out.
Many thanks :)

Defining a new variable in order to make a huge iteration giving me an error

I have an endpoint, you can have informaciĆ³n about products
{{URL_API}}/products/
If i perform a GET method over that endpoint i will obtain the information of every product
BUT i can also specify the product that i want to know about, i.e:
{{URL_API}}/products/9345TERFER (the last code is the id of the product, called SKU)
The problem is that if i want to make a CSV in order to update the information of different products i have to define a variable called sku in the endpoint so i will be able to pass the corresponding SKU
I want to create the variable {{sku}} but i do not understand how to do that.. i tried so many times and i failed, i've searched a lot but i do not really understand
Also, should i use ":" before the declaration of the variable? i mean:
{{URL_API}}/products/:{{sku}}
or simply:
{{URL_API}}/ns/products/{{sku}}
Can you help me?
I'm super lost :(
EDIT:
I want to perform a PUT method, i want to pass different values to the body and then.. send the request (it throws an error: 404 not found)
This is what i did:
PUT|{{URL_API}}/products/{{sku}}
body:
{
"tax_percentage":"{{tax_percentage}}",
"store_code":"{{store_code}}",
"markup_top":"{{markup_top}}",
"status":"{{status}}",
"group_prices": [
{
"group":"{{class_a}}",
"price":"{{price_a}}",
"website":"{{website_a}}"
}
]
}
CSV:
POSTMAN:
Your issue seems to be just a basic understanding of how data files work with variables in Postman, here's a simple example that will work the same way for you too.
This is a basic request I'm using to resolve the variable from the data file - It's a GET request but that doesn't matter as all we're look at here is using a data file to resolve variables. All you need to do is ensure the URL is correct and that you SAVE the request before using the runner.
Here's a simple CSV file created in a text editor. The heading sku in the name on the variable it will reference inside the Postman request. Each value under that is the value that will be used for each iteration.
In the Runner, select your Collection from the list (If you have more than one) then select the CSV file. Once imported, you will be able to see a preview of the data.
If that's correct, press the Run button. The Runner will then iterate through the file and pick up the sku value in the CSV file and use it in the request. I've expanded one of the requests so you can see that the value was used in the request.