-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add api response examples to the api documentation #682
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,12 +20,36 @@ class Api::BackupsController < ApiController | |
|
||
api :GET, "/api/crowbar/backups", "Returns a list of available backups" | ||
api_version "2.0" | ||
example ' | ||
[ | ||
{ | ||
"id": 1, | ||
"name": "testbackup", | ||
"version": "4.0", | ||
"size": 76815, | ||
"created_at": "2016-09-27T06:05:10.208Z", | ||
"updated_at": "2016-09-27T06:05:10.208Z", | ||
"migration_level": 20160819142156 | ||
} | ||
] | ||
' | ||
def index | ||
render json: Api::Backup.all | ||
end | ||
|
||
api :GET, "/api/crowbar/backups/:id", "Returns a specific backup" | ||
api_version "2.0" | ||
example ' | ||
{ | ||
"id": 1, | ||
"name": "testbackup", | ||
"version": "4.0", | ||
"size": 76815, | ||
"created_at": "2016-09-27T06:05:10.208Z", | ||
"updated_at": "2016-09-27T06:05:10.208Z", | ||
"migration_level": 20160819142156 | ||
} | ||
' | ||
def show | ||
render json: @backup | ||
end | ||
|
@@ -35,6 +59,17 @@ def show | |
param :backup, Hash, desc: "Backup info", required: true do | ||
param :name, String, desc: "Name of the backup", required: true | ||
end | ||
example ' | ||
{ | ||
"id": 1, | ||
"name": "testbackup", | ||
"version": "4.0", | ||
"size": 76815, | ||
"created_at": "2016-09-27T06:05:10.208Z", | ||
"updated_at": "2016-09-27T06:05:10.208Z", | ||
"migration_level": 20160819142156 | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was expecting the file to be returned as part of the backup creation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why that? you mean it should be downloaded right after creation? I think that would be wrong There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, I guess we can use the id to download the backup file. Although I would expect an href > download > link attribute to get it from this response |
||
' | ||
def create | ||
@backup = Api::Backup.new(backup_params) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,15 @@ | |
class Api::CrowbarController < ApiController | ||
api :GET, "/api/crowbar", "Show the crowbar object" | ||
api_version "2.0" | ||
example ' | ||
{ | ||
"version": "4.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also document the different possible versions we'll get? What is cloud6? what's crowbar-init? what's cloud7? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cloud 6 is crowbar 3.0, cloud 7 is crowbar 4.0 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please Add that as part of the documentation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where? as a comment on that line it would be probably too long There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer a long line in the example than a comment on a github review ;) I'm reading Apipie issues and it seems there is no better approach to represent the responses other than examples. A lot of people reference to swagger.io or raml.org, claiming they both support it... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @santiph. Github PR comments should never be considered as documentation ... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @aspiers me too :) not sure who would not ... :/ |
||
"addons": [ | ||
"ceph", | ||
"ha" | ||
] | ||
} | ||
' | ||
def show | ||
render json: Api::Crowbar.status | ||
end | ||
|
@@ -28,6 +37,20 @@ def update | |
end | ||
|
||
api :GET, "/api/crowbar/upgrade", "Status of Crowbar Upgrade" | ||
example ' | ||
{ | ||
"version": "4.0", | ||
"addons": [ | ||
"ceph", | ||
"ha" | ||
], | ||
"upgrade": { | ||
"upgrading": false, # the crowbar admin server is currently upgrading | ||
"success": false, # the crowbar admin server has been successfully upgraded | ||
"failed": false # the crowbar admin server failed to upgrade | ||
} | ||
} | ||
' | ||
api :POST, "/api/crowbar/upgrade", "Upgrade Crowbar" | ||
api_version "2.0" | ||
def upgrade | ||
|
@@ -54,6 +77,24 @@ def maintenance | |
|
||
api :GET, "/api/crowbar/repocheck", "Sanity check for Crowbar server repositories" | ||
api_version "2.0" | ||
example ' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have we already agreed on the format of the result here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, but do we need to show something else besides the json response? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
{ | ||
"os": { | ||
"available": true, | ||
"repos": {} | ||
}, | ||
"cloud": { | ||
"available": false, | ||
"repos": { | ||
"x86_64": { | ||
"missing": [ | ||
"SUSE OpenStack Cloud 7" | ||
] | ||
} | ||
} | ||
} | ||
} | ||
' | ||
def repocheck | ||
check = Api::Crowbar.repocheck | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,29 @@ | |
class Api::UpgradeController < ApiController | ||
api :GET, "/api/upgrade", "Show the Upgrade status object" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the difference with upgrade under There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just look at the example :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just ignore it for now, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough |
||
api_version "2.0" | ||
example ' | ||
{ | ||
"crowbar": { | ||
"version": "4.0", | ||
"addons": [ | ||
"ceph", | ||
"ha" | ||
], | ||
"upgrade": { | ||
"upgrading": false, | ||
"success": false, | ||
"failed": false | ||
} | ||
}, | ||
"checks": { | ||
"sanity_checks": true, | ||
"maintenance_updates_installed": true, | ||
"clusters_healthy": true, | ||
"compute_resources_available": true, | ||
"ceph_healthy": true | ||
} | ||
} | ||
' | ||
def show | ||
render json: Api::Upgrade.status | ||
end | ||
|
@@ -64,6 +87,15 @@ def services | |
|
||
api :GET, "/api/upgrade/prechecks", "Shows a sanity check in preparation for the upgrade" | ||
api_version "2.0" | ||
example ' | ||
{ | ||
"sanity_checks": true, | ||
"maintenance_updates_installed": true, | ||
"clusters_healthy": true, | ||
"compute_resources_available": true, | ||
"ceph_healthy": true | ||
} | ||
' | ||
def prechecks | ||
render json: Api::Upgrade.check | ||
end | ||
|
@@ -82,6 +114,39 @@ def cancel | |
|
||
api :GET, "/api/upgrade/repocheck", "Check for missing node repositories" | ||
api_version "2.0" | ||
example ' | ||
{ | ||
"ceph": { | ||
"available": false, | ||
"repos": {} | ||
}, | ||
"ha": { | ||
"available": false, | ||
"repos": {} | ||
}, | ||
"os": { | ||
"available": true, | ||
"repos": {} | ||
}, | ||
"openstack": { | ||
"available": false, | ||
"repos": { | ||
"missing": { | ||
"x86_64": [ | ||
"SUSE-OpenStack-Cloud-7-Pool", | ||
"SUSE-OpenStack-Cloud-7-Updates" | ||
] | ||
}, | ||
"inactive": { | ||
"x86_64": [ | ||
"SUSE-OpenStack-Cloud-7-Pool", | ||
"SUSE-OpenStack-Cloud-7-Updates" | ||
] | ||
} | ||
} | ||
} | ||
} | ||
' | ||
def repocheck | ||
render json: Api::Upgrade.repocheck | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can we download the files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with the download endpoint