{"size": 5145, "ext": "js", "max_stars_repo_path": "src/fireedge/src/client/types/provision.js", "max_stars_repo_name": "DigitEgal/one", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/fireedge/src/client/types/provision.js", "max_issues_repo_name": "DigitEgal/one", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/fireedge/src/client/types/provision.js", "max_forks_repo_name": "DigitEgal/one", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 30.8083832335, "max_line_length": 74, "alphanum_fraction": 0.6952380952}
import PropTypes from 'prop-types'
import { PROVIDERS_TYPES, PROVISIONS_TYPES } from 'client/constants'

const providerTypes = Object.values(PROVIDERS_TYPES).map(({ id }) => id)
const provisionTypes = Object.values(PROVISIONS_TYPES).map(({ id }) => id)

export const UserInput = PropTypes.shape({
  name: PropTypes.string.isRequired,
  description: PropTypes.string,
  type: PropTypes.oneOf([
    'text',
    'text64',
    'password',
    'number',
    'number-float',
    'range',
    'range-float',
    'boolean',
    'list',
    'array',
    'list-multiple'
  ]).isRequired,
  options: PropTypes.arrayOf(
    PropTypes.oneOfType([PropTypes.string, PropTypes.number])
  ),
  min_value: PropTypes.number,
  max_value: PropTypes.number,
  default: PropTypes.oneOfType([
    PropTypes.string,
    PropTypes.number
  ])
})

export const ProviderType = PropTypes.oneOf(providerTypes)

export const ProvisionType = PropTypes.oneOf(provisionTypes)

export const ProvisionHost = PropTypes.shape({
  im_mad: PropTypes.string.isRequired,
  vm_mad: PropTypes.string.isRequired,
  provision: PropTypes.shape({
    count: PropTypes.oneOfType([
      PropTypes.string,
      PropTypes.number
    ]),
    hostname: PropTypes.string
  })
})

export const ProviderPlainInfo = PropTypes.shape({
  image: PropTypes.string,
  location_key: PropTypes.oneOfType([
    PropTypes.string,
    PropTypes.arrayOf(PropTypes.string)
  ]),
  provision_type: ProvisionType.isRequired
})

export const ProviderTemplate = PropTypes.shape({
  name: PropTypes.string.isRequired,
  description: PropTypes.string,
  provider: ProviderType.isRequired,
  plain: ProviderPlainInfo.isRequired,
  connection: PropTypes.objectOf(PropTypes.string),
  inputs: PropTypes.arrayOf(UserInput)
})

export const ProvisionTemplate = PropTypes.shape({
  name: PropTypes.string.isRequired,
  description: PropTypes.string,
  provider: ProviderType.isRequired,
  provision_type: ProvisionType.isRequired,
  defaults: PropTypes.shape({
    provision: PropTypes.shape({
      provider_name: PropTypes.string
    })
  }).isRequired,
  hosts: PropTypes.arrayOf(ProvisionHost),
  inputs: PropTypes.arrayOf(UserInput)
})

export const Provider = PropTypes.shape({
  ID: PropTypes.string.isRequired,
  UID: PropTypes.string.isRequired,
  GID: PropTypes.string.isRequired,
  UNAME: PropTypes.string.isRequired,
  GNAME: PropTypes.string.isRequired,
  NAME: PropTypes.string.isRequired,
  TYPE: PropTypes.string.isRequired,
  PERMISSIONS: PropTypes.shape({
    OWNER_U: PropTypes.oneOf(['0', '1']).isRequired,
    OWNER_M: PropTypes.oneOf(['0', '1']).isRequired,
    OWNER_A: PropTypes.oneOf(['0', '1']).isRequired,
    GROUP_U: PropTypes.oneOf(['0', '1']).isRequired,
    GROUP_M: PropTypes.oneOf(['0', '1']).isRequired,
    GROUP_A: PropTypes.oneOf(['0', '1']).isRequired,
    OTHER_U: PropTypes.oneOf(['0', '1']).isRequired,
    OTHER_M: PropTypes.oneOf(['0', '1']).isRequired,
    OTHER_A: PropTypes.oneOf(['0', '1']).isRequired
  }).isRequired,
  TEMPLATE: PropTypes.shape({
    PLAIN: ProviderPlainInfo,
    PROVISION_BODY: PropTypes.oneOfType([
      // encrypted
      PropTypes.string,
      PropTypes.shape({
        provider: ProviderType,
        connection: PropTypes.objectOf(PropTypes.string),
        registration_time: PropTypes.number,
        description: PropTypes.oneOfType([
          PropTypes.string,
          PropTypes.number
        ]),
        inputs: PropTypes.arrayOf(UserInput)
      }).isRequired
    ])
  })
})

const ProvisionInfrastructure = PropTypes.shape({
  id: PropTypes.number.isRequired,
  name: PropTypes.string.isRequired
})

export const Provision = PropTypes.shape({
  ID: PropTypes.string.isRequired,
  UID: PropTypes.string.isRequired,
  GID: PropTypes.string.isRequired,
  UNAME: PropTypes.string.isRequired,
  GNAME: PropTypes.string.isRequired,
  NAME: PropTypes.string.isRequired,
  TYPE: PropTypes.string.isRequired,
  PERMISSIONS: PropTypes.shape({
    OWNER_U: PropTypes.oneOf(['0', '1']).isRequired,
    OWNER_M: PropTypes.oneOf(['0', '1']).isRequired,
    OWNER_A: PropTypes.oneOf(['0', '1']).isRequired,
    GROUP_U: PropTypes.oneOf(['0', '1']).isRequired,
    GROUP_M: PropTypes.oneOf(['0', '1']).isRequired,
    GROUP_A: PropTypes.oneOf(['0', '1']).isRequired,
    OTHER_U: PropTypes.oneOf(['0', '1']).isRequired,
    OTHER_M: PropTypes.oneOf(['0', '1']).isRequired,
    OTHER_A: PropTypes.oneOf(['0', '1']).isRequired
  }).isRequired,
  TEMPLATE: PropTypes.shape({
    BODY: PropTypes.shape({
      name: PropTypes.string,
      description: PropTypes.oneOfType([
        PropTypes.string,
        PropTypes.number
      ]),
      start_time: PropTypes.number,
      state: PropTypes.number,
      provider: PropTypes.string,
      provision: PropTypes.shape({
        infrastructure: PropTypes.shape({
          clusters: PropTypes.arrayOf(ProvisionInfrastructure),
          datastores: PropTypes.arrayOf(ProvisionInfrastructure),
          networks: PropTypes.arrayOf(ProvisionInfrastructure)
        }),
        resource: PropTypes.object
      }),
      image: PropTypes.string,
      provision_type: ProvisionType
    }).isRequired
  })
})
