trav3 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/trav3.rb +208 -2
- data/lib/trav3/rest.rb +1 -0
- data/lib/trav3/rest/create.rb +29 -0
- data/lib/trav3/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f0e2d396b8b3a4e5aa159cf69661b88b2d3919bb7e9aceac6658251592e69f02
|
|
4
|
+
data.tar.gz: e3956e9b90b658689b21026d4e69c1198eb2ad10d15f9376bef4c16bb95eae6f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 111a2df7f87c5748c86d319231f6b0a09c0dd47507ecabcb20844fb8b4335cc2841377e52d01f82305e3111329dc81470b8bfee126289df068ccb174d2483390
|
|
7
|
+
data.tar.gz: 2dda90b5419e0f1761344ba6ce1d365e2af5565ca8e9095cd123d6c2d1eb9f17f706b1f10d4b8ef22599fa6a2a982a7949937185f761c52afebf679b960cf3d9
|
data/lib/trav3.rb
CHANGED
|
@@ -624,6 +624,7 @@ module Trav3
|
|
|
624
624
|
# ```
|
|
625
625
|
#
|
|
626
626
|
# DELETE <code>/repo/{repository.id}/caches</code>
|
|
627
|
+
#
|
|
627
628
|
# Template Variable Type Description
|
|
628
629
|
# repository.id Integer Value uniquely identifying the repository.
|
|
629
630
|
#
|
|
@@ -1164,7 +1165,8 @@ module Trav3
|
|
|
1164
1165
|
#
|
|
1165
1166
|
# **Sortable by:** <code>id</code>, <code>github_id</code>, <code>owner_name</code>, <code>name</code>, <code>active</code>, <code>default_branch.last_build</code>, append <code>:desc</code> to any attribute to reverse order.
|
|
1166
1167
|
#
|
|
1167
|
-
# **For Current User
|
|
1168
|
+
# **For Current User**
|
|
1169
|
+
#
|
|
1168
1170
|
# This returns a list of repositories the current user has access to.
|
|
1169
1171
|
#
|
|
1170
1172
|
# GET <code>/repos</code>
|
|
@@ -1333,7 +1335,7 @@ module Trav3
|
|
|
1333
1335
|
validate_repo_format repo
|
|
1334
1336
|
|
|
1335
1337
|
repo = sanitize_repo_name repo
|
|
1336
|
-
action = '' unless %w[star unstar activate
|
|
1338
|
+
action = '' unless %w[star unstar activate deactivate].include? action.to_s
|
|
1337
1339
|
|
|
1338
1340
|
if action.empty?
|
|
1339
1341
|
get("#{without_repo}/repo/#{repo}")
|
|
@@ -1342,6 +1344,206 @@ module Trav3
|
|
|
1342
1344
|
end
|
|
1343
1345
|
end
|
|
1344
1346
|
|
|
1347
|
+
# An individual request
|
|
1348
|
+
#
|
|
1349
|
+
# ## Attributes
|
|
1350
|
+
#
|
|
1351
|
+
# **Minimal Representation**
|
|
1352
|
+
#
|
|
1353
|
+
# Included when the resource is returned as part of another resource.
|
|
1354
|
+
#
|
|
1355
|
+
# Name Type Description
|
|
1356
|
+
# id Integer Value uniquely identifying the request.
|
|
1357
|
+
# state String The state of a request (eg. whether it has been processed or not).
|
|
1358
|
+
# result String The result of the request (eg. rejected or approved).
|
|
1359
|
+
# message String Travis-ci status message attached to the request.
|
|
1360
|
+
#
|
|
1361
|
+
# **Standard Representation**
|
|
1362
|
+
#
|
|
1363
|
+
# Included when the resource is the main response of a request, or is {https://developer.travis-ci.com/eager-loading eager loaded}.
|
|
1364
|
+
#
|
|
1365
|
+
# Name Type Description
|
|
1366
|
+
# id Integer Value uniquely identifying the request.
|
|
1367
|
+
# state String The state of a request (eg. whether it has been processed or not).
|
|
1368
|
+
# result String The result of the request (eg. rejected or approved).
|
|
1369
|
+
# message String Travis-ci status message attached to the request.
|
|
1370
|
+
# repository Repository GitHub user or organization the request belongs to.
|
|
1371
|
+
# branch_name String Name of the branch requested to be built.
|
|
1372
|
+
# commit Commit The commit the request is associated with.
|
|
1373
|
+
# builds [Build] The request's builds.
|
|
1374
|
+
# owner Owner GitHub user or organization the request belongs to.
|
|
1375
|
+
# created_at String When Travis CI created the request.
|
|
1376
|
+
# event_type String Origin of request (push, pull request, api).
|
|
1377
|
+
# base_commit String The base commit the request is associated with.
|
|
1378
|
+
# head_commit String The head commit the request is associated with.
|
|
1379
|
+
#
|
|
1380
|
+
# ## Actions
|
|
1381
|
+
#
|
|
1382
|
+
# **Find**
|
|
1383
|
+
#
|
|
1384
|
+
# Document `resources/request/actions/find` not found.
|
|
1385
|
+
#
|
|
1386
|
+
# GET <code>/repo/{repository.id}/request/{request.id}</code>
|
|
1387
|
+
#
|
|
1388
|
+
# Template Variable Type Description
|
|
1389
|
+
# repository.id Integer Value uniquely identifying the repository.
|
|
1390
|
+
# request.id Integer Value uniquely identifying the request.
|
|
1391
|
+
# Query Parameter Type Description
|
|
1392
|
+
# include [String] List of attributes to eager load.
|
|
1393
|
+
#
|
|
1394
|
+
# GET <code>/repo/{repository.slug}/request/{request.id}</code>
|
|
1395
|
+
#
|
|
1396
|
+
# Template Variable Type Description
|
|
1397
|
+
# repository.slug String Same as {repository.owner.name}/{repository.name}.
|
|
1398
|
+
# request.id Integer Value uniquely identifying the request.
|
|
1399
|
+
# Query Parameter Type Description
|
|
1400
|
+
# include [String] List of attributes to eager load.
|
|
1401
|
+
#
|
|
1402
|
+
# @param request_id [String, Integer] request id
|
|
1403
|
+
# @return [Success, RequestError]
|
|
1404
|
+
def request(request_id)
|
|
1405
|
+
validate_number request_id
|
|
1406
|
+
|
|
1407
|
+
get("#{with_repo}/request/#{request_id}")
|
|
1408
|
+
end
|
|
1409
|
+
|
|
1410
|
+
# A list of requests.
|
|
1411
|
+
#
|
|
1412
|
+
# If querying using the repository slug, it must be formatted using {http://www.w3schools.com/tags/ref_urlencode.asp standard URL encoding}, including any special characters.
|
|
1413
|
+
#
|
|
1414
|
+
# ## Attributes
|
|
1415
|
+
#
|
|
1416
|
+
# Name Type Description
|
|
1417
|
+
# requests [Request] List of requests.
|
|
1418
|
+
#
|
|
1419
|
+
# **Collection Items**
|
|
1420
|
+
#
|
|
1421
|
+
# Each entry in the **requests** array has the following attributes:
|
|
1422
|
+
#
|
|
1423
|
+
# Name Type Description
|
|
1424
|
+
# id Integer Value uniquely identifying the request.
|
|
1425
|
+
# state String The state of a request (eg. whether it has been processed or not).
|
|
1426
|
+
# result String The result of the request (eg. rejected or approved).
|
|
1427
|
+
# message String Travis-ci status message attached to the request.
|
|
1428
|
+
# repository Repository GitHub user or organization the request belongs to.
|
|
1429
|
+
# branch_name String Name of the branch requested to be built.
|
|
1430
|
+
# commit Commit The commit the request is associated with.
|
|
1431
|
+
# builds [Build] The request's builds.
|
|
1432
|
+
# owner Owner GitHub user or organization the request belongs to.
|
|
1433
|
+
# created_at String When Travis CI created the request.
|
|
1434
|
+
# event_type String Origin of request (push, pull request, api).
|
|
1435
|
+
# base_commit String The base commit the request is associated with.
|
|
1436
|
+
# head_commit String The head commit the request is associated with.
|
|
1437
|
+
# yaml_config Unknown The request's yaml_config.
|
|
1438
|
+
#
|
|
1439
|
+
# ## Actions
|
|
1440
|
+
#
|
|
1441
|
+
# **Find**
|
|
1442
|
+
#
|
|
1443
|
+
# This will return a list of requests belonging to a repository.
|
|
1444
|
+
#
|
|
1445
|
+
# GET <code>/repo/{repository.id}/requests</code>
|
|
1446
|
+
#
|
|
1447
|
+
# Template Variable Type Description
|
|
1448
|
+
# repository.id Integer Value uniquely identifying the repository.
|
|
1449
|
+
# Query Parameter Type Description
|
|
1450
|
+
# include [String] List of attributes to eager load.
|
|
1451
|
+
# limit Integer How many requests to include in the response. Used for pagination.
|
|
1452
|
+
# offset Integer How many requests to skip before the first entry in the response. Used for pagination.
|
|
1453
|
+
#
|
|
1454
|
+
# Example: GET /repo/891/requests?limit=5
|
|
1455
|
+
#
|
|
1456
|
+
# GET <code>/repo/{repository.slug}/requests</code>
|
|
1457
|
+
#
|
|
1458
|
+
# Template Variable Type Description
|
|
1459
|
+
# repository.slug String Same as {repository.owner.name}/{repository.name}.
|
|
1460
|
+
# Query Parameter Type Description
|
|
1461
|
+
# include [String] List of attributes to eager load.
|
|
1462
|
+
# limit Integer How many requests to include in the response. Used for pagination.
|
|
1463
|
+
# offset Integer How many requests to skip before the first entry in the response. Used for pagination.
|
|
1464
|
+
#
|
|
1465
|
+
# Example: GET /repo/rails%2Frails/requests?limit=5
|
|
1466
|
+
#
|
|
1467
|
+
# **Create**
|
|
1468
|
+
#
|
|
1469
|
+
# This will create a request for an individual repository, triggering a build to run on Travis CI.
|
|
1470
|
+
#
|
|
1471
|
+
# Use namespaced params in JSON format in the request body to pass any accepted parameters. Any keys in the request's config will override keys existing in the `.travis.yml`.
|
|
1472
|
+
#
|
|
1473
|
+
# ```bash
|
|
1474
|
+
# curl -X POST \
|
|
1475
|
+
# -H "Content-Type: application/json" \
|
|
1476
|
+
# -H "Travis-API-Version: 3" \
|
|
1477
|
+
# -H "Authorization: token xxxxxxxxxxxx" \
|
|
1478
|
+
# -d '{ "request": {
|
|
1479
|
+
# "message": "Override the commit message: this is an api request", "branch": "master" }}'\
|
|
1480
|
+
# https://api.travis-ci.com/repo/1/requests
|
|
1481
|
+
# ```
|
|
1482
|
+
#
|
|
1483
|
+
# The response includes the following body:
|
|
1484
|
+
#
|
|
1485
|
+
# ```json
|
|
1486
|
+
# {
|
|
1487
|
+
# "@type": "pending",
|
|
1488
|
+
# "remaining_requests": 1,
|
|
1489
|
+
# "repository": {
|
|
1490
|
+
# "@type": "repository",
|
|
1491
|
+
# "@href": "/repo/1",
|
|
1492
|
+
# "@representation": "minimal",
|
|
1493
|
+
# "id": 1,
|
|
1494
|
+
# "name": "test",
|
|
1495
|
+
# "slug": "owner/repo"
|
|
1496
|
+
# },
|
|
1497
|
+
# "request": {
|
|
1498
|
+
# "repository": {
|
|
1499
|
+
# "id": 1,
|
|
1500
|
+
# "owner_name": "owner",
|
|
1501
|
+
# "name": "repo"
|
|
1502
|
+
# },
|
|
1503
|
+
# "user": {
|
|
1504
|
+
# "id": 1
|
|
1505
|
+
# },
|
|
1506
|
+
# "id": 1,
|
|
1507
|
+
# "message": "Override the commit message: this is an api request",
|
|
1508
|
+
# "branch": "master",
|
|
1509
|
+
# "config": { }
|
|
1510
|
+
# },
|
|
1511
|
+
# "resource_type": "request"
|
|
1512
|
+
# }
|
|
1513
|
+
# ```
|
|
1514
|
+
#
|
|
1515
|
+
# POST <code>/repo/{repository.id}/requests</code>
|
|
1516
|
+
#
|
|
1517
|
+
# Template Variable Type Description
|
|
1518
|
+
# repository.id Integer Value uniquely identifying the repository.
|
|
1519
|
+
# Accepted Parameter Type Description
|
|
1520
|
+
# request.config String Build configuration (as parsed from .travis.yml).
|
|
1521
|
+
# request.message String Travis-ci status message attached to the request.
|
|
1522
|
+
# request.branch String Branch requested to be built.
|
|
1523
|
+
# request.token Object Travis token associated with webhook on GitHub (DEPRECATED).
|
|
1524
|
+
#
|
|
1525
|
+
# Example: POST /repo/891/requests
|
|
1526
|
+
#
|
|
1527
|
+
# POST <code>/repo/{repository.slug}/requests</code>
|
|
1528
|
+
#
|
|
1529
|
+
# Template Variable Type Description
|
|
1530
|
+
# repository.slug String Same as {repository.owner.name}/{repository.name}.
|
|
1531
|
+
# Accepted Parameter Type Description
|
|
1532
|
+
# request.config String Build configuration (as parsed from .travis.yml).
|
|
1533
|
+
# request.message String Travis-ci status message attached to the request.
|
|
1534
|
+
# request.branch String Branch requested to be built.
|
|
1535
|
+
# request.token Object Travis token associated with webhook on GitHub (DEPRECATED).
|
|
1536
|
+
#
|
|
1537
|
+
# Example: POST /repo/rails%2Frails/requests
|
|
1538
|
+
#
|
|
1539
|
+
# @param attributes [Hash] request attributes
|
|
1540
|
+
# @return [Success, RequestError]
|
|
1541
|
+
def requests(**attributes)
|
|
1542
|
+
return get("#{with_repo}/requests") if attributes.empty?
|
|
1543
|
+
|
|
1544
|
+
create("#{with_repo}/requests", 'request': attributes)
|
|
1545
|
+
end
|
|
1546
|
+
|
|
1345
1547
|
# A list of stages.
|
|
1346
1548
|
#
|
|
1347
1549
|
# Currently this is nested within a build.
|
|
@@ -1624,6 +1826,10 @@ module Trav3
|
|
|
1624
1826
|
|
|
1625
1827
|
private # @private
|
|
1626
1828
|
|
|
1829
|
+
def create(url, **data)
|
|
1830
|
+
Trav3::REST.create(self, url, **data)
|
|
1831
|
+
end
|
|
1832
|
+
|
|
1627
1833
|
def delete(url)
|
|
1628
1834
|
Trav3::REST.delete(self, url)
|
|
1629
1835
|
end
|
data/lib/trav3/rest.rb
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# rubocop:disable Metrics/MethodLength
|
|
4
|
+
require 'net/http'
|
|
5
|
+
require 'uri'
|
|
6
|
+
require 'json'
|
|
7
|
+
|
|
8
|
+
module Trav3
|
|
9
|
+
module REST
|
|
10
|
+
def self.create(travis, url, **data)
|
|
11
|
+
uri = URI( url.sub(/\?.*$/, '') )
|
|
12
|
+
req = Net::HTTP::Post.new(uri.request_uri)
|
|
13
|
+
travis.headers.each_pair do |header, value|
|
|
14
|
+
req[header] = value
|
|
15
|
+
end
|
|
16
|
+
req.body = JSON.generate(data) unless data.empty?
|
|
17
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
18
|
+
http.use_ssl = (uri.scheme == 'https')
|
|
19
|
+
response = http.request(req)
|
|
20
|
+
|
|
21
|
+
if [Net::HTTPAccepted, Net::HTTPOK].include? response.code_type
|
|
22
|
+
Success.new(travis, response)
|
|
23
|
+
else
|
|
24
|
+
RequestError.new(travis, response)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
# rubocop:enable Metrics/MethodLength
|
data/lib/trav3/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: trav3
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel P. Clark
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-01-
|
|
11
|
+
date: 2019-01-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -90,6 +90,7 @@ files:
|
|
|
90
90
|
- lib/trav3/options.rb
|
|
91
91
|
- lib/trav3/pagination.rb
|
|
92
92
|
- lib/trav3/rest.rb
|
|
93
|
+
- lib/trav3/rest/create.rb
|
|
93
94
|
- lib/trav3/rest/delete.rb
|
|
94
95
|
- lib/trav3/rest/get.rb
|
|
95
96
|
- lib/trav3/rest/patch.rb
|