├── .editorconfig
├── .github
├── CODEOWNERS
├── auto-label.yaml
├── label-sync.yml
├── quality-checker
│ ├── main.go
│ ├── rule_documented.go
│ ├── rule_name.go
│ └── rule_registered.go
├── release-please.yml
├── renovate.json5
└── workflows
│ ├── ci.yaml
│ └── release.yaml
├── .gitignore
├── .golangci.yml
├── .release-please-config.json
├── .release-please-manifest.json
├── CHANGELOG.md
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── SECURITY.md
├── cmd
└── api-linter
│ ├── cli.go
│ ├── cli_test.go
│ ├── github_actions.go
│ ├── github_actions_test.go
│ ├── integration_test.go
│ ├── internal
│ └── testdata
│ │ ├── build_errors.proto
│ │ ├── dummy.proto
│ │ └── dummy.protoset
│ ├── main.go
│ ├── rules.go
│ ├── summary.go
│ └── summary_test.go
├── docs
├── .dockerignore
├── .gitignore
├── .prettierignore
├── .prettierrc.yaml
├── CNAME
├── Dockerfile
├── Gemfile
├── Gemfile.lock
├── _config.yml
├── _includes
│ ├── linter-aip-listing.md
│ ├── linter-breadcrumb.html
│ ├── linter-group-listing.html
│ ├── linter-nav-mobile.html
│ ├── linter-rule-summary.html
│ ├── prepositions.md
│ ├── svgs.html
│ └── toc.html
├── _layouts
│ └── default.html
├── _sass
│ ├── api-linter
│ │ ├── correct.scss
│ │ ├── summary.scss
│ │ └── tables.scss
│ ├── breadcrumbs.scss
│ ├── callouts.scss
│ ├── colors.scss
│ ├── content.scss
│ ├── footer.scss
│ ├── glue.scss
│ ├── headings.scss
│ ├── lists.scss
│ ├── sidebar.scss
│ └── syntax.scss
├── assets
│ ├── css
│ │ ├── print.scss
│ │ └── style.scss
│ ├── images
│ │ └── github.png
│ └── js
│ │ ├── global.js
│ │ └── proto-syntax.js
├── configuration.md
├── contributing.md
├── favicon.ico
├── index.md
├── rules
│ ├── 4232
│ │ ├── index.md
│ │ ├── repeated-fields.md
│ │ └── required-fields.md
│ ├── 0121
│ │ ├── index.md
│ │ ├── no-mutable-cycles.md
│ │ ├── resource-must-support-get.md
│ │ └── resource-must-support-list.md
│ ├── 0122
│ │ ├── camel-case-uris.md
│ │ ├── embedded-resource.md
│ │ ├── index.md
│ │ ├── name-suffix.md
│ │ ├── no-self-links.md
│ │ ├── resource-collection-identifiers.md
│ │ ├── resource-id-output-only.md
│ │ └── resource-reference-type.md
│ ├── 0123
│ │ ├── duplicate-resource.md
│ │ ├── index.md
│ │ ├── name-never-optional.md
│ │ ├── resource-annotation.md
│ │ ├── resource-definition-pattern.md
│ │ ├── resource-definition-type-name.md
│ │ ├── resource-definition-variables.md
│ │ ├── resource-name-components-alternate.md
│ │ ├── resource-name-field.md
│ │ ├── resource-pattern-plural.md
│ │ ├── resource-pattern-singular.md
│ │ ├── resource-pattern.md
│ │ ├── resource-plural.md
│ │ ├── resource-reference-type.md
│ │ ├── resource-singular.md
│ │ ├── resource-type-message.md
│ │ ├── resource-type-name.md
│ │ └── resource-variables.md
│ ├── 0124
│ │ ├── index.md
│ │ └── reference-same-package.md
│ ├── 0126
│ │ ├── index.md
│ │ ├── unspecified.md
│ │ └── upper-snake-values.md
│ ├── 0127
│ │ ├── http-annotation.md
│ │ ├── http-template-pattern.md
│ │ ├── http-template-syntax.md
│ │ ├── index.md
│ │ ├── resource-name-extraction.md
│ │ └── uri-leading-slash.md
│ ├── 0128
│ │ ├── index.md
│ │ ├── resource-annotations-field.md
│ │ ├── resource-reconciling-behavior.md
│ │ └── resource-reconciling-field.md
│ ├── 0131
│ │ ├── http-body.md
│ │ ├── http-method.md
│ │ ├── http-uri-name.md
│ │ ├── index.md
│ │ ├── method-signature.md
│ │ ├── request-message-name.md
│ │ ├── request-name-behavior.md
│ │ ├── request-name-field.md
│ │ ├── request-name-reference-type.md
│ │ ├── request-name-reference.md
│ │ ├── request-name-required.md
│ │ ├── request-required-fields.md
│ │ ├── request-unknown-fields.md
│ │ ├── response-message-name.md
│ │ └── synonyms.md
│ ├── 0132
│ │ ├── http-body.md
│ │ ├── http-method.md
│ │ ├── http-uri-parent.md
│ │ ├── index.md
│ │ ├── method-signature.md
│ │ ├── request-field-types.md
│ │ ├── request-message-name.md
│ │ ├── request-parent-behavior.md
│ │ ├── request-parent-field.md
│ │ ├── request-parent-reference.md
│ │ ├── request-parent-required.md
│ │ ├── request-parent-valid-reference.md
│ │ ├── request-required-fields.md
│ │ ├── request-show-deleted-required.md
│ │ ├── request-unknown-fields.md
│ │ ├── resource-reference-type.md
│ │ ├── response-message-name.md
│ │ └── response-unknown-fields.md
│ ├── 0133
│ │ ├── http-body.md
│ │ ├── http-method.md
│ │ ├── http-uri-parent.md
│ │ ├── http-uri-resource.md
│ │ ├── index.md
│ │ ├── method-signature.md
│ │ ├── request-id-field.md
│ │ ├── request-message-name.md
│ │ ├── request-parent-behavior.md
│ │ ├── request-parent-field.md
│ │ ├── request-parent-reference.md
│ │ ├── request-parent-required.md
│ │ ├── request-required-fields.md
│ │ ├── request-resource-behavior.md
│ │ ├── request-resource-field.md
│ │ ├── request-unknown-fields.md
│ │ ├── resource-reference-type.md
│ │ ├── response-lro.md
│ │ ├── response-message-name.md
│ │ └── synonyms.md
│ ├── 0134
│ │ ├── http-body.md
│ │ ├── http-method.md
│ │ ├── http-uri-name.md
│ │ ├── index.md
│ │ ├── method-signature.md
│ │ ├── request-allow-missing-field.md
│ │ ├── request-mask-field.md
│ │ ├── request-mask-required.md
│ │ ├── request-message-name.md
│ │ ├── request-required-fields.md
│ │ ├── request-resource-field.md
│ │ ├── request-resource-required.md
│ │ ├── request-unknown-fields.md
│ │ ├── response-lro.md
│ │ ├── response-message-name.md
│ │ ├── synonyms.md
│ │ └── update-mask-optional-behavior.md
│ ├── 0135
│ │ ├── force-field.md
│ │ ├── http-body.md
│ │ ├── http-method.md
│ │ ├── http-uri-name.md
│ │ ├── index.md
│ │ ├── method-signature.md
│ │ ├── request-force-field.md
│ │ ├── request-message-name.md
│ │ ├── request-name-behavior.md
│ │ ├── request-name-field.md
│ │ ├── request-name-reference.md
│ │ ├── request-name-required.md
│ │ ├── request-required-fields.md
│ │ ├── request-unknown-fields.md
│ │ ├── response-lro.md
│ │ └── response-message-name.md
│ ├── 0136
│ │ ├── declarative-standard-methods-only.md
│ │ ├── http-body.md
│ │ ├── http-method.md
│ │ ├── http-name-variable.md
│ │ ├── http-parent-variable.md
│ │ ├── http-uri-suffix.md
│ │ ├── index.md
│ │ ├── prepositions.md
│ │ ├── request-message-name.md
│ │ ├── response-message-name.md
│ │ └── verb-noun.md
│ ├── 0140
│ │ ├── abbreviations.md
│ │ ├── base64.md
│ │ ├── index.md
│ │ ├── lower-snake.md
│ │ ├── numbers.md
│ │ ├── prepositions.md
│ │ ├── reserved-words.md
│ │ ├── underscores.md
│ │ └── uri.md
│ ├── 0141
│ │ ├── count-suffix.md
│ │ ├── forbidden-types.md
│ │ └── index.md
│ ├── 0142
│ │ ├── index.md
│ │ ├── time-field-names.md
│ │ └── time-field-type.md
│ ├── 0143
│ │ ├── index.md
│ │ ├── standardized-codes.md
│ │ └── string-type.md
│ ├── 0144
│ │ ├── http-body.md
│ │ ├── http-method.md
│ │ ├── index.md
│ │ └── request-message-name.md
│ ├── 0146
│ │ ├── any.md
│ │ └── index.md
│ ├── 0148
│ │ ├── declarative-friendly-fields.md
│ │ ├── field-behavior.md
│ │ ├── human-names.md
│ │ ├── index.md
│ │ ├── ip-address-format.md
│ │ ├── uid-format.md
│ │ └── use-uid.md
│ ├── 0151
│ │ ├── index.md
│ │ ├── lro-metadata-reachable.md
│ │ ├── lro-metadata-type.md
│ │ ├── lro-response-reachable.md
│ │ ├── lro-response-type.md
│ │ ├── operation-info.md
│ │ └── response-unary.md
│ ├── 0152
│ │ ├── http-body.md
│ │ ├── http-method.md
│ │ ├── http-uri-suffix.md
│ │ ├── index.md
│ │ ├── request-message-name.md
│ │ ├── request-name-behavior.md
│ │ ├── request-name-field.md
│ │ ├── request-name-reference.md
│ │ ├── request-resource-suffix.md
│ │ └── response-message-name.md
│ ├── 0154
│ │ ├── declarative-friendly-required.md
│ │ ├── field-type.md
│ │ ├── index.md
│ │ └── no-duplicate-etag.md
│ ├── 0155
│ │ ├── index.md
│ │ └── request-id-format.md
│ ├── 0156
│ │ ├── forbidden-methods.md
│ │ └── index.md
│ ├── 0157
│ │ ├── index.md
│ │ └── request-read-mask-field.md
│ ├── 0158
│ │ ├── index.md
│ │ ├── request-page-size-field.md
│ │ ├── request-page-token-field.md
│ │ ├── request-skip-field.md
│ │ ├── response-next-page-token-field.md
│ │ ├── response-plural-first-field.md
│ │ ├── response-repeated-first-field.md
│ │ └── response-unary.md
│ ├── 0159
│ │ ├── hardcoded-hyphen.md
│ │ └── index.md
│ ├── 0162
│ │ ├── commit-http-body.md
│ │ ├── commit-http-method.md
│ │ ├── commit-http-uri-suffix.md
│ │ ├── commit-request-message-name.md
│ │ ├── commit-request-name-behavior.md
│ │ ├── commit-request-name-field.md
│ │ ├── commit-request-name-reference.md
│ │ ├── commit-response-message-name.md
│ │ ├── delete-revision-http-body.md
│ │ ├── delete-revision-http-method.md
│ │ ├── delete-revision-http-uri-suffix.md
│ │ ├── delete-revision-request-message-name.md
│ │ ├── delete-revision-request-name-behavior.md
│ │ ├── delete-revision-request-name-field.md
│ │ ├── delete-revision-request-name-reference.md
│ │ ├── delete-revision-response-message-name.md
│ │ ├── index.md
│ │ ├── rollback-http-body.md
│ │ ├── rollback-http-method.md
│ │ ├── rollback-http-uri-suffix.md
│ │ ├── rollback-request-message-name.md
│ │ ├── rollback-request-name-behavior.md
│ │ ├── rollback-request-name-field.md
│ │ ├── rollback-request-name-reference.md
│ │ ├── rollback-request-revision-id-behavior.md
│ │ ├── rollback-request-revision-id-field.md
│ │ ├── rollback-response-message-name.md
│ │ ├── tag-revision-http-body.md
│ │ ├── tag-revision-http-method.md
│ │ ├── tag-revision-http-uri-suffix.md
│ │ ├── tag-revision-request-message-name.md
│ │ ├── tag-revision-request-name-behavior.md
│ │ ├── tag-revision-request-name-field.md
│ │ ├── tag-revision-request-name-reference.md
│ │ ├── tag-revision-request-tag-behavior.md
│ │ ├── tag-revision-request-tag-field.md
│ │ └── tag-revision-response-message-name.md
│ ├── 0163
│ │ ├── declarative-friendly-required.md
│ │ ├── index.md
│ │ └── synonyms.md
│ ├── 0164
│ │ ├── http-body.md
│ │ ├── http-method.md
│ │ ├── http-uri-suffix.md
│ │ ├── index.md
│ │ ├── request-message-name.md
│ │ ├── request-name-behavior.md
│ │ ├── request-name-field.md
│ │ ├── request-name-reference.md
│ │ ├── request-unknown-fields.md
│ │ ├── resource-expire-time-field.md
│ │ ├── response-lro.md
│ │ └── response-message-name.md
│ ├── 0165
│ │ ├── http-body.md
│ │ ├── http-method.md
│ │ ├── http-parent-variable.md
│ │ ├── http-uri-suffix.md
│ │ ├── index.md
│ │ ├── request-filter-behavior.md
│ │ ├── request-filter-field.md
│ │ ├── request-force-field.md
│ │ ├── request-message-name.md
│ │ ├── request-parent-behavior.md
│ │ ├── request-parent-field.md
│ │ ├── request-parent-reference.md
│ │ ├── response-message-name.md
│ │ ├── response-purge-count-field.md
│ │ ├── response-purge-sample-field.md
│ │ └── response-purge-sample-reference.md
│ ├── 0191
│ │ ├── csharp-namespace.md
│ │ ├── file-layout.md
│ │ ├── file-option-consistency.md
│ │ ├── filenames.md
│ │ ├── index.md
│ │ ├── java-multiple-files.md
│ │ ├── java-outer-classname.md
│ │ ├── java-package.md
│ │ ├── php-namespace.md
│ │ ├── proto-package.md
│ │ ├── proto-version.md
│ │ └── ruby-package.md
│ ├── 0192
│ │ ├── absolute-links.md
│ │ ├── deprecated-comment.md
│ │ ├── has-comments.md
│ │ ├── index.md
│ │ ├── no-html.md
│ │ ├── no-markdown-headings.md
│ │ ├── no-markdown-tables.md
│ │ ├── only-leading-comments.md
│ │ └── trademarked-names.md
│ ├── 0202
│ │ ├── index.md
│ │ └── string-only-format.md
│ ├── 0203
│ │ ├── field-behavior-required.md
│ │ ├── index.md
│ │ ├── resource-identifier-only.md
│ │ ├── resource-name-identifier.md
│ │ └── unordered-list-repeated.md
│ ├── 0214
│ │ ├── index.md
│ │ ├── resource-expiry.md
│ │ └── ttl-type.md
│ ├── 0215
│ │ ├── foreign-type-reference.md
│ │ ├── index.md
│ │ └── versioned-packages.md
│ ├── 0216
│ │ ├── index.md
│ │ ├── nesting.md
│ │ ├── state-field-output-only.md
│ │ ├── synonyms.md
│ │ └── value-synonyms.md
│ ├── 0217
│ │ ├── index.md
│ │ ├── return-partial-success-type.md
│ │ ├── return-partial-success-with-unreachable.md
│ │ ├── synonyms.md
│ │ └── unreachable-field-type.md
│ ├── 0231
│ │ ├── http-body.md
│ │ ├── http-method.md
│ │ ├── http-uri-suffix.md
│ │ ├── index.md
│ │ ├── plural-method-name.md
│ │ ├── request-message-name.md
│ │ ├── request-names-behavior.md
│ │ ├── request-names-field.md
│ │ ├── request-names-reference.md
│ │ ├── request-parent-field.md
│ │ ├── request-parent-reference.md
│ │ ├── request-unknown-fields.md
│ │ ├── response-message-name.md
│ │ └── response-resource-field.md
│ ├── 0233
│ │ ├── http-body.md
│ │ ├── http-method.md
│ │ ├── http-uri-suffix.md
│ │ ├── index.md
│ │ ├── plural-method-name.md
│ │ ├── request-message-name.md
│ │ ├── request-parent-field.md
│ │ ├── request-parent-reference.md
│ │ ├── request-requests-behavior.md
│ │ ├── request-requests-field.md
│ │ ├── request-unknown-fields.md
│ │ ├── resource-reference-type.md
│ │ ├── response-message-name.md
│ │ └── response-resource-field.md
│ ├── 0234
│ │ ├── http-body.md
│ │ ├── http-method.md
│ │ ├── http-uri-suffix.md
│ │ ├── index.md
│ │ ├── plural-method-name.md
│ │ ├── request-message-name.md
│ │ ├── request-parent-field.md
│ │ ├── request-parent-reference.md
│ │ ├── request-requests-behavior.md
│ │ ├── request-requests-field.md
│ │ ├── request-unknown-fields.md
│ │ ├── response-message-name.md
│ │ └── response-resource-field.md
│ ├── 0235
│ │ ├── http-body.md
│ │ ├── http-method.md
│ │ ├── http-uri-suffix.md
│ │ ├── index.md
│ │ ├── plural-method-name.md
│ │ ├── request-message-name.md
│ │ ├── request-names-behavior.md
│ │ ├── request-names-field.md
│ │ ├── request-names-reference.md
│ │ ├── request-parent-field.md
│ │ ├── request-parent-reference.md
│ │ ├── request-requests-behavior.md
│ │ ├── request-unknown-fields.md
│ │ ├── response-message-name.md
│ │ └── response-resource-field.md
│ ├── client-libraries.md
│ ├── cloud.md
│ ├── core.md
│ └── index.md
├── serve.sh
└── support
│ └── search.html
├── go.mod
├── go.sum
├── internal
└── version.go
├── lint
├── config.go
├── config_test.go
├── lint.go
├── lint_test.go
├── problem.go
├── problem_test.go
├── response.go
├── rule.go
├── rule_aliases.go
├── rule_enabled.go
├── rule_enabled_test.go
├── rule_groups.go
├── rule_groups_test.go
├── rule_name.go
├── rule_name_test.go
├── rule_registry.go
├── rule_registry_test.go
├── rule_test.go
├── rule_urls.go
└── rule_urls_test.go
├── locations
├── descriptor_locations.go
├── descriptor_locations_test.go
├── field_locations.go
├── field_locations_test.go
├── file_locations.go
├── file_locations_test.go
├── locations.go
├── locations_test.go
├── message_locations.go
├── message_locations_test.go
├── method_locations.go
└── method_locations_test.go
└── rules
├── aip0121
├── aip0121.go
├── aip0121_test.go
├── no_mutable_cycles.go
├── no_mutable_cycles_test.go
├── resource_must_support_get.go
├── resource_must_support_get_test.go
├── resource_must_support_list.go
└── resource_must_support_list_test.go
├── aip0122
├── aip0122.go
├── api0122_test.go
├── camel_case_uris.go
├── camel_case_uris_test.go
├── embedded_resource.go
├── embedded_resource_test.go
├── name_suffix.go
├── name_suffix_test.go
├── no_self_links.go
├── no_self_links_test.go
├── resource_collection_identifiers.go
├── resource_collection_identifiers_test.go
├── resource_id_output_only.go
├── resource_id_output_only_test.go
├── resource_reference_type.go
└── resource_reference_type_test.go
├── aip0123
├── aip0123.go
├── aip0123_test.go
├── duplicate_resource.go
├── duplicate_resource_test.go
├── name_never_optional.go
├── name_never_optional_test.go
├── resource_annotation.go
├── resource_annotation_test.go
├── resource_definition_pattern.go
├── resource_definition_pattern_test.go
├── resource_definition_type_name.go
├── resource_definition_type_name_test.go
├── resource_definition_variables.go
├── resource_definition_variables_test.go
├── resource_name_components_alternate.go
├── resource_name_components_alternate_test.go
├── resource_name_field.go
├── resource_name_field_test.go
├── resource_pattern.go
├── resource_pattern_plural.go
├── resource_pattern_plural_test.go
├── resource_pattern_singular.go
├── resource_pattern_singular_test.go
├── resource_pattern_test.go
├── resource_plural.go
├── resource_plural_test.go
├── resource_reference_type.go
├── resource_reference_type_test.go
├── resource_singular.go
├── resource_singular_test.go
├── resource_type_message.go
├── resource_type_message_test.go
├── resource_type_name.go
├── resource_type_name_test.go
├── resource_variables.go
└── resource_variables_test.go
├── aip0124
├── aip0124.go
├── aip0124_test.go
├── reference_same_package.go
└── reference_same_package_test.go
├── aip0126
├── aip0126.go
├── aip0126_test.go
├── unspecified.go
├── unspecified_test.go
├── upper_snake_values.go
└── upper_snake_values_test.go
├── aip0127
├── aip0127.go
├── aip0127_test.go
├── http_annotation.go
├── http_annotation_test.go
├── http_template_pattern.go
├── http_template_pattern_test.go
├── http_template_syntax.go
├── http_template_syntax_test.go
├── resource_name_extraction.go
├── resource_name_extraction_test.go
├── uri_leading_slash.go
└── uri_leading_slash_test.go
├── aip0128
├── aip0128.go
├── aip0128_test.go
├── resource_annotations_field.go
├── resource_annotations_field_test.go
├── resource_reconciling_behavior.go
├── resource_reconciling_behavior_test.go
├── resource_reconciling_field.go
└── resource_reconciling_field_test.go
├── aip0131
├── aip0131.go
├── aip0131_test.go
├── http_body.go
├── http_body_test.go
├── http_method.go
├── http_method_test.go
├── http_uri_name.go
├── http_uri_name_test.go
├── method_signature.go
├── method_signature_test.go
├── request_message_name.go
├── request_message_name_test.go
├── request_name_behavior.go
├── request_name_behavior_test.go
├── request_name_field.go
├── request_name_field_test.go
├── request_name_reference.go
├── request_name_reference_test.go
├── request_name_reference_type.go
├── request_name_reference_type_test.go
├── request_name_required.go
├── request_name_required_test.go
├── request_required_fields.go
├── request_required_fields_test.go
├── request_unknown_fields.go
├── request_unknown_fields_test.go
├── response_message_name.go
├── response_message_name_test.go
├── synonyms.go
└── synonyms_test.go
├── aip0132
├── aip0132.go
├── aip0132_test.go
├── http_body.go
├── http_body_test.go
├── http_method.go
├── http_method_test.go
├── http_uri_parent.go
├── http_uri_parent_test.go
├── method_signature.go
├── method_signature_test.go
├── request_field_types.go
├── request_field_types_test.go
├── request_message_name.go
├── request_message_name_test.go
├── request_parent_behavior.go
├── request_parent_behavior_test.go
├── request_parent_field.go
├── request_parent_field_test.go
├── request_parent_reference.go
├── request_parent_reference_test.go
├── request_parent_required.go
├── request_parent_required_test.go
├── request_parent_valid_reference.go
├── request_parent_valid_reference_test.go
├── request_required_fields.go
├── request_required_fields_test.go
├── request_show_deleted_required.go
├── request_show_deleted_required_test.go
├── request_unknown_fields.go
├── request_unknown_fields_test.go
├── resource_reference_type.go
├── resource_reference_type_test.go
├── response_message_name.go
├── response_message_name_test.go
├── response_unknown_fields.go
└── response_unknown_fields_test.go
├── aip0133
├── aip0133.go
├── aip0133_test.go
├── http_body.go
├── http_body_test.go
├── http_method.go
├── http_method_test.go
├── http_uri_parent.go
├── http_uri_parent_test.go
├── http_uri_resource.go
├── http_uri_resource_test.go
├── method_signature.go
├── method_signature_test.go
├── request_id_field.go
├── request_id_field_test.go
├── request_message_name.go
├── request_message_name_test.go
├── request_parent_behavior.go
├── request_parent_behavior_test.go
├── request_parent_field.go
├── request_parent_field_test.go
├── request_parent_reference.go
├── request_parent_reference_test.go
├── request_parent_required.go
├── request_parent_required_test.go
├── request_required_fields.go
├── request_required_fields_test.go
├── request_resource_behavior.go
├── request_resource_behavior_test.go
├── request_resource_field.go
├── request_resource_field_test.go
├── request_unknown_fields.go
├── request_unknown_fields_test.go
├── resource_reference_type.go
├── resource_reference_type_test.go
├── response_lro.go
├── response_lro_test.go
├── response_message_name.go
├── response_message_name_test.go
├── synonyms.go
└── synonyms_test.go
├── aip0134
├── aip0134.go
├── aip0134_test.go
├── http_body.go
├── http_body_test.go
├── http_method.go
├── http_method_test.go
├── http_uri_name.go
├── http_uri_name_test.go
├── method_signature.go
├── method_signature_test.go
├── request_allow_missing_field.go
├── request_allow_missing_field_test.go
├── request_mask_field.go
├── request_mask_field_test.go
├── request_mask_required.go
├── request_mask_required_test.go
├── request_message_name.go
├── request_message_name_test.go
├── request_required_fields.go
├── request_required_fields_test.go
├── request_resource_field.go
├── request_resource_field_test.go
├── request_resource_required.go
├── request_resource_required_test.go
├── request_unknown_fields.go
├── request_unknown_fields_test.go
├── response_lro.go
├── response_lro_test.go
├── response_message_name.go
├── response_message_name_test.go
├── synonyms.go
├── synonyms_test.go
├── update_mask_optional_behavior.go
└── update_mask_optional_behavior_test.go
├── aip0135
├── aip0135.go
├── aip0135_test.go
├── force_field.go
├── force_field_test.go
├── http_body.go
├── http_body_test.go
├── http_method.go
├── http_method_test.go
├── http_uri_name.go
├── http_uri_name_test.go
├── method_signature.go
├── method_signature_test.go
├── request_force_field.go
├── request_force_field_test.go
├── request_message_name.go
├── request_message_name_test.go
├── request_name_behavior.go
├── request_name_behavior_test.go
├── request_name_field.go
├── request_name_field_test.go
├── request_name_reference.go
├── request_name_reference_test.go
├── request_name_required.go
├── request_name_required_test.go
├── request_required_fields.go
├── request_required_fields_test.go
├── request_unknown_fields.go
├── request_unknown_fields_test.go
├── response_lro.go
├── response_lro_test.go
├── response_message_name.go
└── response_message_name_test.go
├── aip0136
├── aip0136.go
├── aip0136_test.go
├── declarative_standard_methods_only.go
├── declarative_standard_methods_only_test.go
├── http_body.go
├── http_body_test.go
├── http_method.go
├── http_method_test.go
├── http_name_variable.go
├── http_name_variable_test.go
├── http_parent_variable.go
├── http_parent_variable_test.go
├── http_uri_suffix.go
├── http_uri_suffix_test.go
├── prepositions.go
├── prepositions_test.go
├── request_message_name.go
├── request_message_name_test.go
├── response_message_name.go
├── response_message_name_test.go
├── verb_noun.go
└── verb_noun_test.go
├── aip0140
├── abbreviations.go
├── abbreviations_test.go
├── aip0140.go
├── aip0140_test.go
├── base64.go
├── base64_test.go
├── lower_snake.go
├── lower_snake_test.go
├── numbers.go
├── numbers_test.go
├── prepositions.go
├── prepositions_test.go
├── reserved_words.go
├── reserved_words_test.go
├── underscores.go
├── underscores_test.go
├── uri.go
└── uri_test.go
├── aip0141
├── aip0141.go
├── aip0141_test.go
├── count_suffix.go
├── count_suffix_test.go
├── forbidden_types.go
└── forbidden_types_test.go
├── aip0142
├── aip0142.go
├── aip0142_test.go
├── time_field_names.go
├── time_field_names_test.go
├── time_field_type.go
└── time_field_type_test.go
├── aip0143
├── aip0143.go
├── aip0143_test.go
├── standardized_codes.go
├── standardized_codes_test.go
├── string_type.go
└── string_type_test.go
├── aip0144
├── aip0144.go
├── aip0144_test.go
├── http_body.go
├── http_body_test.go
├── http_method.go
├── http_method_test.go
├── request_message_name.go
└── request_message_name_test.go
├── aip0146
├── aip0146.go
├── aip0146_test.go
├── any.go
└── any_test.go
├── aip0148
├── aip0148.go
├── aip0148_test.go
├── declarative_friendly_fields.go
├── declarative_friendly_fields_test.go
├── field_behavior.go
├── field_behavior_test.go
├── human_names.go
├── human_names_test.go
├── ip_address_format.go
├── ip_address_format_test.go
├── uid_format.go
├── uid_format_test.go
├── use_uid.go
└── use_uid_test.go
├── aip0151
├── aip0151.go
├── aip0151_test.go
├── lro_metadata_reachable.go
├── lro_metadata_reachable_test.go
├── lro_metadata_type.go
├── lro_metadata_type_test.go
├── lro_response_reachable.go
├── lro_response_reachable_test.go
├── lro_response_type.go
├── lro_response_type_test.go
├── operation_info.go
├── operation_info_test.go
├── response_unary.go
└── response_unary_test.go
├── aip0152
├── aip0152.go
├── aip0152_test.go
├── http_body.go
├── http_body_test.go
├── http_method.go
├── http_method_test.go
├── http_uri_suffix.go
├── http_uri_suffix_test.go
├── request_message_name.go
├── request_message_name_test.go
├── request_name_behavior.go
├── request_name_behavior_test.go
├── request_name_field.go
├── request_name_field_test.go
├── request_name_reference.go
├── request_name_reference_test.go
├── request_resource_suffix.go
├── request_resource_suffix_test.go
├── response_message_name.go
└── response_message_name_test.go
├── aip0154
├── aip0154.go
├── aip0154_test.go
├── declarative_friendly_required.go
├── declarative_friendly_required_test.go
├── field_type.go
├── field_type_test.go
├── no_duplicate_etag.go
└── no_duplicate_etag_test.go
├── aip0155
├── aip0155.go
├── aip0155_test.go
├── request_id_format.go
└── request_id_format_test.go
├── aip0156
├── aip0156.go
├── aip0156_test.go
├── forbidden_methods.go
└── forbidden_methods_test.go
├── aip0157
├── aip0157.go
├── request_read_mask_field.go
└── request_read_mask_field_test.go
├── aip0158
├── aip0158.go
├── aip0158_test.go
├── request_page_size_field.go
├── request_page_size_field_test.go
├── request_page_token_field.go
├── request_page_token_field_test.go
├── request_skip_field.go
├── request_skip_field_test.go
├── response_next_page_token_field.go
├── response_next_page_token_field_test.go
├── response_plural_first_field.go
├── response_plural_first_field_test.go
├── response_repeated_first_field.go
├── response_repeated_first_field_test.go
├── response_unary.go
└── response_unary_test.go
├── aip0159
├── aip0159.go
├── aip0159_test.go
├── hardcoded_hyphen.go
└── hardcoded_hyphen_test.go
├── aip0162
├── aip0162.go
├── commit_http_body.go
├── commit_http_body_test.go
├── commit_http_method.go
├── commit_http_method_test.go
├── commit_http_uri_suffix.go
├── commit_http_uri_suffix_test.go
├── commit_request_message_name.go
├── commit_request_message_name_test.go
├── commit_request_name_behavior.go
├── commit_request_name_behavior_test.go
├── commit_request_name_field.go
├── commit_request_name_field_test.go
├── commit_request_name_reference.go
├── commit_request_name_reference_test.go
├── commit_response_message_name.go
├── commit_response_message_name_test.go
├── delete_revision_http_body.go
├── delete_revision_http_body_test.go
├── delete_revision_http_method.go
├── delete_revision_http_method_test.go
├── delete_revision_http_uri_suffix.go
├── delete_revision_http_uri_suffix_test.go
├── delete_revision_request_message_name.go
├── delete_revision_request_message_name_test.go
├── delete_revision_request_name_behavior.go
├── delete_revision_request_name_behavior_test.go
├── delete_revision_request_name_field.go
├── delete_revision_request_name_field_test.go
├── delete_revision_request_name_reference.go
├── delete_revision_request_name_reference_test.go
├── delete_revision_response_message_name.go
├── delete_revision_response_message_name_test.go
├── rollback_http_body.go
├── rollback_http_body_test.go
├── rollback_http_method.go
├── rollback_http_method_test.go
├── rollback_http_uri_suffix.go
├── rollback_http_uri_suffix_test.go
├── rollback_request_message_name.go
├── rollback_request_message_name_test.go
├── rollback_request_name_behavior.go
├── rollback_request_name_behavior_test.go
├── rollback_request_name_field.go
├── rollback_request_name_field_test.go
├── rollback_request_name_reference.go
├── rollback_request_name_reference_test.go
├── rollback_request_revision_id_behavior.go
├── rollback_request_revision_id_behavior_test.go
├── rollback_request_revision_id_field.go
├── rollback_request_revision_id_field_test.go
├── rollback_response_message_name.go
├── rollback_response_message_name_test.go
├── tag_revision_http_body.go
├── tag_revision_http_body_test.go
├── tag_revision_http_method.go
├── tag_revision_http_method_test.go
├── tag_revision_http_uri_suffix.go
├── tag_revision_http_uri_suffix_test.go
├── tag_revision_request_message_name.go
├── tag_revision_request_message_name_test.go
├── tag_revision_request_name_behavior.go
├── tag_revision_request_name_behavior_test.go
├── tag_revision_request_name_field.go
├── tag_revision_request_name_field_test.go
├── tag_revision_request_name_reference.go
├── tag_revision_request_name_reference_test.go
├── tag_revision_request_tag_behavior.go
├── tag_revision_request_tag_behavior_test.go
├── tag_revision_request_tag_field.go
├── tag_revision_request_tag_field_test.go
├── tag_revision_response_message_name.go
└── tag_revision_response_message_name_test.go
├── aip0163
├── aip0163.go
├── aip0163_test.go
├── declarative_friendly_required.go
├── declarative_friendly_required_test.go
├── synonyms.go
└── synonyms_test.go
├── aip0164
├── aip0164.go
├── aip0164_test.go
├── http_body.go
├── http_body_test.go
├── http_method.go
├── http_method_test.go
├── http_uri_suffix.go
├── http_uri_suffix_test.go
├── request_message_name.go
├── request_message_name_test.go
├── request_name_behavior.go
├── request_name_behavior_test.go
├── request_name_field.go
├── request_name_field_test.go
├── request_name_reference.go
├── request_name_reference_test.go
├── request_unknown_fields.go
├── request_unknown_fields_test.go
├── resource_expire_time_field.go
├── resource_expire_time_field_test.go
├── response_lro.go
├── response_lro_test.go
├── response_message_name.go
└── response_message_name_test.go
├── aip0165
├── aip0165.go
├── aip0165_test.go
├── http_body.go
├── http_body_test.go
├── http_method.go
├── http_method_test.go
├── http_parent_variable.go
├── http_parent_variable_test.go
├── http_uri_suffix.go
├── http_uri_suffix_test.go
├── request_filter_behavior.go
├── request_filter_behavior_test.go
├── request_filter_field.go
├── request_filter_field_test.go
├── request_force_field.go
├── request_force_field_test.go
├── request_message_name.go
├── request_message_name_test.go
├── request_parent_behavior.go
├── request_parent_behavior_test.go
├── request_parent_field.go
├── request_parent_field_test.go
├── request_parent_reference.go
├── request_parent_reference_test.go
├── response_message_name.go
├── response_message_name_test.go
├── response_purge_count_field.go
├── response_purge_count_field_test.go
├── response_purge_sample_field.go
├── response_purge_sample_field_test.go
├── response_purge_sample_reference.go
└── response_purge_sample_reference_test.go
├── aip0191
├── aip0191.go
├── aip0191_test.go
├── csharp_namespace.go
├── csharp_namespace_test.go
├── file_layout.go
├── file_layout_test.go
├── file_option_consistency.go
├── file_option_consistency_test.go
├── filenames.go
├── filenames_test.go
├── java_multiple_files.go
├── java_multiple_files_test.go
├── java_outer_classname.go
├── java_outer_classname_test.go
├── java_package.go
├── java_package_test.go
├── php_namespace.go
├── php_namespace_test.go
├── proto_package.go
├── proto_package_test.go
├── proto_version.go
├── proto_version_test.go
├── ruby_package.go
└── ruby_package_test.go
├── aip0192
├── absolute_links.go
├── absolute_links_test.go
├── aip0192.go
├── aip0192_test.go
├── deprecated_comment.go
├── deprecated_test.go
├── has_comments.go
├── has_comments_test.go
├── no_html.go
├── no_html_test.go
├── no_markdown_headings.go
├── no_markdown_headings_test.go
├── no_markdown_tables.go
├── no_markdown_tables_test.go
├── only_leading_comments.go
├── only_leading_comments_test.go
├── trademarked_names.go
└── trademarked_names_test.go
├── aip0202
├── aip0202.go
├── aip0202_test.go
├── string_only_format.go
└── string_only_format_test.go
├── aip0203
├── aip0203.go
├── aip0203_test.go
├── field_behavior_required.go
├── field_behavior_required_test.go
├── resource_identifier_only.go
├── resource_identifier_only_test.go
├── resource_name_identifier.go
├── resource_name_identifier_test.go
├── unordered_list_repeated.go
└── unordered_list_repeated_test.go
├── aip0214
├── aip0214.go
├── aip0214_test.go
├── resource_expiry.go
├── resource_expiry_test.go
├── ttl_type.go
└── ttl_type_test.go
├── aip0215
├── aip0215.go
├── aip0215_test.go
├── foreign_type_reference.go
├── foreign_type_reference_test.go
├── versioned_packages.go
└── versioned_packages_test.go
├── aip0216
├── aip0216.go
├── aip0216_test.go
├── nesting.go
├── nesting_test.go
├── state_field_output_only.go
├── state_field_output_only_test.go
├── synonyms.go
├── synonyms_test.go
├── value_synonyms.go
└── value_synonyms_test.go
├── aip0217
├── aip0217.go
├── aip0217_test.go
├── return_partial_success_type.go
├── return_partial_success_type_test.go
├── return_partial_success_with_unreachable.go
├── return_partial_success_with_unreachable_test.go
├── synonyms.go
├── synonyms_test.go
├── unreachable_field_type.go
└── unreachable_field_type_test.go
├── aip0231
├── aip0231.go
├── aip0231_test.go
├── http_body.go
├── http_body_test.go
├── http_method.go
├── http_method_test.go
├── http_uri_suffix.go
├── http_uri_suffix_test.go
├── plural_method_name.go
├── plural_method_name_test.go
├── request_message_name.go
├── request_message_name_test.go
├── request_names_behavior.go
├── request_names_behavior_test.go
├── request_names_field.go
├── request_names_field_test.go
├── request_names_reference.go
├── request_names_reference_test.go
├── request_parent_field.go
├── request_parent_field_test.go
├── request_parent_reference.go
├── request_parent_reference_test.go
├── request_unknown_fields.go
├── request_unknown_fields_test.go
├── response_message_name.go
├── response_message_name_test.go
├── response_resource_field.go
└── response_resource_field_test.go
├── aip0233
├── aip0233.go
├── aip0233_test.go
├── http_body.go
├── http_body_test.go
├── http_method.go
├── http_method_test.go
├── http_uri_suffix.go
├── http_uri_suffix_test.go
├── plural_method_name.go
├── plural_method_name_test.go
├── request_message_name.go
├── request_message_name_test.go
├── request_parent_field.go
├── request_parent_field_test.go
├── request_parent_reference.go
├── request_parent_reference_test.go
├── request_requests_behavior.go
├── request_requests_behavior_test.go
├── request_requests_field.go
├── request_requests_field_test.go
├── request_unknown_fields.go
├── request_unknown_fields_test.go
├── resource_reference_type.go
├── resource_reference_type_test.go
├── response_message_name.go
├── response_message_name_test.go
├── response_resource_field.go
└── response_resource_field_test.go
├── aip0234
├── aip0234.go
├── aip0234_test.go
├── http_body.go
├── http_body_test.go
├── http_method.go
├── http_method_test.go
├── http_uri_suffix.go
├── http_uri_suffix_test.go
├── plural_method_name.go
├── plural_method_name_test.go
├── request_message_name.go
├── request_message_name_test.go
├── request_parent_field.go
├── request_parent_field_test.go
├── request_parent_reference.go
├── request_parent_reference_test.go
├── request_requests_behavior.go
├── request_requests_behavior_test.go
├── request_requests_field.go
├── request_requests_field_test.go
├── request_unknown_fields.go
├── request_unknown_fields_test.go
├── response_message_name.go
├── response_message_name_test.go
├── response_resource_field.go
└── response_resource_field_test.go
├── aip0235
├── aip0235.go
├── aip0235_test.go
├── http_body.go
├── http_body_test.go
├── http_method.go
├── http_method_test.go
├── http_uri_suffix.go
├── http_uri_suffix_test.go
├── plural_method_name.go
├── plural_method_name_test.go
├── request_message_name.go
├── request_message_name_test.go
├── request_names_behavior.go
├── request_names_behavior_test.go
├── request_names_field.go
├── request_names_field_test.go
├── request_names_reference.go
├── request_names_reference_test.go
├── request_parent_field.go
├── request_parent_field_test.go
├── request_parent_reference.go
├── request_parent_reference_test.go
├── request_requests_behavior.go
├── request_requests_behavior_test.go
├── request_unknown_fields.go
├── request_unknown_fields_test.go
├── response_message_name.go
├── response_message_name_test.go
├── response_resource_field.go
└── response_resource_field_test.go
├── aip4232
├── aip4232.go
├── aip4232_test.go
├── repeated_fields.go
├── repeated_fields_test.go
├── required_fields.go
└── required_fields_test.go
├── internal
├── data
│ ├── data.go
│ └── data_test.go
├── testutils
│ ├── parse.go
│ ├── parse_test.go
│ ├── problems.go
│ └── problems_test.go
└── utils
│ ├── casing.go
│ ├── casing_test.go
│ ├── comments.go
│ ├── comments_test.go
│ ├── common_lints.go
│ ├── common_lints_test.go
│ ├── common_proto.go
│ ├── common_proto_test.go
│ ├── declarative_friendly.go
│ ├── declarative_friendly_test.go
│ ├── extension.go
│ ├── extension_test.go
│ ├── find.go
│ ├── find_test.go
│ ├── http.go
│ ├── http_test.go
│ ├── message.go
│ ├── message_test.go
│ ├── method.go
│ ├── method_test.go
│ ├── resource.go
│ ├── resource_test.go
│ ├── string_pluralize.go
│ ├── string_pluralize_test.go
│ ├── type_name.go
│ └── type_name_test.go
├── rules.go
└── rules_test.go
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig is awesome: http://EditorConfig.org
2 |
3 | # top-most EditorConfig file
4 | root = true
5 |
6 | # Unix-style newlines with a newline ending every file
7 | [*]
8 | end_of_line = lf
9 | insert_final_newline = true
10 |
11 | # Matches multiple files with brace expansion notation
12 | # Set default charset
13 | [*.go]
14 | indent_style = tab
15 | indent_size = 2
16 | trim_trailing_whitespace = true
17 |
--------------------------------------------------------------------------------
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # The API linter team owns this repository.
2 | * @googleapis/api-linter
3 |
--------------------------------------------------------------------------------
/.github/auto-label.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | product: false
3 |
--------------------------------------------------------------------------------
/.github/label-sync.yml:
--------------------------------------------------------------------------------
1 | ignored: true
2 |
--------------------------------------------------------------------------------
/.github/quality-checker/rule_documented.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package main
16 |
17 | import (
18 | "fmt"
19 | "os"
20 | )
21 |
22 | func checkRuleDocumented(aip int, name string) []error {
23 | // Ensure that the expected documentation file exists.
24 | wantFile := fmt.Sprintf("docs/rules/%04d/%s.md", aip, name)
25 | if _, err := os.ReadFile(wantFile); err != nil {
26 | return []error{fmt.Errorf("missing rule documentation: %s", wantFile)}
27 | }
28 | return nil
29 | }
30 |
--------------------------------------------------------------------------------
/.github/release-please.yml:
--------------------------------------------------------------------------------
1 | handleGHRelease: true
2 | manifest: true
3 | manifestFile: .release-please-manifest.json
4 | manifestConfig: .release-please-config.json
5 | releaseType: go-yoshi
6 | changelogPath: CHANGELOG.md
7 |
--------------------------------------------------------------------------------
/.github/renovate.json5:
--------------------------------------------------------------------------------
1 | {
2 | extends: [
3 | "config:base",
4 | "group:all",
5 | "schedule:weekly",
6 | ":semanticCommitTypeAll(chore)"
7 | ],
8 | labels: ["automerge"],
9 | postUpdateOptions: ["gomodTidy"],
10 | packageRules: [
11 | {
12 | matchPackageNames: [
13 | "bitbucket.org/creachadair/stringset",
14 | "dominikh/staticcheck-action",
15 | "github.com/jhump/protoreflect",
16 | ],
17 | enabled: false
18 | }
19 | ],
20 | force: {
21 | constraints: {
22 | go: "1.23"
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | name: ci
3 | on:
4 | pull_request:
5 | branches:
6 | - main
7 | jobs:
8 | unit-tests:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v4
12 | with:
13 | fetch-depth: 1
14 | - uses: actions/setup-go@v5
15 | with:
16 | go-version-file: 'go.mod'
17 | - run: go test -race ./...
18 | lint:
19 | runs-on: ubuntu-latest
20 | steps:
21 | - uses: actions/checkout@v4
22 | with:
23 | fetch-depth: 1
24 | - uses: actions/setup-go@v5
25 | with:
26 | go-version-file: 'go.mod'
27 | - name: staticcheck
28 | uses: dominikh/staticcheck-action@v1.3.1
29 | with:
30 | version: "2024.1.1"
31 | install-go: false
32 | quality-checker:
33 | runs-on: ubuntu-latest
34 | steps:
35 | - uses: actions/checkout@v4
36 | with:
37 | fetch-depth: 1
38 | - uses: actions/setup-go@v5
39 | with:
40 | go-version-file: 'go.mod'
41 | - name: run the quality checker (which catches obvious mistakes, missing docs, etc.)
42 | run: go run ./.github/quality-checker
43 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | .vscode
3 |
4 | # Jekyll
5 | docs/default.profraw
6 | docs/_site
7 | docs/.jekyll-metadata
8 |
9 | # Vim
10 | *.sw*
11 | *.vim
12 |
13 | # Ruby
14 | .ruby-version
15 |
--------------------------------------------------------------------------------
/.golangci.yml:
--------------------------------------------------------------------------------
1 | ---
2 | linters:
3 | enable:
4 | - goimports
5 | - misspell
6 |
--------------------------------------------------------------------------------
/.release-please-config.json:
--------------------------------------------------------------------------------
1 | {
2 | "release-type": "go-yoshi",
3 | "include-component-in-tag": false,
4 | "include-v-in-tag": true,
5 | "changelog-path": "CHANGELOG.md",
6 | "packages": {
7 | ".": {
8 | "component": "api-linter"
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/.release-please-manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | ".": "1.69.2"
3 | }
4 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | docs/contributing.md
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | To report a security issue, please use [g.co/vulnz](https://g.co/vulnz).
4 |
5 | The Google Security Team will respond within 5 working days of your report on g.co/vulnz.
6 |
7 | We use g.co/vulnz for our intake, and do coordination and disclosure here using GitHub Security Advisory to privately discuss and fix the issue.
8 |
--------------------------------------------------------------------------------
/cmd/api-linter/internal/testdata/build_errors.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package foo;
4 |
5 | message Bar1 {
6 | // first build error
7 | string baz1 = 1
8 | }
9 |
10 | message Bar2 {
11 | // second build error
12 | string baz2 = 1
13 | }
14 |
--------------------------------------------------------------------------------
/cmd/api-linter/internal/testdata/dummy.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto2";
2 |
3 | package dummy;
4 |
5 | message Dummy {}
--------------------------------------------------------------------------------
/cmd/api-linter/internal/testdata/dummy.protoset:
--------------------------------------------------------------------------------
1 |
2 |
3 | dummy.protodummy"
4 | Dummy
--------------------------------------------------------------------------------
/docs/.dockerignore:
--------------------------------------------------------------------------------
1 | # Version control scaffolding
2 | .git
3 | .gitignore
4 |
5 | # Docker scaffolding
6 | Dockerfile
7 | .dockerignore
8 |
9 | # Ruby & Jekyll scaffolding
10 | _site
11 |
12 | # Translations
13 | *.mo
14 |
15 | # Mac
16 | .DS_Store
17 |
18 | # Mr Developer
19 | .mr.developer.cfg
20 | .project
21 | .pydevproject
22 |
23 | # JetBrains
24 | .idea
25 |
26 | # Built documentation
27 | docs/_build
28 | docs/_build_doc2dash
29 |
30 | # Virtual environment
31 | env/
32 | coverage.xml
33 |
34 | # Jekyll metadata
35 | .jekyll-metadata
36 |
--------------------------------------------------------------------------------
/docs/.gitignore:
--------------------------------------------------------------------------------
1 | # Jekyll
2 | default.profraw
3 | _site
4 | .jekyll-metadata
5 |
--------------------------------------------------------------------------------
/docs/.prettierignore:
--------------------------------------------------------------------------------
1 | _includes/aip-nav.html
2 | _includes/svgs.html
3 | _sass/colors.scss
4 |
--------------------------------------------------------------------------------
/docs/.prettierrc.yaml:
--------------------------------------------------------------------------------
1 | ---
2 | printWidth: 79
3 | proseWrap: always
4 | singleQuote: true
5 | trailingComma: es5
6 |
--------------------------------------------------------------------------------
/docs/CNAME:
--------------------------------------------------------------------------------
1 | linter.aip.dev
--------------------------------------------------------------------------------
/docs/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ruby:3.4-alpine
2 |
3 | # Copy the existing code into the Docker image.
4 | #
5 | # This will copy everything *at build time* (not at runtime), so it is
6 | # still important to use `--mount` to get a reasonable development loop.
7 | # This makes the image work for both purposes, though.
8 | COPY . /code/
9 | WORKDIR /code/
10 |
11 | # Install bundler and gems for this project.
12 | RUN echo "gem: --no-ri --no-rdoc" > ~/.gemrc && \
13 | apk add --no-cache alpine-sdk && \
14 | gem update --system && \
15 | gem install bundler && \
16 | bundle install && \
17 | apk del --no-cache alpine-sdk && \
18 | rm ~/.gemrc
19 |
20 | # Install git. (Jekyll expects it.)
21 | RUN apk add --no-cache git
22 |
23 | # Set environment variables that GitHub Pages expects.
24 | ENV PAGES_REPO_NWO googleapis/googleapis.github.io
25 |
26 | # Expose appropriate ports.
27 | EXPOSE 4000
28 | EXPOSE 35729
29 |
30 | # Run Jekyll's dev server.
31 | # Reminder: Use -p with `docker run` to publish ports.
32 | ENTRYPOINT ["bundle", "exec", "jekyll", "serve", \
33 | "--destination", "/site", \
34 | "--host", "0.0.0.0"]
35 |
--------------------------------------------------------------------------------
/docs/Gemfile:
--------------------------------------------------------------------------------
1 | source "https://rubygems.org"
2 |
3 | gem "jekyll"
4 | gem "webrick"
5 | gem "github-pages", group: :jekyll_plugins
6 |
--------------------------------------------------------------------------------
/docs/_config.yml:
--------------------------------------------------------------------------------
1 | ---
2 | markdown: kramdown
3 | plugins:
4 | - jekyll-redirect-from
5 | url: https://linter.aip.dev
6 | defaults:
7 | - scope:
8 | path: ''
9 | values:
10 | js:
11 | - assets/js/proto-syntax.js
12 |
--------------------------------------------------------------------------------
/docs/_includes/linter-rule-summary.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{ page.rule.name | last }} |
4 |
5 | {% if page.rule -%}
6 |
7 | Rule Group |
8 | {{ page.rule.name | first }} |
9 |
10 |
11 | AIP |
12 |
13 | {{ page.rule.aip }}
14 | |
15 |
16 | {% if page.rule.updated -%}
17 |
18 | Updated |
19 | {{ page.rule.updated }} |
20 |
21 | {% endif -%} {% endif -%}
22 |
23 |
--------------------------------------------------------------------------------
/docs/_includes/prepositions.md:
--------------------------------------------------------------------------------
1 | - after
2 | - at
3 | - before
4 | - between
5 | - but
6 | - by
7 | - except
8 | - for
9 | - from
10 | - in
11 | - including
12 | - into
13 | - of
14 | - over
15 | - since
16 | - to
17 | - toward
18 | - under
19 | - upon
20 | - with
21 | - within
22 | - without
23 |
--------------------------------------------------------------------------------
/docs/_sass/api-linter/correct.scss:
--------------------------------------------------------------------------------
1 | @import 'colors';
2 |
3 | .api-linter-incorrect pre.highlight {
4 | border-left: 4px solid $h-google-red-700;
5 | }
6 |
7 | .api-linter-correct pre.highlight {
8 | border-left: 4px solid $h-google-green-700;
9 | }
10 |
11 | @media screen {
12 | .c1.hide-screen {
13 | display: none;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/docs/_sass/api-linter/summary.scss:
--------------------------------------------------------------------------------
1 | @import 'colors';
2 |
3 | table#linter-rule-summary {
4 | background-color: $h-gm-grey-50;
5 | border: 1px solid $h-gm-grey-200;
6 | float: right;
7 | margin-top: 2px;
8 | margin-left: 10px;
9 | margin-bottom: 20px;
10 | width: 220px;
11 |
12 | @media (max-width: 800px) {
13 | display: none;
14 | }
15 |
16 | th {
17 | color: $h-gm-grey-800;
18 | font-size: 14px;
19 | padding: 8px 0px;
20 | text-align: center;
21 | }
22 |
23 | tr {
24 | td {
25 | font-size: 12px;
26 | padding: 2px 5px;
27 |
28 | &:first-child {
29 | @extend .glue-mod-font-weight-bold;
30 | color: $h-gm-grey-700;
31 | width: 60px;
32 | padding-left: 12px;
33 | }
34 | }
35 |
36 | &:last-child td {
37 | padding-bottom: 8px;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/docs/_sass/api-linter/tables.scss:
--------------------------------------------------------------------------------
1 | .api-linter-rule-listing {
2 | width: 100%;
3 |
4 | @media (max-width: 1024px) {
5 | &.glue-table--datatable.glue-table--stacked {
6 | border-top: 0px;
7 | }
8 | }
9 |
10 | &.glue-table--stacked {
11 | @media (min-width: 1024px) {
12 | td {
13 | width: 50%;
14 | }
15 | }
16 |
17 | td:before {
18 | display: none;
19 | }
20 | }
21 | }
22 |
23 | .glue-expansion-panels .glue-expansion-panel-content > div.has-rule-listing {
24 | padding: 0px;
25 | }
26 |
27 | div.aip-rule-listing {
28 | margin-top: 40px;
29 | margin-bottom: 40px;
30 | }
31 |
--------------------------------------------------------------------------------
/docs/_sass/breadcrumbs.scss:
--------------------------------------------------------------------------------
1 | ol.api-linter-breadcrumbs {
2 | margin-bottom: 0;
3 | }
4 |
--------------------------------------------------------------------------------
/docs/_sass/footer.scss:
--------------------------------------------------------------------------------
1 | @import 'colors';
2 |
3 | footer {
4 | border-top: 1px solid $h-gm-grey-300;
5 | color: $h-gm-grey-700;
6 | font-size: 13px;
7 | font-style: italic;
8 | margin-bottom: 10px;
9 | margin-top: 25px;
10 | padding-top: 10px;
11 | }
12 |
--------------------------------------------------------------------------------
/docs/_sass/headings.scss:
--------------------------------------------------------------------------------
1 | @import 'glue';
2 |
3 | // Headers
4 | .docs-component-main {
5 | h1,
6 | h2,
7 | h3,
8 | h4 {
9 | @extend .glue-headline;
10 | @extend .glue-has-top-margin;
11 |
12 | // This creates a "fake block" above the header that does not show up
13 | // anywhere but tricks the browser into thinking that the anchor is 80px
14 | // higher than it actually is.
15 | &::before {
16 | display: block;
17 | content: ' ';
18 | height: 80px;
19 | margin-top: -80px;
20 | pointer-events: none;
21 | visibility: hidden;
22 | }
23 | }
24 | h1 {
25 | @extend .glue-headline--two;
26 | @extend .glue-has-bottom-margin;
27 | }
28 | h2 {
29 | @extend .glue-headline--three;
30 | @extend .glue-has-bottom-margin;
31 | }
32 | h3 {
33 | @extend .glue-headline--four;
34 | @extend .glue-has-bottom-margin;
35 | }
36 | h4 {
37 | @extend .glue-headline--four;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/docs/_sass/lists.scss:
--------------------------------------------------------------------------------
1 | .docs-component-main {
2 | ul {
3 | margin-top: 20px;
4 | padding-left: 20px;
5 |
6 | > li > ul {
7 | margin-top: 0px;
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/docs/assets/css/style.scss:
--------------------------------------------------------------------------------
1 | ---
2 | ---
3 |
4 | @import 'breadcrumbs';
5 | @import 'callouts';
6 | @import 'colors';
7 | @import 'content';
8 | @import 'footer';
9 | @import 'headings';
10 | @import 'lists';
11 | @import 'sidebar';
12 | @import 'syntax';
13 |
14 | @import 'api-linter/correct';
15 | @import 'api-linter/summary';
16 | @import 'api-linter/tables';
17 |
--------------------------------------------------------------------------------
/docs/assets/images/github.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googleapis/api-linter/d4cd0d0540fc0dbe456897a50463a4703178cc01/docs/assets/images/github.png
--------------------------------------------------------------------------------
/docs/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/googleapis/api-linter/d4cd0d0540fc0dbe456897a50463a4703178cc01/docs/favicon.ico
--------------------------------------------------------------------------------
/docs/rules/0121/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 121
3 | permalink: /121/
4 | redirect_from:
5 | - /0121/
6 | ---
7 |
8 | # Resource names
9 |
10 | {% include linter-aip-listing.md aip=121 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0122/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 122
3 | permalink: /122/
4 | redirect_from:
5 | - /0122/
6 | ---
7 |
8 | # Resource names
9 |
10 | {% include linter-aip-listing.md aip=122 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0123/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 123
3 | permalink: /123/
4 | redirect_from:
5 | - /0123/
6 | ---
7 |
8 | # Unified resource types
9 |
10 | {% include linter-aip-listing.md aip=123 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0124/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 124
3 | permalink: /124/
4 | redirect_from:
5 | - /0124/
6 | ---
7 |
8 | # Resource association
9 |
10 | {% include linter-aip-listing.md aip=124 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0126/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 126
3 | permalink: /126/
4 | redirect_from:
5 | - /0126/
6 | ---
7 |
8 | # Enumerations
9 |
10 | {% include linter-aip-listing.md aip=126 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0127/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 127
3 | permalink: /127/
4 | redirect_from:
5 | - /0127/
6 | ---
7 |
8 | # HTTP and gRPC Transcoding
9 |
10 | {% include linter-aip-listing.md aip=127 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0127/uri-leading-slash.md:
--------------------------------------------------------------------------------
1 | ---
2 | rule:
3 | aip: 127
4 | name: [core, '0127', uri-leading-slash]
5 | summary: URIs should always begin with a leading slash.
6 | permalink: /127/uri-leading-slash
7 | redirect_from:
8 | - /0127/uri-leading-slash
9 | ---
10 |
11 | # URI Forward Slashes
12 |
13 | This rule enforces that URIs must begin with a forward slash, as mandated in
14 | [AIP-127][].
15 |
16 | ## Details
17 |
18 | This rule scans all methods and complains if it finds a URI that does not start
19 | with `/`.
20 |
21 | ## Examples
22 |
23 | **Incorrect** code for this rule:
24 |
25 | ```proto
26 | // Incorrect.
27 | rpc GetBook(GetBookRequest) returns (Book) {
28 | option (google.api.http) = {
29 | // Should be /v1/{name=publishers/*/books/*}
30 | get: "v1/{name=publishers/*/books/*}"
31 | };
32 | }
33 | ```
34 |
35 | **Correct** code for this rule:
36 |
37 | ```proto
38 | // Correct.
39 | rpc GetBook(GetBookRequest) returns (Book) {
40 | option (google.api.http) = {
41 | get: "/v1/{name=publishers/*/books/*}"
42 | };
43 | }
44 | ```
45 |
46 | ## Disabling
47 |
48 | Do not violate this rule. This would create an invalid URL.
49 |
50 | [aip-127]: https://aip.dev/127
51 |
--------------------------------------------------------------------------------
/docs/rules/0128/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 128
3 | permalink: /128/
4 | redirect_from:
5 | - /0128/
6 | prose_title: declarative-friendly interfaces
7 | ---
8 |
9 | # Declarative-friendly interfaces
10 |
11 | {% include linter-aip-listing.md aip=128 %}
12 |
--------------------------------------------------------------------------------
/docs/rules/0131/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 131
3 | permalink: /131/
4 | redirect_from:
5 | - /0131/
6 | prose_title: get methods
7 | ---
8 |
9 | # Standard methods: Get
10 |
11 | {% include linter-aip-listing.md aip=131 %}
12 |
--------------------------------------------------------------------------------
/docs/rules/0132/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 132
3 | permalink: /132/
4 | redirect_from:
5 | - /0132/
6 | prose_title: list methods
7 | ---
8 |
9 | # Standard methods: List
10 |
11 | {% include linter-aip-listing.md aip=132 %}
12 |
--------------------------------------------------------------------------------
/docs/rules/0133/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 133
3 | permalink: /133/
4 | redirect_from:
5 | - /0133/
6 | prose_title: create methods
7 | ---
8 |
9 | # Standard methods: Create
10 |
11 | {% include linter-aip-listing.md aip=133 %}
12 |
--------------------------------------------------------------------------------
/docs/rules/0134/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 134
3 | permalink: /134/
4 | redirect_from:
5 | - /0134/
6 | prose_title: update methods
7 | ---
8 |
9 | # Standard methods: Update
10 |
11 | {% include linter-aip-listing.md aip=134 %}
12 |
--------------------------------------------------------------------------------
/docs/rules/0135/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 135
3 | permalink: /135/
4 | redirect_from:
5 | - /0135/
6 | prose_title: delete methods
7 | ---
8 |
9 | # Standard methods: Delete
10 |
11 | {% include linter-aip-listing.md aip=135 %}
12 |
--------------------------------------------------------------------------------
/docs/rules/0136/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 136
3 | permalink: /136/
4 | redirect_from:
5 | - /0136/
6 | ---
7 |
8 | # Custom methods
9 |
10 | {% include linter-aip-listing.md aip=136 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0140/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 140
3 | permalink: /140/
4 | redirect_from:
5 | - /0140/
6 | ---
7 |
8 | # Field names
9 |
10 | {% include linter-aip-listing.md aip=140 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0141/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 141
3 | permalink: /141/
4 | redirect_from:
5 | - /0141/
6 | ---
7 |
8 | # Quantities
9 |
10 | {% include linter-aip-listing.md aip=141 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0142/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 142
3 | permalink: /142/
4 | redirect_from:
5 | - /0142/
6 | ---
7 |
8 | # Time and duration
9 |
10 | {% include linter-aip-listing.md aip=142 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0143/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 143
3 | permalink: /143/
4 | redirect_from:
5 | - /0143/
6 | ---
7 |
8 | # Standardized codes
9 |
10 | {% include linter-aip-listing.md aip=143 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0144/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 144
3 | permalink: /144/
4 | redirect_from:
5 | - /0144/
6 | prose_title: add/remove methods
7 | ---
8 |
9 | # Add/Remove methods
10 |
11 | {% include linter-aip-listing.md aip=144 %}
12 |
--------------------------------------------------------------------------------
/docs/rules/0146/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 146
3 | permalink: /146/
4 | redirect_from:
5 | - /0146/
6 | ---
7 |
8 | # Generic fields
9 |
10 | {% include linter-aip-listing.md aip=146 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0148/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 148
3 | permalink: /148/
4 | redirect_from:
5 | - /0148/
6 | ---
7 |
8 | # Standard fields
9 |
10 | {% include linter-aip-listing.md aip=148 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0151/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 151
3 | permalink: /151/
4 | redirect_from:
5 | - /0151/
6 | ---
7 |
8 | # Long-running operations
9 |
10 | {% include linter-aip-listing.md aip=151 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0152/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 152
3 | permalink: /152/
4 | redirect_from:
5 | - /0152/
6 | prose_title: jobs
7 | ---
8 |
9 | # Jobs
10 |
11 | {% include linter-aip-listing.md aip=152 %}
12 |
--------------------------------------------------------------------------------
/docs/rules/0154/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 154
3 | permalink: /154/
4 | redirect_from:
5 | - /0154/
6 | ---
7 |
8 | # Long-running operations
9 |
10 | {% include linter-aip-listing.md aip=154 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0155/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 155
3 | permalink: /155/
4 | redirect_from:
5 | - /0155/
6 | ---
7 |
8 | # Singleton resources
9 |
10 | {% include linter-aip-listing.md aip=155 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0156/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 156
3 | permalink: /156/
4 | redirect_from:
5 | - /0156/
6 | ---
7 |
8 | # Singleton resources
9 |
10 | {% include linter-aip-listing.md aip=156 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0157/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 157
3 | permalink: /157/
4 | redirect_from:
5 | - /0157/
6 | prose_title: partial responses
7 | ---
8 |
9 | # Partial Responses
10 |
11 | {% include linter-aip-listing.md aip=157 %}
12 |
--------------------------------------------------------------------------------
/docs/rules/0158/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 158
3 | permalink: /158/
4 | redirect_from:
5 | - /0158/
6 | ---
7 |
8 | # Pagination
9 |
10 | {% include linter-aip-listing.md aip=158 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0159/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 159
3 | permalink: /159/
4 | redirect_from:
5 | - /0159/
6 | ---
7 |
8 | # Reading across collections
9 |
10 | {% include linter-aip-listing.md aip=159 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0162/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 162
3 | permalink: /162/
4 | redirect_from:
5 | - /0162/
6 | ---
7 |
8 | # Resource revisions
9 |
10 | {% include linter-aip-listing.md aip=162 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0163/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 163
3 | permalink: /163/
4 | redirect_from:
5 | - /0163/
6 | ---
7 |
8 | # Change validation
9 |
10 | {% include linter-aip-listing.md aip=163 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0164/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 164
3 | permalink: /164/
4 | redirect_from:
5 | - /0164/
6 | ---
7 |
8 | # Soft delete
9 |
10 | {% include linter-aip-listing.md aip=164 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0165/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 165
3 | permalink: /165/
4 | redirect_from:
5 | - /0165/
6 | ---
7 |
8 | # Criteria-based delete
9 |
10 | {% include linter-aip-listing.md aip=165 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0191/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 191
3 | permalink: /191/
4 | redirect_from:
5 | - /0191/
6 | ---
7 |
8 | # File and directory structure
9 |
10 | {% include linter-aip-listing.md aip=191 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0192/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 192
3 | permalink: /192/
4 | redirect_from:
5 | - /0192/
6 | ---
7 |
8 | # Documentation
9 |
10 | {% include linter-aip-listing.md aip=192 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0202/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 202
3 | permalink: /202/
4 | redirect_from:
5 | - /0202/
6 | ---
7 |
8 | # Field behavior
9 |
10 | {% include linter-aip-listing.md aip=202 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0203/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 203
3 | permalink: /203/
4 | redirect_from:
5 | - /0203/
6 | ---
7 |
8 | # Field behavior
9 |
10 | {% include linter-aip-listing.md aip=203 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0214/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 214
3 | permalink: /214/
4 | redirect_from:
5 | - /0214/
6 | ---
7 |
8 | # States
9 |
10 | {% include linter-aip-listing.md aip=214 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0215/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 215
3 | permalink: /215/
4 | redirect_from:
5 | - /0215/
6 | ---
7 |
8 | # Common component versions
9 |
10 | {% include linter-aip-listing.md aip=215 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0216/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 216
3 | permalink: /216/
4 | redirect_from:
5 | - /0216/
6 | ---
7 |
8 | # States
9 |
10 | {% include linter-aip-listing.md aip=216 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0217/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 217
3 | permalink: /217/
4 | redirect_from:
5 | - /0217/
6 | ---
7 |
8 | # States
9 |
10 | {% include linter-aip-listing.md aip=217 %}
11 |
--------------------------------------------------------------------------------
/docs/rules/0231/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 231
3 | permalink: /231/
4 | redirect_from:
5 | - /0231/
6 | prose_title: batch get methods
7 | ---
8 |
9 | # Batch methods: Get
10 |
11 | {% include linter-aip-listing.md aip=231 %}
12 |
--------------------------------------------------------------------------------
/docs/rules/0233/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 233
3 | permalink: /233/
4 | redirect_from:
5 | - /0233/
6 | prose_title: batch create methods
7 | ---
8 |
9 | # Batch methods: Create
10 |
11 | {% include linter-aip-listing.md aip=233 %}
12 |
--------------------------------------------------------------------------------
/docs/rules/0234/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 234
3 | permalink: /234/
4 | redirect_from:
5 | - /0234/
6 | prose_title: batch update methods
7 | ---
8 |
9 | # Batch methods: Update
10 |
11 | {% include linter-aip-listing.md aip=234 %}
12 |
--------------------------------------------------------------------------------
/docs/rules/0235/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 235
3 | permalink: /235/
4 | redirect_from:
5 | - /0235/
6 | prose_title: batch delete methods
7 | ---
8 |
9 | # Batch methods: Delete
10 |
11 | {% include linter-aip-listing.md aip=235 %}
12 |
--------------------------------------------------------------------------------
/docs/rules/4232/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | aip_listing: 4232
3 | permalink: /4232/
4 | prose_title: method signatures
5 | ---
6 |
7 | # Method Signatures: Repeated fields
8 |
9 | {% include linter-aip-listing.md aip=4232 %}
10 |
--------------------------------------------------------------------------------
/docs/rules/client-libraries.md:
--------------------------------------------------------------------------------
1 | ---
2 | permalink: /rules/client-libraries/
3 | ---
4 |
5 | # Client Library rules
6 |
7 | Client library rules are based on [client library-specific AIPs][]. They are
8 | enabled by default, and **should** be enabled for APIs that ship public client
9 | libraries. It is recommended that APIs which do not want to follow certain AIPs
10 | within the client libraries section disable those rules individually, rather
11 | than disabling the client library rules as a set.
12 |
13 | {% include linter-group-listing.html start=4200 end=4299 %}
14 |
15 | [client library-specific aips]: https://aip.dev/client-libraries
16 |
--------------------------------------------------------------------------------
/docs/rules/cloud.md:
--------------------------------------------------------------------------------
1 | ---
2 | permalink: /rules/cloud/
3 | ---
4 |
5 | # Cloud rules
6 |
7 | Cloud rules are based on [Cloud-specific AIPs][]. They are not enabled by
8 | default, and should only be enabled for Cloud APIs.
9 |
10 | {% include linter-group-listing.html start=2500 end=2599 %}
11 | {% include linter-group-listing.html start=25000 end=25999 %}
12 |
13 | [Cloud-specific aips]: https://aip.dev/cloud
14 |
--------------------------------------------------------------------------------
/docs/rules/core.md:
--------------------------------------------------------------------------------
1 | ---
2 | permalink: /rules/core/
3 | ---
4 |
5 | # Core rules
6 |
7 | Core rules are based on [generally-applicable AIPs][]. They are enabled by
8 | default, and **should** be enabled for most APIs. It is recommended that APIs
9 | which do not want to follow certain AIPs within the core section disable those
10 | rules individually, rather than disabling the core rules as a set.
11 |
12 | {% include linter-group-listing.html start=100 end=999 %}
13 |
14 | [generally-applicable aips]: https://aip.dev/general
15 |
--------------------------------------------------------------------------------
/docs/support/search.html:
--------------------------------------------------------------------------------
1 | ---
2 | title: Search
3 | description: 'Search this site'
4 | permalink: /search/
5 | layout: default
6 | tipue_search_active: true
7 | exclude_from_search: true
8 | css:
9 | - /assets/css/search.css
10 | js:
11 | - /assets/js/search/tipuesearch_content.js
12 | - /assets/js/search/tipuesearch_set.js
13 | - /assets/js/search/tipuesearch.min.js
14 | ---
15 |
16 |
31 |
32 |
33 |
34 |
35 |
42 |
--------------------------------------------------------------------------------
/internal/version.go:
--------------------------------------------------------------------------------
1 | // Copyright 2023 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package internal
15 |
16 | // Version is the current tagged release of the library.
17 | const Version = "1.69.2"
18 |
--------------------------------------------------------------------------------
/lint/response.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package lint
16 |
17 | // Response describes the result returned by a rule.
18 | type Response struct {
19 | FilePath string `json:"file_path" yaml:"file_path"`
20 | Problems []Problem `json:"problems" yaml:"problems"`
21 | }
22 |
--------------------------------------------------------------------------------
/lint/rule_aliases.go:
--------------------------------------------------------------------------------
1 | package lint
2 |
3 | // aliasMap stores legacy names for some rules.
4 | // At Google, we inject rule-alias mapping into this map.
5 | // Example:
6 | // We will compile an addition file -- "google_rule_aliases.go".
7 | // ````````````````````````````````````````````````````````````
8 | // package lint
9 | //
10 | // func init() {
11 | // aliasMap["core::0140::lower-snake"] = "naming-format"
12 | // aliasMap["core::0140::enum-names::abbreviations"] = "abbreviations"
13 | // }
14 | //
15 | // ````````````````````````````````````````````````````````````
16 | var aliasMap = map[string]string{}
17 |
--------------------------------------------------------------------------------
/locations/descriptor_locations.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package locations
16 |
17 | import (
18 | "github.com/jhump/protoreflect/desc"
19 | dpb "google.golang.org/protobuf/types/descriptorpb"
20 | )
21 |
22 | // DescriptorName returns the precise location for a descriptor's name.
23 | //
24 | // This works for any descriptor, regardless of type (message, field, etc.).
25 | func DescriptorName(d desc.Descriptor) *dpb.SourceCodeInfo_Location {
26 | // All descriptors seem to have `string name = 1`, so this conveniently works.
27 | return pathLocation(d, 1)
28 | }
29 |
--------------------------------------------------------------------------------
/locations/message_locations.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package locations
16 |
17 | import (
18 | "github.com/jhump/protoreflect/desc"
19 | apb "google.golang.org/genproto/googleapis/api/annotations"
20 | dpb "google.golang.org/protobuf/types/descriptorpb"
21 | )
22 |
23 | // MessageResource returns the precise location of the `google.api.resource`
24 | // annotation.
25 | func MessageResource(m *desc.MessageDescriptor) *dpb.SourceCodeInfo_Location {
26 | return pathLocation(m, 7, int(apb.E_Resource.TypeDescriptor().Number())) // MessageDescriptor.options == 7
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0121/aip0121.go:
--------------------------------------------------------------------------------
1 | // Copyright 2023 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | // Package aip0121 contains rules defined in https://aip.dev/121.
16 | package aip0121
17 |
18 | import (
19 | "github.com/googleapis/api-linter/lint"
20 | )
21 |
22 | // AddRules accepts a register function and registers each of
23 | // this AIP's rules to it.
24 | func AddRules(r lint.RuleRegistry) error {
25 | return r.Register(
26 | 121,
27 | resourceMustSupportGet,
28 | resourceMustSupportList,
29 | noMutableCycles,
30 | )
31 | }
32 |
--------------------------------------------------------------------------------
/rules/aip0121/aip0121_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2023 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | // Package aip0121 contains rules defined in https://aip.dev/121.
16 | package aip0121
17 |
18 | import (
19 | "testing"
20 |
21 | "github.com/googleapis/api-linter/lint"
22 | )
23 |
24 | func TestAddRules(t *testing.T) {
25 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
26 | t.Errorf("AddRules got an error: %v", err)
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/rules/aip0122/aip0122.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | // Package aip0122 contains rules defined in https://aip.dev/122.
16 | package aip0122
17 |
18 | import (
19 | "github.com/googleapis/api-linter/lint"
20 | )
21 |
22 | // AddRules accepts a register function and registers each of
23 | // this AIP's rules to it.
24 | func AddRules(r lint.RuleRegistry) error {
25 | return r.Register(
26 | 122,
27 | resourceCollectionIdentifiers,
28 | httpURICase,
29 | nameSuffix,
30 | noSelfLinks,
31 | resourceReferenceType,
32 | resourceIdOutputOnly,
33 | embeddedResource,
34 | )
35 | }
36 |
--------------------------------------------------------------------------------
/rules/aip0122/api0122_test.go:
--------------------------------------------------------------------------------
1 | package aip0122
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/googleapis/api-linter/lint"
7 | )
8 |
9 | func TestAddRules(t *testing.T) {
10 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
11 | t.Errorf("AddRules got an error: %v", err)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rules/aip0124/aip0124_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0124
16 |
17 | import (
18 | "testing"
19 |
20 | "github.com/googleapis/api-linter/lint"
21 | )
22 |
23 | func TestAddRules(t *testing.T) {
24 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
25 | t.Errorf("AddRules got an error: %v", err)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0126/aip0126.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | // Package aip0126 contains rules defined in https://aip.dev/126.
16 | package aip0126
17 |
18 | import "github.com/googleapis/api-linter/lint"
19 |
20 | // AddRules adds all of the AIP-126 rules to the provided registry.
21 | func AddRules(r lint.RuleRegistry) error {
22 | return r.Register(
23 | 126,
24 | enumValueUpperSnakeCase,
25 | unspecified,
26 | )
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0126/aip0126_test.go:
--------------------------------------------------------------------------------
1 | package aip0126
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/googleapis/api-linter/lint"
7 | )
8 |
9 | func TestAddRules(t *testing.T) {
10 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
11 | t.Errorf("AddRules got an error: %v", err)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rules/aip0126/upper_snake_values.go:
--------------------------------------------------------------------------------
1 | package aip0126
2 |
3 | import (
4 | "fmt"
5 | "strings"
6 |
7 | "github.com/googleapis/api-linter/lint"
8 | "github.com/googleapis/api-linter/locations"
9 | "github.com/jhump/protoreflect/desc"
10 | "github.com/stoewer/go-strcase"
11 | )
12 |
13 | // All enum values must use UPPER_SNAKE_CASE.
14 | var enumValueUpperSnakeCase = &lint.EnumRule{
15 | Name: lint.NewRuleName(126, "upper-snake-values"),
16 | LintEnum: func(e *desc.EnumDescriptor) []lint.Problem {
17 | var problems []lint.Problem
18 | for _, v := range e.GetValues() {
19 | if got, want := v.GetName(), toUpperSnakeCase(v.GetName()); got != want {
20 | problems = append(problems, lint.Problem{
21 | Message: fmt.Sprintf("Enum value %q must use UPPER_SNAKE_CASE.", got),
22 | Suggestion: want,
23 | Descriptor: v,
24 | Location: locations.DescriptorName(v),
25 | })
26 | }
27 | }
28 | return problems
29 | },
30 | }
31 |
32 | func toUpperSnakeCase(s string) string {
33 | return strings.ToUpper(strcase.SnakeCase(s))
34 | }
35 |
--------------------------------------------------------------------------------
/rules/aip0127/aip0127.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | // Package aip0127 contains rules defined in https://aip.dev/127.
16 | package aip0127
17 |
18 | import (
19 | "github.com/googleapis/api-linter/lint"
20 | )
21 |
22 | // AddRules adds all of the AIP-127 rules to the provided registry.
23 | func AddRules(r lint.RuleRegistry) error {
24 | return r.Register(
25 | 127,
26 | hasAnnotation,
27 | httpTemplatePattern,
28 | httpTemplateSyntax,
29 | leadingSlash,
30 | resourceNameExtraction,
31 | )
32 | }
33 |
--------------------------------------------------------------------------------
/rules/aip0127/aip0127_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 | package aip0127
15 |
16 | import (
17 | "testing"
18 |
19 | "github.com/googleapis/api-linter/lint"
20 | )
21 |
22 | func TestAddRules(t *testing.T) {
23 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
24 | t.Errorf("AddRules got an error: %v", err)
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/rules/aip0128/aip0128_test.go:
--------------------------------------------------------------------------------
1 | package aip0128
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/googleapis/api-linter/lint"
7 | )
8 |
9 | func TestAddRules(t *testing.T) {
10 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
11 | t.Errorf("AddRules got an error: %v", err)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rules/aip0128/resource_reconciling_behavior.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0128
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var resourceReconcilingBehavior = &lint.FieldRule{
24 | Name: lint.NewRuleName(128, "resource-reconciling-behavior"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isDeclarativeFriendlyResource(f.GetOwner()) && f.GetName() == "reconciling"
27 | },
28 | LintField: utils.LintOutputOnlyField,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0131/aip0131_test.go:
--------------------------------------------------------------------------------
1 | package aip0131
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/googleapis/api-linter/lint"
7 | )
8 |
9 | func TestAddRules(t *testing.T) {
10 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
11 | t.Errorf("AddRules got an error: %v", err)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rules/aip0131/http_body.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0131
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Get methods should not have an HTTP body.
23 | var httpBody = &lint.MethodRule{
24 | Name: lint.NewRuleName(131, "http-body"),
25 | OnlyIf: utils.IsGetMethod,
26 | LintMethod: utils.LintNoHTTPBody,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0131/http_method.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0131
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Get methods should use the HTTP GET verb.
23 | var httpMethod = &lint.MethodRule{
24 | Name: lint.NewRuleName(131, "http-method"),
25 | OnlyIf: utils.IsGetMethod,
26 | LintMethod: utils.LintHTTPMethod("GET"),
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0131/http_uri_name.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0131
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Get methods should have a proper HTTP pattern.
23 | var httpNameField = &lint.MethodRule{
24 | Name: lint.NewRuleName(131, "http-uri-name"),
25 | OnlyIf: utils.IsGetMethod,
26 | LintMethod: utils.LintHTTPURIHasNameVariable,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0131/request_message_name.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0131
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Get messages should have a properly named Request message.
23 | var requestMessageName = &lint.MethodRule{
24 | Name: lint.NewRuleName(131, "request-message-name"),
25 | OnlyIf: utils.IsGetMethod,
26 | LintMethod: utils.LintMethodHasMatchingRequestName,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0131/request_name_behavior.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0131
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestNameBehavior = &lint.FieldRule{
24 | Name: lint.NewRuleName(131, "request-name-behavior"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return utils.IsGetRequestMessage(f.GetOwner()) && f.GetName() == "name"
27 | },
28 | LintField: utils.LintRequiredField,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0131/request_name_field.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0131
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | // Get request should have a string name field.
24 | var requestNameField = &lint.FieldRule{
25 | Name: lint.NewRuleName(131, "request-name-field"),
26 | OnlyIf: func(f *desc.FieldDescriptor) bool {
27 | return utils.IsGetRequestMessage(f.GetOwner()) && f.GetName() == "name"
28 | },
29 | LintField: utils.LintSingularStringField,
30 | }
31 |
--------------------------------------------------------------------------------
/rules/aip0131/request_name_reference.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0131
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestNameReference = &lint.FieldRule{
24 | Name: lint.NewRuleName(131, "request-name-reference"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return utils.IsGetRequestMessage(f.GetOwner()) && f.GetName() == "name"
27 | },
28 | LintField: utils.LintFieldResourceReference,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0132/aip0132_test.go:
--------------------------------------------------------------------------------
1 | package aip0132
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/googleapis/api-linter/lint"
7 | )
8 |
9 | func TestAddRules(t *testing.T) {
10 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
11 | t.Errorf("AddRules got an error: %v", err)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rules/aip0132/http_body.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0132
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // List methods should not have an HTTP body.
23 | var httpBody = &lint.MethodRule{
24 | Name: lint.NewRuleName(132, "http-body"),
25 | OnlyIf: utils.IsListMethod,
26 | LintMethod: utils.LintNoHTTPBody,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0132/http_method.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0132
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // List methods should use the HTTP GET verb.
23 | var httpMethod = &lint.MethodRule{
24 | Name: lint.NewRuleName(132, "http-method"),
25 | OnlyIf: utils.IsListMethod,
26 | LintMethod: utils.LintHTTPMethod("GET"),
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0132/request_message_name.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0132
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // List messages should have a properly named Request message.
23 | var requestMessageName = &lint.MethodRule{
24 | Name: lint.NewRuleName(132, "request-message-name"),
25 | OnlyIf: utils.IsListMethod,
26 | LintMethod: utils.LintMethodHasMatchingRequestName,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0132/request_parent_behavior.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0132
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestParentBehavior = &lint.FieldRule{
24 | Name: lint.NewRuleName(132, "request-parent-behavior"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return utils.IsListRequestMessage(f.GetOwner()) && f.GetName() == "parent"
27 | },
28 | LintField: utils.LintRequiredField,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0132/request_parent_reference.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0132
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestParentReference = &lint.FieldRule{
24 | Name: lint.NewRuleName(132, "request-parent-reference"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return utils.IsListRequestMessage(f.GetOwner()) && f.GetName() == "parent"
27 | },
28 | LintField: utils.LintFieldResourceReference,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0132/response_message_name.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0132
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // List messages should use a `ListFoosResponse` response message.
23 | var responseMessageName = &lint.MethodRule{
24 | Name: lint.NewRuleName(132, "response-message-name"),
25 | OnlyIf: utils.IsListMethod,
26 | LintMethod: utils.LintMethodHasMatchingResponseName,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0133/aip0133_test.go:
--------------------------------------------------------------------------------
1 | package aip0133
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/googleapis/api-linter/lint"
7 | )
8 |
9 | func TestAddRules(t *testing.T) {
10 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
11 | t.Errorf("AddRules got an error: %v", err)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rules/aip0133/http_method.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0133
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Create methods should use the HTTP POST verb.
23 | var httpMethod = &lint.MethodRule{
24 | Name: lint.NewRuleName(133, "http-method"),
25 | OnlyIf: utils.IsCreateMethod,
26 | LintMethod: utils.LintHTTPMethod("POST"),
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0133/request_message_name.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0133
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Create method should have a properly named input message.
23 | var inputName = &lint.MethodRule{
24 | Name: lint.NewRuleName(133, "request-message-name"),
25 | OnlyIf: utils.IsCreateMethod,
26 | LintMethod: utils.LintMethodHasMatchingRequestName,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0133/request_parent_behavior.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0133
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestParentBehavior = &lint.FieldRule{
24 | Name: lint.NewRuleName(133, "request-parent-behavior"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return utils.IsCreateRequestMessage(f.GetOwner()) && f.GetName() == "parent"
27 | },
28 | LintField: utils.LintRequiredField,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0133/request_parent_reference.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0133
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestParentReference = &lint.FieldRule{
24 | Name: lint.NewRuleName(133, "request-parent-reference"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return utils.IsCreateRequestMessage(f.GetOwner()) && f.GetName() == "parent"
27 | },
28 | LintField: utils.LintFieldResourceReference,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0134/aip0134_test.go:
--------------------------------------------------------------------------------
1 | package aip0134
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/googleapis/api-linter/lint"
7 | )
8 |
9 | func TestAddRules(t *testing.T) {
10 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
11 | t.Errorf("AddRules got an error: %v", err)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rules/aip0134/http_method.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0134
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Update methods should use the HTTP PATCH verb.
23 | var httpMethod = &lint.MethodRule{
24 | Name: lint.NewRuleName(134, "http-method"),
25 | OnlyIf: utils.IsUpdateMethod,
26 | LintMethod: utils.LintHTTPMethod("PATCH"),
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0134/request_mask_field.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0134
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestMaskField = &lint.FieldRule{
24 | Name: lint.NewRuleName(134, "request-mask-field"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return utils.IsUpdateRequestMessage(f.GetOwner()) && f.GetName() == "update_mask"
27 | },
28 | LintField: utils.LintFieldMask,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0134/request_message_name.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0134
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Update methods should have a properly named Request message.
23 | var requestMessageName = &lint.MethodRule{
24 | Name: lint.NewRuleName(134, "request-message-name"),
25 | OnlyIf: utils.IsUpdateMethod,
26 | LintMethod: utils.LintMethodHasMatchingRequestName,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0134/request_resource_required.go:
--------------------------------------------------------------------------------
1 | package aip0134
2 |
3 | import (
4 | "fmt"
5 |
6 | "github.com/googleapis/api-linter/lint"
7 | "github.com/googleapis/api-linter/rules/internal/utils"
8 | "github.com/jhump/protoreflect/desc"
9 | )
10 |
11 | // The create request message should have resource field.
12 | var requestResourceRequired = &lint.MessageRule{
13 | Name: lint.NewRuleName(134, "request-resource-required"),
14 | OnlyIf: utils.IsUpdateRequestMessage,
15 | LintMessage: func(m *desc.MessageDescriptor) []lint.Problem {
16 | resourceMsgName := extractResource(m.GetName())
17 | for _, fieldDesc := range m.GetFields() {
18 | msgDesc := fieldDesc.GetMessageType()
19 | if msgDesc != nil && msgDesc.GetName() == resourceMsgName {
20 | // found the resource field.
21 | return nil
22 | }
23 | }
24 |
25 | // No resource field.
26 | return []lint.Problem{{
27 | Message: fmt.Sprintf("Message %q has no %q type field", m.GetName(), resourceMsgName),
28 | Descriptor: m,
29 | }}
30 | },
31 | }
32 |
--------------------------------------------------------------------------------
/rules/aip0135/aip0135_test.go:
--------------------------------------------------------------------------------
1 | package aip0135
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/googleapis/api-linter/lint"
7 | )
8 |
9 | func TestAddRules(t *testing.T) {
10 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
11 | t.Errorf("AddRules got an error: %v", err)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rules/aip0135/http_body.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0135
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Delete methods should not have an HTTP body.
23 | var httpBody = &lint.MethodRule{
24 | Name: lint.NewRuleName(135, "http-body"),
25 | OnlyIf: utils.IsDeleteMethod,
26 | LintMethod: utils.LintNoHTTPBody,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0135/http_method.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0135
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Delete methods should use the HTTP DELETE method.
23 | var httpMethod = &lint.MethodRule{
24 | Name: lint.NewRuleName(135, "http-method"),
25 | OnlyIf: utils.IsDeleteMethod,
26 | LintMethod: utils.LintHTTPMethod("DELETE"),
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0135/http_uri_name.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0135
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Delete methods should have a proper HTTP pattern.
23 | var httpNameField = &lint.MethodRule{
24 | Name: lint.NewRuleName(135, "http-uri-name"),
25 | OnlyIf: utils.IsDeleteMethod,
26 | LintMethod: utils.LintHTTPURIHasNameVariable,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0135/request_force_field.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0135
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestForceField = &lint.FieldRule{
24 | Name: lint.NewRuleName(135, "request-force-field"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return utils.IsDeleteRequestMessage(f.GetOwner()) && f.GetName() == "force"
27 | },
28 | LintField: utils.LintSingularBoolField,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0135/request_message_name.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0135
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Delete messages should have a properly named Request message.
23 | var requestMessageName = &lint.MethodRule{
24 | Name: lint.NewRuleName(135, "request-message-name"),
25 | OnlyIf: utils.IsDeleteMethod,
26 | LintMethod: utils.LintMethodHasMatchingRequestName,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0135/request_name_behavior.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0135
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestNameBehavior = &lint.FieldRule{
24 | Name: lint.NewRuleName(135, "request-name-behavior"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return utils.IsDeleteRequestMessage(f.GetOwner()) && f.GetName() == "name"
27 | },
28 | LintField: utils.LintRequiredField,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0135/request_name_field.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0135
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestNameField = &lint.FieldRule{
24 | Name: lint.NewRuleName(135, "request-name-field"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return utils.IsDeleteRequestMessage(f.GetOwner()) && f.GetName() == "name"
27 | },
28 | LintField: utils.LintSingularStringField,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0135/request_name_reference.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0135
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestNameReference = &lint.FieldRule{
24 | Name: lint.NewRuleName(135, "request-name-reference"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return utils.IsDeleteRequestMessage(f.GetOwner()) && f.GetName() == "name"
27 | },
28 | LintField: utils.LintFieldResourceReference,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0136/aip0136_test.go:
--------------------------------------------------------------------------------
1 | package aip0136
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/googleapis/api-linter/lint"
7 | )
8 |
9 | func TestAddRules(t *testing.T) {
10 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
11 | t.Errorf("AddRules got an error: %v", err)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rules/aip0136/request_message_name.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0136
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Custom methods should have a properly named Request message.
23 | var requestMessageName = &lint.MethodRule{
24 | Name: lint.NewRuleName(136, "request-message-name"),
25 | OnlyIf: utils.IsCustomMethod,
26 | LintMethod: utils.LintMethodHasMatchingRequestName,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0140/aip0140_test.go:
--------------------------------------------------------------------------------
1 | package aip0140
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/googleapis/api-linter/lint"
7 | )
8 |
9 | func TestAddRules(t *testing.T) {
10 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
11 | t.Errorf("AddRules got an error: %v", err)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rules/aip0141/aip0141.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | // Package aip0141 contains rules defined in https://aip.dev/141.
16 | package aip0141
17 |
18 | import (
19 | "github.com/googleapis/api-linter/lint"
20 | )
21 |
22 | // AddRules adds all of the AIP-141 rules to the provided registry.
23 | func AddRules(r lint.RuleRegistry) error {
24 | return r.Register(
25 | 141,
26 | count,
27 | forbiddenTypes,
28 | )
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0141/aip0141_test.go:
--------------------------------------------------------------------------------
1 | package aip0141
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/googleapis/api-linter/lint"
7 | )
8 |
9 | func TestAddRules(t *testing.T) {
10 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
11 | t.Errorf("AddRules got an error: %v", err)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rules/aip0142/aip0142_test.go:
--------------------------------------------------------------------------------
1 | package aip0142
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/googleapis/api-linter/lint"
7 | )
8 |
9 | func TestAddRules(t *testing.T) {
10 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
11 | t.Errorf("AddRules got an error: %v", err)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rules/aip0143/aip0143.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | // Package aip0143 contains rules defined in https://aip.dev/143.
16 | package aip0143
17 |
18 | import (
19 | "github.com/googleapis/api-linter/lint"
20 | )
21 |
22 | // AddRules adds all of the AIP-143 rules to the provided registry.
23 | func AddRules(r lint.RuleRegistry) error {
24 | return r.Register(
25 | 143,
26 | fieldNames,
27 | fieldTypes,
28 | )
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0143/aip0143_test.go:
--------------------------------------------------------------------------------
1 | package aip0143
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/googleapis/api-linter/lint"
7 | )
8 |
9 | func TestAddRules(t *testing.T) {
10 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
11 | t.Errorf("AddRules got an error: %v", err)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rules/aip0144/aip0144_test.go:
--------------------------------------------------------------------------------
1 | package aip0144
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/googleapis/api-linter/lint"
7 | )
8 |
9 | func TestAddRules(t *testing.T) {
10 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
11 | t.Errorf("AddRules got an error: %v", err)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rules/aip0144/http_body.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0144
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Add/Remove methods should use "*" as the HTTP body.
23 | var httpBody = &lint.MethodRule{
24 | Name: lint.NewRuleName(144, "http-body"),
25 | OnlyIf: isAddRemoveMethod,
26 | LintMethod: utils.LintWildcardHTTPBody,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0144/http_method.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0144
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Add/Remove methods should use the HTTP POST method.
23 | var httpMethod = &lint.MethodRule{
24 | Name: lint.NewRuleName(144, "http-method"),
25 | OnlyIf: isAddRemoveMethod,
26 | LintMethod: utils.LintHTTPMethod("POST"),
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0144/request_message_name.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0144
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Add/Remove methods should have a properly named request message.
23 | var requestMessageName = &lint.MethodRule{
24 | Name: lint.NewRuleName(144, "request-message-name"),
25 | OnlyIf: isAddRemoveMethod,
26 | LintMethod: utils.LintMethodHasMatchingRequestName,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0146/aip0146.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | // Package aip0146 contains rules defined in https://aip.dev/146.
16 | package aip0146
17 |
18 | import (
19 | "github.com/googleapis/api-linter/lint"
20 | )
21 |
22 | // AddRules adds all of the AIP-146 rules to the provided registry.
23 | func AddRules(r lint.RuleRegistry) error {
24 | return r.Register(
25 | 146,
26 | any,
27 | )
28 | }
29 |
--------------------------------------------------------------------------------
/rules/aip0146/aip0146_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0146
16 |
17 | import (
18 | "testing"
19 |
20 | "github.com/googleapis/api-linter/lint"
21 | )
22 |
23 | func TestAddRules(t *testing.T) {
24 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
25 | t.Errorf("AddRules got an error: %v", err)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0148/aip0148.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | // Package aip0148 contains rules defined in https://aip.dev/148.
16 | package aip0148
17 |
18 | import (
19 | "github.com/googleapis/api-linter/lint"
20 | )
21 |
22 | // AddRules adds all of the AIP-148 rules to the provided registry.
23 | func AddRules(r lint.RuleRegistry) error {
24 | return r.Register(
25 | 148,
26 | declarativeFriendlyRequired,
27 | fieldBehavior,
28 | humanNames,
29 | ipAddressFormat,
30 | useUid,
31 | uidFormat,
32 | )
33 | }
34 |
--------------------------------------------------------------------------------
/rules/aip0148/aip0148_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0148
16 |
17 | import (
18 | "testing"
19 |
20 | "github.com/googleapis/api-linter/lint"
21 | )
22 |
23 | func TestAddRules(t *testing.T) {
24 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
25 | t.Errorf("AddRules got an error: %v", err)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0151/aip0151_test.go:
--------------------------------------------------------------------------------
1 | package aip0151
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/googleapis/api-linter/lint"
7 | )
8 |
9 | func TestAddRules(t *testing.T) {
10 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
11 | t.Errorf("AddRules got an error: %v", err)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rules/aip0152/aip0152_test.go:
--------------------------------------------------------------------------------
1 | package aip0152
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/googleapis/api-linter/lint"
7 | )
8 |
9 | func TestAddRules(t *testing.T) {
10 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
11 | t.Errorf("AddRules got an error: %v", err)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rules/aip0152/http_body.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0152
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Run methods should use "*" as the HTTP body.
23 | var httpBody = &lint.MethodRule{
24 | Name: lint.NewRuleName(152, "http-body"),
25 | OnlyIf: isRunMethod,
26 | LintMethod: utils.LintWildcardHTTPBody,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0152/http_method.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0152
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Run methods should use the HTTP POST method.
23 | var httpMethod = &lint.MethodRule{
24 | Name: lint.NewRuleName(152, "http-method"),
25 | OnlyIf: isRunMethod,
26 | LintMethod: utils.LintHTTPMethod("POST"),
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0152/request_message_name.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0152
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Run messages should have a properly named request message.
23 | var requestMessageName = &lint.MethodRule{
24 | Name: lint.NewRuleName(152, "request-message-name"),
25 | OnlyIf: isRunMethod,
26 | LintMethod: utils.LintMethodHasMatchingRequestName,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0152/request_name_behavior.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0152
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestNameBehavior = &lint.FieldRule{
24 | Name: lint.NewRuleName(152, "request-name-behavior"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isRunRequestMessage(f.GetOwner()) && f.GetName() == "name"
27 | },
28 | LintField: utils.LintRequiredField,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0152/request_name_field.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0152
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | var requestNameField = &lint.MessageRule{
23 | Name: lint.NewRuleName(152, "request-name-field"),
24 | OnlyIf: isRunRequestMessage,
25 | LintMessage: utils.LintFieldPresentAndSingularString("name"),
26 | }
27 |
--------------------------------------------------------------------------------
/rules/aip0152/request_name_reference.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0152
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestNameReference = &lint.FieldRule{
24 | Name: lint.NewRuleName(152, "request-name-reference"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isRunRequestMessage(f.GetOwner()) && f.GetName() == "name"
27 | },
28 | LintField: utils.LintFieldResourceReference,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0154/aip0154.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | // Package aip0154 contains rules defined in https://aip.dev/154.
16 | package aip0154
17 |
18 | import (
19 | "github.com/googleapis/api-linter/lint"
20 | )
21 |
22 | // AddRules adds all of the AIP-154 rules to the provided registry.
23 | func AddRules(r lint.RuleRegistry) error {
24 | return r.Register(
25 | 154,
26 | declarativeFriendlyRequired,
27 | fieldType,
28 | noDuplicateEtag,
29 | )
30 | }
31 |
--------------------------------------------------------------------------------
/rules/aip0154/aip0154_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0154
16 |
17 | import (
18 | "testing"
19 |
20 | "github.com/googleapis/api-linter/lint"
21 | )
22 |
23 | func TestAddRules(t *testing.T) {
24 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
25 | t.Errorf("AddRules got an error: %v", err)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0155/aip0155.go:
--------------------------------------------------------------------------------
1 | // Copyright 2023 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | // Package aip0155 contains rules defined in https://aip.dev/155.
16 | package aip0155
17 |
18 | import (
19 | "github.com/googleapis/api-linter/lint"
20 | )
21 |
22 | // AddRules adds all of the AIP-155 rules to the provided registry.
23 | func AddRules(r lint.RuleRegistry) error {
24 | return r.Register(
25 | 155,
26 | requestIdFormat,
27 | )
28 | }
29 |
--------------------------------------------------------------------------------
/rules/aip0155/aip0155_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2023 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0155
16 |
17 | import (
18 | "testing"
19 |
20 | "github.com/googleapis/api-linter/lint"
21 | )
22 |
23 | func TestAddRules(t *testing.T) {
24 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
25 | t.Errorf("AddRules got an error: %v", err)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0156/aip0156.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | // Package aip0156 contains rules defined in https://aip.dev/156.
16 | package aip0156
17 |
18 | import (
19 | "github.com/googleapis/api-linter/lint"
20 | )
21 |
22 | // AddRules adds all of the AIP-156 rules to the provided registry.
23 | func AddRules(r lint.RuleRegistry) error {
24 | return r.Register(
25 | 156,
26 | forbiddenMethods,
27 | )
28 | }
29 |
--------------------------------------------------------------------------------
/rules/aip0156/aip0156_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0156
16 |
17 | import (
18 | "testing"
19 |
20 | "github.com/googleapis/api-linter/lint"
21 | )
22 |
23 | func TestAddRules(t *testing.T) {
24 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
25 | t.Errorf("AddRules got an error: %v", err)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0157/request_read_mask_field.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0157
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestReadMaskField = &lint.FieldRule{
24 | Name: lint.NewRuleName(157, "request-read-mask-field"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isRequestMessage(f.GetOwner()) && f.GetName() == "read_mask"
27 | },
28 | LintField: utils.LintFieldMask,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0158/aip0158_test.go:
--------------------------------------------------------------------------------
1 | package aip0158
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/googleapis/api-linter/lint"
7 | )
8 |
9 | func TestAddRules(t *testing.T) {
10 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
11 | t.Errorf("AddRules got an error: %v", err)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rules/aip0158/response_next_page_token_field.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0158
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | var responsePaginationNextPageToken = &lint.MessageRule{
23 | Name: lint.NewRuleName(158, "response-next-page-token-field"),
24 | OnlyIf: isPaginatedResponseMessage,
25 | LintMessage: utils.LintFieldPresentAndSingularString("next_page_token"),
26 | }
27 |
--------------------------------------------------------------------------------
/rules/aip0159/aip0159.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | // Package aip0159 contains rules defined in https://aip.dev/159.
16 | package aip0159
17 |
18 | import (
19 | "github.com/googleapis/api-linter/lint"
20 | )
21 |
22 | // AddRules adds all of the AIP-159 rules to the provided registry.
23 | func AddRules(r lint.RuleRegistry) error {
24 | return r.Register(
25 | 159,
26 | hardcodedHyphen,
27 | )
28 | }
29 |
--------------------------------------------------------------------------------
/rules/aip0159/aip0159_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0159
16 |
17 | import (
18 | "testing"
19 |
20 | "github.com/googleapis/api-linter/lint"
21 | )
22 |
23 | func TestAddRules(t *testing.T) {
24 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
25 | t.Errorf("AddRules got an error: %v", err)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0162/commit_http_body.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0162
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Commit methods should have "*" as the HTTP body.
23 | var commitHTTPBody = &lint.MethodRule{
24 | Name: lint.NewRuleName(162, "commit-http-body"),
25 | OnlyIf: utils.IsCommitRevisionMethod,
26 | LintMethod: utils.LintWildcardHTTPBody,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0162/commit_http_method.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0162
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Commit methods should use the HTTP POST method.
23 | var commitHTTPMethod = &lint.MethodRule{
24 | Name: lint.NewRuleName(162, "commit-http-method"),
25 | OnlyIf: utils.IsCommitRevisionMethod,
26 | LintMethod: utils.LintHTTPMethod("POST"),
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0162/commit_request_message_name.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0162
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Commit messages should have a properly named request message.
23 | var commitRequestMessageName = &lint.MethodRule{
24 | Name: lint.NewRuleName(162, "commit-request-message-name"),
25 | OnlyIf: utils.IsCommitRevisionMethod,
26 | LintMethod: utils.LintMethodHasMatchingRequestName,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0162/commit_request_name_behavior.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0162
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var commitRequestNameBehavior = &lint.FieldRule{
24 | Name: lint.NewRuleName(162, "commit-request-name-behavior"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isCommitRequestMessage(f.GetOwner()) && f.GetName() == "name"
27 | },
28 | LintField: utils.LintRequiredField,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0162/commit_request_name_field.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0162
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // The Commit request message should have a name field.
23 | var commitRequestNameField = &lint.MessageRule{
24 | Name: lint.NewRuleName(162, "commit-request-name-field"),
25 | OnlyIf: isCommitRequestMessage,
26 | LintMessage: utils.LintFieldPresentAndSingularString("name"),
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0162/commit_request_name_reference.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0162
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var commitRequestNameReference = &lint.FieldRule{
24 | Name: lint.NewRuleName(162, "commit-request-name-reference"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isCommitRequestMessage(f.GetOwner()) && f.GetName() == "name"
27 | },
28 | LintField: utils.LintFieldResourceReference,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0162/delete_revision_http_body.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0162
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Delete Revision methods should have no HTTP body.
23 | var deleteRevisionHTTPBody = &lint.MethodRule{
24 | Name: lint.NewRuleName(162, "delete-revision-http-body"),
25 | OnlyIf: utils.IsDeleteRevisionMethod,
26 | LintMethod: utils.LintNoHTTPBody,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0162/delete_revision_http_method.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0162
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Delete Revision methods should use the HTTP DELETE method.
23 | var deleteRevisionHTTPMethod = &lint.MethodRule{
24 | Name: lint.NewRuleName(162, "delete-revision-http-method"),
25 | OnlyIf: utils.IsDeleteRevisionMethod,
26 | LintMethod: utils.LintHTTPMethod("DELETE"),
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0162/delete_revision_request_message_name.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0162
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Delete Revision messages should have a properly named request message.
23 | var deleteRevisionRequestMessageName = &lint.MethodRule{
24 | Name: lint.NewRuleName(162, "delete-revision-request-message-name"),
25 | OnlyIf: utils.IsDeleteRevisionMethod,
26 | LintMethod: utils.LintMethodHasMatchingRequestName,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0162/delete_revision_request_name_field.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0162
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // The Delete Revision request message should have a name field.
23 | var deleteRevisionRequestNameField = &lint.MessageRule{
24 | Name: lint.NewRuleName(162, "delete-revision-request-name-field"),
25 | OnlyIf: isDeleteRevisionRequestMessage,
26 | LintMessage: utils.LintFieldPresentAndSingularString("name"),
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0162/rollback_http_body.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0162
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Rollback methods should have "*" as the HTTP body.
23 | var rollbackHTTPBody = &lint.MethodRule{
24 | Name: lint.NewRuleName(162, "rollback-http-body"),
25 | OnlyIf: utils.IsRollbackRevisionMethod,
26 | LintMethod: utils.LintWildcardHTTPBody,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0162/rollback_http_method.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0162
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Rollback methods should use the HTTP POST method.
23 | var rollbackHTTPMethod = &lint.MethodRule{
24 | Name: lint.NewRuleName(162, "rollback-http-method"),
25 | OnlyIf: utils.IsRollbackRevisionMethod,
26 | LintMethod: utils.LintHTTPMethod("POST"),
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0162/rollback_request_message_name.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0162
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Rollback messages should have a properly named request message.
23 | var rollbackRequestMessageName = &lint.MethodRule{
24 | Name: lint.NewRuleName(162, "rollback-request-message-name"),
25 | OnlyIf: utils.IsRollbackRevisionMethod,
26 | LintMethod: utils.LintMethodHasMatchingRequestName,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0162/rollback_request_name_behavior.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0162
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var rollbackRequestNameBehavior = &lint.FieldRule{
24 | Name: lint.NewRuleName(162, "rollback-request-name-behavior"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isRollbackRequestMessage(f.GetOwner()) && f.GetName() == "name"
27 | },
28 | LintField: utils.LintRequiredField,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0162/rollback_request_name_field.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0162
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // The Rollback request message should have a name field.
23 | var rollbackRequestNameField = &lint.MessageRule{
24 | Name: lint.NewRuleName(162, "rollback-request-name-field"),
25 | OnlyIf: isRollbackRequestMessage,
26 | LintMessage: utils.LintFieldPresentAndSingularString("name"),
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0162/rollback_request_name_reference.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0162
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var rollbackRequestNameReference = &lint.FieldRule{
24 | Name: lint.NewRuleName(162, "rollback-request-name-reference"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isRollbackRequestMessage(f.GetOwner()) && f.GetName() == "name"
27 | },
28 | LintField: utils.LintFieldResourceReference,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0162/rollback_request_revision_id_field.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0162
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // The Rollback request message should have a revision_id field.
23 | var rollbackRequestRevisionIDField = &lint.MessageRule{
24 | Name: lint.NewRuleName(162, "rollback-request-revision-id-field"),
25 | OnlyIf: isRollbackRequestMessage,
26 | LintMessage: utils.LintFieldPresentAndSingularString("revision_id"),
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0162/tag_revision_http_body.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0162
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Tag Revision methods should have "*" as the HTTP body.
23 | var tagRevisionHTTPBody = &lint.MethodRule{
24 | Name: lint.NewRuleName(162, "tag-revision-http-body"),
25 | OnlyIf: utils.IsTagRevisionMethod,
26 | LintMethod: utils.LintWildcardHTTPBody,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0162/tag_revision_http_method.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0162
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Tag Revision methods should use the HTTP POST method.
23 | var tagRevisionHTTPMethod = &lint.MethodRule{
24 | Name: lint.NewRuleName(162, "tag-revision-http-method"),
25 | OnlyIf: utils.IsTagRevisionMethod,
26 | LintMethod: utils.LintHTTPMethod("POST"),
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0162/tag_revision_request_message_name.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0162
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Tag Revision messages should have a properly named request message.
23 | var tagRevisionRequestMessageName = &lint.MethodRule{
24 | Name: lint.NewRuleName(162, "tag-revision-request-message-name"),
25 | OnlyIf: utils.IsTagRevisionMethod,
26 | LintMethod: utils.LintMethodHasMatchingRequestName,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0162/tag_revision_request_name_behavior.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0162
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var tagRevisionRequestNameBehavior = &lint.FieldRule{
24 | Name: lint.NewRuleName(162, "tag-revision-request-name-behavior"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isTagRevisionRequestMessage(f.GetOwner()) && f.GetName() == "name"
27 | },
28 | LintField: utils.LintRequiredField,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0162/tag_revision_request_name_field.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0162
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // The Tag Revision request message should have a name field.
23 | var tagRevisionRequestNameField = &lint.MessageRule{
24 | Name: lint.NewRuleName(162, "tag-revision-request-name-field"),
25 | OnlyIf: isTagRevisionRequestMessage,
26 | LintMessage: utils.LintFieldPresentAndSingularString("name"),
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0162/tag_revision_request_tag_behavior.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0162
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var tagRevisionRequestTagBehavior = &lint.FieldRule{
24 | Name: lint.NewRuleName(162, "tag-revision-request-tag-behavior"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isTagRevisionRequestMessage(f.GetOwner()) && f.GetName() == "tag"
27 | },
28 | LintField: utils.LintRequiredField,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0162/tag_revision_request_tag_field.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0162
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // The Tag Revision request message should have a tag field.
23 | var tagRevisionRequestTagField = &lint.MessageRule{
24 | Name: lint.NewRuleName(162, "tag-revision-request-tag-field"),
25 | OnlyIf: isTagRevisionRequestMessage,
26 | LintMessage: utils.LintFieldPresentAndSingularString("tag"),
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0163/aip0163.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | // Package aip0163 contains rules defined in https://aip.dev/163.
16 | package aip0163
17 |
18 | import (
19 | "github.com/googleapis/api-linter/lint"
20 | )
21 |
22 | // AddRules adds all of the AIP-163 rules to the provided registry.
23 | func AddRules(r lint.RuleRegistry) error {
24 | return r.Register(
25 | 163,
26 | declarativeFriendlyRequired,
27 | synonyms,
28 | )
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0163/aip0163_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0163
16 |
17 | import (
18 | "testing"
19 |
20 | "github.com/googleapis/api-linter/lint"
21 | )
22 |
23 | func TestAddRules(t *testing.T) {
24 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
25 | t.Errorf("AddRules got an error: %v", err)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0164/aip0164_test.go:
--------------------------------------------------------------------------------
1 | package aip0164
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/googleapis/api-linter/lint"
7 | )
8 |
9 | func TestAddRules(t *testing.T) {
10 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
11 | t.Errorf("AddRules got an error: %v", err)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rules/aip0164/http_body.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0164
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Undelete methods should have "*" as the HTTP body.
23 | var httpBody = &lint.MethodRule{
24 | Name: lint.NewRuleName(164, "http-body"),
25 | OnlyIf: isUndeleteMethod,
26 | LintMethod: utils.LintWildcardHTTPBody,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0164/http_method.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0164
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Undelete methods should use the HTTP POST method.
23 | var httpMethod = &lint.MethodRule{
24 | Name: lint.NewRuleName(164, "http-method"),
25 | OnlyIf: isUndeleteMethod,
26 | LintMethod: utils.LintHTTPMethod("POST"),
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0164/request_message_name.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0164
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Undelete messages should have a properly named request message.
23 | var requestMessageName = &lint.MethodRule{
24 | Name: lint.NewRuleName(164, "request-message-name"),
25 | OnlyIf: isUndeleteMethod,
26 | LintMethod: utils.LintMethodHasMatchingRequestName,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0164/request_name_behavior.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0164
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestNameBehavior = &lint.FieldRule{
24 | Name: lint.NewRuleName(164, "request-name-behavior"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isUndeleteRequestMessage(f.GetOwner()) && f.GetName() == "name"
27 | },
28 | LintField: utils.LintRequiredField,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0164/request_name_field.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0164
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | var requestNameField = &lint.MessageRule{
23 | Name: lint.NewRuleName(164, "request-name-field"),
24 | OnlyIf: isUndeleteRequestMessage,
25 | LintMessage: utils.LintFieldPresentAndSingularString("name"),
26 | }
27 |
--------------------------------------------------------------------------------
/rules/aip0164/request_name_reference.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0164
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestNameReference = &lint.FieldRule{
24 | Name: lint.NewRuleName(164, "request-name-reference"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isUndeleteRequestMessage(f.GetOwner()) && f.GetName() == "name"
27 | },
28 | LintField: utils.LintFieldResourceReference,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0164/resource_expire_time_field.go:
--------------------------------------------------------------------------------
1 | package aip0164
2 |
3 | import (
4 | "github.com/googleapis/api-linter/lint"
5 | "github.com/googleapis/api-linter/rules/internal/utils"
6 | "github.com/jhump/protoreflect/desc"
7 | )
8 |
9 | // Resources supporting soft delete must have an expire_time field.
10 | var resourceExpireTimeField = &lint.MessageRule{
11 | Name: lint.NewRuleName(164, "resource-expire-time-field"),
12 | OnlyIf: func(m *desc.MessageDescriptor) bool {
13 | resource := m.GetName()
14 | return utils.FindMethod(m.GetFile(), "Undelete"+resource) != nil
15 | },
16 | LintMessage: func(m *desc.MessageDescriptor) []lint.Problem {
17 | // for backwards compatibility, do not lint on expire_time.
18 | // previously expire_time was the recommended term.
19 | if m.FindFieldByName("expire_time") != nil {
20 | return nil
21 | }
22 | if m.FindFieldByName("purge_time") != nil {
23 | return nil
24 | }
25 | return []lint.Problem{{
26 | Message: "Resources supporting soft delete must have a `google.protobuf.Timestamp purge_time` field.",
27 | Descriptor: m,
28 | }}
29 | },
30 | }
31 |
--------------------------------------------------------------------------------
/rules/aip0165/aip0165_test.go:
--------------------------------------------------------------------------------
1 | package aip0165
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/googleapis/api-linter/lint"
7 | )
8 |
9 | func TestAddRules(t *testing.T) {
10 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
11 | t.Errorf("AddRules got an error: %v", err)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rules/aip0165/http_body.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0165
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Purge methods should have "*" as the HTTP body.
23 | var httpBody = &lint.MethodRule{
24 | Name: lint.NewRuleName(165, "http-body"),
25 | OnlyIf: isPurgeMethod,
26 | LintMethod: utils.LintWildcardHTTPBody,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0165/http_method.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0165
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Purge methods should use the HTTP POST method.
23 | var httpMethod = &lint.MethodRule{
24 | Name: lint.NewRuleName(165, "http-method"),
25 | OnlyIf: isPurgeMethod,
26 | LintMethod: utils.LintHTTPMethod("POST"),
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0165/request_filter_behavior.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0165
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestFilterBehavior = &lint.FieldRule{
24 | Name: lint.NewRuleName(165, "request-filter-behavior"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isPurgeRequestMessage(f.GetOwner()) && f.GetName() == "filter"
27 | },
28 | LintField: utils.LintRequiredField,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0165/request_filter_field.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0165
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // The Purge request message should have filter field.
23 | var requestFilterField = &lint.MessageRule{
24 | Name: lint.NewRuleName(165, "request-filter-field"),
25 | OnlyIf: isPurgeRequestMessage,
26 | LintMessage: utils.LintFieldPresentAndSingularString("filter"),
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0165/request_message_name.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0165
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Purge messages should have a properly named request message.
23 | var requestMessageName = &lint.MethodRule{
24 | Name: lint.NewRuleName(165, "request-message-name"),
25 | OnlyIf: isPurgeMethod,
26 | LintMethod: utils.LintMethodHasMatchingRequestName,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0165/request_parent_behavior.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0165
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestParentBehavior = &lint.FieldRule{
24 | Name: lint.NewRuleName(165, "request-parent-behavior"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isPurgeRequestMessage(f.GetOwner()) && f.GetName() == "parent"
27 | },
28 | LintField: utils.LintRequiredField,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0165/request_parent_reference.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0165
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestParentReference = &lint.FieldRule{
24 | Name: lint.NewRuleName(165, "request-parent-reference"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isPurgeRequestMessage(f.GetOwner()) && f.GetName() == "parent"
27 | },
28 | LintField: utils.LintFieldResourceReference,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0165/response_purge_sample_reference.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0165
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var responsePurgeSampleReference = &lint.FieldRule{
24 | Name: lint.NewRuleName(165, "response-purge-sample-reference"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isPurgeResponseMessage(f.GetOwner()) && f.GetName() == "purge_sample"
27 | },
28 | LintField: utils.LintFieldResourceReference,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0191/aip0191_test.go:
--------------------------------------------------------------------------------
1 | package aip0191
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/googleapis/api-linter/lint"
7 | )
8 |
9 | func TestAddRules(t *testing.T) {
10 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
11 | t.Errorf("AddRules got an error: %v", err)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rules/aip0192/aip0192_test.go:
--------------------------------------------------------------------------------
1 | package aip0192
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/googleapis/api-linter/lint"
7 | )
8 |
9 | func TestAddRules(t *testing.T) {
10 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
11 | t.Errorf("AddRules got an error: %v", err)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rules/aip0202/aip0202.go:
--------------------------------------------------------------------------------
1 | // Copyright 2023 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | // Package aip0202 contains rules defined in https://aip.dev/202.
16 | package aip0202
17 |
18 | import (
19 | "github.com/googleapis/api-linter/lint"
20 | )
21 |
22 | // AddRules adds all of the AIP-202 rules to the provided registry.
23 | func AddRules(r lint.RuleRegistry) error {
24 | return r.Register(
25 | 202,
26 | stringOnlyFormat,
27 | )
28 | }
29 |
--------------------------------------------------------------------------------
/rules/aip0202/aip0202_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2023 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0202
16 |
17 | import (
18 | "testing"
19 |
20 | "github.com/googleapis/api-linter/lint"
21 | )
22 |
23 | func TestAddRules(t *testing.T) {
24 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
25 | t.Errorf("AddRules got an error: %v", err)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0203/aip0203.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | // Package aip0203 contains rules defined in https://aip.dev/203.
16 | package aip0203
17 |
18 | import (
19 | "github.com/googleapis/api-linter/lint"
20 | )
21 |
22 | // AddRules adds all of the AIP-203 rules to the provided registry.
23 | func AddRules(r lint.RuleRegistry) error {
24 | return r.Register(
25 | 203,
26 | fieldBehaviorRequired,
27 | unorderedListRepeated,
28 | resourceNameIdentifier,
29 | resourceIdentifierOnly,
30 | )
31 | }
32 |
--------------------------------------------------------------------------------
/rules/aip0203/aip0203_test.go:
--------------------------------------------------------------------------------
1 | package aip0203
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/googleapis/api-linter/lint"
7 | )
8 |
9 | func TestAddRules(t *testing.T) {
10 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
11 | t.Errorf("AddRules got an error: %v", err)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rules/aip0214/aip0214.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | // Package aip0214 contains rules defined in https://aip.dev/214.
16 | package aip0214
17 |
18 | import (
19 | "github.com/googleapis/api-linter/lint"
20 | )
21 |
22 | // AddRules adds all of the AIP-214 rules to the provided registry.
23 | func AddRules(r lint.RuleRegistry) error {
24 | return r.Register(
25 | 214,
26 | resourceExpiry,
27 | ttlType,
28 | )
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0214/aip0214_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0214
16 |
17 | import (
18 | "testing"
19 |
20 | "github.com/googleapis/api-linter/lint"
21 | )
22 |
23 | func TestAddRules(t *testing.T) {
24 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
25 | t.Errorf("AddRules got an error: %v", err)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0215/aip0215.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | // Package aip0215 contains rules defined in https://aip.dev/215.
16 | package aip0215
17 |
18 | import (
19 | "github.com/googleapis/api-linter/lint"
20 | )
21 |
22 | // AddRules adds all of the AIP-215 rules to the provided registry.
23 | func AddRules(r lint.RuleRegistry) error {
24 | return r.Register(
25 | 215,
26 | versionedPackages,
27 | foreignTypeReference,
28 | )
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0215/aip0215_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0215
16 |
17 | import (
18 | "testing"
19 |
20 | "github.com/googleapis/api-linter/lint"
21 | )
22 |
23 | func TestAddRules(t *testing.T) {
24 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
25 | t.Errorf("AddRules got an error: %v", err)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0216/aip0216.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | // Package aip0216 contains rules defined in https://aip.dev/216.
16 | package aip0216
17 |
18 | import "github.com/googleapis/api-linter/lint"
19 |
20 | // AddRules accepts a register function and registers each of
21 | // this AIP's rules to it.
22 | func AddRules(r lint.RuleRegistry) error {
23 | return r.Register(
24 | 216,
25 | nesting,
26 | synonyms,
27 | valueSynonyms,
28 | stateFieldOutputOnly,
29 | )
30 | }
31 |
--------------------------------------------------------------------------------
/rules/aip0216/aip0216_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0216
16 |
17 | import (
18 | "testing"
19 |
20 | "github.com/googleapis/api-linter/lint"
21 | )
22 |
23 | func TestAddRules(t *testing.T) {
24 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
25 | t.Errorf("AddRules got an error: %v", err)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0217/aip0217.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | // Package aip0217 contains rules defined in https://aip.dev/217.
16 | package aip0217
17 |
18 | import "github.com/googleapis/api-linter/lint"
19 |
20 | // AddRules accepts a register function and registers each of
21 | // this AIP's rules to it.
22 | func AddRules(r lint.RuleRegistry) error {
23 | return r.Register(
24 | 217,
25 | returnPartialSuccessType,
26 | returnPartialSuccessWithUnreachable,
27 | synonyms,
28 | unreachableFieldType,
29 | )
30 | }
31 |
--------------------------------------------------------------------------------
/rules/aip0217/aip0217_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0217
16 |
17 | import (
18 | "testing"
19 |
20 | "github.com/googleapis/api-linter/lint"
21 | )
22 |
23 | func TestAddRules(t *testing.T) {
24 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
25 | t.Errorf("AddRules got an error: %v", err)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0231/aip0231_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0231
16 |
17 | import (
18 | "testing"
19 |
20 | "github.com/googleapis/api-linter/lint"
21 | )
22 |
23 | func TestAddRules(t *testing.T) {
24 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
25 | t.Errorf("AddRules got an error: %v", err)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0231/http_body.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0231
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Batch Get methods should not have an HTTP body.
23 | var httpBody = &lint.MethodRule{
24 | Name: lint.NewRuleName(231, "http-body"),
25 | OnlyIf: isBatchGetMethod,
26 | LintMethod: utils.LintNoHTTPBody,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0231/http_method.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0231
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Batch Get methods should use the HTTP GET verb.
23 | var httpVerb = &lint.MethodRule{
24 | Name: lint.NewRuleName(231, "http-method"),
25 | OnlyIf: isBatchGetMethod,
26 | LintMethod: utils.LintHTTPMethod("GET"),
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0231/request_message_name.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0231
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Batch Get method should have a properly named Request message.
23 | var inputName = &lint.MethodRule{
24 | Name: lint.NewRuleName(231, "request-message-name"),
25 | OnlyIf: isBatchGetMethod,
26 | LintMethod: utils.LintMethodHasMatchingRequestName,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0231/request_names_behavior.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0231
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestNamesBehavior = &lint.FieldRule{
24 | Name: lint.NewRuleName(231, "request-names-behavior"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isBatchGetRequestMessage(f.GetOwner()) && f.GetName() == "names"
27 | },
28 | LintField: utils.LintRequiredField,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0231/request_names_reference.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0231
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestNamesReference = &lint.FieldRule{
24 | Name: lint.NewRuleName(231, "request-names-reference"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isBatchGetRequestMessage(f.GetOwner()) && f.GetName() == "names"
27 | },
28 | LintField: utils.LintFieldResourceReference,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0231/request_parent_reference.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0231
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestParentReference = &lint.FieldRule{
24 | Name: lint.NewRuleName(231, "request-parent-reference"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isBatchGetRequestMessage(f.GetOwner()) && f.GetName() == "parent"
27 | },
28 | LintField: utils.LintFieldResourceReference,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0231/response_message_name.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0231
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Batch Get method should have a properly named Response message.
23 | var outputName = &lint.MethodRule{
24 | Name: lint.NewRuleName(231, "response-message-name"),
25 | OnlyIf: isBatchGetMethod,
26 | LintMethod: utils.LintMethodHasMatchingResponseName,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0233/aip0233_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0233
16 |
17 | import (
18 | "testing"
19 |
20 | "github.com/googleapis/api-linter/lint"
21 | )
22 |
23 | func TestAddRules(t *testing.T) {
24 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
25 | t.Errorf("AddRules got an error: %v", err)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0233/http_body.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0233
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Batch Create methods should use "*" as the HTTP body.
23 | var httpBody = &lint.MethodRule{
24 | Name: lint.NewRuleName(233, "http-body"),
25 | OnlyIf: isBatchCreateMethod,
26 | LintMethod: utils.LintWildcardHTTPBody,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0233/http_method.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0233
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Batch Create methods should use the HTTP POST verb.
23 | var httpVerb = &lint.MethodRule{
24 | Name: lint.NewRuleName(233, "http-method"),
25 | OnlyIf: isBatchCreateMethod,
26 | LintMethod: utils.LintHTTPMethod("POST"),
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0233/request_message_name.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0233
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Batch Create method should have a properly named Request message.
23 | var requestMessageName = &lint.MethodRule{
24 | Name: lint.NewRuleName(233, "request-message-name"),
25 | OnlyIf: isBatchCreateMethod,
26 | LintMethod: utils.LintMethodHasMatchingRequestName,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0233/request_parent_reference.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0233
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestParentReference = &lint.FieldRule{
24 | Name: lint.NewRuleName(233, "request-parent-reference"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isBatchCreateRequestMessage(f.GetOwner()) && f.GetName() == "parent"
27 | },
28 | LintField: utils.LintFieldResourceReference,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0233/request_requests_behavior.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0233
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestRequestsBehavior = &lint.FieldRule{
24 | Name: lint.NewRuleName(233, "request-requests-behavior"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isBatchCreateRequestMessage(f.GetOwner()) && f.GetName() == "requests"
27 | },
28 | LintField: utils.LintRequiredField,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0234/aip0234_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0234
16 |
17 | import (
18 | "testing"
19 |
20 | "github.com/googleapis/api-linter/lint"
21 | )
22 |
23 | func TestAddRules(t *testing.T) {
24 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
25 | t.Errorf("AddRules got an error: %v", err)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0234/http_body.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0234
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Batch Update methods should use "*" as the HTTP body.
23 | var httpBody = &lint.MethodRule{
24 | Name: lint.NewRuleName(234, "http-body"),
25 | OnlyIf: isBatchUpdateMethod,
26 | LintMethod: utils.LintWildcardHTTPBody,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0234/http_method.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0234
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Batch Create methods should use the HTTP POST verb.
23 | var httpMethod = &lint.MethodRule{
24 | Name: lint.NewRuleName(234, "http-method"),
25 | OnlyIf: isBatchUpdateMethod,
26 | LintMethod: utils.LintHTTPMethod("POST"),
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0234/request_message_name.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0234
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Batch Update method should have a properly named Request message.
23 | var requestMessageName = &lint.MethodRule{
24 | Name: lint.NewRuleName(234, "request-message-name"),
25 | OnlyIf: isBatchUpdateMethod,
26 | LintMethod: utils.LintMethodHasMatchingRequestName,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0234/request_parent_reference.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0234
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestParentReference = &lint.FieldRule{
24 | Name: lint.NewRuleName(234, "request-parent-reference"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isBatchUpdateRequestMessage(f.GetOwner()) && f.GetName() == "parent"
27 | },
28 | LintField: utils.LintFieldResourceReference,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0234/request_requests_behavior.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0234
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestRequestsBehavior = &lint.FieldRule{
24 | Name: lint.NewRuleName(234, "request-requests-behavior"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isBatchUpdateRequestMessage(f.GetOwner()) && f.GetName() == "requests"
27 | },
28 | LintField: utils.LintRequiredField,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0235/aip0235_test.go:
--------------------------------------------------------------------------------
1 | package aip0235
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/googleapis/api-linter/lint"
7 | )
8 |
9 | func TestAddRules(t *testing.T) {
10 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
11 | t.Errorf("AddRules got an error: %v", err)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/rules/aip0235/http_body.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0235
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Batch Delete methods should use "*" as the HTTP body.
23 | var httpBody = &lint.MethodRule{
24 | Name: lint.NewRuleName(235, "http-body"),
25 | OnlyIf: isBatchDeleteMethod,
26 | LintMethod: utils.LintWildcardHTTPBody,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0235/http_method.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0235
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Batch Delete methods should use the HTTP POST method.
23 | var httpMethod = &lint.MethodRule{
24 | Name: lint.NewRuleName(235, "http-method"),
25 | OnlyIf: isBatchDeleteMethod,
26 | LintMethod: utils.LintHTTPMethod("POST"),
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0235/request_message_name.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0235
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | )
21 |
22 | // Batch Delete messages should have a properly named Request message.
23 | var requestMessageName = &lint.MethodRule{
24 | Name: lint.NewRuleName(235, "request-message-name"),
25 | OnlyIf: isBatchDeleteMethod,
26 | LintMethod: utils.LintMethodHasMatchingRequestName,
27 | }
28 |
--------------------------------------------------------------------------------
/rules/aip0235/request_names_behavior.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0235
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestNamesBehavior = &lint.FieldRule{
24 | Name: lint.NewRuleName(235, "request-names-behavior"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isBatchDeleteRequestMessage(f.GetOwner()) && f.GetName() == "names"
27 | },
28 | LintField: utils.LintRequiredField,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0235/request_names_reference.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0235
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestNamesReference = &lint.FieldRule{
24 | Name: lint.NewRuleName(235, "request-names-reference"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isBatchDeleteRequestMessage(f.GetOwner()) && f.GetName() == "names"
27 | },
28 | LintField: utils.LintFieldResourceReference,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0235/request_parent_reference.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0235
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestParentReference = &lint.FieldRule{
24 | Name: lint.NewRuleName(235, "request-parent-reference"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isBatchDeleteRequestMessage(f.GetOwner()) && f.GetName() == "parent"
27 | },
28 | LintField: utils.LintFieldResourceReference,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip0235/request_requests_behavior.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip0235
16 |
17 | import (
18 | "github.com/googleapis/api-linter/lint"
19 | "github.com/googleapis/api-linter/rules/internal/utils"
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | var requestRequestsBehavior = &lint.FieldRule{
24 | Name: lint.NewRuleName(235, "request-requests-behavior"),
25 | OnlyIf: func(f *desc.FieldDescriptor) bool {
26 | return isBatchDeleteRequestMessage(f.GetOwner()) && f.GetName() == "requests"
27 | },
28 | LintField: utils.LintRequiredField,
29 | }
30 |
--------------------------------------------------------------------------------
/rules/aip4232/aip4232_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package aip4232
16 |
17 | import (
18 | "testing"
19 |
20 | "github.com/googleapis/api-linter/lint"
21 | )
22 |
23 | func TestAddRules(t *testing.T) {
24 | if err := AddRules(lint.NewRuleRegistry()); err != nil {
25 | t.Errorf("AddRules got an error: %v", err)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/rules/internal/data/data_test.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package data
16 |
17 | import "testing"
18 |
19 | // "per" is a special exception to the preposition rule, per AIP-140
20 | // (but it would be easy for a well-meaning person to add it to the set).
21 | func TestPrepositionsExcludesPer(t *testing.T) {
22 | if Prepositions.Contains("per") {
23 | t.Errorf("`per` should be an acceptable preposition.")
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/rules/internal/utils/common_proto.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 Google LLC
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // https://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package utils
16 |
17 | import (
18 | "strings"
19 |
20 | "github.com/jhump/protoreflect/desc"
21 | )
22 |
23 | // IsCommonProto returns true if a proto file is considered "common".
24 | func IsCommonProto(f *desc.FileDescriptor) bool {
25 | p := f.GetPackage()
26 | for _, prefix := range []string{"google.api", "google.protobuf", "google.rpc", "google.longrunning"} {
27 | if strings.HasPrefix(p, prefix) {
28 | return true
29 | }
30 | }
31 | return false
32 | }
33 |
--------------------------------------------------------------------------------