droplet_kit 2.2.2 → 2.3.0
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/CHANGELOG.md +3 -0
- data/README.md +3 -3
- data/lib/droplet_kit/mappings/certificate_mapping.rb +5 -0
- data/lib/droplet_kit/models/certificate.rb +3 -0
- data/lib/droplet_kit/version.rb +1 -1
- data/spec/fixtures/certificates/all.json +4 -1
- data/spec/fixtures/certificates/find.json +4 -1
- data/spec/fixtures/certificates/lets_encrypt.json +12 -0
- data/spec/lib/droplet_kit/resources/certificate_resource_spec.rb +31 -1
- metadata +5 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 2ecbe9de2e2f4c7fc8678c9c3e997208d79b3b8f
         | 
| 4 | 
            +
              data.tar.gz: 6a9e211e1303f9c226d3d039789308c047340bcd
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 3a762b334cf6b65390ad5551ebae8286499f82aa49e996e16772609046904261e2c52c1dbe2b9926f244cd88f694053cba74e1805ec007ceb83d250bd4e3c460
         | 
| 7 | 
            +
              data.tar.gz: d43a3564498375614861eb2416de54e3182879130efd71a7321ae04205f01e7e9e92a73088cb4a9d044149ee8ba0bd49b57c2e08292c6a0c751c673d18d16128
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -49,7 +49,7 @@ When you'd like to save objects, it's your responsibility to instantiate the obj | |
| 49 49 |  | 
| 50 50 | 
             
            ```ruby
         | 
| 51 51 | 
             
            client = DropletKit::Client.new(access_token: 'YOUR_TOKEN')
         | 
| 52 | 
            -
            droplet = DropletKit::Droplet.new(name: 'mysite.com', region: 'nyc2', image: 'ubuntu-14-04-x64', size: ' | 
| 52 | 
            +
            droplet = DropletKit::Droplet.new(name: 'mysite.com', region: 'nyc2', image: 'ubuntu-14-04-x64', size: 's-1vcpu-1gb')
         | 
| 53 53 | 
             
            created = client.droplets.create(droplet)
         | 
| 54 54 | 
             
            # => DropletKit::Droplet(id: 1231, name: 'something.com', ...)
         | 
| 55 55 | 
             
            ```
         | 
| @@ -134,7 +134,7 @@ Actions supported: | |
| 134 134 | 
             
            * `client.droplet_actions.rename(droplet_id: droplet.id, name: 'New-Droplet-Name')`
         | 
| 135 135 | 
             
            * `client.droplet_actions.rebuild(droplet_id: droplet.id, image: 'image_id')`
         | 
| 136 136 | 
             
            * `client.droplet_actions.restore(droplet_id: droplet.id, image: 'image_id')`
         | 
| 137 | 
            -
            * `client.droplet_actions.resize(droplet_id: droplet.id, size: '1gb')`
         | 
| 137 | 
            +
            * `client.droplet_actions.resize(droplet_id: droplet.id, size: 's-1vcpu-1gb')`
         | 
| 138 138 | 
             
            * `client.droplet_actions.find(droplet_id: droplet.id, id: action.id)`
         | 
| 139 139 | 
             
            * `client.droplet_actions.action_for_id(droplet_id: droplet.id, type: 'event_name', param: 'value')`
         | 
| 140 140 | 
             
            * `client.droplet_actions.action_for_tag(tag_name: 'tag_name', type: 'event_name', param: 'value')`
         | 
| @@ -312,7 +312,7 @@ When you want to create a droplet using your stored SSH key. | |
| 312 312 | 
             
            ```ruby
         | 
| 313 313 | 
             
            client = DropletKit::Client.new(access_token: 'YOUR_TOKEN')
         | 
| 314 314 | 
             
            my_ssh_keys = client.ssh_keys.all.collect {|key| key.fingerprint}
         | 
| 315 | 
            -
            droplet = DropletKit::Droplet.new(name: 'mysite.com', region: 'nyc2', image: 'ubuntu-14-04-x64', size: ' | 
| 315 | 
            +
            droplet = DropletKit::Droplet.new(name: 'mysite.com', region: 'nyc2', image: 'ubuntu-14-04-x64', size: 's-1vcpu-1gb', ssh_keys: my_ssh_keys)
         | 
| 316 316 | 
             
            created = client.droplets.create(droplet)
         | 
| 317 317 | 
             
            # => DropletKit::Droplet(id: 1231, name: 'something.com', ...)
         | 
| 318 318 | 
             
            ```
         | 
