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

Data Faker #4

Open
laszewsk opened this issue Dec 21, 2018 · 4 comments
Open

Data Faker #4

laszewsk opened this issue Dec 21, 2018 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@laszewsk
Copy link
Contributor

We are in need of a data faker for general

  • REST services
  • Graphql models

For REST this is pretty simple:

Let us assume the REST service is defined in yaml via OpenAPI.
Under definitions: we find the definition of the resource. What we want is some way of defining lots of them with a reasonable data set that makes somewhat sense.

I was thinking. Maybe we can have a prg that just writes this to a file and than we in : notation attach a python function to it that creates sample data. I remember you have a data generator somewher, where is it, I think we need to generalize this

@laszewsk laszewsk added the enhancement New feature or request label Dec 21, 2018
@laszewsk
Copy link
Contributor Author

laszewsk commented Dec 21, 2018

So lets assume we have in the yaml file:

definitions:
  VM:
    type: object
    properties:
      provider:
        type: string
        description: Name of the provider
      id:
        type: string
        description: a unique id for the vm
      name:
        type: string
        description: the name of the vm
      image:
        type: string
        description: the image for the vm
      region:
        type: string
        description: an optional region
      size:
        type: string
        description: The size of the vm
      state:
        type: string
        description: The state of the vm
      private_ips:
        type: string
        description: The private IPs
      public_ips:
        type: string
        description: The public IPS
      metadata:
        type: string
        description: The meta data passed along to the VM

What I like is that we add a new filed such as

   x-faker: cloudmesh.faker.unique_ip("[127-255].0.0.[1-255]")

which for example would create an ip address randomly in that range, but be unique

or
region:

   x-faker: cloudmesh.faker.list["uswest", "useats", .... some more in the list]

@MihirNS
Copy link
Collaborator

MihirNS commented Dec 21, 2018

This sounds cool. It will be very helpful. We have data generator here

https://github.com/cloudmesh-community/graphql/blob/master/cloudmesh-graphql-server/database.py

We can write standalone prg by taking cue from this file.

@MihirNS MihirNS self-assigned this Oct 6, 2019
@MihirNS
Copy link
Collaborator

MihirNS commented Oct 6, 2019

I have done basic implementation.

6bac833

Cmd to execute script

./yaml_reader.py --yaml-file input.yml --out-file output --json --yaml

Either json or yaml option are required. I have checked in sample 'input.yml' file. Here is the output

definitions:
  VM:
    properties:
      id:
        description: a unique id for the vm
        type: string
      image:
        description: the image for the vm
        type: string
        value: CC-Ubuntu14.04
        x-faker: cloudmesh_faker.list(['CC-Ubuntu16.04','CC-Ubuntu14.04','CC-Ubuntu18.04','CC-Ubuntu12.04'])
      metadata:
        description: The meta data passed along to the VM
        type: string
      name:
        description: the name of the vm
        type: string
      private_ips:
        description: The private IPs
        type: string
        value: 64.0.0.11
        x-faker: cloudmesh_faker.unique_ip("[24-96].0.0.[1-128]")
      provider:
        description: Name of the provider
        type: string
      public_ips:
        description: The public IPS
        type: string
        value: 229.0.0.246
        x-faker: cloudmesh_faker.unique_ip("[127-255].0.0.[1-255]")
      region:
        description: an optional region
        type: string
        value: South Central US
        x-faker: cloudmesh_faker.list(['West Central US','West US 2','East US 2','East
          US','North Central US','South Central US','Central US','West US'])
      size:
        description: The size of the vm
        type: string
      state:
        description: The state of the vm
        type: string
        value: Stopping
        x-faker: cloudmesh_faker.list(['Starting','Running','Stopping','Stopped','Deallocating','Deallocated'])
    type: object

@laszewsk
Copy link
Contributor Author

laszewsk commented Oct 7, 2019

this will come in handy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants