How to fetch the content from same tag from GitHub Api using bash - bash

I want to get the data of tag_name from this link
https://api.github.com/repos/checkstyle/checkstyle/releases
but as we have a lot of releases. How can I get a particular tag_name
I do
LATEST_RELEASE_TAG=$(curl -s https://api.github.com/repos/checkstyle/checkstyle/releases/latest \
| jq ".tag_name")
to get the latest tag_name but how to fetch the second tag_name?
eg:
[ {
"url": "https://api.github.com/repos/checkstyle/checkstyle/releases/73283356",
"assets_url": "https://api.github.com/repos/checkstyle/checkstyle/releases/73283356/assets",
"upload_url": "https://uploads.github.com/repos/checkstyle/checkstyle/releases/73283356/assets{?name,label}",
"html_url": "https://github.com/checkstyle/checkstyle/releases/tag/checkstyle-10.3.2",
"id": 73283356,
"author": {
"login": "romani",
"id": 812984,
"node_id": "MDQ6VXNlcjgxMjk4NA==",
"avatar_url": "https://avatars.githubusercontent.com/u/812984?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/romani",
"html_url": "https://github.com/romani",
"followers_url": "https://api.github.com/users/romani/followers",
"following_url": "https://api.github.com/users/romani/following{/other_user}",
"gists_url": "https://api.github.com/users/romani/gists{/gist_id}",
"starred_url": "https://api.github.com/users/romani/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/romani/subscriptions",
"organizations_url": "https://api.github.com/users/romani/orgs",
"repos_url": "https://api.github.com/users/romani/repos",
"events_url": "https://api.github.com/users/romani/events{/privacy}",
"received_events_url": "https://api.github.com/users/romani/received_events",
"type": "User",
"site_admin": false
},
"node_id": "RE_kwDOAL65M84EXjcc",
"tag_name": "checkstyle-10.3.2",
"target_commitish": "master",
"name": "",
"draft": false,
"prerelease": false,
"created_at": "2022-07-31T13:38:47Z",
"published_at": "2022-07-31T13:54:14Z",
"assets": [
{
"url": "https://api.github.com/repos/checkstyle/checkstyle/releases/assets/73245332",
"id": 73245332,
"node_id": "RA_kwDOAL65M84EXaKU",
"name": "checkstyle-10.3.2-all.jar",
"label": "",
"uploader": {
"login": "romani",
"id": 812984,
"node_id": "MDQ6VXNlcjgxMjk4NA==",
"avatar_url": "https://avatars.githubusercontent.com/u/812984?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/romani",
"html_url": "https://github.com/romani",
"followers_url": "https://api.github.com/users/romani/followers",
"following_url": "https://api.github.com/users/romani/following{/other_user}",
"gists_url": "https://api.github.com/users/romani/gists{/gist_id}",
"starred_url": "https://api.github.com/users/romani/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/romani/subscriptions",
"organizations_url": "https://api.github.com/users/romani/orgs",
"repos_url": "https://api.github.com/users/romani/repos",
"events_url": "https://api.github.com/users/romani/events{/privacy}",
"received_events_url": "https://api.github.com/users/romani/received_events",
"type": "User",
"site_admin": false
},
"content_type": "application/zip",
"state": "uploaded",
"size": 16208747,
"download_count": 505,
"created_at": "2022-07-31T13:54:16Z",
"updated_at": "2022-07-31T13:55:12Z",
"browser_download_url": "https://github.com/checkstyle/checkstyle/releases/download/checkstyle-10.3.2/checkstyle-10.3.2-all.jar"
}
],
"tarball_url": "https://api.github.com/repos/checkstyle/checkstyle/tarball/checkstyle-10.3.2",
"zipball_url": "https://api.github.com/repos/checkstyle/checkstyle/zipball/checkstyle-10.3.2",
"body": "https://checkstyle.org/releasenotes.html#Release_10.3.2\r\n\r\nBug fixes:\r\n\r\n #11736 - MissingJavadocType: Support qualified annotation names\r\n #11655 - Update google_checks.xml to have the SuppressionCommentFilter and SuppressWarningsHolder modules in the config by default (and by extension, SuppressWarningsFilter)\r\n\r\n<details>\r\n<summary>Other Changes:</summary>\r\n<br>\r\n Update releasenotes to use GitHub Pages execution\r\n<br />\r\n Allow SuppressWarningHolder to suppress the violation with NameCheck\r\n<br />\r\n Pitest: Kill all surviving mutations\r\n<br />\r\n Pitest: Activate \"ALL\" mutator group\r\n<br />\r\n Use Shellcheck to resolve violations code in Shell Script\r\n<br />\r\n pitest: increase mutation coverage for pitest-imports profile to 100% \r\n<br />\r\n Update GitHub Action for bump-license-year.sh\r\n<br />\r\n Solve fb-contrib errors\r\n<br />\r\n Remove pitest mutation checking HTML model\r\n<br />\r\n automate execution by Github action bump-license-year.sh on first day of month\r\n<br />\r\n update code base to have javadoc tag to explain noinspection tag content\r\n<br />\r\n doc: put example of enableExternalDtdLoad to xdoc\r\n<br />\r\n update doc for SuppressWarningsHolder\r\n<br />\r\n releasenotes script generated empty commit\r\n<br />\r\n Include CDG Accelerator Plugin to boost pitest performance\r\n<br />\r\n Enforce file size on Java inputs\r\n<br />\r\n Expand XPath IT Regression Testing\r\n<br />\r\n There are semantic problems in the Chinese error message of keyword `design.forExtension` .\r\n<br />\r\n prepare-settings.sh fails to create settings.xml\r\n<br />\r\n Use groovy version provided by `apt` in pitest.yml\r\n<br />\r\n tweet-releasenotes.sh does not check env variables\r\n<br />\r\n download of m2 cache from sourceforge.io is slow \r\n<br />\r\n infra: turns off create dependency reduced pom for shade plugin\r\n<br />\r\n Update Tests to use new 'verifyXxxxxx' method or 'execute' that use inlined config in Input files\r\n<br />\r\n Specify violation messages in input files.\r\n<br />\r\n pitest: increase mutation coverage for javadoc profile to 100%\r\n<br />\r\n</details>",
"reactions": {
"url": "https://api.github.com/repos/checkstyle/checkstyle/releases/73283356/reactions",
"total_count": 10,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 6,
"confused": 0,
"heart": 2,
"rocket": 2,
"eyes": 0
} }, {
"url": "https://api.github.com/repos/checkstyle/checkstyle/releases/70647006",
"assets_url": "https://api.github.com/repos/checkstyle/checkstyle/releases/70647006/assets",
"upload_url": "https://uploads.github.com/repos/checkstyle/checkstyle/releases/70647006/assets{?name,label}",
"html_url": "https://github.com/checkstyle/checkstyle/releases/tag/checkstyle-10.3.1",
"id": 70647006,
"author": {
"login": "romani",
"id": 812984,
"node_id": "MDQ6VXNlcjgxMjk4NA==",
"avatar_url": "https://avatars.githubusercontent.com/u/812984?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/romani",
"html_url": "https://github.com/romani",
"followers_url": "https://api.github.com/users/romani/followers",
"following_url": "https://api.github.com/users/romani/following{/other_user}",
"gists_url": "https://api.github.com/users/romani/gists{/gist_id}",
"starred_url": "https://api.github.com/users/romani/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/romani/subscriptions",
"organizations_url": "https://api.github.com/users/romani/orgs",
"repos_url": "https://api.github.com/users/romani/repos",
"events_url": "https://api.github.com/users/romani/events{/privacy}",
"received_events_url": "https://api.github.com/users/romani/received_events",
"type": "User",
"site_admin": false
},
"node_id": "RE_kwDOAL65M84ENfze",
"tag_name": "checkstyle-10.3.1",
"target_commitish": "master",
"name": "",
"draft": false,
"prerelease": false,
"created_at": "2022-06-27T13:50:30Z",
"published_at": "2022-06-27T14:07:12Z",
"assets": [
{
"url": "https://api.github.com/repos/checkstyle/checkstyle/releases/assets/69790751",
"id": 69790751,
"node_id": "RA_kwDOAL65M84EKOwf",
"name": "checkstyle-10.3.1-all.jar",
"label": "",
"uploader": {
"login": "romani",
"id": 812984,
"node_id": "MDQ6VXNlcjgxMjk4NA==",
"avatar_url": "https://avatars.githubusercontent.com/u/812984?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/romani",
"html_url": "https://github.com/romani",
"followers_url": "https://api.github.com/users/romani/followers",
"following_url": "https://api.github.com/users/romani/following{/other_user}",
"gists_url": "https://api.github.com/users/romani/gists{/gist_id}",
"starred_url": "https://api.github.com/users/romani/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/romani/subscriptions",
"organizations_url": "https://api.github.com/users/romani/orgs",
"repos_url": "https://api.github.com/users/romani/repos",
"events_url": "https://api.github.com/users/romani/events{/privacy}",
"received_events_url": "https://api.github.com/users/romani/received_events",
"type": "User",
"site_admin": false
},
"content_type": "application/zip",
"state": "uploaded",
"size": 15396315,
"download_count": 3577,
"created_at": "2022-06-27T14:07:13Z",
"updated_at": "2022-06-27T14:08:06Z",
"browser_download_url": "https://github.com/checkstyle/checkstyle/releases/download/checkstyle-10.3.1/checkstyle-10.3.1-all.jar"
}
],
"tarball_url": "https://api.github.com/repos/checkstyle/checkstyle/tarball/checkstyle-10.3.1",
"zipball_url": "https://api.github.com/repos/checkstyle/checkstyle/zipball/checkstyle-10.3.1",
"body": "https://checkstyle.org/releasenotes.html#Release_10.3.1",
"reactions": {
"url": "https://api.github.com/repos/checkstyle/checkstyle/releases/70647006/reactions",
"total_count": 8,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 7,
"confused": 0,
"heart": 1,
"rocket": 0,
"eyes": 0
} },
This has 2 tag_name and I want to fetch the data of the second tag_name. Now It's like I always want the 2nd number tag_name only.
-> I want to use this tag_name as the previous release so I want the latest tag_name as the latest tag and the 2nd tag "tag_name" as the previous tag. I want to use these in a shell script.

Fetching the Two Most Recent Release
You can have the Github releases API respond with the two most recent releases, and then use jq to access all .tag_name fields in the array objects and then read them into separate bash variables, like so:
#!/bin/bash
# You only care about the latest release and previous, so you can
# pass the per_page query parameter
github_rsp="$(curl -s https://api.github.com/repos/checkstyle/checkstyle/releases?per_page=2)"
# jq lets you access multiple objects in a list
# using different syntaxes. Here, ".[].tag_name" will just
# access every tag_name field in each object of the response array
# and then we put those into an array that we then join with ";'
# We then read jq's output into two separate shell variables
# using ";' as our separator
IFS=";" read latest previous < <(jq -r '[.[].tag_name] | join(";")' <<< $github_rsp)
echo " Latest version: $latest"
echo "Previous version: $previous"
With this as output
❯ ./parse.sh
Latest version: checkstyle-10.3.2
Previous version: checkstyle-10.3.1
Also see the following for even more info about how my script works, if you need explanation beyond my notes:
jq Object Value Iterator
Github REST API - List Releases
Fetching a Single Release
Since you asked about getting any arbitrary release, if you have a tag name, you can use the Github Release-by-Tag API, where you put a specific tag into the releases API URL.
#!/bin/bash
function get_release() {
local repo="$1"
local tag="$2"
local release_url="https://api.github.com/repos/${repo}/releases/tags/${tag}"
rsp=$(curl -s -H 'Accept: application/vnd.github+json' "$release_url")
echo "$rsp"
}
get_release "checkstyle/checkstyle" "checkstyle-10.1" | jq
And running this script I get...
❯ ./single-release.sh
{
"url": "https://api.github.com/repos/checkstyle/checkstyle/releases/62869604",
"assets_url": "https://api.github.com/repos/checkstyle/checkstyle/releases/62869604/assets",
"upload_url": "https://uploads.github.com/repos/checkstyle/checkstyle/releases/62869604/assets{?name,label}",
"html_url": "https://github.com/checkstyle/checkstyle/releases/tag/checkstyle-10.1",
"id": 62869604,
"author": {
"login": "romani",
"id": 812984,
"node_id": "MDQ6VXNlcjgxMjk4NA==",
"avatar_url": "https://avatars.githubusercontent.com/u/812984?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/romani",
"html_url": "https://github.com/romani",
"followers_url": "https://api.github.com/users/romani/followers",
"following_url": "https://api.github.com/users/romani/following{/other_user}",
"gists_url": "https://api.github.com/users/romani/gists{/gist_id}",
"starred_url": "https://api.github.com/users/romani/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/romani/subscriptions",
"organizations_url": "https://api.github.com/users/romani/orgs",
"repos_url": "https://api.github.com/users/romani/repos",
"events_url": "https://api.github.com/users/romani/events{/privacy}",
"received_events_url": "https://api.github.com/users/romani/received_events",
"type": "User",
"site_admin": false
},
"node_id": "RE_kwDOAL65M84Dv1Bk",
"tag_name": "checkstyle-10.1",
"target_commitish": "master",
"name": "",
"draft": false,
"prerelease": false,
"created_at": "2022-03-27T14:51:31Z",
"published_at": "2022-03-27T15:06:48Z",
"assets": [
{
"url": "https://api.github.com/repos/checkstyle/checkstyle/releases/assets/60754101",
"id": 60754101,
"node_id": "RA_kwDOAL65M84Dnwi1",
"name": "checkstyle-10.1-all.jar",
"label": "",
"uploader": {
"login": "romani",
"id": 812984,
"node_id": "MDQ6VXNlcjgxMjk4NA==",
"avatar_url": "https://avatars.githubusercontent.com/u/812984?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/romani",
"html_url": "https://github.com/romani",
"followers_url": "https://api.github.com/users/romani/followers",
"following_url": "https://api.github.com/users/romani/following{/other_user}",
"gists_url": "https://api.github.com/users/romani/gists{/gist_id}",
"starred_url": "https://api.github.com/users/romani/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/romani/subscriptions",
"organizations_url": "https://api.github.com/users/romani/orgs",
"repos_url": "https://api.github.com/users/romani/repos",
"events_url": "https://api.github.com/users/romani/events{/privacy}",
"received_events_url": "https://api.github.com/users/romani/received_events",
"type": "User",
"site_admin": false
},
"content_type": "application/zip",
"state": "uploaded",
"size": 13403044,
"download_count": 6227,
"created_at": "2022-03-27T15:06:49Z",
"updated_at": "2022-03-27T15:07:35Z",
"browser_download_url": "https://github.com/checkstyle/checkstyle/releases/download/checkstyle-10.1/checkstyle-10.1-all.jar"
}
],
"tarball_url": "https://api.github.com/repos/checkstyle/checkstyle/tarball/checkstyle-10.1",
"zipball_url": "https://api.github.com/repos/checkstyle/checkstyle/zipball/checkstyle-10.1",
"body": "https://checkstyle.org/releasenotes.html#Release_10.1",
"reactions": {
"url": "https://api.github.com/repos/checkstyle/checkstyle/releases/62869604/reactions",
"total_count": 4,
"+1": 1,
"-1": 0,
"laugh": 0,
"hooray": 3,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
}
}

Related

Guest can't submit answer Adaptative Card on Microsoft Teams

I'm having an error with a custom bot when I send an adaptative card to a meeting and a guest tries to submit an answer. It works when a logged user tries to submit it. It used to work perfectly with a Guest. It seems like the problem is something about the bot login process.
Uncaught TypeError: Cannot read property '*BotId*' of undefined
at t.recordBotMriUsage (3.2-app.min-2477809.js:4)
at _.debounce.trailing (3.2-app.min-2477809.js:3)
at e (2-vendor.min-9ae85bb.js:64)
at f (2-vendor.min-9ae85bb.js:65)
at t.e.buttonClicked (3.2-app.min-2477809.js:3)
at o (lazy-ng1-mod-adaptive-card-components.min-1b02b78.js:1)
at c (lazy-ng1-mod-adaptive-card-components.min-1b02b78.js:1)
at t.handleOnExecuteAction (lazy-ng1-mod-adaptive-card-components.min-1b02b78.js:1)
at adaptiveCard.onExecuteAction (lazy-ng1-mod-adaptive-card-components.min-1b02b78.js:1)
at p (3.2-app.min-2477809.js:3)
Failed to get app entitlement for botId 28:*BotId*
500 Invoke failed due to internal error: Invoke failed: something went wrong in ProcessInvoke
[BotCardService::onButtonClicked_messageback()] sendInvoke failed: {"statusCode":500,"headers":{"cache-control":"no-store, must-revalidate, no-cache","content-length":"119","content-type":"application/json; charset=utf-8","contextid":"tcid=******,server=*****,cv=*******/hfA.1.0","pragma":"no-cache","set-registrationtoken":"**redacted**"},"errorMessage":"Error Code: 500 ","errorCode":500,"request":{}}
error log
EDIT: Here is the manifest.json of the app
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.7/MicrosoftTeams.schema.json",
"manifestVersion": "1.7",
"version": "1.0.0",
"id": "redacted",
"packageName": "redacted",
"developer": {
"name": "redacted",
"websiteUrl": "redacted",
"privacyUrl": "redacted",
"termsOfUseUrl": "redacted"
},
"icons": {
"color": "color.png",
"outline": "outline.png"
},
"name": {
"short": "redacted",
"full": "redacted"
},
"description": {
"short": "redacted",
"full": "redacted"
},
"accentColor": "#FFFFFF",
"bots": [
{
"botId": "redacted",
"scopes": ["personal", "groupchat"],
"supportsFiles": false,
"isNotificationOnly": false
}
],
"composeExtensions": [
{
"botId": "redacted",
"canUpdateConfiguration": true,
"commands": [
{
"id": "getPollCM",
"type": "action",
"title": "Generar encuesta prestador",
"description": "Genera una encuesta para prestadores",
"initialRun": true,
"fetchTask": false,
"context": ["commandBox", "compose"],
"parameters": [
{
"name": "NIT",
"title": "NIT del prestador",
"description": "Solo números",
"inputType": "text"
}
]
}
]
}
],
"permissions": ["identity", "messageTeamMembers"],
"validDomains": ["redacted"]
}