| @@ -9,16 +9,21 @@ module DropletKit | |
| 9 9 | 
             
                  scoped :read do
         | 
| 10 10 | 
             
                    property :id
         | 
| 11 11 | 
             
                    property :name
         | 
| 12 | 
            +
                    property :dns_names
         | 
| 12 13 | 
             
                    property :not_after
         | 
| 13 14 | 
             
                    property :sha1_fingerprint
         | 
| 14 15 | 
             
                    property :created_at
         | 
| 16 | 
            +
                    property :state
         | 
| 17 | 
            +
                    property :type
         | 
| 15 18 | 
             
                  end
         | 
| 16 19 |  | 
| 17 20 | 
             
                  scoped :create do
         | 
| 18 21 | 
             
                    property :name
         | 
| 22 | 
            +
                    property :dns_names
         | 
| 19 23 | 
             
                    property :private_key
         | 
| 20 24 | 
             
                    property :leaf_certificate
         | 
| 21 25 | 
             
                    property :certificate_chain
         | 
| 26 | 
            +
                    property :type
         | 
| 22 27 | 
             
                  end
         | 
| 23 28 | 
             
                end
         | 
| 24 29 | 
             
              end
         | 
| @@ -2,11 +2,14 @@ module DropletKit | |
| 2 2 | 
             
              class Certificate < BaseModel
         | 
| 3 3 | 
             
                attribute :id
         | 
| 4 4 | 
             
                attribute :name
         | 
| 5 | 
            +
                attribute :dns_names
         | 
| 5 6 | 
             
                attribute :not_after
         | 
| 6 7 | 
             
                attribute :sha1_fingerprint
         | 
| 7 8 | 
             
                attribute :created_at
         | 
| 8 9 | 
             
                attribute :private_key
         | 
| 9 10 | 
             
                attribute :leaf_certificate
         | 
| 10 11 | 
             
                attribute :certificate_chain
         | 
| 12 | 
            +
                attribute :type
         | 
| 13 | 
            +
                attribute :state
         | 
| 11 14 | 
             
              end
         | 
| 12 15 | 
             
            end
         | 
    
        data/lib/droplet_kit/version.rb
    CHANGED
    
    
| @@ -2,10 +2,13 @@ | |
| 2 2 | 
             
              "certificates": [
         | 
| 3 3 | 
             
                {
         | 
| 4 4 | 
             
                  "id": "892071a0-bb95-49bc-8021-3afd67a210bf",
         | 
| 5 | 
            +
                  "dns_names": [],
         | 
| 5 6 | 
             
                  "name": "web-cert-01",
         | 
| 6 7 | 
             
                  "not_after": "2017-02-22T00:23:00Z",
         | 
| 7 8 | 
             
                  "sha1_fingerprint": "dfcc9f57d86bf58e321c2c6c31c7a971be244ac7",
         | 
| 8 | 
            -
                  "created_at": "2017-02-08T16:02:37Z"
         | 
| 9 | 
            +
                  "created_at": "2017-02-08T16:02:37Z",
         | 
| 10 | 
            +
                  "state": "verified",
         | 
| 11 | 
            +
                  "type": "custom"
         | 
| 9 12 | 
             
                }
         | 
| 10 13 | 
             
              ],
         | 
