parameters: (cls: Type[ServiceSpecT], json_spec: Dict)
return_statement: return _cls._from_json_impl(c)
docstring: Initialize 'ServiceSpec' object data from a json structure
  
          There are two valid styles for service specs:
  
          the "old" style:
  
          .. code:: yaml
  
              service_type: nfs
              service_id: foo
              pool: mypool
              namespace: myns
  
          and the "new" style:
  
          .. code:: yaml
  
              service_type: nfs
              service_id: foo
              config:
                some_option: the_value
              networks: [10.10.0.0/16]
              spec:
                pool: mypool
                namespace: myns
  
          In https://tracker.ceph.com/issues/45321 we decided that we'd like to
          prefer the new style as it is more readable and provides a better
          understanding of what fields are special for a give service type.
  
          Note, we'll need to stay compatible with both versions for the
          the next two major releases (octoups, pacific).
  
          :param json_spec: A valid dict with ServiceSpec
  
          :meta private:
docstring_summary: Initialize 'ServiceSpec' object data from a json structure
docstring_tokens: Initialize ServiceSpec object data from a json structure
function: def from_json(cls: Type[ServiceSpecT], json_spec: Dict) -> ServiceSpecT:
          """
          Initialize 'ServiceSpec' object data from a json structure
  
          There are two valid styles for service specs:
  
          the "old" style:
  
          .. code:: yaml
  
              service_type: nfs
              service_id: foo
              pool: mypool
              namespace: myns
  
          and the "new" style:
  
          .. code:: yaml
  
              service_type: nfs
              service_id: foo
              config:
                some_option: the_value
              networks: [10.10.0.0/16]
              spec:
                pool: mypool
                namespace: myns
  
          In https://tracker.ceph.com/issues/45321 we decided that we'd like to
          prefer the new style as it is more readable and provides a better
          understanding of what fields are special for a give service type.
  
          Note, we'll need to stay compatible with both versions for the
          the next two major releases (octoups, pacific).
  
          :param json_spec: A valid dict with ServiceSpec
  
          :meta private:
          """
          if not isinstance(json_spec, dict):
              raise SpecValidationError(
                  f'Service Spec is not an (JSON or YAML) object. got "{str(json_spec)}"')
  
          json_spec = cls.normalize_json(json_spec)
  
          c = json_spec.copy()
  
          # kludge to make `from_json` compatible to `Orchestrator.describe_service`
          # Open question: Remove `service_id` form to_json?
          if c.get('service_name', ''):
              service_type_id = c['service_name'].split('.', 1)
  
              if not c.get('service_type', ''):
                  c['service_type'] = service_type_id[0]
              if not c.get('service_id', '') and len(service_type_id) > 1:
                  c['service_id'] = service_type_id[1]
              del c['service_name']
  
          service_type = c.get('service_type', '')
          _cls = cls._cls(service_type)
  
          if 'status' in c:
              del c['status']  # kludge to make us compatible to `ServiceDescription.to_json()`
  
          return _cls._from_json_impl(c)
function_tokens: def from_json ( cls : Type [ ServiceSpecT ] , json_spec : Dict ) -> ServiceSpecT : if not isinstance ( json_spec , dict ) : raise SpecValidationError ( f'Service Spec is not an (JSON or YAML) object. got "{str(json_spec)}"' ) json_spec = cls . normalize_json ( json_spec ) c = json_spec . copy ( ) # kludge to make `from_json` compatible to `Orchestrator.describe_service` # Open question: Remove `service_id` form to_json? if c . get ( 'service_name' , '' ) : service_type_id = c [ 'service_name' ] . split ( '.' , 1 ) if not c . get ( 'service_type' , '' ) : c [ 'service_type' ] = service_type_id [ 0 ] if not c . get ( 'service_id' , '' ) and len ( service_type_id ) > 1 : c [ 'service_id' ] = service_type_id [ 1 ] del c [ 'service_name' ] service_type = c . get ( 'service_type' , '' ) _cls = cls . _cls ( service_type ) if 'status' in c : del c [ 'status' ] # kludge to make us compatible to `ServiceDescription.to_json()` return _cls . _from_json_impl ( c )