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

Generic Object Definition Actions #37

Merged
merged 1 commit into from
Sep 15, 2017
Merged

Generic Object Definition Actions #37

merged 1 commit into from
Sep 15, 2017

Conversation

jntullo
Copy link

@jntullo jntullo commented Aug 31, 2017

Generic Object Definition Actions

Dependent upon ManageIQ/manageiq#15893

@miq-bot add_label enhancement, wip
@miq-bot assign @abellotti

General Usage Information

  • Can reference a generic object definition by name, id, or href (see "add_attributes" example for how to specify)

Examples

add_attributes

POST /api/generic_object_definitions
{
  "action": "add_attributes",
  "resources": {
    "attributes": [
    {
      "name": "name",
      "resource": {
        "attributes": {
          "attr1": "string",
          "another": "boolean"
        }
      }
    },
    {
      "id": ":id",
      "resource": {
        "attributes": {
          "attr2": "string"
        }
      }
    },
    {
      "href": "/generic_object_definition/:id",
      "resource": {
        "attributes": {
          "attr3": "string"
        }
      }
    }
  ]}
}
POST /generic_object_definitions/:id
{
  "action"   : "add_attributes",
  "resource" : {
    "attributes" : {
      "added_attribute1" : "string",
      "added_attribute2" : "boolean"
    }
  }
}

remove_attributes

  • Accepts same payload as "add_attributes", with different action specified
POST /generic_object_definitions/:id
{
  "action"   : "remove_attributes",
  "resource" : {
    "attributes" : {
      "added_attribute1" : "string",
      "added_attribute2" : "boolean"
    }
  }
}

add_methods

POST /generic_object_definitions
{
  "action"    : "add_methods",
  "resources" : [
    { "id" : "id", "resource" : { "methods" : ["method1", "method2"] } }
  ]
}
POST /generic_object_definitions/:id
{
  "action"   : "add_methods",
  "resource" : {
    "methods" : ["foo", "bar"]
  }
}

remove_methods

  • accepts same payload as add_methods with different action specified
POST /generic_object_definitions
{
  "action"    : "remove_methods",
  "resources" : [
    { "id" : "id", "resource" : { "methods" : ["method1", "method2"] } }
  ]
}
POST /generic_object_definitions/:id
{
  "action"   : "remove_methods",
  "resource" : {
    "methods" : ["foo", "bar"]
  }
}

add_associations

POST /generic_object_definitions
{
  "action"    : "add_associations",
  "resources" : [
    { "href" : "/generic_object_definition/:id", "resource" : { "associations" : { "zones" : "AvailabilityZone" } }}
  ]
}
POST /generic_object_definitions/:id
{
  "action"   : "add_associations",
  "resource" : {
    "associations" : {
      "az"         : "AvailabilityZone",
      "chargeback" : "ChargebackVm"
    }
  }
}

remove_associations

  • accepts same payload as add_associations with different action specified
POST /generic_object_definitions
{
  "action"    : "remove_associations",
  "resources" : [
    { "href" : "/generic_object_definition/:id", "resource" : { "associations" : { "zones" : "AvailabilityZone" } }}
  ]
}
POST /generic_object_definitions/:id
{
  "action"   : "remove_associations",
  "resource" : {
    "associations" : {
      "az"         : "AvailabilityZone",
      "chargeback" : "ChargebackVm"
    }
  }
}

@miq-bot
Copy link
Member

miq-bot commented Sep 7, 2017

This pull request is not mergeable. Please rebase and repush.

@imtayadeway
Copy link
Contributor

Hi! It looks like your PR has been affected by the recently merged #40, and as a result will need to be rebased. First, I apologize for any inconvenience caused. After rebasing, you'll need to update some specs in order for them to pass. In particular you'll need to change any path helpers, applying the following pattern:

vms_url => api_vms_url
vms_url(vm.id) => api_vm_url(nil, vm) 
vms_url(vm.compressed_id) => api_vm_url(nil, vm.compressed_id)
"#{vms_url(vm.id)}/tags" => api_vm_tags_url(nil, vm)
"#{vms_url(vm.compressed_id}/tags" => api_vm_tags_url(nil, vm.compressed_id)
"#{vms_url(vm.id)}/tags/#{tag.id}" => api_vm_tag_url(nil, vm, tag)
"#{vms_url(vm.compressed_id)}/tags/#{tag.compressed_id}" => api_vm_tag_url(nil, vm.compressed_id, tag.compressed_id)

If you run into any issues, please ping me and I will try to help you out.

Many thanks!
Tim

@jntullo jntullo changed the title [WIP] Generic Object Definition Actions Generic Object Definition Actions Sep 12, 2017
@miq-bot miq-bot removed the wip label Sep 12, 2017
@abellotti
Copy link
Member

Hi @jntullo maybe add the :forbidden result cases for each of the new action in case they don't have the right role.

go_def.destroy!
rescue => err
raise BadRequestError, "Failed to delete generic object definition - #{err}"
end

def add_attributes_resource(type, id, data)
go_def = fetch_generic_object_definition(type, id, data)
attributes = data['attributes'] || data['resource']['attributes']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this handled by the base class, ie. if data['resource'] exists, that will be the data coming in ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abellotti not in the case where the id is the name of the generic object

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@abellotti
Copy link
Member

Hi @jntullo, looks like #51 was merged yesterday, can you update the failing tests to use the new get/post/etc. signatures ? Thanks !!

@jntullo
Copy link
Author

jntullo commented Sep 15, 2017

@abellotti whoops, missed that. this should make them 🍏 😄

@miq-bot
Copy link
Member

miq-bot commented Sep 15, 2017

Checked commit jntullo@e4e5adb with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
2 files checked, 0 offenses detected
Everything looks fine. 🏆

@abellotti abellotti added this to the Sprint 69 Ending Sep 18, 2017 milestone Sep 15, 2017
@abellotti
Copy link
Member

Thanks @jntullo for the update. LGTM!! 👍

@abellotti abellotti merged commit 0787827 into ManageIQ:master Sep 15, 2017
@jntullo jntullo mentioned this pull request Sep 18, 2017
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.

4 participants