spring-boot 2 with jolokia: how to disable authentication

ENV: springboot 2.0.5.RELEASE, jolokia 1.5.0
How to disable jokolia authentication?
Endpoint jolokia response looks like following:
{
"request": {
"type": "version"
},
"value": {
"agent": "1.5.0",
"protocol": "7.2",
"config": {
"listenForHttpService": "true",
"authIgnoreCerts": "false",
"agentId": "172.22.0.3-7-72f8afb3-servlet",
"debug": "false",
"agentType": "servlet",
"policyLocation": "classpath:/jolokia-access.xml",
"agentContext": "/jolokia",
"serializeException": "false",
"mimeType": "text/plain",
"dispatcherClasses": "org.jolokia.http.Jsr160ProxyNotEnabledByDefaultAnymoreDispatcher",
"authMode": "basic",
"streaming": "true",
"canonicalNaming": "true",
"historyMaxEntries": "10",
"allowErrorDetails": "true",
"allowDnsReverseLookup": "true",
"realm": "jolokia",
"includeStackTrace": "true",
"useRestrictorService": "false",
"debugMaxEntries": "100"
},
"info": {
"product": "tomcat",
"vendor": "Apache",
"version": "8.5.34"
}
},
"timestamp": 1538476345,
"status": 200
}
Same user application environment with springboot 1.5.9.RELEASE and jokolia 1.3.7 no authentication necessary. Endpoint jokolia responds like following:
{
"request": {
"type": "version"
},
"value": {
"agent": "1.3.7",
"protocol": "7.2",
"config": {
"agentId": "172.27.0.2-6-57fcc568-servlet",
"agentType": "servlet"
},
"info": {
"product": "tomcat",
"vendor": "Apache",
"version": "8.5.23"
}
},
"timestamp": 1538487291,
"status": 200
}
You should place the file jolokia-access.xml in src/main/resources so that it is part of the classpath.
Quote from my comment: Solved using ignoring management port altogether. I was using web.ignoring().requestMatchers(EndpointRequest.toAnyEndpoint()). It seems like it only matches requests to the level of those endpoints, but not levels deeper.

PHPUnit: post contents of file to an endpoint

I am writing a test for an application that takes in pullrequestevents from github.
As part of that, I want to post the pullrequestevent JSON as supplied by GitHub, to ensure it is parsed and stored correctly.
but the supplied method in phpunit $this->post is expecting an array.
this is my test
public function testPullRequestEventCanBePosted()
{
$content = File::get('./sampleRequests/openPullRequest.json');
$response = $this->post('/pullrequest', $content->toArray());
$response->assertSuccessful();
}
and this is the json file
{
"action": "open",
"number": 2,
"pull_request": {
"url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1",
"id": 191568743,
"node_id": "MDExOlB1bGxSZXF1ZXN0MTkxNTY4NzQz",
"html_url": "https://github.com/Codertocat/Hello-World/pull/1",
"diff_url": "https://github.com/Codertocat/Hello-World/pull/1.diff",
"patch_url": "https://github.com/Codertocat/Hello-World/pull/1.patch",
"issue_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/1",
"number": 2,
"state": "open",
"locked": false,
"title": "Update the README with new information",
"user": {
"login": "Codertocat",
"id": 21031067,
"node_id": "MDQ6VXNlcjIxMDMxMDY3",
"avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Codertocat",
"html_url": "https://github.com/Codertocat",
"followers_url": "https://api.github.com/users/Codertocat/followers",
"following_url": "https://api.github.com/users/Codertocat/following{/other_user}",
"gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions",
"organizations_url": "https://api.github.com/users/Codertocat/orgs",
"repos_url": "https://api.github.com/users/Codertocat/repos",
"events_url": "https://api.github.com/users/Codertocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/Codertocat/received_events",
"type": "User",
"site_admin": false
},
"body": "This is a pretty simple change that we need to pull into master.",
"created_at": "2018-05-30T20:18:30Z",
"updated_at": "2018-05-30T20:18:50Z",
"closed_at": "2018-05-30T20:18:50Z",
"merged_at": null,
"merge_commit_sha": "414cb0069601a32b00bd122a2380cd283626a8e5",
"assignee": null,
"assignees": [
],
"requested_reviewers": [
],
"requested_teams": [
],
"labels": [
],
"milestone": null,
"commits_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1/commits",
"review_comments_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1/comments",
"review_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls/comments{/number}",
"comments_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/1/comments",
"statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/34c5c7793cb3b279e22454cb6750c80560547b3a",
"head": {
"label": "Codertocat:changes",
"ref": "changes",
"sha": "34c5c7793cb3b279e22454cb6750c80560547b3a",
"user": {
"login": "Codertocat",
"id": 21031067,
"node_id": "MDQ6VXNlcjIxMDMxMDY3",
"avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Codertocat",
"html_url": "https://github.com/Codertocat",
"followers_url": "https://api.github.com/users/Codertocat/followers",
"following_url": "https://api.github.com/users/Codertocat/following{/other_user}",
"gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions",
"organizations_url": "https://api.github.com/users/Codertocat/orgs",
"repos_url": "https://api.github.com/users/Codertocat/repos",
"events_url": "https://api.github.com/users/Codertocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/Codertocat/received_events",
"type": "User",
"site_admin": false
},
"repo": {
"id": 135493233,
"node_id": "MDEwOlJlcG9zaXRvcnkxMzU0OTMyMzM=",
"name": "Hello-World",
"full_name": "Codertocat/Hello-World",
"owner": {
"login": "Codertocat",
"id": 21031067,
"node_id": "MDQ6VXNlcjIxMDMxMDY3",
"avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Codertocat",
"html_url": "https://github.com/Codertocat",
"followers_url": "https://api.github.com/users/Codertocat/followers",
"following_url": "https://api.github.com/users/Codertocat/following{/other_user}",
"gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions",
"organizations_url": "https://api.github.com/users/Codertocat/orgs",
"repos_url": "https://api.github.com/users/Codertocat/repos",
"events_url": "https://api.github.com/users/Codertocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/Codertocat/received_events",
"type": "User",
"site_admin": false
},
"private": false,
"html_url": "https://github.com/Codertocat/Hello-World",
"description": null,
"fork": false,
"url": "https://api.github.com/repos/Codertocat/Hello-World",
"forks_url": "https://api.github.com/repos/Codertocat/Hello-World/forks",
"keys_url": "https://api.github.com/repos/Codertocat/Hello-World/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/Codertocat/Hello-World/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/Codertocat/Hello-World/teams",
"hooks_url": "https://api.github.com/repos/Codertocat/Hello-World/hooks",
"issue_events_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/events{/number}",
"events_url": "https://api.github.com/repos/Codertocat/Hello-World/events",
"assignees_url": "https://api.github.com/repos/Codertocat/Hello-World/assignees{/user}",
"branches_url": "https://api.github.com/repos/Codertocat/Hello-World/branches{/branch}",
"tags_url": "https://api.github.com/repos/Codertocat/Hello-World/tags",
"blobs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/Codertocat/Hello-World/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/Codertocat/Hello-World/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/{sha}",
"languages_url": "https://api.github.com/repos/Codertocat/Hello-World/languages",
"stargazers_url": "https://api.github.com/repos/Codertocat/Hello-World/stargazers",
"contributors_url": "https://api.github.com/repos/Codertocat/Hello-World/contributors",
"subscribers_url": "https://api.github.com/repos/Codertocat/Hello-World/subscribers",
"subscription_url": "https://api.github.com/repos/Codertocat/Hello-World/subscription",
"commits_url": "https://api.github.com/repos/Codertocat/Hello-World/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/Codertocat/Hello-World/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/Codertocat/Hello-World/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/Codertocat/Hello-World/contents/{+path}",
"compare_url": "https://api.github.com/repos/Codertocat/Hello-World/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/Codertocat/Hello-World/merges",
"archive_url": "https://api.github.com/repos/Codertocat/Hello-World/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/Codertocat/Hello-World/downloads",
"issues_url": "https://api.github.com/repos/Codertocat/Hello-World/issues{/number}",
"pulls_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls{/number}",
"milestones_url": "https://api.github.com/repos/Codertocat/Hello-World/milestones{/number}",
"notifications_url": "https://api.github.com/repos/Codertocat/Hello-World/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/Codertocat/Hello-World/labels{/name}",
"releases_url": "https://api.github.com/repos/Codertocat/Hello-World/releases{/id}",
"deployments_url": "https://api.github.com/repos/Codertocat/Hello-World/deployments",
"created_at": "2018-05-30T20:18:04Z",
"updated_at": "2018-05-30T20:18:50Z",
"pushed_at": "2018-05-30T20:18:48Z",
"git_url": "git://github.com/Codertocat/Hello-World.git",
"ssh_url": "git#github.com:Codertocat/Hello-World.git",
"clone_url": "https://github.com/Codertocat/Hello-World.git",
"svn_url": "https://github.com/Codertocat/Hello-World",
"homepage": null,
"size": 0,
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": true,
"forks_count": 0,
"mirror_url": null,
"archived": false,
"open_issues_count": 1,
"license": null,
"forks": 0,
"open_issues": 1,
"watchers": 0,
"default_branch": "master"
}
},
"base": {
"label": "Codertocat:master",
"ref": "master",
"sha": "a10867b14bb761a232cd80139fbd4c0d33264240",
"user": {
"login": "Codertocat",
"id": 21031067,
"node_id": "MDQ6VXNlcjIxMDMxMDY3",
"avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Codertocat",
"html_url": "https://github.com/Codertocat",
"followers_url": "https://api.github.com/users/Codertocat/followers",
"following_url": "https://api.github.com/users/Codertocat/following{/other_user}",
"gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions",
"organizations_url": "https://api.github.com/users/Codertocat/orgs",
"repos_url": "https://api.github.com/users/Codertocat/repos",
"events_url": "https://api.github.com/users/Codertocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/Codertocat/received_events",
"type": "User",
"site_admin": false
},
"repo": {
"id": 135493233,
"node_id": "MDEwOlJlcG9zaXRvcnkxMzU0OTMyMzM=",
"name": "Hello-World",
"full_name": "Codertocat/Hello-World",
"owner": {
"login": "Codertocat",
"id": 21031067,
"node_id": "MDQ6VXNlcjIxMDMxMDY3",
"avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Codertocat",
"html_url": "https://github.com/Codertocat",
"followers_url": "https://api.github.com/users/Codertocat/followers",
"following_url": "https://api.github.com/users/Codertocat/following{/other_user}",
"gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions",
"organizations_url": "https://api.github.com/users/Codertocat/orgs",
"repos_url": "https://api.github.com/users/Codertocat/repos",
"events_url": "https://api.github.com/users/Codertocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/Codertocat/received_events",
"type": "User",
"site_admin": false
},
"private": false,
"html_url": "https://github.com/Codertocat/Hello-World",
"description": null,
"fork": false,
"url": "https://api.github.com/repos/Codertocat/Hello-World",
"forks_url": "https://api.github.com/repos/Codertocat/Hello-World/forks",
"keys_url": "https://api.github.com/repos/Codertocat/Hello-World/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/Codertocat/Hello-World/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/Codertocat/Hello-World/teams",
"hooks_url": "https://api.github.com/repos/Codertocat/Hello-World/hooks",
"issue_events_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/events{/number}",
"events_url": "https://api.github.com/repos/Codertocat/Hello-World/events",
"assignees_url": "https://api.github.com/repos/Codertocat/Hello-World/assignees{/user}",
"branches_url": "https://api.github.com/repos/Codertocat/Hello-World/branches{/branch}",
"tags_url": "https://api.github.com/repos/Codertocat/Hello-World/tags",
"blobs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/Codertocat/Hello-World/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/Codertocat/Hello-World/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/{sha}",
"languages_url": "https://api.github.com/repos/Codertocat/Hello-World/languages",
"stargazers_url": "https://api.github.com/repos/Codertocat/Hello-World/stargazers",
"contributors_url": "https://api.github.com/repos/Codertocat/Hello-World/contributors",
"subscribers_url": "https://api.github.com/repos/Codertocat/Hello-World/subscribers",
"subscription_url": "https://api.github.com/repos/Codertocat/Hello-World/subscription",
"commits_url": "https://api.github.com/repos/Codertocat/Hello-World/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/Codertocat/Hello-World/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/Codertocat/Hello-World/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/Codertocat/Hello-World/contents/{+path}",
"compare_url": "https://api.github.com/repos/Codertocat/Hello-World/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/Codertocat/Hello-World/merges",
"archive_url": "https://api.github.com/repos/Codertocat/Hello-World/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/Codertocat/Hello-World/downloads",
"issues_url": "https://api.github.com/repos/Codertocat/Hello-World/issues{/number}",
"pulls_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls{/number}",
"milestones_url": "https://api.github.com/repos/Codertocat/Hello-World/milestones{/number}",
"notifications_url": "https://api.github.com/repos/Codertocat/Hello-World/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/Codertocat/Hello-World/labels{/name}",
"releases_url": "https://api.github.com/repos/Codertocat/Hello-World/releases{/id}",
"deployments_url": "https://api.github.com/repos/Codertocat/Hello-World/deployments",
"created_at": "2018-05-30T20:18:04Z",
"updated_at": "2018-05-30T20:18:50Z",
"pushed_at": "2018-05-30T20:18:48Z",
"git_url": "git://github.com/Codertocat/Hello-World.git",
"ssh_url": "git#github.com:Codertocat/Hello-World.git",
"clone_url": "https://github.com/Codertocat/Hello-World.git",
"svn_url": "https://github.com/Codertocat/Hello-World",
"homepage": null,
"size": 0,
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": true,
"forks_count": 0,
"mirror_url": null,
"archived": false,
"open_issues_count": 1,
"license": null,
"forks": 0,
"open_issues": 1,
"watchers": 0,
"default_branch": "master"
}
},
"_links": {
"self": {
"href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1"
},
"html": {
"href": "https://github.com/Codertocat/Hello-World/pull/1"
},
"issue": {
"href": "https://api.github.com/repos/Codertocat/Hello-World/issues/1"
},
"comments": {
"href": "https://api.github.com/repos/Codertocat/Hello-World/issues/1/comments"
},
"review_comments": {
"href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1/comments"
},
"review_comment": {
"href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/comments{/number}"
},
"commits": {
"href": "https://api.github.com/repos/Codertocat/Hello-World/pulls/1/commits"
},
"statuses": {
"href": "https://api.github.com/repos/Codertocat/Hello-World/statuses/34c5c7793cb3b279e22454cb6750c80560547b3a"
}
},
"author_association": "OWNER",
"merged": false,
"mergeable": true,
"rebaseable": true,
"mergeable_state": "clean",
"merged_by": null,
"comments": 0,
"review_comments": 1,
"maintainer_can_modify": false,
"commits": 1,
"additions": 1,
"deletions": 1,
"changed_files": 1
},
"repository": {
"id": 135493233,
"node_id": "MDEwOlJlcG9zaXRvcnkxMzU0OTMyMzM=",
"name": "Hello-World",
"full_name": "Codertocat/Hello-World",
"owner": {
"login": "Codertocat",
"id": 21031067,
"node_id": "MDQ6VXNlcjIxMDMxMDY3",
"avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Codertocat",
"html_url": "https://github.com/Codertocat",
"followers_url": "https://api.github.com/users/Codertocat/followers",
"following_url": "https://api.github.com/users/Codertocat/following{/other_user}",
"gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions",
"organizations_url": "https://api.github.com/users/Codertocat/orgs",
"repos_url": "https://api.github.com/users/Codertocat/repos",
"events_url": "https://api.github.com/users/Codertocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/Codertocat/received_events",
"type": "User",
"site_admin": false
},
"private": false,
"html_url": "https://github.com/Codertocat/Hello-World",
"description": null,
"fork": false,
"url": "https://api.github.com/repos/Codertocat/Hello-World",
"forks_url": "https://api.github.com/repos/Codertocat/Hello-World/forks",
"keys_url": "https://api.github.com/repos/Codertocat/Hello-World/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/Codertocat/Hello-World/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/Codertocat/Hello-World/teams",
"hooks_url": "https://api.github.com/repos/Codertocat/Hello-World/hooks",
"issue_events_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/events{/number}",
"events_url": "https://api.github.com/repos/Codertocat/Hello-World/events",
"assignees_url": "https://api.github.com/repos/Codertocat/Hello-World/assignees{/user}",
"branches_url": "https://api.github.com/repos/Codertocat/Hello-World/branches{/branch}",
"tags_url": "https://api.github.com/repos/Codertocat/Hello-World/tags",
"blobs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/Codertocat/Hello-World/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/Codertocat/Hello-World/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/Codertocat/Hello-World/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/Codertocat/Hello-World/statuses/{sha}",
"languages_url": "https://api.github.com/repos/Codertocat/Hello-World/languages",
"stargazers_url": "https://api.github.com/repos/Codertocat/Hello-World/stargazers",
"contributors_url": "https://api.github.com/repos/Codertocat/Hello-World/contributors",
"subscribers_url": "https://api.github.com/repos/Codertocat/Hello-World/subscribers",
"subscription_url": "https://api.github.com/repos/Codertocat/Hello-World/subscription",
"commits_url": "https://api.github.com/repos/Codertocat/Hello-World/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/Codertocat/Hello-World/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/Codertocat/Hello-World/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/Codertocat/Hello-World/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/Codertocat/Hello-World/contents/{+path}",
"compare_url": "https://api.github.com/repos/Codertocat/Hello-World/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/Codertocat/Hello-World/merges",
"archive_url": "https://api.github.com/repos/Codertocat/Hello-World/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/Codertocat/Hello-World/downloads",
"issues_url": "https://api.github.com/repos/Codertocat/Hello-World/issues{/number}",
"pulls_url": "https://api.github.com/repos/Codertocat/Hello-World/pulls{/number}",
"milestones_url": "https://api.github.com/repos/Codertocat/Hello-World/milestones{/number}",
"notifications_url": "https://api.github.com/repos/Codertocat/Hello-World/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/Codertocat/Hello-World/labels{/name}",
"releases_url": "https://api.github.com/repos/Codertocat/Hello-World/releases{/id}",
"deployments_url": "https://api.github.com/repos/Codertocat/Hello-World/deployments",
"created_at": "2018-05-30T20:18:04Z",
"updated_at": "2018-05-30T20:18:50Z",
"pushed_at": "2018-05-30T20:18:48Z",
"git_url": "git://github.com/Codertocat/Hello-World.git",
"ssh_url": "git#github.com:Codertocat/Hello-World.git",
"clone_url": "https://github.com/Codertocat/Hello-World.git",
"svn_url": "https://github.com/Codertocat/Hello-World",
"homepage": null,
"size": 0,
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": true,
"forks_count": 0,
"mirror_url": null,
"archived": false,
"open_issues_count": 1,
"license": null,
"forks": 0,
"open_issues": 1,
"watchers": 0,
"default_branch": "master"
},
"sender": {
"login": "Codertocat",
"id": 21031067,
"node_id": "MDQ6VXNlcjIxMDMxMDY3",
"avatar_url": "https://avatars1.githubusercontent.com/u/21031067?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Codertocat",
"html_url": "https://github.com/Codertocat",
"followers_url": "https://api.github.com/users/Codertocat/followers",
"following_url": "https://api.github.com/users/Codertocat/following{/other_user}",
"gists_url": "https://api.github.com/users/Codertocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Codertocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Codertocat/subscriptions",
"organizations_url": "https://api.github.com/users/Codertocat/orgs",
"repos_url": "https://api.github.com/users/Codertocat/repos",
"events_url": "https://api.github.com/users/Codertocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/Codertocat/received_events",
"type": "User",
"site_admin": false
}
}
What method do I need to use to post this to the endpoint? is it a case of installing something like guzzle?
Not sure about what results you might be getting at this point, but it looks like you are missing to decode the file contents as a proper JSON object:
// get plaintext contents from the json file stub
$plaintext = File::get('./sampleRequests/openPullRequest.json');
// decode the plaintext into an actual JSON object
$stubObject = json_decode($plaintext);
// Get the object attributes as an array instead of stdclass
$arrayContent = get_object_vars($stubObject);
$response = $this->post('/pullrequest', $arrayContent);
This is not guarantee that your test will pass, since we don't know how your endpoint should behave, but it basically points out the need of converting data to the proper type before using on the tester methods (post() in this case).

