-
Notifications
You must be signed in to change notification settings - Fork 43
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
[APPINT-1044] Feature/app setup #563
base: feature/app-setup
Are you sure you want to change the base?
Conversation
@ouranos Please, review |
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.
Please add authorization
Rails.logger.info("Error on request #{url} with options #{options}: #{e}") | ||
end | ||
end | ||
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.
No newline at EOF
module MnoEnterprise | ||
module AddOnHelper | ||
|
||
def AddOnHelper.send_request(instance, method, path, options = {}) |
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.
def self.send_request
@@ -16,7 +16,7 @@ module MnoEnterprise::Concerns::Controllers::Jpi::V1::AppInstancesController | |||
# GET /mnoe/jpi/v1/organization/1/app_instances | |||
def index | |||
statuses = MnoEnterprise::AppInstance::ACTIVE_STATUSES.join(',') | |||
@app_instances = MnoEnterprise::AppInstance.includes(:app).where(owner_id: parent_organization.id, 'status.in': statuses).to_a.select do |i| | |||
@app_instances = MnoEnterprise::AppInstance.with_params(extra_fields: true).includes(:app).where(owner_id: parent_organization.id, 'status.in': statuses).to_a.select do |i| |
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.
What is extra_fields
doing? Couldn't find it
def setup_form | ||
app_instance = MnoEnterprise::AppInstance.find_one(params[:id], :app) | ||
response = MnoEnterprise::AddOnHelper.send_request(app_instance, :get, '/setup_form') | ||
MnoEnterprise::EventLogger.info('addon_form_request', current_user.id, 'Request add_on form', app_instance) |
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.
Do we need an event every time the form is displayed?
# GET /mnoe/jpi/v1/organization/1/app_instances/11/setup_form | ||
def setup_form | ||
app_instance = MnoEnterprise::AppInstance.find_one(params[:id], :app) | ||
response = MnoEnterprise::AddOnHelper.send_request(app_instance, :get, '/setup_form') |
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.
Authorization?
def create_omniauth | ||
app_instance = MnoEnterprise::AppInstance.find_one(params[:id], :app) | ||
body = params[:app_instance].merge!(org_uid: app_instance.channel_id) | ||
response = MnoEnterprise::AddOnHelper.send_request(app_instance, :post, "/auth/#{app_instance.name.downcase}/request", body: body) |
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.
Authorization?
def stub_add_on(instance, method, path, status, response = {}) | ||
url = instance.metadata['app']['host'] + path | ||
stub_options = { | ||
headers: { |
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.
You don't need to specify all the headers
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.
@@ -16,7 +16,7 @@ module MnoEnterprise::Concerns::Controllers::Jpi::V1::AppInstancesController | |||
# GET /mnoe/jpi/v1/organization/1/app_instances | |||
def index | |||
statuses = MnoEnterprise::AppInstance::ACTIVE_STATUSES.join(',') | |||
@app_instances = MnoEnterprise::AppInstance.with_params(extra_fields: true).includes(:app).where(owner_id: parent_organization.id, 'status.in': statuses).to_a.select do |i| | |||
@app_instances = MnoEnterprise::AppInstance.select(MnoEnterprise::AppInstance::REQUIRED_INDEX_FIELDS).includes(:app).where(owner_id: parent_organization.id, 'status.in': statuses).to_a.select do |i| |
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.
Nice use of select
02f2137
to
4032d5b
Compare
76bf13a
to
b0803f2
Compare
Add new endpoints on app instances to interact with mno-enterprise-angular and mno-hub
List of new endpoints:
=> Returns the form generated by the add-on for the user to link their account
=> Link the user's account to the add-on
=> Launches a sync on the add-on
=> Unlink the user's account
=> History of add-on syncs
=> List of add-on id-maps