Skip to content
Permalink
Browse files

Merge pull request #129 from linode/object-storage-plugin

Added `obj` plugin to support Linode Object Storage
  • Loading branch information...
yoshizzle committed Jun 25, 2019
2 parents 623a16f + 29b83d4 commit f53c3655ce3c20f3ca71166ea854c79590656ccd
Showing with 751 additions and 4 deletions.
  1. +6 −2 linodecli/cli.py
  2. +11 −2 linodecli/operation.py
  3. +734 −0 linodecli/plugins/obj.py
@@ -142,6 +142,7 @@ def bake(self, spec):
"""
self.spec = spec
self.ops = {}
default_servers = [c['url'] for c in spec['servers']]

for path, data in self.spec['paths'].items():
command = data.get("x-linode-cli-command") or "default"
@@ -168,6 +169,9 @@ def bake(self, spec):

summary = data[m].get('summary') or ''

use_servers = ([c['url'] for c in data[m]['servers']]
if 'servers' in data[m] else default_servers)

args = {}
required_fields = []
if m in ('post','put') and 'requestBody' in data[m]:
@@ -238,7 +242,7 @@ def bake(self, spec):

self.ops[command][action] = CLIOperation(m, use_path, summary,
cli_args, response_model,
use_params)
use_params, use_servers)

# hide the base_url from the spec away
self.ops['_base_url'] = spec['servers'][0]['url']
@@ -370,7 +374,7 @@ def do_request(self, operation, args, filter_header=None):

body = json.dumps(expanded_json)

result = method(self.base_url+url, headers=headers, data=body)
result = method(url, headers=headers, data=body)

# if the API indicated it's newer major or minor version than the client, print a warning
if 'X-Spec-Version' in result.headers:
@@ -117,13 +117,22 @@ class CLIOperation:
responses with the help of their ResponseModel
"""
def __init__(self, method, url, summary, args, response_model,
params):
params, servers):
self.method = method
self.url = url
self._url = url
self.summary = summary
self.args = args
self.response_model = response_model
self.params = params
self.servers = servers

@property
def url(self):
"""
Returns the full URL for this resource based on servers and endpoint
"""
base_url = self.servers[0]
return base_url + '/' + self._url

def parse_args(self, args):
"""

0 comments on commit f53c365

Please sign in to comment.
You can’t perform that action at this time.