Skip to content

Commit 6f026cd

Browse files
committed
user info endpoint
1 parent bdba4ce commit 6f026cd

File tree

8 files changed

+66
-5
lines changed

8 files changed

+66
-5
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export(xforce_malware_for_hash)
88
export(xforce_resolve)
99
export(xforce_url_malware)
1010
export(xforce_url_report)
11+
export(xforce_user_profile)
1112
export(xforce_whois)
1213
import(httr)
1314
importFrom(jsonlite,fromJSON)

R/ip-history.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' Get IP History
1+
#' Get IP History/Reputation
22
#'
33
#' @md
44
#' @param ip IP address

R/malware-hash.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#' [on the IBM X-Force Portal](api_key=Sys.getenv("XFORCE_API_KEY")).
1010
#' @export
1111
#' @examples \donrun{
12-
#' xforce_ip_history("174.62.167.97")
12+
#' xforce_malware_for_hash("474B9CCF5AB9D72CA8A333889BBB34F0")
1313
#' }
1414
xforce_malware_for_hash <- function(hash, api_key=Sys.getenv("XFORCE_API_KEY"),
1515
api_password=Sys.getenv("XFORCE_API_PASSWORD")) {

R/user-profile.R

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#' Get User Profile
2+
#'
3+
#' @md
4+
#' @param api_key,api_password IBM X-Force API Key & Password. All `xforce`
5+
#' API functions will look for these in the `XFORCE_API_KEY` and
6+
#' `XFORCE_API_PASSWORD` environment variables. You can store these
7+
#' in `~/.Renviron` and you can obtain them
8+
#' [on the IBM X-Force Portal](api_key=Sys.getenv("XFORCE_API_KEY")).
9+
#' @export
10+
#' @examples \donrun{
11+
#' xforce_user_profile()
12+
#' }
13+
xforce_user_profile <- function(api_key=Sys.getenv("XFORCE_API_KEY"),
14+
api_password=Sys.getenv("XFORCE_API_PASSWORD")) {
15+
16+
httr::GET(
17+
url = "https://api.xforce.ibmcloud.com/user/profile",
18+
httr::accept_json(),
19+
httr::user_agent("R xforce package (https://github.com/hrbrmstr/xforce"),
20+
httr::authenticate(
21+
user = api_key,
22+
password = api_password
23+
)
24+
) -> res
25+
26+
httr::stop_for_status(res)
27+
28+
out <- httr::content(res, as = "text")
29+
30+
out <- jsonlite::fromJSON(out)
31+
32+
out
33+
34+
}

README.Rmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ All `xforce` API functions will look for these in the `XFORCE_API_KEY` and
1818
The following functions are implemented:
1919

2020
- `xforce_as_networks`: Get Networks Assigned to an Autonomous System Number
21-
- `xforce_ip_history`: Get IP History
21+
- `xforce_ip_history`: Get IP History/Reputation
2222
- `xforce_ip_malware`: Get Malware Associated with the IP
2323
- `xforce_ip_report`: Get IP Report
2424
- `xforce_malware_for_hash`: Get Malware for File Hash
2525
- `xforce_resolve`: Get DNS Records
2626
- `xforce_url_malware`: Get Malware for URL
2727
- `xforce_url_report`: Get URL Report
28+
- `xforce_user_profile`: Get User Profile
2829
- `xforce_whois`: Get WHOIS Information for a Host
2930

3031
## TODO

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ The following functions are implemented:
2121

2222
- `xforce_as_networks`: Get Networks Assigned to an Autonomous System
2323
Number
24-
- `xforce_ip_history`: Get IP History
24+
- `xforce_ip_history`: Get IP History/Reputation
2525
- `xforce_ip_malware`: Get Malware Associated with the IP
2626
- `xforce_ip_report`: Get IP Report
2727
- `xforce_malware_for_hash`: Get Malware for File Hash
2828
- `xforce_resolve`: Get DNS Records
2929
- `xforce_url_malware`: Get Malware for URL
3030
- `xforce_url_report`: Get URL Report
31+
- `xforce_user_profile`: Get User Profile
3132
- `xforce_whois`: Get WHOIS Information for a Host
3233

3334
## TODO

man/xforce_malware_for_hash.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/xforce_user_profile.Rd

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)