How to get remote state file for my latest Terraform (Enterprise) run? - api

I want to get the latest run for my workspace and grab its Terraform state file. We are using Terraform Enterprise.
I did the below and I got get the payload:
https://ptfe-dev.company.com.au/api/v2/organizations/organization-name/workspaces/workspace1
I get output but information of the workspace id etc, but that is what not what I want.
With the above output, I get workspace id and I ran the query below:
https://ptfe-dev.companyname.com.au/api/v2/organizations/organization-name/workspaces/workspace1/current-state-version
However, the above query returns:
Sorry, the page /api/v2/organizations/rganization-name/workspaces/workspace1/states/sv-DKBZ2AFoV5mwY4kP could not be found.
This error could mean one of two things:
The resource doesn't exist
The resource exists, but you do not have permission to access it
If someone has linked you to this resource, ensure that they have given you proper permissions to access it.
I can, however, access the same resource (workspace1) state file via TFE UI.
Can anyone please advise me what I am doing wrong here?

In the payload from the first API call, you'll get the reference to the endpoint to get the state.
<tfe_host>/api/v2/workspaces/<workspace_id>/current-state-version
To include outputs, add include=putputs parameter like this:
<tfe_host>/api/v2/workspaces/<workspace_id>/current-state-version?include=outputs
You only need the organizations to get the workspace itself. When you get the state, you're referencing the workspace ID directly and don't need to include the organization.

Related

How to get MS Teams' channel files and folders

I'm working on an API and i want to get Files and Folders of a specific teams' channel. I've tried with Graph Explorer but could not find anything resource. I have also tried the official documentation Microsoft Graph API.
I have tried the following API in explorer but it does not give the desired results.
https://graph.microsoft.com/v1.0/teams/{teamId}/channels/{channelId}/filesFolder
It is highly possible that i might have overlooked the my required resource but can someone help me out in it. Thanks
You are using the correct endpoint
GET https://graph.microsoft.com/v1.0/teams/{team_id}/channels/{channel_id}/filesFolder
returns metadata about driveItem.
Use parentReference.driveId and id in the next API call to get folders and files
GET https://graph.microsoft.com/v1.0/drives/{drive_id}/items/{id}/children
It returns a collection of driveItems with unique id.
If driveItem represents a file then file property is not null.
For each item that represents the file you can call
GET https://graph.microsoft.com/v1.0/drives/{drive_id}/items/{item_id}
to get more details about the file.
If driveItem represents a folder then folder property is not null.
For each item that represents the folder you can call
GET https://graph.microsoft.com/v1.0/drives/{drive_id}/items/{item_id}
GET https://graph.microsoft.com/v1.0/drives/{drive_id}/items/{item_id}/children
to get more details about the folder or to get items inside the folder.

Is it possible to link to a job in the bigquery console?

If I execute a BigQuery job using the REST API (i.e. bigquery.googleapis.com) in the response I get back a selfLink that looks something like this:
https://bigquery.googleapis.com/bigquery/v2/projects/my-project/jobs/job_0123456789ABCDEF?location=EU
In the UI (ie.. console.cloud.google.com) I can see the very same job in the project's query history:
Is it possible to use the information within that API response and construct a URL that will allow a person to visit that URL in the browser and be taken directly to the information about that query in the UI? This would be really useful because we could log a message containing that URL so that anyone viewing the logs can see a user-friendly UI regarding that job.
I suspect the answer is "no" but just thought I'd ask.
I believe you can share this link:
https://console.cloud.google.com/bigquery?project=<my-project>j=<bq:<location>:<job_id>>&page=queryresults
For example: https://console.cloud.google.com/bigquery?project=my-project&j=bq:US:2846160a-9a13-4192-9bff-e691ff2adab6&page=queryresults
If a user has BQ Job List permission in that project, then when they open up the link they will be be able to see the query that was run in the UI, along with the job information.
But they can't see the query results, which is intended behavior. Instead they will get a warning:
Access Denied: User does not have permission to access results of another user's job.

Can I get children using folder name and id in the same time using Microsoft Graph API?

I am trying to display folder and file list from a Sharepoint in my CakePHP web application.
Please review my previous question here.
What I am going to do is to get children from a folder with id and also inner folder with name, in the same time, using Graph API.
I want to get list from an api like
https://graph.microsoft.com/v1.0/drives/{drive-id}/root:/{folder-name}:/items/{item-id}/children
I am not sure if it is available and how to implement it.
At this moment, I can get children from a folder with its name.
https://graph.microsoft.com/v1.0/drives/{drive-id}/root:/{folder-name}:/children
And I can filter the response using query parameters like below.
https://graph.microsoft.com/v1.0/drives/{drive-id}/root:/{folder-name}:/children/?$filter=id eq '{folder-id}'
Can I get sub folder's children at this moment?
Any help?
There is no such method. As #Shiva said, their properties are the same. You cannot use the folder name and folder ID at the same time. You can try the api provided by Shiva. I think it is a good method:
https://graph.microsoft.com/v1.0/me/drive/root:/{folder-name}?$expand=children

GitLab api: how am i able the get the list of projects using gitlab api?

i was trying to get the list of projects in my gitlab using Git api. for that i was following Git lab api instruction.
they said i can access the list of project by this link:
https://gitlab.com/api/v4/projects?access_token=some_token.
but unfortunately with the above link i got bunch of information, which is not mine at all. i got the information which is owned by other users.
In that case how am i able the get my own projects information?
Nevertheless, the respond JSON has so many attribute. is there anyway that i can achieve the attribute according to my desire?
You can use owned=true to get only project which you are owner and simple=true to have limited field, check this :
https://gitlab.com/api/v4/projects?access_token=some_token&owned=true&simple=true

asana tasks api does not work for GET /tasks GET /workspaces/workspace_id/tasks but for GET /projects/project_id

My query were these:
https://app.asana.com/api/1.0/tasks
But I have this error instead: "Must specify exactly one of project, tag, or workspace"
When I try out for the workspace with this:
https://app.asana.com/api/1.0/workspaces/workspace_id/tasks
I have this error: "assignee: Missing input"
However, I will get a list of tasks if i use the projects instead...
Please advice.
(I work at Asana)
You must always filter a task query with something, as we do not yet support pagination and all tasks in a workspaces will usually be a huge volume of data. Specifying a project implicitly scopes the query to a workspace, as every project exists in exactly one workspace. You can specify assignee, but then you must additionally filter by workspace.
So your choices for filtering tasks are either by project or by BOTH assignee and workspace.