Skip to content

Commit

Permalink
refactor(config): sw-828 rhel, billing to cloud provider (RedHatInsig…
Browse files Browse the repository at this point in the history
…hts#1044)

* locale, updated cloud provider refs
* config, rhel use cloud provider
* services, rhsm constants, schema
  • Loading branch information
cdcabrera authored Feb 3, 2023
1 parent dcbc56f commit f8a813f
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 51 deletions.
25 changes: 16 additions & 9 deletions public/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,25 @@
"tableEmptyInventoryTitle": "No results found",
"tableEmptyInventoryMessage": "To show more results, clear some or all filters.",
"tableSkeletonAriaLabel": "Loading",
"label_billing_provider": "Unknown",
"label_billing_provider_aws": "AWS",
"label_billing_provider_azure": "Azure",
"label_billing_provider_gcp": "GCP",
"label_billing_provider": "$t(curiosity-inventory.label_cloud_provider)",
"label_billing_provider_aws": "$t(curiosity-inventory.label_cloud_provider_aws)",
"label_billing_provider_azure": "$t(curiosity-inventory.label_cloud_provider_azure)",
"label_billing_provider_gcp": "$t(curiosity-inventory.label_cloud_provider_gcp)",
"label_billing_provider_none": "None",
"label_billing_provider_oracle": "Oracle",
"label_billing_provider_oracle": "$t(curiosity-inventory.label_cloud_provider_oracle)",
"label_billing_provider_red hat": "Red Hat",
"label_category": "{{context}}",
"label_category_cloud": "Public cloud",
"label_category_hypervisor": "Hypervisor",
"label_category_physical": "Physical",
"label_category_virtual": "Virtual",
"label_cloud_provider": "Unknown",
"label_cloud_provider_alibaba": "Alibaba",
"label_cloud_provider_aws": "AWS",
"label_cloud_provider_azure": "Azure",
"label_cloud_provider_gcp": "GCP",
"label_cloud_provider_ibm": "IBM",
"label_cloud_provider_oracle": "Oracle",
"label_has_infinite_quantity_cores": "Unlimited cores",
"label_has_infinite_quantity_sockets": "Unlimited sockets",
"label_number_of_guests": "{{context}}",
Expand All @@ -187,11 +194,11 @@
"label_subscription_type_Annual": "Annual",
"label_subscription_type_On-demand": "On-Demand",
"cloudProvider": "{{context}}",
"cloudProvider_alibaba": "Alibaba",
"cloudProvider_aws": "AWS",
"cloudProvider_azure": "Azure",
"cloudProvider_alibaba": "$t(curiosity-inventory.label_cloud_provider_alibaba)",
"cloudProvider_aws": "$t(curiosity-inventory.label_cloud_provider_aws)",
"cloudProvider_azure": "$t(curiosity-inventory.label_cloud_provider_azure)",
"cloudProvider_google": "Google",
"cloudProvider_ibm": "IBM",
"cloudProvider_ibm": "$t(curiosity-inventory.label_cloud_provider_ibm)",
"hardwareType": "{{context}}",
"hardwareType_cloud": "Public cloud",
"hardwareType_hypervisor": "Hypervisor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ exports[`I18n Component should generate a predictable locale key output snapshot
},
{
"key": "curiosity-inventory.label",
"match": "translate('curiosity-inventory.label', { context: [INVENTORY_TYPES.BILLING_PROVIDER, billingProvider?.value] })",
"match": "translate('curiosity-inventory.label', { context: [INVENTORY_TYPES.CLOUD_PROVIDER, cloudProvider?.value] })",
},
{
"key": "curiosity-inventory.header",
Expand Down
6 changes: 5 additions & 1 deletion src/config/__tests__/__snapshots__/product.rhel.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,11 @@ exports[`Product RHEL config should apply hosts inventory configuration: filtere
"title": <React.Fragment>
t(curiosity-inventory.label, {"context":"category"})
<Label
color="purple"
>
t(curiosity-inventory.label_cloud_provider, {"context":"dolor sit"})
</Label>
</React.Fragment>,
},
{
Expand Down
6 changes: 3 additions & 3 deletions src/config/product.rhel.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,13 @@ const config = {
},
{
id: INVENTORY_TYPES.CATEGORY,
cell: ({ [INVENTORY_TYPES.BILLING_PROVIDER]: billingProvider, [INVENTORY_TYPES.CATEGORY]: category } = {}) => (
cell: ({ [INVENTORY_TYPES.CLOUD_PROVIDER]: cloudProvider, [INVENTORY_TYPES.CATEGORY]: category } = {}) => (
<React.Fragment>
{translate('curiosity-inventory.label', { context: [INVENTORY_TYPES.CATEGORY, category?.value] })}{' '}
{(billingProvider?.value && (
{(cloudProvider?.value && (
<PfLabel color="purple">
{translate('curiosity-inventory.label', {
context: [INVENTORY_TYPES.BILLING_PROVIDER, billingProvider?.value]
context: [INVENTORY_TYPES.CLOUD_PROVIDER, cloudProvider?.value]
})}
</PfLabel>
)) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ exports[`RHSM Constants should have specific properties: all exported constants
"BILLING_ACCOUNT_ID": "billing_account_id",
"BILLING_PROVIDER": "billing_provider",
"CATEGORY": "category",
"CLOUD_PROVIDER": "cloud_provider",
"DISPLAY_NAME": "display_name",
"INVENTORY_ID": "inventory_id",
"LAST_SEEN": "last_seen",
Expand Down Expand Up @@ -225,6 +226,7 @@ exports[`RHSM Constants should have specific properties: all exported constants
"BILLING_ACCOUNT_ID": "billing_account_id",
"BILLING_PROVIDER": "billing_provider",
"CATEGORY": "category",
"CLOUD_PROVIDER": "cloud_provider",
"DISPLAY_NAME": "display_name",
"HAS_INFINITE_QUANTITY": "has_infinite_quantity",
"INVENTORY_ID": "inventory_id",
Expand Down Expand Up @@ -479,6 +481,7 @@ exports[`RHSM Constants should have specific properties: all exported constants
"BILLING_ACCOUNT_ID": "billing_account_id",
"BILLING_PROVIDER": "billing_provider",
"CATEGORY": "category",
"CLOUD_PROVIDER": "cloud_provider",
"DISPLAY_NAME": "display_name",
"INVENTORY_ID": "inventory_id",
"LAST_SEEN": "last_seen",
Expand Down Expand Up @@ -506,6 +509,7 @@ exports[`RHSM Constants should have specific properties: all exported constants
"BILLING_ACCOUNT_ID": "billing_account_id",
"BILLING_PROVIDER": "billing_provider",
"CATEGORY": "category",
"CLOUD_PROVIDER": "cloud_provider",
"DISPLAY_NAME": "display_name",
"HAS_INFINITE_QUANTITY": "has_infinite_quantity",
"INVENTORY_ID": "inventory_id",
Expand Down Expand Up @@ -761,6 +765,7 @@ exports[`RHSM Constants should have specific properties: all exported constants
"BILLING_ACCOUNT_ID": "billing_account_id",
"BILLING_PROVIDER": "billing_provider",
"CATEGORY": "category",
"CLOUD_PROVIDER": "cloud_provider",
"DISPLAY_NAME": "display_name",
"INVENTORY_ID": "inventory_id",
"LAST_SEEN": "last_seen",
Expand Down Expand Up @@ -788,6 +793,7 @@ exports[`RHSM Constants should have specific properties: all exported constants
"BILLING_ACCOUNT_ID": "billing_account_id",
"BILLING_PROVIDER": "billing_provider",
"CATEGORY": "category",
"CLOUD_PROVIDER": "cloud_provider",
"DISPLAY_NAME": "display_name",
"HAS_INFINITE_QUANTITY": "has_infinite_quantity",
"INVENTORY_ID": "inventory_id",
Expand Down Expand Up @@ -1047,6 +1053,7 @@ exports[`RHSM Constants should have specific properties: specific constants 1`]
"BILLING_ACCOUNT_ID": "billing_account_id",
"BILLING_PROVIDER": "billing_provider",
"CATEGORY": "category",
"CLOUD_PROVIDER": "cloud_provider",
"DISPLAY_NAME": "display_name",
"INVENTORY_ID": "inventory_id",
"LAST_SEEN": "last_seen",
Expand Down Expand Up @@ -1074,6 +1081,7 @@ exports[`RHSM Constants should have specific properties: specific constants 1`]
"BILLING_ACCOUNT_ID": "billing_account_id",
"BILLING_PROVIDER": "billing_provider",
"CATEGORY": "category",
"CLOUD_PROVIDER": "cloud_provider",
"DISPLAY_NAME": "display_name",
"HAS_INFINITE_QUANTITY": "has_infinite_quantity",
"INVENTORY_ID": "inventory_id",
Expand Down
74 changes: 37 additions & 37 deletions src/services/rhsm/rhsmConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,13 @@ const RHSM_API_RESPONSE_HOSTS_META_TYPES = {
* RHSM response Instance DATA types.
*
* @type {{MEASUREMENTS: string, BILLING_ACCOUNT_ID: string, CATEGORY: string, SUBSCRIPTION_MANAGER_ID: string,
* INVENTORY_ID: string, NUMBER_OF_GUESTS: string, BILLING_PROVIDER: string, DISPLAY_NAME: string, LAST_SEEN: string}}
* INVENTORY_ID: string, NUMBER_OF_GUESTS: string, BILLING_PROVIDER: string, DISPLAY_NAME: string, CLOUD_PROVIDER: string,
* LAST_SEEN: string}}
*/
const RHSM_API_RESPONSE_INSTANCES_DATA_TYPES = {
BILLING_PROVIDER: 'billing_provider',
BILLING_ACCOUNT_ID: 'billing_account_id',
CLOUD_PROVIDER: 'cloud_provider',
CATEGORY: 'category',
DISPLAY_NAME: 'display_name',
INVENTORY_ID: 'inventory_id',
Expand Down Expand Up @@ -472,50 +474,48 @@ const RHSM_INTERNAL_PRODUCT_DISPLAY_TYPES = {
* RHSM_API_RESPONSE_INSTANCES_META_TYPES: {MEASUREMENTS: string, PRODUCT: string, COUNT: string},
* RHSM_API_RESPONSE_INSTANCES_DATA_TYPES: {MEASUREMENTS: string, BILLING_ACCOUNT_ID: string, CATEGORY: string,
* SUBSCRIPTION_MANAGER_ID: string, INVENTORY_ID: string, NUMBER_OF_GUESTS: string, BILLING_PROVIDER: string,
* DISPLAY_NAME: string, LAST_SEEN: string}, RHSM_API_RESPONSE_SLA_TYPES: {PREMIUM: string, SELF: string, NONE: string,
* STANDARD: string}, RHSM_API_PATH_PRODUCT_ARCHITECTURE_RHEL_TYPES: {RHEL_ARM: string, RHEL_IBM_Z: string,
* RHEL_IBM_POWER: string, RHEL_X86: string}, RHSM_API_RESPONSE_HOSTS_META_TYPES: {PRODUCT: string, COUNT: string},
* RHSM_API_RESPONSE_META_TYPES: {PRODUCT: string, COUNT: string}, RHSM_API_RESPONSE_ERRORS_CODE_TYPES: {GENERIC: string,
* OPTIN: string}, RHSM_API_QUERY_GRANULARITY_TYPES: {WEEKLY: string, QUARTERLY: string, DAILY: string, MONTHLY: string},
* RHSM_API_RESPONSE_UOM_TYPES: {CORES: string, SOCKETS: string},
* RHSM_API_RESPONSE_SUBSCRIPTIONS_DATA_TYPES: {BILLING_ACCOUNT_ID: string, QUANTITY: string,
* SUBSCRIPTION_MANAGER_ID: string, INVENTORY_ID: string, NUMBER_OF_GUESTS: string, HAS_INFINITE_QUANTITY: string,
* TOTAL_CAPACITY: string, PRODUCT_NAME: string, SERVICE_LEVEL: string, DISPLAY_NAME: string, MEASUREMENTS: string,
* UOM: string, CATEGORY: string, NEXT_EVENT_DATE: string, BILLING_PROVIDER: string, LAST_SEEN: string},
* RHSM_API_QUERY_INVENTORY_SORT_DIRECTION_TYPES: {ASCENDING: string, DESCENDING: string},
* RHSM_API_RESPONSE_SUBSCRIPTION_TYPES: {ANNUAL: string, ON_DEMAND: string},
* DISPLAY_NAME: string, CLOUD_PROVIDER: string, LAST_SEEN: string}, RHSM_API_RESPONSE_SLA_TYPES: {PREMIUM: string,
* SELF: string, NONE: string, STANDARD: string}, RHSM_API_PATH_PRODUCT_ARCHITECTURE_RHEL_TYPES: {RHEL_ARM: string,
* RHEL_IBM_Z: string, RHEL_IBM_POWER: string, RHEL_X86: string}, RHSM_API_RESPONSE_HOSTS_META_TYPES: {PRODUCT: string,
* COUNT: string}, RHSM_API_RESPONSE_META_TYPES: {PRODUCT: string, COUNT: string},
* RHSM_API_RESPONSE_ERRORS_CODE_TYPES: {GENERIC: string, OPTIN: string}, RHSM_API_QUERY_GRANULARITY_TYPES: {WEEKLY: string,
* QUARTERLY: string, DAILY: string, MONTHLY: string}, RHSM_API_RESPONSE_UOM_TYPES: {CORES: string, SOCKETS: string},
* RHSM_API_RESPONSE_SUBSCRIPTIONS_DATA_TYPES: {BILLING_ACCOUNT_ID: string, QUANTITY: string, SUBSCRIPTION_MANAGER_ID: string,
* INVENTORY_ID: string, NUMBER_OF_GUESTS: string, HAS_INFINITE_QUANTITY: string, TOTAL_CAPACITY: string, PRODUCT_NAME: string,
* SERVICE_LEVEL: string, DISPLAY_NAME: string, MEASUREMENTS: string, UOM: string, CATEGORY: string, NEXT_EVENT_DATE: string,
* BILLING_PROVIDER: string, LAST_SEEN: string}, RHSM_API_QUERY_INVENTORY_SORT_DIRECTION_TYPES: {ASCENDING: string,
* DESCENDING: string}, RHSM_API_RESPONSE_SUBSCRIPTION_TYPES: {ANNUAL: string, ON_DEMAND: string},
* RHSM_API_QUERY_INVENTORY_SORT_TYPES: {CORES: string, STORAGE_GIBIBYTES: string, CATEGORY: string, SOCKETS: string,
* INSTANCE_HOURS: string, NUMBER_OF_GUESTS: string, TRANSFER_GIBIBYTES: string, BILLING_PROVIDER: string,
* CORE_SECONDS: string, STORAGE_GIBIBYTE_MONTHS: string, LAST_SEEN: string, NAME: string},
* RHSM_API_PATH_PRODUCT_TYPES: {RHEL_ARM: string, OPENSHIFT_METRICS: string, SATELLITE: string, RHEL_WORKSTATION: string,
* RHODS: string, RHOSAK: string, RHEL_COMPUTE_NODE: string, RHEL_X86: string, OPENSHIFT: string,
* SATELLITE_SERVER: string, OPENSHIFT_DEDICATED_METRICS: string, RHEL_DESKTOP: string, RHEL: string,
* SATELLITE_CAPSULE: string, RHEL_SERVER: string, RHEL_IBM_Z: string, RHACS: string, RHEL_IBM_POWER: string},
* RHSM_API_RESPONSE_BILLING_PROVIDER_TYPES: {AZURE: string, GCP: string, RED_HAT: string, NONE: string, AWS: string,
* ORACLE: string}, RHSM_API_RESPONSE_ERRORS_TYPES: {CODE: string},
* RHSM_API_RESPONSE_TALLY_CAPACITY_DATA_TYPES: {DATE: string, HAS_DATA: string, VALUE: string,
* HAS_INFINITE_QUANTITY: string}, RHSM_API_RESPONSE_TALLY_CAPACITY_META_TYPES: {TOTAL_MONTHLY: string, DATE: string,
* PRODUCT: string, HAS_CLOUDIGRADE_DATA: string, HAS_CLOUDIGRADE_MISMATCH: string, HAS_DATA: string, METRIC_ID: string,
* COUNT: string, VALUE: string}, RHSM_API_QUERY_BILLING_PROVIDER_TYPES: {AZURE: string, GCP: string, RED_HAT: string,
* NONE: string, AWS: string, ORACLE: string}, RHSM_API_QUERY_CATEGORY_TYPES: {CLOUD: string, PHYSICAL: string,
* HYPERVISOR: string, VIRTUAL: string}, RHSM_API_QUERY_USAGE_TYPES: {UNSPECIFIED: string, DISASTER: string,
* DEVELOPMENT: string, PRODUCTION: string}, RHSM_API_QUERY_SLA_TYPES: {PREMIUM: string, SELF: string, NONE: string,
* STANDARD: string}, RHSM_API_QUERY_SET_INVENTORY_TYPES: {BILLING_ACCOUNT_ID: string, DIRECTION: string, END_DATE: string,
* SLA: string, LIMIT: string, START_DATE: string, VARIANT: string, DISPLAY_NAME: string, UOM: string, USAGE: string,
* CATEGORY: string, ARCHITECTURE: string, SORT: string, OFFSET: string, BILLING_PROVIDER: string},
* INSTANCE_HOURS: string, NUMBER_OF_GUESTS: string, TRANSFER_GIBIBYTES: string, BILLING_PROVIDER: string, CORE_SECONDS: string,
* STORAGE_GIBIBYTE_MONTHS: string, LAST_SEEN: string, NAME: string}, RHSM_API_PATH_PRODUCT_TYPES: {RHEL_ARM: string,
* OPENSHIFT_METRICS: string, SATELLITE: string, RHEL_WORKSTATION: string, RHODS: string, RHOSAK: string,
* RHEL_COMPUTE_NODE: string, RHEL_X86: string, OPENSHIFT: string, SATELLITE_SERVER: string, OPENSHIFT_DEDICATED_METRICS: string,
* RHEL_DESKTOP: string, RHEL: string, SATELLITE_CAPSULE: string, RHEL_SERVER: string, RHEL_IBM_Z: string, RHACS: string,
* RHEL_IBM_POWER: string}, RHSM_API_RESPONSE_BILLING_PROVIDER_TYPES: {AZURE: string, GCP: string, RED_HAT: string, NONE: string,
* AWS: string, ORACLE: string}, RHSM_API_RESPONSE_ERRORS_TYPES: {CODE: string},
* RHSM_API_RESPONSE_TALLY_CAPACITY_DATA_TYPES: {DATE: string, HAS_DATA: string, VALUE: string, HAS_INFINITE_QUANTITY: string},
* RHSM_API_RESPONSE_TALLY_CAPACITY_META_TYPES: {TOTAL_MONTHLY: string, DATE: string, PRODUCT: string,
* HAS_CLOUDIGRADE_DATA: string, HAS_CLOUDIGRADE_MISMATCH: string, HAS_DATA: string, METRIC_ID: string, COUNT: string,
* VALUE: string}, RHSM_API_QUERY_BILLING_PROVIDER_TYPES: {AZURE: string, GCP: string, RED_HAT: string, NONE: string, AWS: string,
* ORACLE: string}, RHSM_API_QUERY_CATEGORY_TYPES: {CLOUD: string, PHYSICAL: string, HYPERVISOR: string, VIRTUAL: string},
* RHSM_API_QUERY_USAGE_TYPES: {UNSPECIFIED: string, DISASTER: string, DEVELOPMENT: string, PRODUCTION: string},
* RHSM_API_QUERY_SLA_TYPES: {PREMIUM: string, SELF: string, NONE: string, STANDARD: string},
* RHSM_API_QUERY_SET_INVENTORY_TYPES: {BILLING_ACCOUNT_ID: string, DIRECTION: string, END_DATE: string, SLA: string,
* LIMIT: string, START_DATE: string, VARIANT: string, DISPLAY_NAME: string, UOM: string, USAGE: string, CATEGORY: string,
* ARCHITECTURE: string, SORT: string, OFFSET: string, BILLING_PROVIDER: string},
* RHSM_API_RESPONSE_HOSTS_DATA_TYPES: {MEASUREMENT_TYPE: string, CORES: string, CORE_HOURS: string, HARDWARE_TYPE: string,
* SUBSCRIPTION_MANAGER_ID: string, INSTANCE_HOURS: string, SOCKETS: string, INVENTORY_ID: string, NUMBER_OF_GUESTS: string,
* DISPLAY_NAME: string, CLOUD_PROVIDER: string, LAST_SEEN: string}, RHSM_API_RESPONSE_ERRORS: string,
* RHSM_API_QUERY_UOM_TYPES: {CORES: string, SOCKETS: string}, RHSM_API_RESPONSE_META: string,
* RHSM_API_RESPONSE_GRANULARITY_TYPES: {WEEKLY: string, QUARTERLY: string, DAILY: string, MONTHLY: string},
* RHSM_API_QUERY_SET_TYPES: {UOM: string, GRANULARITY: string, USAGE: string, DIRECTION: string, SORT: string,
* END_DATE: string, OFFSET: string, SLA: string, LIMIT: string, START_DATE: string, DISPLAY_NAME: string},
* RHSM_API_QUERY_SET_TYPES: {UOM: string, GRANULARITY: string, USAGE: string, DIRECTION: string, SORT: string, END_DATE: string,
* OFFSET: string, SLA: string, LIMIT: string, START_DATE: string, DISPLAY_NAME: string},
* RHSM_API_QUERY_INVENTORY_SUBSCRIPTIONS_SORT_TYPES: {QUANTITY: string, USAGE: string, NEXT_EVENT_TYPE: string,
* NEXT_EVENT_DATE: string, TOTAL_CAPACITY: string, PRODUCT_NAME: string, SKU: string, SERVICE_LEVEL: string},
* RHSM_INTERNAL_PRODUCT_DISPLAY_TYPES: {CAPACITY: string, LEGACY: string, DUAL_AXES: string, PARTIAL: string,
* HOURLY: string}, RHSM_API_RESPONSE_USAGE_TYPES: {UNSPECIFIED: string, DISASTER: string, DEVELOPMENT: string,
* PRODUCTION: string}, RHSM_API_QUERY_INVENTORY_HOSTS_SORT_TYPES: {CORES: string, CORE_HOURS: string, HARDWARE: string,
* INSTANCE_HOURS: string, SOCKETS: string, MEASUREMENT: string, LAST_SEEN: string, NAME: string}}}
* RHSM_INTERNAL_PRODUCT_DISPLAY_TYPES: {CAPACITY: string, LEGACY: string, DUAL_AXES: string, PARTIAL: string, HOURLY: string},
* RHSM_API_RESPONSE_USAGE_TYPES: {UNSPECIFIED: string, DISASTER: string, DEVELOPMENT: string, PRODUCTION: string},
* RHSM_API_QUERY_INVENTORY_HOSTS_SORT_TYPES: {CORES: string, CORE_HOURS: string, HARDWARE: string, INSTANCE_HOURS: string,
* SOCKETS: string, MEASUREMENT: string, LAST_SEEN: string, NAME: string}}}
*/
const rhsmConstants = {
RHSM_API_PATH_PRODUCT_TYPES,
Expand Down
1 change: 1 addition & 0 deletions src/services/rhsm/rhsmSchemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ const instancesMetaSchema = metaResponseSchema
const instancesItem = Joi.object({
inventory_id: Joi.string().optional().allow(null),
category: Joi.string().lowercase().optional().allow(null),
cloud_provider: Joi.string().lowercase().optional().allow(null, ''),
display_name: Joi.string().optional().allow(null),
billing_provider: Joi.string().lowercase().optional().allow(null, ''),
billing_account_id: Joi.string().optional().allow(null),
Expand Down

0 comments on commit f8a813f

Please sign in to comment.