Download .mp4 from Google Photo using Google Drive API will get wrong md5Checksum

When we try to download a file with an extension of .mp4 from Google Photo using Google Drive API, the downloaded file always has different md5 hash value with the md5Checksum field provided by remote metadata.
For example, assume there exists a file name video.mp4 on Google Photo. After we download the file using either one of the following URL:
(v2) https://doc-14-6c-docs.googleusercontent.com/docs/securesc/[SOME_VALUES]?h=[SOME_VALUES]&e=download&gd=true
(v3) https://www.googleapis.com/drive/v3/files/[FILEID]?alt=media
Both methods will download the file correctly on a local machine. The file size is also the same as the fileSize field of remote metadata.
However, the md5 hash value is inconsistent with the md5Checksum field of remote metadata. For example, if we enter $md5sum video.mp4 command, we may got 5cf9fb1bb88dc9bf38d1de5c9180dc4e video.mp4. This is not the hash recorded at remote metadata.
All other files work fine (size and hash are consistent), except for the files with an extension of .mp4. By the way, we use CURL to send a request to Google Drive API to download these files, instead of using any of Google Drive SDK.
Hope someone can help us, thanks!
[Update] more explanation
These files are from our customer's Google Photo. We don't know the exact way to reproduce such situaion. We provide the metadata of one of problematic file for your reference. (we remove some private information.)
{
"kind": "drive#file",
"id": "(REMOVED)",
"etag": "(REMOVED)",
"selfLink": "(REMOVED)",
"webContentLink": "(REMOVED)",
"alternateLink": "(REMOVED)",
"embedLink": "(REMOVED)",
"iconLink": "(REMOVED)",
"thumbnailLink": "(REMOVED)",
"title": "(REMOVED)",
"mimeType": "video/mp4",
"description": "",
"labels": {
"starred": false,
"hidden": false,
"trashed": false,
"restricted": false,
"viewed": false
},
"createdDate": "2016-10-10T11:42:25.000Z",
"modifiedDate": "2016-10-18T23:01:19.000Z",
"modifiedByMeDate": "2016-10-18T23:01:19.000Z",
"markedViewedByMeDate": "1970-01-01T00:00:00.000Z",
"version": "133589",
"parents": [
{
"kind": "drive#parentReference",
"id": "(REMOVED)",
"selfLink": "(REMOVED)",
"parentLink": "(REMOVED)",
"isRoot": false
}
],
"downloadUrl": "(REMOVED)",
"userPermission": {
"kind": "drive#permission",
"etag": "(REMOVED)",
"id": "me",
"selfLink": "(REMOVED)",
"role": "owner",
"type": "user"
},
"originalFilename": "(REMOVED)",
"fileExtension": "mp4",
"md5Checksum": "c5a208198614c34b6fc61186d025df77",
"fileSize": "15284923",
"quotaBytesUsed": "0",
"ownerNames": [
"(REMOVED)"
],
"owners": [
{
"kind": "drive#user",
"displayName": "(REMOVED)",
"picture": {
"url": "(REMOVED)"
},
"isAuthenticatedUser": true,
"permissionId": "(REMOVED)",
"emailAddress": "(REMOVED)"
}
],
"lastModifyingUserName": "(REMOVED)",
"lastModifyingUser": {
"kind": "drive#user",
"displayName": "(REMOVED)",
"picture": {
"url": "(REMOVED)"
},
"isAuthenticatedUser": true,
"permissionId": "(REMOVED)",
"emailAddress": "(REMOVED)"
},
"capabilities": {
"canCopy": true,
"canEdit": true
},
"editable": true,
"copyable": true,
"writersCanShare": true,
"shared": false,
"explicitlyTrashed": false,
"appDataContents": false,
"headRevisionId": "(REMOVED)",
"videoMediaMetadata": {
"width": 720,
"height": 1280,
"durationMillis": "43697"
},
"spaces": [
"photos",
"drive"
]}
As you can see, the md5Checksum field shows c5a208198614c34b6fc61186d025df77 in the metadata. However, the actual md5 hash value equals to 95be52d721e2f5d8d02650b27095d466 instead.

