Skip to content
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

Expose DDF schema for a provider when asking using OPTIONS + type #645

Merged
merged 1 commit into from
Sep 30, 2019

Conversation

skateman
Copy link
Member

@skateman skateman commented Aug 8, 2019

Extracted the providers_options into a separate method and only returning when the type isn't set for the /api/providers. If the type param is set in a request, the API will try to append the data-driven-form schema if specified under the data.provider_form_schema key. This schema can be used by the UI to render the right form that contains all the required info for adding a provider of the given type.

// OPTIONS api/providers?type=ManageIQ::Providers::Amazon::CloudManager
{
  ...
  "data": {
    ...
    "provider_form_schema": {
      "title": "Configure AWS",
      "fields": [
        {
          "component": "text-field",
          "name": "role",
          "type": "hidden",
          "initialValue": "ec2"
        },
        {
          "component": "text-field",
          "name": "region",
          "label": "Region"
        },
        {
          "component": "text-field",
          "name": "ec2_username",
          "label": "Access Key"
        },
        {
          "component": "text-field",
          "name": "ec2_password",
          "label": "Secret Key",
          "type": "password"
        }
      ]
    }
  }
}

If the type argument cannot be safely constantized into a subclass of ExtManagementSystem or the provider has no DDF specified it will raise an BadRequestError. The request without the type parameter behaves like the OPTIONS request before this change.

Example of the DDF schema in the amazon provider: ManageIQ/manageiq-providers-amazon#551
Parent issue: ManageIQ/manageiq#18818

@miq-bot add_reviewer @lpichler
@miq-bot add_reviewer @abellotti
@miq-bot add_label enhancement, ivanchuk/no, hammer/no

cc @Hyperkid123, @martinpovolny, @agrare

@skateman skateman changed the title [WIP] 1Expose DDF schema for a provider when asking using OPTIONS + type Expose DDF schema for a provider when asking using OPTIONS + type Aug 8, 2019
@miq-bot miq-bot requested review from lpichler and abellotti August 8, 2019 18:44
@skateman skateman force-pushed the provider-params-for-create branch from 883c633 to de283d8 Compare August 9, 2019 09:21
@Hyperkid123
Copy link
Contributor

Hyperkid123 commented Aug 12, 2019

@skateman is there way to get auth_type for these fields? If so it would be great if we could scope the fields. Something like name: authentication.default.userid. This would basically copy the request payload format necessary for API. It would also make it easier for providers with multiple auth types. Then we would have API payload like this:

{
"authentication": {
    "default": {
      "name": "foo",
      "password": "bar"
     },
    "remote": {
      "name": "foo",
      "password": "bar"
    }
  }
}

@skateman
Copy link
Member Author

skateman commented Aug 12, 2019

@Hyperkid123 I'm just exposing the stuff @agrare is defining in ManageIQ/manageiq-providers-amazon#551, if I'd do what you want here, we would end up with the same if-else-case 🍝 we have in ems_common.

@Fryguy
Copy link
Member

Fryguy commented Sep 4, 2019

ManageIQ/manageiq#19120 has been merged.

@skateman
Copy link
Member Author

skateman commented Sep 4, 2019

@Fryguy we don't depend on the validation backend here, this PR could go in right now without any backend modifications...but thanks, I'll take a look at it.

@skateman skateman force-pushed the provider-params-for-create branch from de283d8 to 8fb1bd1 Compare September 6, 2019 08:12
@skateman skateman force-pushed the provider-params-for-create branch from 8fb1bd1 to 2c98c6f Compare September 9, 2019 07:32
@miq-bot
Copy link
Member

miq-bot commented Sep 9, 2019

Checked commit skateman@2c98c6f with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. ⭐

@lpichler lpichler closed this Sep 9, 2019
@lpichler lpichler reopened this Sep 9, 2019
@agrare agrare merged commit 485f398 into ManageIQ:master Sep 30, 2019
@agrare agrare added this to the Sprint 121 Ending Sep 30, 2019 milestone Sep 30, 2019
@skateman skateman deleted the provider-params-for-create branch September 30, 2019 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants