-
Notifications
You must be signed in to change notification settings - Fork 175
get rest api to work with 4.0 api structure, also took out oapi refer… #88
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
Changes from 1 commit
d9b20c4
dd68b1d
b428b06
c20a12e
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 |
|---|---|---|
|
|
@@ -5,8 +5,8 @@ module Rest | |
| module OpenShift | ||
| extend Helper | ||
|
|
||
| def self.populate(path, base_opts, opts) | ||
| populate_common("/oapi/<oapi_version>", path, base_opts, opts) | ||
| def self.populate(path, base_opts, opts, type) | ||
| populate_common("/apis/#{type}.openshift.io/<api_version>", path, base_opts, opts) | ||
|
Contributor
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. Using /lgtm
Member
Author
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 do you mean by
Contributor
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 initial assumpion was that there will be one global API version like 1, 2, 3. Now they have multiple On the other hand it can be overridden for each call so maybe will work. As long as it works now, I'm fine. |
||
| end | ||
|
|
||
| class << self | ||
|
|
@@ -21,7 +21,7 @@ class << self | |
| # "gitVersion": "v3.3.0.27", | ||
| # "buildDate": "2016-08-29T14:44:33Z" | ||
| # } | ||
| def self.version(base_opts, opts) | ||
| def self.version(base_opts, opts, type="version") | ||
| populate_common("/version", "/openshift", base_opts, opts) | ||
| return perform(**base_opts, method: "GET") { |res| | ||
| res[:props][:openshift] = res[:parsed]["gitVersion"] | ||
|
|
@@ -31,75 +31,73 @@ def self.version(base_opts, opts) | |
| } | ||
| end | ||
|
|
||
| def self.delete_oauthaccesstoken(base_opts, opts) | ||
| populate("/oauthaccesstokens/<token_to_delete>", base_opts, opts) | ||
| def self.delete_oauthaccesstoken(base_opts, opts, type="oauth") | ||
| populate("/oauthaccesstokens/<token_to_delete>", base_opts, opts, type) | ||
| return perform(**base_opts, method: "DELETE") | ||
| end | ||
|
|
||
| def self.list_projects(base_opts, opts) | ||
| populate("/projects", base_opts, opts) | ||
| def self.list_projects(base_opts, opts, type="project") | ||
|
Contributor
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 think that
Member
Author
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. yeah, we can put it here or at the
Contributor
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. Ok, please remove this parameter See my other comment. I would leave it to you about merging k8s and openshift calls in same place.
Member
Author
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. @akostadinov ok, I fixed that now. |
||
| populate("/projects", base_opts, opts, type) | ||
| return perform(**base_opts, method: "GET") | ||
| end | ||
|
|
||
| def self.delete_project(base_opts, opts) | ||
| populate("/projects/<project_name>", base_opts, opts) | ||
| def self.delete_project(base_opts, opts, type="project") | ||
| populate("/projects/<project_name>", base_opts, opts, type) | ||
| return perform(**base_opts, method: "DELETE") | ||
| end | ||
|
|
||
| def self.get_project(base_opts, opts) | ||
| populate("/projects/<project_name>", base_opts, opts) | ||
| def self.get_project(base_opts, opts, type="project") | ||
| populate("/projects/<project_name>", base_opts, opts, type) | ||
| return perform(**base_opts, method: "GET") | ||
| end | ||
|
|
||
| def self.get_user(base_opts, opts) | ||
| populate("/users/<username>", base_opts, opts) | ||
| def self.get_user(base_opts, opts, type="user") | ||
| populate("/users/<username>", base_opts, opts, type) | ||
| return perform(**base_opts, method: "GET") { |res| | ||
| res[:props][:name] = res[:parsed]["metadata"]["name"] | ||
| res[:props][:uid] = res[:parsed]["metadata"]["uid"] | ||
| } | ||
| end | ||
|
|
||
| # this usually creates a project in fact | ||
| def self.create_project_request(base_opts, opts) | ||
| def self.create_project_request(base_opts, opts, type="project") | ||
| base_opts[:payload] = {} | ||
| # see https://bugzilla.redhat.com/show_bug.cgi?id=1244889 for apiVersion | ||
| base_opts[:payload][:apiVersion] = opts[:oapi_version] | ||
| base_opts[:payload]["displayName"] = opts[:display_name] if opts[:display_name] | ||
| base_opts[:payload]["description"] = opts[:description] if opts[:description] | ||
| # base_opts[:payload][:kind] = "ProjectRequest" | ||
| base_opts[:payload][:metadata] = {name: opts[:project_name]} | ||
|
|
||
| populate("/projectrequests", base_opts, opts) | ||
| populate("/projectrequests", base_opts, opts, type) | ||
| return Http.request(**base_opts, method: "POST") | ||
| end | ||
|
|
||
| def self.post_local_resource_access_reviews(base_opts, opts) | ||
| def self.post_local_resource_access_reviews(base_opts, opts, type="authorization") | ||
| base_opts[:payload] = {} | ||
| base_opts[:payload][:apiVersion] = opts[:oapi_version] | ||
| base_opts[:payload][:kind] = "LocalResourceAccessReview" | ||
| base_opts[:payload][:verb] = opts[:verb] | ||
| base_opts[:payload][:resource] = opts[:resource] | ||
| project_name = opts[:project_name] | ||
| populate("/namespaces/<project_name>/localresourceaccessreviews", base_opts, opts) | ||
| populate("/namespaces/<project_name>/localresourceaccessreviews", base_opts, opts, type) | ||
| return perform(**base_opts, method: "POST") | ||
| end | ||
|
|
||
| # did not find out how to use this one yet | ||
| def self.create_oauth_access_token(base_opts, opts) | ||
| def self.create_oauth_access_token(base_opts, opts, type="oauth") | ||
| base_opts[:payload] = {} | ||
| base_opts[:payload]["expiresIn"] = opts[:expires_in] if opts[:expires_in] | ||
| base_opts[:payload]["userName"] = opts[:user_name] if opts[:user_name] | ||
| base_opts[:payload][:scopes] = opts[:scopes] if opts[:scopes] | ||
|
|
||
|
|
||
| populate("/oauthaccesstokens", base_opts, opts) | ||
| populate("/oauthaccesstokens", base_opts, opts, type) | ||
| return perform(**base_opts, method: "POST") { |res| | ||
| # res[:props][:name] = res[:parsed]["metadata"]["name"] | ||
| # res[:props][:uid] = res[:parsed]["metadata"]["uid"] | ||
| } | ||
| end | ||
|
|
||
| def self.rollback_deploy(base_opts, opts) | ||
| def self.rollback_deploy(base_opts, opts, type="apps") | ||
| base_opts[:payload] = {} | ||
| base_opts[:payload][:spec] = {} | ||
| base_opts[:payload][:spec][:from] = {name: opts[:deploy_name]} | ||
|
|
@@ -110,42 +108,26 @@ def self.rollback_deploy(base_opts, opts) | |
|
|
||
| project_name = opts[:project_name] | ||
|
|
||
| populate("/namespaces/<project_name>/deploymentconfigrollbacks", base_opts, opts) | ||
| populate("/namespaces/<project_name>/deploymentconfigrollbacks", base_opts, opts, type) | ||
| return Http.request(**base_opts, method: "POST") | ||
| end | ||
|
|
||
| def self.get_subresources_oapi(base_opts, opts) | ||
| populate("/namespaces/<project_name>/<resource_type>/<resource_name>/status", base_opts, opts) | ||
| return Http.request(**base_opts, method: "GET") | ||
| end | ||
|
|
||
| def self.post_role_oapi(base_opts, opts) | ||
|
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. @pruan-rht any replacement for this method?
Member
Author
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. @stuartchuan, for 4.0, oapi has been removed, that's why I took out this method |
||
| base_opts[:payload] = {} | ||
| base_opts[:payload]["kind"] = opts[:kind] | ||
| base_opts[:payload]["apiVersion"] = opts[:api_version] | ||
| base_opts[:payload]["verb"] = opts[:verb] | ||
| base_opts[:payload]["resource"] = opts[:resource] | ||
| base_opts[:payload]["user"] = opts[:user] | ||
|
|
||
| populate("/namespaces/<project_name>/<role>", base_opts, opts) | ||
| return Http.request(**base_opts, method: "POST") | ||
| end | ||
|
|
||
| def self.post_pod_security_policy_self_subject_reviews(base_opts, opts) | ||
| def self.post_pod_security_policy_self_subject_reviews(base_opts, opts, type="security") | ||
| base_opts[:payload] = File.read(expand_path(opts[:payload_file])) | ||
| populate("/namespaces/<project_name>/podsecuritypolicyselfsubjectreviews", base_opts, opts) | ||
| populate("/namespaces/<project_name>/podsecuritypolicyselfsubjectreviews", base_opts, opts, type) | ||
| return perform(**base_opts, method: "POST") | ||
| end | ||
|
|
||
| def self.post_pod_security_policy_subject_reviews(base_opts, opts) | ||
| def self.post_pod_security_policy_subject_reviews(base_opts, opts, type="security") | ||
| base_opts[:payload] = File.read(expand_path(opts[:payload_file])) | ||
| populate("/namespaces/<project_name>/podsecuritypolicysubjectreviews", base_opts, opts) | ||
| populate("/namespaces/<project_name>/podsecuritypolicysubjectreviews", base_opts, opts, type) | ||
| return perform(**base_opts, method: "POST") | ||
| end | ||
|
|
||
| def self.post_pod_security_policy_reviews(base_opts, opts) | ||
| def self.post_pod_security_policy_reviews(base_opts, opts, type="security") | ||
| base_opts[:payload] = File.read(expand_path(opts[:payload_file])) | ||
| populate("/namespaces/<project_name>/podsecuritypolicyreviews", base_opts, opts) | ||
| populate("/namespaces/<project_name>/podsecuritypolicyreviews", base_opts, opts, type) | ||
| return perform(**base_opts, method: "POST") | ||
| end | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.