Where can I get a list of Ansible pre-defined variables?

I see that Ansible provide some pre-defined variables that we can use in playbooks and template files. For example, the host IP address is ansible_eth0.ipv4.address. Googleing and searching the docs I couldn't find a list of all available variables.
Would someone list them for me?
From the FAQ:
How do I see a list of all of the ansible_ variables?
Ansible by default gathers “facts” about the machines under management, and these facts can be accessed in playbooks and in templates. To see a list of all of the facts that are available about a machine, you can run the setup module as an ad hoc action:
ansible -m setup hostname
This will print out a dictionary of all of the facts that are available for that particular host. You might want to pipe the output to a pager.This does NOT include inventory variables or internal ‘magic’ variables. See the next question if you need more than just ‘facts’.
Here is the output for my vagrant virtual machine called scdev:
scdev | success >> {
"ansible_facts": {
"ansible_all_ipv4_addresses": [
"10.0.2.15",
"192.168.10.10"
],
"ansible_all_ipv6_addresses": [
"fe80::a00:27ff:fe12:9698",
"fe80::a00:27ff:fe74:1330"
],
"ansible_architecture": "i386",
"ansible_bios_date": "12/01/2006",
"ansible_bios_version": "VirtualBox",
"ansible_cmdline": {
"BOOT_IMAGE": "/vmlinuz-3.2.0-23-generic-pae",
"quiet": true,
"ro": true,
"root": "/dev/mapper/precise32-root"
},
"ansible_date_time": {
"date": "2013-09-17",
"day": "17",
"epoch": "1379378304",
"hour": "00",
"iso8601": "2013-09-17T00:38:24Z",
"iso8601_micro": "2013-09-17T00:38:24.425092Z",
"minute": "38",
"month": "09",
"second": "24",
"time": "00:38:24",
"tz": "UTC",
"year": "2013"
},
"ansible_default_ipv4": {
"address": "10.0.2.15",
"alias": "eth0",
"gateway": "10.0.2.2",
"interface": "eth0",
"macaddress": "08:00:27:12:96:98",
"mtu": 1500,
"netmask": "255.255.255.0",
"network": "10.0.2.0",
"type": "ether"
},
"ansible_default_ipv6": {},
"ansible_devices": {
"sda": {
"holders": [],
"host": "SATA controller: Intel Corporation 82801HM/HEM (ICH8M/ICH8M-E) SATA Controller [AHCI mode] (rev 02)",
"model": "VBOX HARDDISK",
"partitions": {
"sda1": {
"sectors": "497664",
"sectorsize": 512,
"size": "243.00 MB",
"start": "2048"
},
"sda2": {
"sectors": "2",
"sectorsize": 512,
"size": "1.00 KB",
"start": "501758"
},
},
"removable": "0",
"rotational": "1",
"scheduler_mode": "cfq",
"sectors": "167772160",
"sectorsize": "512",
"size": "80.00 GB",
"support_discard": "0",
"vendor": "ATA"
},
"sr0": {
"holders": [],
"host": "IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)",
"model": "CD-ROM",
"partitions": {},
"removable": "1",
"rotational": "1",
"scheduler_mode": "cfq",
"sectors": "2097151",
"sectorsize": "512",
"size": "1024.00 MB",
"support_discard": "0",
"vendor": "VBOX"
},
"sr1": {
"holders": [],
"host": "IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)",
"model": "CD-ROM",
"partitions": {},
"removable": "1",
"rotational": "1",
"scheduler_mode": "cfq",
"sectors": "2097151",
"sectorsize": "512",
"size": "1024.00 MB",
"support_discard": "0",
"vendor": "VBOX"
}
},
"ansible_distribution": "Ubuntu",
"ansible_distribution_release": "precise",
"ansible_distribution_version": "12.04",
"ansible_domain": "",
"ansible_eth0": {
"active": true,
"device": "eth0",
"ipv4": {
"address": "10.0.2.15",
"netmask": "255.255.255.0",
"network": "10.0.2.0"
},
"ipv6": [
{
"address": "fe80::a00:27ff:fe12:9698",
"prefix": "64",
"scope": "link"
}
],
"macaddress": "08:00:27:12:96:98",
"module": "e1000",
"mtu": 1500,
"type": "ether"
},
"ansible_eth1": {
"active": true,
"device": "eth1",
"ipv4": {
"address": "192.168.10.10",
"netmask": "255.255.255.0",
"network": "192.168.10.0"
},
"ipv6": [
{
"address": "fe80::a00:27ff:fe74:1330",
"prefix": "64",
"scope": "link"
}
],
"macaddress": "08:00:27:74:13:30",
"module": "e1000",
"mtu": 1500,
"type": "ether"
},
"ansible_form_factor": "Other",
"ansible_fqdn": "scdev",
"ansible_hostname": "scdev",
"ansible_interfaces": [
"lo",
"eth1",
"eth0"
],
"ansible_kernel": "3.2.0-23-generic-pae",
"ansible_lo": {
"active": true,
"device": "lo",
"ipv4": {
"address": "127.0.0.1",
"netmask": "255.0.0.0",
"network": "127.0.0.0"
},
"ipv6": [
{
"address": "::1",
"prefix": "128",
"scope": "host"
}
],
"mtu": 16436,
"type": "loopback"
},
"ansible_lsb": {
"codename": "precise",
"description": "Ubuntu 12.04 LTS",
"id": "Ubuntu",
"major_release": "12",
"release": "12.04"
},
"ansible_machine": "i686",
"ansible_memfree_mb": 23,
"ansible_memtotal_mb": 369,
"ansible_mounts": [
{
"device": "/dev/mapper/precise32-root",
"fstype": "ext4",
"mount": "/",
"options": "rw,errors=remount-ro",
"size_available": 77685088256,
"size_total": 84696281088
},
{
"device": "/dev/sda1",
"fstype": "ext2",
"mount": "/boot",
"options": "rw",
"size_available": 201044992,
"size_total": 238787584
},
{
"device": "/vagrant",
"fstype": "vboxsf",
"mount": "/vagrant",
"options": "uid=1000,gid=1000,rw",
"size_available": 42013151232,
"size_total": 484145360896
}
],
"ansible_os_family": "Debian",
"ansible_pkg_mgr": "apt",
"ansible_processor": [
"Pentium(R) Dual-Core CPU E5300 # 2.60GHz"
],
"ansible_processor_cores": "NA",
"ansible_processor_count": 1,
"ansible_product_name": "VirtualBox",
"ansible_product_serial": "NA",
"ansible_product_uuid": "NA",
"ansible_product_version": "1.2",
"ansible_python_version": "2.7.3",
"ansible_selinux": false,
"ansible_swapfree_mb": 766,
"ansible_swaptotal_mb": 767,
"ansible_system": "Linux",
"ansible_system_vendor": "innotek GmbH",
"ansible_user_id": "neves",
"ansible_userspace_architecture": "i386",
"ansible_userspace_bits": "32",
"ansible_virtualization_role": "guest",
"ansible_virtualization_type": "virtualbox"
},
"changed": false
}
The current documentation now has a complete chapter about Discovering variables: facts and magic variables.
ansible -m setup hostname
Only gets the facts gathered by the setup module.
Gilles Cornu posted a template trick to list all variables for a specific host.
Template (later called dump_variables):
HOSTVARS (ANSIBLE GATHERED, group_vars, host_vars) :
{{ hostvars[inventory_hostname] | to_yaml }}
PLAYBOOK VARS:
{{ vars | to_yaml }}
Playbook to use it:
- hosts: all
tasks:
- template:
src: templates/dump_variables
dest: /tmp/ansible_variables
- fetch:
src: /tmp/ansible_variables
dest: "{{inventory_hostname}}_ansible_variables"
After that you have a dump of all variables on every host, and a copy of each text dump file on your local workstation in your tmp folder. If you don't want local copies, you can remove the fetch statement.
This includes gathered facts, host variables and group variables.
Therefore you see ansible default variables like group_names, inventory_hostname, ansible_ssh_host and so on.
There are 3 sources of variables in Ansible:
Variables gathered from facts. You can get them by running command: ansible -m setup hostname
Built-in (pre-defined) Ansible variables (AKA 'magic' variables). They are documented in Ansible documentation: http://docs.ansible.com/playbooks_variables.html#magic-variables-and-how-to-access-information-about-other-hosts
Here is the list extracted from Ansible 1.9 documentation:
group_names
groups
inventory_hostname
ansible_hostname
inventory_hostname_short
play_hosts
delegate_to
inventory_dir
inventory_file
Variables passed to ansible via command line. But obviously you know what they are
I use this simple playbook:
---
# vars.yml
#
# Shows the value of all variables/facts.
#
# Example:
#
# ansible-playbook vars.yml -e 'hosts=localhost'
#
- hosts: localhost
tasks:
- fail: "You must specify a value for `hosts` variable - e.g.: ansible-playbook vars.yml -e 'hosts=localhost'"
when: hosts is not defined
- hosts: "{{ hosts }}"
tasks:
- debug: var=vars
- debug: var=hostvars[inventory_hostname]
There is lot of variables defined as Facts -- http://docs.ansible.com/ansible/playbooks_variables.html#information-discovered-from-systems-facts
"ansible_all_ipv4_addresses": [
"REDACTED IP ADDRESS"
],
"ansible_all_ipv6_addresses": [
"REDACTED IPV6 ADDRESS"
],
"ansible_architecture": "x86_64",
"ansible_bios_date": "09/20/2012",
"ansible_bios_version": "6.00",
"ansible_cmdline": {
"BOOT_IMAGE": "/boot/vmlinuz-3.5.0-23-generic",
"quiet": true,
"ro": true,
"root": "UUID=4195bff4-e157-4e41-8701-e93f0aec9e22",
"splash": true
},
"ansible_date_time": {
"date": "2013-10-02",
"day": "02",
"epoch": "1380756810",
"hour": "19",
"iso8601": "2013-10-02T23:33:30Z",
"iso8601_micro": "2013-10-02T23:33:30.036070Z",
"minute": "33",
"month": "10",
"second": "30",
"time": "19:33:30",
"tz": "EDT",
"year": "2013"
},
"ansible_default_ipv4": {
"address": "REDACTED",
"alias": "eth0",
"gateway": "REDACTED",
"interface": "eth0",
"macaddress": "REDACTED",
"mtu": 1500,
"netmask": "255.255.255.0",
"network": "REDACTED",
"type": "ether"
},
"ansible_default_ipv6": {},
"ansible_devices": {
"fd0": {
"holders": [],
"host": "",
"model": null,
"partitions": {},
"removable": "1",
"rotational": "1",
"scheduler_mode": "deadline",
"sectors": "0",
"sectorsize": "512",
"size": "0.00 Bytes",
"support_discard": "0",
"vendor": null
},
"sda": {
"holders": [],
"host": "SCSI storage controller: LSI Logic / Symbios Logic 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI (rev 01)",
"model": "VMware Virtual S",
"partitions": {
"sda1": {
"sectors": "39843840",
"sectorsize": 512,
"size": "19.00 GB",
"start": "2048"
},
"sda2": {
"sectors": "2",
"sectorsize": 512,
"size": "1.00 KB",
"start": "39847934"
},
"sda5": {
"sectors": "2093056",
"sectorsize": 512,
"size": "1022.00 MB",
"start": "39847936"
}
},
"removable": "0",
"rotational": "1",
"scheduler_mode": "deadline",
"sectors": "41943040",
"sectorsize": "512",
"size": "20.00 GB",
"support_discard": "0",
"vendor": "VMware,"
},
"sr0": {
"holders": [],
"host": "IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)",
"model": "VMware IDE CDR10",
"partitions": {},
"removable": "1",
"rotational": "1",
"scheduler_mode": "deadline",
"sectors": "2097151",
"sectorsize": "512",
"size": "1024.00 MB",
"support_discard": "0",
"vendor": "NECVMWar"
}
},
"ansible_distribution": "Ubuntu",
"ansible_distribution_release": "precise",
"ansible_distribution_version": "12.04",
"ansible_domain": "",
"ansible_env": {
"COLORTERM": "gnome-terminal",
"DISPLAY": ":0",
"HOME": "/home/mdehaan",
"LANG": "C",
"LESSCLOSE": "/usr/bin/lesspipe %s %s",
"LESSOPEN": "| /usr/bin/lesspipe %s",
"LOGNAME": "root",
"LS_COLORS": "rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:",
"MAIL": "/var/mail/root",
"OLDPWD": "/root/ansible/docsite",
"PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"PWD": "/root/ansible",
"SHELL": "/bin/bash",
"SHLVL": "1",
"SUDO_COMMAND": "/bin/bash",
"SUDO_GID": "1000",
"SUDO_UID": "1000",
"SUDO_USER": "mdehaan",
"TERM": "xterm",
"USER": "root",
"USERNAME": "root",
"XAUTHORITY": "/home/mdehaan/.Xauthority",
"_": "/usr/local/bin/ansible"
},
"ansible_eth0": {
"active": true,
"device": "eth0",
"ipv4": {
"address": "REDACTED",
"netmask": "255.255.255.0",
"network": "REDACTED"
},
"ipv6": [
{
"address": "REDACTED",
"prefix": "64",
"scope": "link"
}
],
"macaddress": "REDACTED",
"module": "e1000",
"mtu": 1500,
"type": "ether"
},
"ansible_form_factor": "Other",
"ansible_fqdn": "ubuntu2.example.com",
"ansible_hostname": "ubuntu2",
"ansible_interfaces": [
"lo",
"eth0"
],
"ansible_kernel": "3.5.0-23-generic",
"ansible_lo": {
"active": true,
"device": "lo",
"ipv4": {
"address": "127.0.0.1",
"netmask": "255.0.0.0",
"network": "127.0.0.0"
},
"ipv6": [
{
"address": "::1",
"prefix": "128",
"scope": "host"
}
],
"mtu": 16436,
"type": "loopback"
},
"ansible_lsb": {
"codename": "precise",
"description": "Ubuntu 12.04.2 LTS",
"id": "Ubuntu",
"major_release": "12",
"release": "12.04"
},
"ansible_machine": "x86_64",
"ansible_memfree_mb": 74,
"ansible_memtotal_mb": 991,
"ansible_mounts": [
{
"device": "/dev/sda1",
"fstype": "ext4",
"mount": "/",
"options": "rw,errors=remount-ro",
"size_available": 15032406016,
"size_total": 20079898624
}
],
"ansible_nodename": "ubuntu2.example.com",
"ansible_os_family": "Debian",
"ansible_pkg_mgr": "apt",
"ansible_processor": [
"Intel(R) Core(TM) i7 CPU 860 # 2.80GHz"
],
"ansible_processor_cores": 1,
"ansible_processor_count": 1,
"ansible_processor_threads_per_core": 1,
"ansible_processor_vcpus": 1,
"ansible_product_name": "VMware Virtual Platform",
"ansible_product_serial": "REDACTED",
"ansible_product_uuid": "REDACTED",
"ansible_product_version": "None",
"ansible_python_version": "2.7.3",
"ansible_selinux": false,
"ansible_ssh_host_key_dsa_public": "REDACTED KEY VALUE"
"ansible_ssh_host_key_ecdsa_public": "REDACTED KEY VALUE"
"ansible_ssh_host_key_rsa_public": "REDACTED KEY VALUE"
"ansible_swapfree_mb": 665,
"ansible_swaptotal_mb": 1021,
"ansible_system": "Linux",
"ansible_system_vendor": "VMware, Inc.",
"ansible_user_id": "root",
"ansible_userspace_architecture": "x86_64",
"ansible_userspace_bits": "64",
"ansible_virtualization_role": "guest",
"ansible_virtualization_type": "VMware"
The debug module can be used to analyze variables. Be careful running the following command. In our setup it generates 444709 lines with 16MB:
ansible -m debug -a 'var=hostvars' localhost
I am not sure but it might be necessary to enable facts caching.
If you need just one host use the host name as a key for the hostvars hash:
ansible -m debug -a 'var=hostvars.localhost' localhost
This command will display also group and host variables.
Note the official docs on connection configuration variables or "behavioral" variables - which aren't listed in host vars, appears to be List of Behavioral Inventory Parameters in the Inventory documentation.
P.S. The sudo option is undocumented there (yes its sudo not ansible_sudo as you'd expect ...) and probably a couple more aren't, but thats best doc I've found on em.
Some variables are not available on every host, e.g. ansible_domain and domain. If the situation needs to be debugged, I login to the server and issue:
user#server:~$ ansible -m setup localhost | grep domain
[WARNING]: provided hosts list is empty, only localhost is available
"ansible_domain": "prd.example.com",
I know this question has been answered already, but I feel like there are a whole other set of pre-defined variables not covered by the ansible_* facts. This documentation page covers the directives (variables that modify Ansible's behavior), which I was looking for when I came across this page.
This includes some common and some specific use-case directives:
become: Controls privilege escalation (sudo)
delegate_to: run task on another host (like running on localhost)
serial: allows you to run a play across a specific number/percentage of hosts before moving onto next set
https://github.com/f500/ansible-dumpall
FYI: this github project shows you how to list 90% of variables across all hosts. I find it more globally useful than single host commands. The README includes instructions for building a simple inventory report. It's even more valuable to run this at the end of a playbook to see all the Facts. To also debug Task behaviour use register:
The result is missing a few items:
- included YAML file variables
- extra-vars
- a number of the Ansible internal vars described here: Ansible Behavioural Params

Resources