| 11 14 | 
             
              "links": {
         | 
| @@ -1,9 +1,12 @@ | |
| 1 1 | 
             
            {
         | 
| 2 2 | 
             
              "certificate": {
         | 
| 3 3 | 
             
                "id": "892071a0-bb95-49bc-8021-3afd67a210bf",
         | 
| 4 | 
            +
                "dns_names": [],
         | 
| 4 5 | 
             
                "name": "web-cert-01",
         | 
| 5 6 | 
             
                "not_after": "2017-02-22T00:23:00Z",
         | 
| 6 7 | 
             
                "sha1_fingerprint": "dfcc9f57d86bf58e321c2c6c31c7a971be244ac7",
         | 
| 7 | 
            -
                "created_at": "2017-02-08T16:02:37Z"
         | 
| 8 | 
            +
                "created_at": "2017-02-08T16:02:37Z",
         | 
| 9 | 
            +
                "state": "verified",
         | 
| 10 | 
            +
                "type": "custom"
         | 
| 8 11 | 
             
              }
         | 
| 9 12 | 
             
            }
         | 
| @@ -0,0 +1,12 @@ | |
| 1 | 
            +
            {
         | 
| 2 | 
            +
                "certificate": {
         | 
| 3 | 
            +
                  "id": "2ewewe-bb95-49bc-8021-3afd67a210bf",
         | 
| 4 | 
            +
                  "name": "lets-encrypt-cert",
         | 
| 5 | 
            +
                  "dns_names": ["somedomain.com", "api.somedomain.com"],
         | 
| 6 | 
            +
                  "not_after": "",
         | 
| 7 | 
            +
                  "sha1_fingerprint": "",
         | 
| 8 | 
            +
                  "created_at": "2017-02-08T16:02:37Z",
         | 
| 9 | 
            +
                  "state": "pending",
         | 
| 10 | 
            +
                  "type": "lets_encrypt"
         | 
| 11 | 
            +
                }
         | 
| 12 | 
            +
            }
         | 
| @@ -1,4 +1,5 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 | 
            +
            require 'pry'
         | 
| 2 3 |  | 
| 3 4 | 
             
            RSpec.describe DropletKit::CertificateResource do
         | 
| 4 5 | 
             
              include_context 'resources'
         | 
| @@ -12,9 +13,12 @@ RSpec.describe DropletKit::CertificateResource do | |
| 12 13 | 
             
                match do |certificate|
         | 
| 13 14 | 
             
                  expect(certificate.id).to eq('892071a0-bb95-49bc-8021-3afd67a210bf')
         | 
| 14 15 | 
             
                  expect(certificate.name).to eq('web-cert-01')
         | 
| 16 | 
            +
                  expect(certificate.dns_names).to be_empty
         | 
| 15 17 | 
             
                  expect(certificate.not_after).to eq('2017-02-22T00:23:00Z')
         | 
| 16 18 | 
             
                  expect(certificate.sha1_fingerprint).to eq('dfcc9f57d86bf58e321c2c6c31c7a971be244ac7')
         | 
| 17 19 | 
             
                  expect(certificate.created_at).to eq('2017-02-08T16:02:37Z')
         | 
| 20 | 
            +
                  expect(certificate.state).to eq('verified')
         | 
| 21 | 
            +
                  expect(certificate.type).to eq('custom')
         | 
| 18 22 | 
             
                end
         | 
| 19 23 | 
             
              end
         | 
| 20 24 |  | 
| @@ -23,9 +27,12 @@ RSpec.describe DropletKit::CertificateResource do | |
| 23 27 | 
             
                  DropletKit::Certificate.new(
         | 
| 24 28 | 
             
                    id: '892071a0-bb95-49bc-8021-3afd67a210bf',
         | 
| 25 29 | 
             
                    name: 'web-cert-01',
         | 
| 30 | 
            +
                    dns_names: ["somedomain.com"],
         | 
| 26 31 | 
             
                    not_after: '2017-02-22T00:23:00Z',
         | 
| 27 32 | 
             
                    sha1_fingerprint: 'dfcc9f57d86bf58e321c2c6c31c7a971be244ac7',
         | 
| 28 | 
            -
                    created_at: '2017-02-08T16:02:37Z'
         | 
| 33 | 
            +
                    created_at: '2017-02-08T16:02:37Z',
         | 
| 34 | 
            +
                    status: "verified",
         | 
| 35 | 
            +
                    type: "custom",
         | 
| 29 36 | 
             
                  )
         | 
| 30 37 | 
             
                end
         | 
| 31 38 |  | 
| @@ -73,6 +80,29 @@ RSpec.describe DropletKit::CertificateResource do | |
| 73 80 | 
             
                  expect(resource.create(certificate)).to match_certificate_fixture
         | 
| 74 81 | 
             
                end
         | 
| 75 82 |  | 
| 83 | 
            +
                context 'lets encrypt certificate' do
         | 
| 84 | 
            +
                  let(:lets_encrypt_certificate) do
         | 
| 85 | 
            +
                    DropletKit::Certificate.new(
         | 
| 86 | 
            +
                      name: 'lets-encrypt-cert',
         | 
| 87 | 
            +
                      dns_names: ['somedomain.com', 'api.somedomain.com'],
         | 
| 88 | 
            +
                      type: 'lets_encrypt'
         | 
| 89 | 
            +
                    )
         | 
| 90 | 
            +
                  end
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                  it 'returns created lets encrpyt certificate' do
         | 
| 93 | 
            +
                    json_body = DropletKit::CertificateMapping.representation_for(:create, lets_encrypt_certificate)
         | 
| 94 | 
            +
                    stub_do_api(path, :post).with(body: json_body).to_return(body: api_fixture('certificates/lets_encrypt'), status: 201)
         | 
| 95 | 
            +
                    parsed_json = JSON.parse(json_body)
         | 
| 96 | 
            +
             | 
| 97 | 
            +
                    certificate = resource.create(lets_encrypt_certificate)
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                    expect(certificate.name).to eq(parsed_json['name'])
         | 
| 100 | 
            +
                    expect(certificate.type).to eq(parsed_json['type'])
         | 
| 101 | 
            +
                    expect(certificate.dns_names).to match_array(parsed_json['dns_names'])
         | 
| 102 | 
            +
                    expect(certificate.state).to eq('pending')
         | 
| 103 | 
            +
                  end
         | 
| 104 | 
            +
                end
         | 
| 105 | 
            +
             | 
| 76 106 | 
             
                it_behaves_like 'an action that handles invalid parameters' do
         | 
| 77 107 | 
             
                  let(:action) { 'create' }
         | 
| 78 108 | 
             
                  let(:arguments) { DropletKit::Certificate.new }
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: droplet_kit
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2. | 
| 4 | 
            +
              version: 2.3.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Robert Ross
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2018- | 
| 11 | 
            +
            date: 2018-05-08 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: virtus
         | 
| @@ -294,6 +294,7 @@ files: | |
| 294 294 | 
             
            - spec/fixtures/actions/find.json
         | 
| 295 295 | 
             
            - spec/fixtures/certificates/all.json
         | 
| 296 296 | 
             
            - spec/fixtures/certificates/find.json
         | 
| 297 | 
            +
            - spec/fixtures/certificates/lets_encrypt.json
         | 
| 297 298 | 
             
            - spec/fixtures/domain_records/all.json
         | 
| 298 299 | 
             
            - spec/fixtures/domain_records/create.json
         | 
| 299 300 | 
             
            - spec/fixtures/domain_records/find.json
         | 
| @@ -424,7 +425,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 424 425 | 
             
                  version: '0'
         | 
| 425 426 | 
             
            requirements: []
         | 
| 426 427 | 
             
            rubyforge_project: 
         | 
| 427 | 
            -
            rubygems_version: 2.6. | 
| 428 | 
            +
            rubygems_version: 2.6.8
         | 
| 428 429 | 
             
            signing_key: 
         | 
| 429 430 | 
             
            specification_version: 4
         | 
| 430 431 | 
             
            summary: Droplet Kit is the official Ruby library for DigitalOcean's API
         | 
| @@ -434,6 +435,7 @@ test_files: | |
| 434 435 | 
             
            - spec/fixtures/actions/find.json
         | 
| 435 436 | 
             
            - spec/fixtures/certificates/all.json
         | 
| 436 437 | 
             
            - spec/fixtures/certificates/find.json
         | 
| 438 | 
            +
            - spec/fixtures/certificates/lets_encrypt.json
         | 
| 437 439 | 
             
            - spec/fixtures/domain_records/all.json
         | 
| 438 440 | 
             
            - spec/fixtures/domain_records/create.json
         | 
| 439 441 | 
             
            - spec/fixtures/domain_records/find.json
         |