how can I use active Record queries with salesforce as the data-store? - rest

I am connecting to Salesforce.com as a data-store and accessing their REST API's.
Currently, to do a query, have to use SOQL, which is a query language.
How can I use ActiveRecord type 'where' queries instead?

You don't have to use SOQL to retrieve records via the Salesforce.com REST API, if you are retrieving by the Id of the record. To do this, you can just use the following syntax:
/vXX.X/sobjects/SObjectName/id/
To retrieve records that meet a specific clause other than ID, I don't believe there is an alternative to SOQL at this point directly in the REST API.
However, if you are using Ruby, there is a Ruby Toolkit for salesforce that does support using active record style syntax. This is an open source project and you can find out more about it here:
http://quintonwall.com/wp-content/uploads/2011/02/RubyToolkit-gettingstarted.pdf
Here are a couple of examples from the above document:
There are toolkits for other languages, but I am not sure of their support for Active Record style record access.

Related

Docusign REST API call: Using logical operators for search_text

I’m trying to use a REST API call to find all envelopes with subjects that are either {{cSubject_1}} OR {{cSubject_2}}.
I’m using "search_text" for filtering but I’m not sure how I should use the logical operator for “OR” for this purpose.
I would appreciate if you could help me with this.
Thanks,
Kathy
There's currently no support for this type of complex query in the search_text for The Envelopes:listStatusChanges endpoint.
The search_text allows you to have a single text item that is search across the board (recipients, subject, etc.) and is not limited to a specific meta-data. You can use other filters to filter by other means.
I would recommend storing envelope's meta-data in your application storage (or database) and using your own code to query this information if possible.

Retrieve Grafana dashboard query using the API

I would like to get the query used in each of my dashboards using the Grafana API.
The expr field in the JSON model menu of the UI seems to contain the query. Is there a way of querying this using the API?
You can't do that. There is no official API which will return all "dashboard queries". It isn't possible, because frontend in the browser generate that and exact query depends on the user input (e.g. time range, dashboard variables, used macros, ....) and also used datasource.

Returning all data types for a table in SOQL

Is there a simple way to query and return a list of datatypes for all columns in a SOQL table?
I'm trying to migrate SOQL to PostgreSQL but have 100s of tables and 100s of columns and don't want to go through querying every data type or doing it by hand.
In PostgreSQL the equivalent to what I'm looking for would be:
SELECT table_name, data_type, columns.character_maximum_length, columns.udt_name
FROM information_schema.columns
WHERE table_schema = 'public';
Looking around it looks like I might have to go into Apex? But I'm wondering if there's any simpler way. I don't think that SOQL supports information_schema and can't find if there's a simlar
There's no way to introspect schema in SOQL itself. While you can interact with the Describe API via Apex, it's easier as an external API client to do so via the Salesforce REST API.
Specifically, you'd want to hit the Global Describe endpoint to get the list of available sObjects.
The, for each sObject, hit sObject Describe. The response body includes field details for that sObject under the fields key. The field's type is given in each fields entry as both type, which is a high-level UI-oriented type (see DisplayType enum), and as the lower-level soapType, which is usually more relevant for database storage and API interaction.
Note that in both cases the API will enforce FLS and CRUD based on the authenticated user account's credentials. If a logged-in user with those credentials doesn't have permission to see an object or field, neither will your external application.

Proxy for MSGraph APIs

I am trying to create an adapter (WEB API that will act as a pass through)
for invoking the MS Graph APIs for managing my Active Directory.
AD objects like application and users will be customized to meet our application needs (removing some attributes, adding some extension attributes etc.) and a transformation from our application specific object to AD object would happen in our adapter layer before and after calling MS Graph APIs.
MS Graph APIs currently supports OData queries.
Applications and users would be read as page-wise.
If I have to provide the same OData options in my pass thru Web API layer, how can I do that?
i.e.
API A supports OData queries.
API B calls the methods that support OData queries in API A.
API B is exposed to the client. When the client calls the method from API B
with OData $Filter, the result has to be returned.
How can I support the OData options in API B?
Thanks in advance.
Well, I'm not sure I get your question correctly but, from what I understand, you just want to proxy the API calls to MS Graph and make some changes on the fly to the response.
OData queries are just simple query parameters (see the OData tutorial). So, basically, you just have to get those query parameters in your proxy and forward them to the MS Graph. The response you'll get will then be compliant with the original query.
However, depending on how you mangle the data, you may end up not being compliant with the user query. For example:
The user made a $select(Id) query, but your logic add a custom property Foo. The user just wanted Id but you added Foo anyway.
The user made an $orderby Name asc query, but your logic modify the property Name. It may not be ordered after your logic.
The user wants to make $filter query on the Foo property. MS Graph will complain because it doesn't know the Foo property.
Etc.
If you want to handle that cases, well, you'll have to parse the different OData queries and adapt your logic accordingly. $orderby, $top/$skip, $count, $expand and $select should be pretty straight-forward ; $filter and $search would require a bit more work.
Thanks. I was looking for a solution to this.
https://community.apigee.com/questions/8642/how-do-we-fetch-the-query-parameters-odata-standar.html
Instead of parsing the URL to get the OData query parameters, i wanted to understand the standard method to process the OData requests.
Now I am doing the below to extract the OData query parameters and passing them to MSGraph API.
string strODataQuery = String.Join("&", HttpContext.Request.Query.Where(kvp => kvp.Key.StartsWith("$")) .Select(kvp => String.Format("{0}={1}", kvp.Key, Uri.EscapeDataString(kvp.Value))));
And I am performing the conversions after retrieving the results.
Regards

How to find the database id of a cloud firestore project?

I'm trying to use the Cloud Firestore REST API, but can't seem to find the project id.
Firestore's REST API is still in beta; we can't generate our own database ids as of yet.
We have to use the default database id which is currently the following (glaringly literal) string:
(default)
And yes, you have to include the parentheses.