|
| 1 | +""" |
| 2 | +Copyright (c) 2025, Oracle and/or its affiliates. |
| 3 | +Licensed under the Universal Permissive License v1.0 as shown at |
| 4 | +https://oss.oracle.com/licenses/upl. |
| 5 | +""" |
| 6 | + |
| 7 | +from __future__ import annotations |
| 8 | + |
| 9 | +import oci |
| 10 | + |
| 11 | + |
| 12 | +# ---------------------------- |
| 13 | +# Mappers to stable dict shapes |
| 14 | +# ---------------------------- |
| 15 | +def map_service_summary(svc: "oci.limits.models.ServiceSummary") -> dict: |
| 16 | + """Map OCI ServiceSummary to a stable dict shape used by our tools.""" |
| 17 | + return { |
| 18 | + "name": getattr(svc, "name", None), |
| 19 | + "description": getattr(svc, "description", None), |
| 20 | + "supported_subscriptions": getattr(svc, "supported_subscriptions", None), |
| 21 | + } |
| 22 | + |
| 23 | + |
| 24 | +def map_limit_definition_summary( |
| 25 | + defn: "oci.limits.models.LimitDefinitionSummary", |
| 26 | +) -> dict: |
| 27 | + """Map OCI LimitDefinitionSummary to a stable dict shape used by our tools.""" |
| 28 | + return { |
| 29 | + "name": getattr(defn, "name", None), |
| 30 | + "serviceName": getattr(defn, "service_name", None), |
| 31 | + "description": getattr(defn, "description", None), |
| 32 | + "scopeType": getattr(defn, "scope_type", None), |
| 33 | + "areQuotasSupported": getattr(defn, "are_quotas_supported", None), |
| 34 | + "isResourceAvailabilitySupported": getattr( |
| 35 | + defn, "is_resource_availability_supported", None |
| 36 | + ), |
| 37 | + "isDeprecated": getattr(defn, "is_deprecated", None), |
| 38 | + "isEligibleForLimitIncrease": getattr( |
| 39 | + defn, "is_eligible_for_limit_increase", None |
| 40 | + ), |
| 41 | + "isDynamic": getattr(defn, "is_dynamic", None), |
| 42 | + "externalLocationSupportedSubscriptions": getattr( |
| 43 | + defn, "external_location_supported_subscriptions", None |
| 44 | + ), |
| 45 | + "supportedSubscriptions": getattr(defn, "supported_subscriptions", None), |
| 46 | + "supportedQuotaFamilies": getattr(defn, "supported_quota_families", None), |
| 47 | + } |
| 48 | + |
| 49 | + |
| 50 | +def map_limit_value_summary(val: "oci.limits.models.LimitValueSummary") -> dict: |
| 51 | + """Map OCI LimitValueSummary to a stable dict shape used by our tools.""" |
| 52 | + return { |
| 53 | + "name": getattr(val, "name", None), |
| 54 | + "scopeType": getattr(val, "scope_type", None), |
| 55 | + "availabilityDomain": getattr(val, "availability_domain", None), |
| 56 | + "value": getattr(val, "value", None), |
| 57 | + } |
| 58 | + |
| 59 | + |
| 60 | +def map_resource_availability(ra: "oci.limits.models.ResourceAvailability") -> dict: |
| 61 | + """Map OCI ResourceAvailability to a stable dict shape used by our tools.""" |
| 62 | + return { |
| 63 | + "used": getattr(ra, "used", None), |
| 64 | + "available": getattr(ra, "available", None), |
| 65 | + "fractionalUsage": getattr(ra, "fractional_usage", None), |
| 66 | + "fractionalAvailability": getattr(ra, "fractional_availability", None), |
| 67 | + "effectiveQuotaValue": getattr(ra, "effective_quota_value", None), |
| 68 | + } |
| 69 | + |
| 70 | + |
| 71 | +__all__ = [ |
| 72 | + "map_service_summary", |
| 73 | + "map_limit_definition_summary", |
| 74 | + "map_limit_value_summary", |
| 75 | + "map_resource_availability", |
| 76 | +] |
0 commit comments