How can i get the logs of git using github API - command

I referred to many documents to get the logs of GitHub using GitHub API. But I couldn't find the way. I want to get the logs of GitHub events(commit, changes, etc..) and send them to cloudwatch. How can I achieve this? Or any other way to get the log without using authentication?
For example, I need a command like this so that I can get the logs without touching GitHub
curl -i -H "Authorization: token <PAT token>." \
https://api.github.com/user/repos
or any program to get the logs is welcome
or Any rest API to get the GitHub logs
I am not familiar with GitHub. can anyone give me a solution or idea?
below I mentioned the links that I have followed. Anyone can refer and if possible modify any command or API call to get the logs it would be great.
https://www.softwaretestinghelp.com/github-rest-api-tutorial/
https://dev.to/gr2m/github-api-authentication-personal-access-tokens-53kd
https://titanwolf.org/Network/Articles/Article?AID=f441bab7-8fc8-45ae-b12b-4c41efbbe2d1

Related

How to get repos from a specific team using GitHub API?

I have a script to download all the repos in my Organization, and it works fine.
We have recently added Teams, and I would like to target a specific team to download all the repos in that team.
To get for the whole org I can do this: (changing the page number to walk them)
Works:
https://api.github.com/orgs/MY_ORG/repos?access_token=MY_TOKEN&per_page=100&page=1
How do I do it for a team in the Org? I've tried:
Does not work
https://api.github.com/orgs/MY_ORG/teams/TEAM_SLUG/repos?access_token=MY_TOKEN
As well as a few others, none of which works.
By looking at the API Documentation it seems like what I'm trying should work. I can't even get the list of teams which the docs have as:
GET /orgs/:org/teams/:team_slug
So if I do:
https://api.github.com/orgs/MY_ORG/teams/TEAM_SLUG?access_token=MY_TOKEN
I just get back a Not Found, error with a link to the docs.
Anyone have success in doing this?
You are not trying correct API to get the Repos in a team
try
GET /teams/:team_id/repos
To get the team ID you can list all your Organisation teams as follows:
GET https://api.github.com/orgs/<ORGANISATION>/teams
If you are self hosting your GitHub Enterprise then replace https://api.github.com with https://<HOSTNAME>/api/v3/
Send personal access token as:
Authorization: token <PERSONALACCESSTOKEN>
Using Curl:
To get team Repos:
curl -H "Authorization: token <PERSONALACCESSTOKEN>" -X GET https://api.github.com/teams/:team_id/repos
To get the team ID :
curl -H "Authorization: token PERSONALACCESSTOKEN" -X GET https://api.github.com/orgs/<ORGANISATION>/teams
Further reading:
API Authentication: https://developer.github.com/v3/#authentication
Listing teams: https://developer.github.com/v3/teams/#list-team-repos

Unable to launch a single user using REST api

I am using JuPyter hub on K8s. I went through the documentation and had a look at the APIs. Now, I want to use one to start a pod. However, I am unable to start one using this post.
What would be the curl request for this POST request?
I have tried with the given command and it does not work:
curl -XPOST http://some_ip.ap-south-1.elb.amazonaws.com/users/adwait/server
405 : Method Not Allowed

How to successfully pull data from Veracode through REST API?

I'm trying to pull data from veracode(json or xml). I tried to use curl to connect to the api but i keep getting the error:"Failed to connect to analysiscenter.veracode.com port 443:Timed out".
curl --compressed -u USERNAME:PASSWORD https://analysiscenter.veracode.com/api/5.0/getapplist.do -F "include_user_info=true"
According to veracode documentation, to connect to the API, one needs to have Reviewer or Security Lead role.I have both Reviewer and Submitter role.The curl command should return some data like this:
xsi:schemaLocation="https://analysiscenter.veracode.com/schema/2.0/applist https://analysiscenter.veracode.com/resource/2.0/applist.xsd" >applist_version="1.2" account_id="123">Code" policy_updated_date="2013-11-11T14:37:34-05:00"/>
create_application_profile="true" create_sandbox="true" >create_new_build="true" assign_app_to_team="true" >assign_app_to_any_team="true" view_sandbox="true" view_results="true" >approve_mitigations="true" submit_static_scan="true"/>
this looks like a network issue, based on the error that you pasted. Can you ping the URL?
CURL also needs some configuration to use SSL. See this answer for some tips:
Configuring cURL for SSL

Get pull requests for private github repository via API

I want to programmatically get a list of open pull requests for a specific private github repository - ours, as it turns out. I assume I can only do this via the github api (http://developer.github.com/) - feel free to tell me there's another way - but I can't figure out whether the API allows this, either. The given API calls seem to assume the target repository is public, which ours is not. I would have thought there would be a way to authenticate as a user of the given repository via ssh key (the same way committing works), but I don't see anything to that effect. All in all I'm puzzled and not at all sure I can actually do this. Am I missing a crucial part of the documentation, or is there possibly some alternative I can leverage?
Yes, the GitHub Pull Requests API supports private repos also. You just need to authenticate or you will get an error saying that the repository does not exist.
Example using curl and basic authentication:
curl -u "username" https://api.github.com/repos/:user/:repo/pulls
This will then prompt you for your password and return a list of pull requests as described in the API docs.
Also check out the docs on authentication: http://developer.github.com/v3/#authentication

Github v3 API - create a REPO

I’m trying to use the Github v3 API - I already implemented the required OAuth flow and it works well.
Now I’m trying some of the Repos API endpoints (http://developer.github.com/v3/repos/).
So far, I’m able to get a List of my repos using: GET /user/repos
However, when I try to create a repo using POST /user/repos, I get a 404.
Any thoughts what I might be doing wrong?
Joubert
Can you please tell us how exactly you did the HTTP request? The 404 sounds like you were using a wrong path, probably. But to give a reliable answer instead a wild guess, we need to see your request, including how you are sending your token, just mask it with 'xxx' or something.
I'll show you in the meantime an example request, that is working:
curl -XPOST -H 'Authorization: token S3CR3T' https://api.github.com/user/repos -d '{"name":"my-new-repo","description":"my new repo description"}'
You would need to replace the OAuth token of course: S3CR3T
I had the same issue. The reason why you are getting a 404 with your oauth access token is that when you authorize to github you need to also additionally pass the scopes you want. For example, in the header you should see "X-OAuth-Scopes: repo, user", which means this user has read/write access to his profile and repositories. Once you have set the correct scopes you should be able to do POST/PUT requests just fine.
To see whether or not you have the correct permissions. You can do something like the following. Substitute the XXXXXXX with your access token.
curl -I https://api.github.com/user?access_token=XXXXXXXX
For creating repositories as a user you can use an personal access token and basic auth, which can be much simpler when you are fluffing around on the command line and have 2FA enabled.
curl -d '{"name":"test"}' -u githubuser:personaccesstoken https://api.github.com/user/repos
Create a personal access token here https://github.com/settings/tokens and make sure it has the 'repo' scope.
This script lets you read in in the token and project name as variables so you can use it in a script
#!/usr/bin/env bash -u
#
TOKEN=`cat token_file`
PROJECT=myproject
curl -X POST -H 'Content-Type: application/x-www-form-urlencoded' -d '{"name": "'"$PROJECT"'"}' https://api.github.com/user/repos?access_token=$TOKEN