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

Transformation Mappings Read and Create #313

Merged
merged 1 commit into from Feb 20, 2018

Conversation

jntullo
Copy link

@jntullo jntullo commented Feb 6, 2018

Adds reads and creates of Transformation Mappings to the API:

Sample create:

POST /api/transformation_mappings
{"name": "new transformation mapping",
 "description": "clusters to clusters",
 "state": "draft",
 "transformation_mapping_items": [
     { "source": "/api/clusters/10", "destination": "/api/clusters/1" },
     { "source": "/api/clusters/11", "destination": "/api/clusters/1" },
     { "source": "/api/date_stores/12", "destination": "/api/data_stores/13" },
     { "source": "/api/data_stores/2", "destination": "/api/data_stores/13" },
     { "source": "/api/lans/2", "destination": "/api/lans/13" } 
     { "source": "/api/lans/3", "destination": "/api/lans/13" } 
   ]
}

Create will accept transformation_mapping_items as part of the request with href references to the source and destination.

A call to

GET /api/transformation_mappings

Will return all of the transformation mappings.

GET /api/transformation_mappings/:id

Will return a particular transformation mapping.

Transformation Mapping Items may be retrieved via:

GET /api/transformation_mappings/:id?attributes=transformation_mapping_items

which will return

{  
   "href":"http://localhost:3000/api/transformation_mappings/10000000000001",
   "id":"10000000000001",
   "name":"Cluster and Datastores",
   "description":"Cluster and Datastores Mapping",
   "comments":null,
   "state":"draft",
   "options":{  

   },
   "tenant_id":null,
   "created_at":"2018-02-07T16:02:39Z",
   "updated_at":"2018-02-07T16:02:39Z",
   "transformation_mapping_items":[  
      {  
         "id":"10000000000001",
         "source_id":"10000000000002",
         "source_type":"EmsCluster",
         "destination_id":"10000000000005",
         "destination_type":"EmsCluster",
         "transformation_mapping_id":"10000000000001",
         "options":{  

         },
         "created_at":"2018-02-07T16:01:44Z",
         "updated_at":"2018-02-07T16:02:39Z"
      },
      {  
         "id":"10000000000002",
         "source_id":"10000000000001",
         "source_type":"Storage",
         "destination_id":"10000000000018",
         "destination_type":"Storage",
         "transformation_mapping_id":"10000000000001",
         "options":{  

         },
         "created_at":"2018-02-07T16:05:04Z",
         "updated_at":"2018-02-07T16:05:04Z"
      }
   ]
}

Dependent upon:
ManageIQ/manageiq#16787
ManageIQ/manageiq#16947
and needs a factory

cc: @bzwei @gmcculloug

@jntullo jntullo added the wip label Feb 6, 2018
raise BadRequestError, "Must specify mappings" unless data["mappings"]
data["mappings"] = data["mappings"].each_with_object({}) do |(k, v), new_mappings|
begin
klass = collection_config.klass(k)
Copy link
Contributor

Choose a reason for hiding this comment

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

@jntullo does collect_config already map for example cluster to EmsCluster?
What about the GET - where do you do the translation?

Copy link
Author

Choose a reason for hiding this comment

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

@bzwei Yeah, it maps to EmsCluster, as defined in the api.yml - I forgot about the reverse translation (on GET), but I will add that in

@bzwei
Copy link
Contributor

bzwei commented Feb 6, 2018

@jntullo ManageIQ/manageiq#16787 has the factory for transformation_mapping. Hope it satisfies your need.

@jntullo jntullo force-pushed the transformation_mappings branch 3 times, most recently from 287e56e to b3ece58 Compare February 7, 2018 14:10
@bzwei
Copy link
Contributor

bzwei commented Feb 7, 2018

@jntullo the create example should be something like

POST /api/transformation_mappings
{"name": "new transformation mapping",
 "description": "clusters to clusters",
 "state": "draft",
 "transformation_mapping_items": [
     { "source": "/api/clusters/10", "destination": "/api/clusters/1" },
     { "source": "/api/clusters/11", "destination": "/api/clusters/1" },
     { "source": "/api/clusters/12", "destination": "/api/clusters/1" },
     { "source": "/api/clusters/2", "destination": "/api/clusters/13" } 
   ]
}

@bzwei
Copy link
Contributor

bzwei commented Feb 8, 2018

@miq-bot add_label transformation

@miq-bot
Copy link
Member

miq-bot commented Feb 8, 2018

@bzwei Cannot apply the following label because they are not recognized: transformation

@gtanzillo gtanzillo added the v2v label Feb 8, 2018
@jntullo jntullo changed the title [WIP] Transformation Mappings Read and Create Transformation Mappings Read and Create Feb 12, 2018
@bzwei
Copy link
Contributor

bzwei commented Feb 12, 2018

@jntullo can you resolve the travis errors?

expect(response.parsed_body).to include(expected)
expect(response).to have_http_status(:bad_request)
end
end
Copy link
Member

Choose a reason for hiding this comment

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

can you add a test for when the source or destination href is bogus, i.e. /api/invalid_collection/:id, we should get a BadRequest on those. Might need a minor change to fetch_mapping_resource. Thanks.

@abellotti
Copy link
Member

Looks good @jntullo, just an additional test needed.

@miq-bot
Copy link
Member

miq-bot commented Feb 19, 2018

Checked commit jntullo@f324edc with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🏆

@abellotti
Copy link
Member

Thanks @jntullo for updating this. LGTM!! 👍

@abellotti abellotti merged commit 8772e52 into ManageIQ:master Feb 20, 2018
@abellotti abellotti added this to the Sprint 80 Ending Feb 26, 2018 milestone Feb 20, 2018
@jntullo jntullo deleted the transformation_mappings branch February 20, 2018 15:21
@himdel
Copy link
Contributor

himdel commented May 20, 2018

gaprindashvili: depends on ManageIQ/manageiq#16787 and ManageIQ/manageiq#16947 and ManageIQ/manageiq#16988

simaishi pushed a commit that referenced this pull request May 29, 2018
Transformation Mappings Read and Create
(cherry picked from commit 8772e52)
@simaishi
Copy link
Contributor

Gaprindashvili backport details:

$ git log -1
commit 3b42f4a292d440f947d921d1919b2b87f9ceb666
Author: Alberto Bellotti <abellotti@users.noreply.github.com>
Date:   Tue Feb 20 09:56:45 2018 -0500

    Merge pull request #313 from jntullo/transformation_mappings
    
    Transformation Mappings Read and Create
    (cherry picked from commit 8772e526fe61c9c149ec36b3cc0466f0d29266d3)

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.

None yet

7 participants