Module: Gapic::Schema::ServiceConfigParser
- Defined in:
- lib/gapic/schema/service_config_parser.rb
Overview
Contains logic for parsing a subset of service.yaml used for the service generation
Constant Summary collapse
- CONFIG_VERSION_KEY =
"config_version"
- NAME_KEY =
"name"
- VERSION_KEY =
"version"
- ID_KEY =
"id"
- TITLE_KEY =
"title"
- APIS_KEY =
"apis"
- HTTP_KEY =
"http"
- HTTP_RULES_KEY =
"rules"
- HTTP_RULES_SELECTOR_KEY =
"selector"
- HTTP_RULES_VERBS_ALLOWED =
["get", "post", "put", "patch", "delete"].freeze
- HTTP_RULES_BODY_KEY =
"body"
- HTTP_RULES_ADDITIONAL_BINDINGS_KEY =
"additional_bindings"
- PUBS_KEY =
"publishing"
- PUBS_SHORTNAME_KEY =
"api_short_name"
- PUBS_ORGANIZATION_KEY =
"organization"
- PUBS_DOCURL_KEY =
"documentation_uri"
- PUBS_DOCTAG_KEY =
"doc_tag_prefix"
- PUBS_METHOD_SETTINGS =
"method_settings"
- DOCS_KEY =
"documentation"
- DOCS_SUMMARY_KEY =
"summary"
- DOCS_OVERVIEW_KEY =
"overview"
Class Method Summary collapse
-
.parse_api_metadata(service_yaml_text, api_metadata = nil) ⇒ Object
Populates Gapic::Model::ApiMetadata from a service yaml file.
-
.parse_service_yaml(service_yaml_text) ⇒ ::Google::Api::Service
Returns the parsed Google::Api::Service object.
Class Method Details
.parse_api_metadata(service_yaml_text, api_metadata = nil) ⇒ Object
Populates Gapic::Model::ApiMetadata from a service yaml file.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/gapic/schema/service_config_parser.rb', line 80 def service_yaml_text, = nil ||= Gapic::Model::ApiMetadata.new if service_yaml_text && !service_yaml_text.empty? service_yaml = YAML.safe_load service_yaml_text pubs_yaml = service_yaml[PUBS_KEY] || {} docs_yaml = service_yaml[DOCS_KEY] || {} .update! name: service_yaml[NAME_KEY], short_name: pubs_yaml[PUBS_SHORTNAME_KEY], title: service_yaml[TITLE_KEY], summary: docs_yaml[DOCS_SUMMARY_KEY], description: docs_yaml[DOCS_OVERVIEW_KEY], organization: pubs_yaml[PUBS_ORGANIZATION_KEY], documentation_url: pubs_yaml[PUBS_DOCURL_KEY], doc_tag_prefix: pubs_yaml[PUBS_DOCTAG_KEY], method_settings: pubs_yaml[PUBS_METHOD_SETTINGS] || {} end end |
.parse_service_yaml(service_yaml_text) ⇒ ::Google::Api::Service
Returns the parsed Google::Api::Service object. Only supports a limited subset of fields.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/gapic/schema/service_config_parser.rb', line 54 def parse_service_yaml service_yaml_text return nil unless service_yaml_text && !service_yaml_text.empty? service_yaml = YAML.safe_load service_yaml_text service = Google::Api::Service.new if service_yaml.key? CONFIG_VERSION_KEY config_ver = Google::Protobuf::UInt32Value.new config_ver.value = service_yaml[CONFIG_VERSION_KEY] service.config_version = config_ver end service.name = service_yaml[NAME_KEY] if service_yaml.key? NAME_KEY service.id = service_yaml[ID_KEY] if service_yaml.key? ID_KEY service.title = service_yaml[TITLE_KEY] if service_yaml.key? TITLE_KEY service.apis += parse_apis service_yaml[APIS_KEY] if service_yaml.key? APIS_KEY service.http = parse_http service_yaml[HTTP_KEY] if service_yaml.key? HTTP_KEY service end |