Last accessed date of a view in tableau server/tableau using rest api - tableau-api

Is there a way to get the last accessed date of a view in tableau online/server using rest api. I am currently using this
http://my_site/api/3.6/sites/site_id/workbooks/workbook_id/views?includeUsageStatistics=true
but getting usage statics like how many times it was viewed and created date and modified date.

There is a Views method in the rest api. I'm using python and tableauserverclient to get the usage you are looking for. See TSC reference and Direct Rest API for full docs.
import tableauserverclient as TSC
tableau_auth = TSC.TableauAuth('username', 'password')
server = TSC.Server('https://servername')
with server.auth.sign_in(tableau_auth):
all_views, pagination_item = server.views.get()
for x in all_views:
print(x.name, x.total_views)
The output will look like this and I verified directly in Server.
created_at and updated_at are in the WorkbookItem class
I hope that does it for you!

Related

Microsoft Graph Rest API - Filter by last X days

I have a rest URL that I am running against Microsoft Graph via POSTMAN and I'd like to know how to make the date filter check for records with activity in the last 90 days. My URL is this:
https://graph.microsoft.com/beta/users?$select=signInActivity&$filter=signInActivity/lastSignInDateTime%20le%202022-09-01
I do not want to use the hard-coded date like in this example or have to lean on something like powershell. Is there a way to calculate the date in the url or to tell the filter to do so? Something like this would be nice:
https://graph.microsoft.com/beta/users?$select=signInActivity&$filter=signInActivity/lastSignInDateTime%20le%20(today()-days(90))
Graph API does not support functions for working with date.
You can declare a property in Postman and set the property before the request is sent.
Example
The Graph API request is in a Postman collection. You can create a collection variable MyVar and use the variable in $filter query.
Then you can write a pre-request script in JavaScript and set the collection variable.
let d = new Date();
d.setDate(d.getDate()-90);
pm.collectionVariables.set("MyVar", d.toISOString().split('T')[0]);
Send the request and check console how the request looks like.
Resources:
Filter query operators

Magento1.9 Rest Api filters

How to get rest api data filterable by updated_at attribute in Magento1?
I would like my rest API data to be filtered by last updated_at so I have tried something like this:-
http://localhost/mage1/products?page=1&limit=5&filter[0][attribute]=updated_at&filter[0][gteq]=2019-09-01 07:40:30
I have tried the filters shown on devdocs for M1 but didn't succeeded with any proper result. https://prnt.sc/p0lrk9
https://localhost/api/rest/products?filter[0][attribute]=updated_at&filter[0][from][0]=max_date&page=1&limit=100&order=updated_at&dir=asc"
This may help you.It worked for me

How to get proper graph in Grafana

I am using postgresql database with grafana. I have shared the snapshot of graph that i am getting, its very difficult to understand. Please let me know how to get proper graph which is easy to understand.
I tried query like this and it worked for me, just needed to add the order by
Select ts as time,
key AS metric,
long_v as value
FROM public.ts_kv
WHERE key = 'PressureZ'
order by time
inorder to get graph in proper format we need to add order by.

Using Smartsheet API 2.0 how to get ONLY the 'modifiedAt' property of a specific sheet

I need to get the last modified timestamp property of a sheet using Smartsheet API 2.0 (preferably Python SDK).
Ref:
https://smartsheet-platform.github.io/api-docs/
https://github.com/smartsheet-platform/smartsheet-python-sdk
Using Sheets.list_sheets I am able to get the 'modifiedAt' property (along with other properties) for all the sheets that I have access to.
Using Sheets.get_sheet(sheet_id) I get all the data (rows, columns) for the specified sheet.
How do I get only the 'modifiedAt' (it's OK if some other small properties are also present) for a specific sheet with a known sheet ID. I don't want the row, column, cell information to be present in the API response.
I wrote to Smartsheet support team and their answer served my purpose.
Thanks for contacting Smartsheet Support. In order to narrow down the
response that you're getting, you can use the exclude parameter:
http://smartsheet-platform.github.io/api-docs/#query-strings. In my
testing, I excluded all rows and columns where columnIds=0 and
rowIds=0. That left me with only the Sheet information, which includes
the modifiedAt for the sheet. You may be able to limit it further, but
the result I got from this was pretty short and sweet.
(Python SDK example)
response = ss_client.Sheets.get_sheet(MY_SHEET_ID, column_ids='0', row_ids = '0')
Using the above parameters, I was able to exclude all the sheet data and got only the metadata (which included modifiedAt property).
Basically my intention was to run a sync script periodically and store the Smartsheet data into my local db. I wanted the API response to skip the actual Sheet data (rows, columns, cells) if nothing would have changed since the last execution. Another nifty way of achieving this to use the ifVersionAfter parameter.
ifVersionAfter (optional): If version specified is still the current
sheet version, then returns an abbreviated Sheet object with only the
sheet version property. Otherwise, if the sheet has been modified,
returns the complete Sheet object. Intended to allow clients with a
cached copy to make sure they have the latest version.
last_version_fetched = 7724
response = ss_client.Sheets.get_sheet(MY_SHEET_ID, if_version_after=last_version_fetched)
The Get Sheet call will always return the content (row, column, data) from a specific sheet. While there is an 'exclude' query parameter that can filter out some properties, it does not work on the primary sheet data returned from the /sheets/{sheetId} endpoint.
The Sheets.list_sheets call seems like the easier route if you only need the modifiedAt property. I would use that one then iterate over the results until you find the matching id.

Rational ClearQuest Http request to find defects that have been updated since a specific time?

I am trying to use ClearQuest OSLC CM REST API to write an http request to accomplish the following. I want to get a list (in the XML format) of ClearQuest defects that have been updated since a specified time.
So far I have been able to get a list of all defects from a particular defect family that I'm interested in with the following request (I'm using a sample base URL here):
http://localhost:8080/oslc/cqrest/repo/7.0.0/db/SAMPL/record/?oslc_cm.query=Found_in_Product_Family="MyDefectFamily"&rcm.type=Defect
I also was able to put together an http request that returned a complete timestamp history for a single defect like so:
http://localhost:8080/oslc/cqrest/repo/7.0.0/db/SAMPL/record/16777241-38577895?oslc_cm.properties=id,dbid,history{action_timestamp}
I can show sample xml response for both of those requests if anyone thinks it can be helpful here.
I can't seem to figure out how to write a request that will return a list of defects (id, dbid, timestamp) that contain a timestamp later than say 01/01/2014 00:00:00. Or at least a request that would return all defects where each defect entry would contain the last timestamp in it's history. I think I can get a list of all defects with all timestamps for each defect but I would like just the last timestamp. Taking the last node in the timestamp history doesn't work. Timestamp history doesn't seem to be ordered. Some sort of max function seems to be necessary for such a request.
Can anyone point me in the right direction or tell if what I want is impossible with ClearQuest OSLC CM REST API?
This is what I use in VB.NET:
Dim asOfValue = asOf.ToString("'""'yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z""^^xsd:dateTime'")
Dim upToValue = upTo.ToString("'""'yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z""^^xsd:dateTime'")
Dim where = "cq:history{cq:action_timestamp>=" & asOfValue & " and cq:action_timestamp<=" & upToValue & "}"
Const prefix = "cq=<http://www.ibm.com/xmlns/prod/rational/clearquest/1.0/>"
uri.Query = String.Format("oslc.orderBy=dcterms:identifier&oslc.where={0}&oslc.select={1}&oslc.prefix={2}", where, select, prefix)