cloudflared 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a70d9d3f9d8e49c536fb019c0bc5052e4cc900d65cd1a5f616a44a56d7c0636f
4
+ data.tar.gz: e9351f030dc93db44391dd0685c3580a9269a0af63912da46a4051a710df945e
5
+ SHA512:
6
+ metadata.gz: 8e9d5fe29cdae2bb50acd520a58a7357bcf5b57075524a3034869cbe92424eeca0994c99680f10c275818dcda9d7b40a1d26abdb66ce612e9a4b9660a353547a
7
+ data.tar.gz: d15e523393ce50cc5e6395e34ac8b4b06c22301268f0dcd0c9b497e79f84ed8cd22463a6f3d6cf29966dba3de66d0d936061cc1416f5b487d363cb230f03bbd2
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.1.0
data/.yardopts ADDED
@@ -0,0 +1,12 @@
1
+ --no-private
2
+ --exclude test
3
+ --exclude .github
4
+ --exclude coverage
5
+ --exclude doc
6
+ --exclude script
7
+ --markup markdown
8
+ --readme README.md
9
+
10
+ lib/**/*.rb
11
+ -
12
+ CHANGELOG.md
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Cloudflared Changes
2
+
3
+ ## [0.1.0] - 2022-01-29
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at devynbit@users.noreply.github.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in cloudflared.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "minitest", "~> 5.0"
11
+
12
+ gem "yard-junk"
13
+
14
+ gem "standard", "~> 1.7"
data/Gemfile.lock ADDED
@@ -0,0 +1,69 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cloudflared (0.1.3)
5
+ faraday (~> 2.1.0)
6
+ faraday-multipart (~> 1.0, >= 1.0.3)
7
+ marcel (~> 1.0, >= 1.0.2)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ ast (2.4.2)
13
+ backports (3.23.0)
14
+ faraday (2.1.0)
15
+ faraday-net_http (~> 2.0)
16
+ ruby2_keywords (>= 0.0.4)
17
+ faraday-multipart (1.0.3)
18
+ multipart-post (>= 1.2, < 3)
19
+ faraday-net_http (2.0.1)
20
+ marcel (1.0.2)
21
+ minitest (5.15.0)
22
+ multipart-post (2.1.1)
23
+ parallel (1.21.0)
24
+ parser (3.1.0.0)
25
+ ast (~> 2.4.1)
26
+ rainbow (3.1.1)
27
+ rake (13.0.6)
28
+ regexp_parser (2.2.0)
29
+ rexml (3.2.5)
30
+ rubocop (1.25.0)
31
+ parallel (~> 1.10)
32
+ parser (>= 3.1.0.0)
33
+ rainbow (>= 2.2.2, < 4.0)
34
+ regexp_parser (>= 1.8, < 3.0)
35
+ rexml
36
+ rubocop-ast (>= 1.15.1, < 2.0)
37
+ ruby-progressbar (~> 1.7)
38
+ unicode-display_width (>= 1.4.0, < 3.0)
39
+ rubocop-ast (1.15.1)
40
+ parser (>= 3.0.1.1)
41
+ rubocop-performance (1.13.2)
42
+ rubocop (>= 1.7.0, < 2.0)
43
+ rubocop-ast (>= 0.4.0)
44
+ ruby-progressbar (1.11.0)
45
+ ruby2_keywords (0.0.5)
46
+ standard (1.7.0)
47
+ rubocop (= 1.25.0)
48
+ rubocop-performance (= 1.13.2)
49
+ unicode-display_width (2.1.0)
50
+ webrick (1.7.0)
51
+ yard (0.9.27)
52
+ webrick (~> 1.7.0)
53
+ yard-junk (0.0.9)
54
+ backports (>= 3.18)
55
+ rainbow
56
+ yard
57
+
58
+ PLATFORMS
59
+ ruby
60
+
61
+ DEPENDENCIES
62
+ cloudflared!
63
+ minitest (~> 5.0)
64
+ rake (~> 13.0)
65
+ standard (~> 1.7)
66
+ yard-junk
67
+
68
+ BUNDLED WITH
69
+ 2.3.5
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 devynbit
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # Cloudflared
2
+
3
+ [![Build Status](https://github.com/devynbit/cloudflared/actions/workflows/main.yml/badge.svg)](https://github.com/devynbit/cloudflared/actions)
4
+ [![Gem Version](https://badge.fury.io/rb/cloudflared.svg)](https://badge.fury.io/rb/cloudflared)
5
+
6
+ This gem provides API access to the Cloudflare developer platform.
7
+
8
+ Current support: Cloudflare Images
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'cloudflared'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle install
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install cloudflared
25
+
26
+ ## Usage
27
+
28
+ Working with Cloudflare Images:
29
+
30
+ ```ruby
31
+ client = Cloudflared::Client.new(api_key: "foo", account_id: "bar", images_hash: "baz")
32
+ client.images.delete(file_id: "1234")
33
+ client.images.details(file_id: "1234")
34
+ client.images.direct_upload_url
35
+ client.images.download(file_id: "1234")
36
+ client.images.list
37
+ client.images.signed_url(file_id: "1234", key: "default_key", expiry_seconds: 60 * 15)
38
+ client.images.stats
39
+ client.images.update(file_id: "1234", requireSignedURLs: true)
40
+ client.images.upload(file: "/path/to/file", requireSignedURLs: true)
41
+ ```
42
+
43
+ ## Development
44
+
45
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
46
+
47
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
48
+
49
+ ## Contributing
50
+
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/devynbit/cloudflared. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/devynbit/cloudflared/blob/main/CODE_OF_CONDUCT.md).
52
+
53
+ ## License
54
+
55
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
56
+
57
+ ## Code of Conduct
58
+
59
+ Everyone interacting in the Cloudflared project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/devynbit/cloudflared/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ require "standard/rake"
13
+
14
+ task default: [:test, "standard:fix"]
data/bin/console ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "cloudflared"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ @client = Cloudflared::Client.new(account_id: ENV["CLOUDFLARE_IMAGES_ACCOUNT_ID"], api_key: ENV["CLOUDFLARE_IMAGES_API_KEY"])
15
+
16
+ require "irb"
17
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,53 @@
1
+ require "faraday"
2
+
3
+ module Cloudflared
4
+ class Client
5
+ BASE_URL = "https://api.cloudflare.com/client/v4/accounts"
6
+
7
+ attr_reader :api_key, :account_id, :adapter, :images_hash
8
+
9
+ # Initializes a new Cloudflare client.
10
+ #
11
+ # @!attribute api_key
12
+ # @return [String] The Cloudflare api key to use
13
+ #
14
+ # @!attribute account_id
15
+ # @return [String] The Cloudflare account id to use
16
+ #
17
+ # @!attribute images_hash
18
+ # @return [String] The Cloudflare images hash found on the images dashboard. This is used for image delivery urls.
19
+ #
20
+ # @!attribute adapter
21
+ # @return [Symbol] The Faraday adapter to use
22
+ #
23
+ # @!attribute stubs
24
+ # @return [Symbol] Stubs for use in testing
25
+ #
26
+ # @return [Cloudflared]
27
+ def initialize(api_key:, account_id:, images_hash: nil, adapter: Faraday.default_adapter, stubs: nil)
28
+ @api_key = api_key
29
+ @adapter = adapter
30
+ @account_id = account_id
31
+ @images_hash = images_hash
32
+ @stubs = stubs
33
+ end
34
+
35
+ # Accesses the Cloudflare Images developer platform
36
+ def images
37
+ ImagesResource.new(self)
38
+ end
39
+
40
+ # Creates a new connection with the given request type.
41
+ #
42
+ # @!attribute request_type
43
+ # @return [JSON] The request type to use (e.g. application/json)
44
+ def connection(request_type: :json)
45
+ @connection ||= Faraday.new do |conn|
46
+ conn.url_prefix = "#{BASE_URL}/#{@account_id}"
47
+ conn.request request_type
48
+ conn.response :json, content_type: "application/json"
49
+ conn.adapter @stubs.nil? ? adapter : :test, @stubs
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,32 @@
1
+ module Cloudflared
2
+ class Collection
3
+ include Enumerable
4
+
5
+ MAX_PER_PAGE = 100
6
+
7
+ attr_reader :data, :success, :errors, :page, :per_page
8
+
9
+ def self.from_response(response, key:, type:)
10
+ body = response.body["result"]
11
+ new(
12
+ data: body[key].map { |attrs| type.new(attrs) },
13
+ success: body["success"],
14
+ errors: body["errors"],
15
+ messages: body["messages"]
16
+ )
17
+ end
18
+
19
+ def initialize(data:, success:, errors:, messages:, page: 1, per_page: 50)
20
+ @data = data
21
+ @success = success
22
+ @errors = errors
23
+ @messages = messages
24
+ @page = page
25
+ @per_page = per_page
26
+ end
27
+
28
+ def each(&block)
29
+ @data.each(&block)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module Cloudflared
2
+ class Error < StandardError; end
3
+ end
@@ -0,0 +1,19 @@
1
+ require "ostruct"
2
+
3
+ module Cloudflared
4
+ class Object < OpenStruct
5
+ def initialize(attributes)
6
+ super to_ostruct(attributes)
7
+ end
8
+
9
+ def to_ostruct(obj)
10
+ if obj.is_a?(Hash)
11
+ OpenStruct.new(obj.map { |key, val| [key, to_ostruct(val)] }.to_h)
12
+ elsif obj.is_a?(Array)
13
+ obj.map { |o| to_ostruct(o) }
14
+ else # Assumed to be a primitive value
15
+ obj
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,11 @@
1
+ module Cloudflared
2
+ class Image < Object
3
+ def inspect
4
+ "Image id=#{id}, filename=#{filename}"
5
+ end
6
+
7
+ def <=>(other)
8
+ id <=> other.id
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,74 @@
1
+ require "faraday"
2
+ require "marcel"
3
+ require "faraday/multipart"
4
+
5
+ module Cloudflared
6
+ class Resource
7
+ attr_reader :client
8
+ def initialize(client)
9
+ @client = client
10
+ end
11
+
12
+ def get_request(url, params: {}, headers: {})
13
+ handle_response client.connection.get(url, params, default_headers.merge(headers))
14
+ end
15
+
16
+ def post_request(url, body:, headers: {})
17
+ handle_response client.connection.post(url, body, default_headers.merge(headers))
18
+ end
19
+
20
+ def upload_request(url, file:, params: {}, headers: {})
21
+ params[:file] = Faraday::Multipart::FilePart.new(
22
+ file,
23
+ Marcel::MimeType.for(Pathname.new(file))
24
+ )
25
+
26
+ handle_response client.connection(request_type: :multipart).post(url, params, default_headers.merge(headers))
27
+ end
28
+
29
+ def put_request(url, body:, headers: {})
30
+ handle_response client.connection.put(url, body, default_headers.merge(headers))
31
+ end
32
+
33
+ def patch_request(url, body:, headers: {})
34
+ handle_response client.connection.patch(url, body, default_headers.merge(headers))
35
+ end
36
+
37
+ def delete_request(url, params: {}, headers: {})
38
+ handle_response client.connection.delete(url, params, default_headers.merge(headers))
39
+ end
40
+
41
+ def default_headers
42
+ {Authorization: "Bearer #{client.api_key}"}
43
+ end
44
+
45
+ def handle_response(response)
46
+ message = if response.body.is_a? Hash
47
+ response.body["errors"]&.map { |error| error["message"] }&.join(" ")
48
+ else
49
+ response.body.inspect
50
+ end
51
+
52
+ case response.status
53
+ when 400
54
+ raise Error, "Bad request, the request was invalid. #{message}"
55
+ when 401
56
+ raise Error, "Unauthorized, the user does not have permission. #{message}"
57
+ when 403
58
+ raise Error, "Forbidden, the request was not authenticated. #{message}"
59
+ when 404
60
+ raise Error, "Not found, the resource was not found. #{message}"
61
+ when 429
62
+ raise Error, "Too many requests, client is rate limited. #{message}"
63
+ when 405
64
+ raise Error, "Method not allowed, incorrect HTTP method provided. #{message}"
65
+ when 415
66
+ raise Error, "Unsupported media type, response is not valid JSON. #{message}"
67
+ when 500
68
+ raise Error, "Server error. #{message}"
69
+ else
70
+ response
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,65 @@
1
+ require "openssl"
2
+ require "pathname"
3
+
4
+ module Cloudflared
5
+ class ImagesResource < Resource
6
+ # ONE_DAY = 60 * 60 * 24
7
+ # ONE_HOUR = 60 * 60
8
+ # THIRTY_MINUTES = 60 * 30
9
+ FIFTEEN_MINUTES = 60 * 15
10
+ IMAGE_DELIVERY_URL = "https://imagedelivery.net"
11
+
12
+ def delete(file_id:, **params)
13
+ delete_request("images/v1/#{file_id}", params: params)
14
+ true
15
+ end
16
+
17
+ def details(file_id:, **params)
18
+ Image.new get_request("images/v1/#{file_id}", params: params).body.dig("result")
19
+ end
20
+
21
+ def direct_upload_url(**params)
22
+ post_request("images/v1/direct_upload", body: params).body.dig("result", "uploadURL")
23
+ end
24
+
25
+ def download(file_id:, **params)
26
+ get_request("images/v1/#{file_id}/blob", params: params).body
27
+ end
28
+
29
+ def list(**params)
30
+ Collection.from_response get_request("images/v1", params: params), key: "images", type: Image
31
+ end
32
+
33
+ def public_url(path)
34
+ "#{IMAGE_DELIVERY_URL}/#{@client.images_hash}/#{path}"
35
+ end
36
+
37
+ def signed_url(path, key:, expiry_seconds: FIFTEEN_MINUTES)
38
+ # The path uses the image + the file_id (and a variant if passed through)
39
+ path = path[1..] if path[0] == "/"
40
+ path = "#{@client.images_hash}/#{path}"
41
+
42
+ # Calculate the hexdigest with the leading slash
43
+ sig = OpenSSL::HMAC.hexdigest("SHA256", key, "/#{path}")
44
+
45
+ # Calculate the seconds since the epoch in the future
46
+ exp = Time.new.to_i + expiry_seconds
47
+
48
+ # Respond with the url
49
+ qry = path.include?("?") ? "&" : "?"
50
+ "#{IMAGE_DELIVERY_URL}/#{path}#{qry}sig=#{sig}&exp=#{exp}"
51
+ end
52
+
53
+ def stats(**params)
54
+ get_request("images/v1/stats", params: params).body.dig("result")
55
+ end
56
+
57
+ def update(file_id:, **params)
58
+ Image.new patch_request("images/v1/#{file_id}", body: params).body.dig("result")
59
+ end
60
+
61
+ def upload(file:, **params)
62
+ Image.new upload_request("images/v1", file: file, params: params).body.dig("result")
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cloudflared
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "cloudflared/version"
4
+
5
+ module Cloudflared
6
+ autoload :Client, "cloudflared/client"
7
+ autoload :Error, "cloudflared/error"
8
+ autoload :Collection, "cloudflared/collection"
9
+ autoload :Object, "cloudflared/object"
10
+ autoload :Resource, "cloudflared/resource"
11
+
12
+ autoload :Image, "cloudflared/objects/image"
13
+ autoload :ImagesResource, "cloudflared/resources/images"
14
+ end
@@ -0,0 +1,4 @@
1
+ module Cloudflared
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cloudflared
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - devynbit
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-01-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday-multipart
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 1.0.3
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '1.0'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 1.0.3
47
+ - !ruby/object:Gem::Dependency
48
+ name: marcel
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.0'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 1.0.2
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '1.0'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 1.0.2
67
+ description: An API wrapper that focuse on the Cloudflare developer APIs, such as
68
+ images, stream, pages, and workers.
69
+ email:
70
+ - devynbit@users.noreply.github.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - ".rubocop.yml"
76
+ - ".tool-versions"
77
+ - ".yardopts"
78
+ - CHANGELOG.md
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - Gemfile.lock
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/console
86
+ - bin/setup
87
+ - lib/cloudflared.rb
88
+ - lib/cloudflared/client.rb
89
+ - lib/cloudflared/collection.rb
90
+ - lib/cloudflared/error.rb
91
+ - lib/cloudflared/object.rb
92
+ - lib/cloudflared/objects/image.rb
93
+ - lib/cloudflared/resource.rb
94
+ - lib/cloudflared/resources/images.rb
95
+ - lib/cloudflared/version.rb
96
+ - sig/cloudflared.rbs
97
+ homepage: https://github.com/devynbit/cloudflared
98
+ licenses:
99
+ - MIT
100
+ metadata:
101
+ homepage_uri: https://github.com/devynbit/cloudflared
102
+ source_code_uri: https://github.com/devynbit/cloudflared.git
103
+ changelog_uri: https://github.com/devynbit/cloudflared/blob/main/CHANGELOG.md
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 2.6.0
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubygems_version: 3.3.3
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: API wrapper for the Cloudflare developer platform
123
+ test_files: []