Skip to content

Commit a18a7b6

Browse files
Peter HaugeCopilot
andcommitted
docs: add wildcard pattern matching to filter docs and templates
Update filter documentation, getting-started guide, extract command reference, and the filter config template to document wildcard pattern support (* and ? characters). Fix getting-started.md using the old apiNames key instead of apis. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 138fa32 commit a18a7b6

4 files changed

Lines changed: 64 additions & 3 deletions

File tree

docs/commands/extract.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,19 @@ For local development, `az login` is the simplest option. For CI/CD pipelines, u
9595

9696
By default, `apiops extract` exports **all** resources from the APIM instance (34 resource types including APIs, products, backends, named values, tags, policies, and more).
9797

98-
To extract only specific resources, pass a YAML filter file with `--filter`:
98+
To extract only specific resources, pass a YAML filter file with `--filter`. Filter entries support exact names and wildcard patterns (`*` for any characters, `?` for a single character):
9999

100100
```yaml
101101
# configuration.extractor.yaml
102102
apis:
103103
- echo-api
104104
- petstore-api
105+
- prod-* # Wildcard: all APIs starting with prod-
105106
products:
106107
- starter
107108
backends:
108109
- backend-api
110+
- '*-internal' # Wildcard: all backends ending with -internal
109111
namedValues:
110112
- api-key
111113
tags:

docs/getting-started.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ You'll see directories for each resource type — `apis/`, `backends/`, `namedVa
5858
Extract only the APIs you care about. Create a `filter.yaml`:
5959

6060
```yaml
61-
apiNames:
61+
apis:
6262
- pet-store-api
6363
- user-api
64+
- staging-* # Wildcard: all APIs starting with staging-
6465
```
6566
6667
```bash

docs/guides/filtering-resources.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,47 @@ namedValues:
7272
- Simple fields must be an array of strings
7373
- `apis` and `workspaces` also accept nested object entries for sub-resource filtering (see below)
7474
- Names are matched case-insensitively against APIM resource names
75+
- Wildcard patterns are supported — `*` matches any characters, `?` matches a single character (see below)
76+
- Exact names and wildcard patterns can be mixed in the same array
7577
- An empty file extracts everything (same as no filter)
7678
- An empty array (`[]`) excludes ALL resources of that type
7779

7880
---
7981

82+
## Wildcard Pattern Matching
83+
84+
Filter entries support glob-style wildcard patterns for matching multiple resources by naming convention:
85+
86+
| Wildcard | Meaning | Example |
87+
|----------|---------|---------|
88+
| `*` | Matches zero or more characters | `prod-*` matches `prod-api`, `prod-users` |
89+
| `?` | Matches exactly one character | `api-v?` matches `api-v1`, `api-v2` but not `api-v10` |
90+
91+
### Examples
92+
93+
```yaml
94+
apis:
95+
- '*-test' # All APIs ending with -test
96+
- 'prod-*' # All APIs starting with prod-
97+
- '*-internal-*' # All APIs containing -internal-
98+
- 'v2-*-api' # APIs following v2-{name}-api pattern
99+
- 'echo-api' # Exact names and patterns can be mixed
100+
101+
products:
102+
- 'test-*' # All test products
103+
- '*-starter' # All starter tier products
104+
105+
backends:
106+
- 'backend-*-prod' # All production backends
107+
108+
namedValues:
109+
- '*-connection-string' # All connection string named values
110+
```
111+
112+
Wildcard matching is case-insensitive, just like exact matching. Special characters in resource names (e.g., dots in `my.api.v1`) are treated literally — `my.api.*` matches `my.api.test` but not `myXapiXtest`.
113+
114+
---
115+
80116
## Nested Sub-Resource Filtering
81117

82118
### API sub-resource filters
@@ -268,6 +304,20 @@ backends:
268304

269305
There is no "exclude" syntax. To extract everything except certain resources, list all the resources you _do_ want. For large instances, it's often easier to extract everything and use `.gitignore` or separate branches to manage visibility.
270306

307+
### Pattern-Based Team Filtering
308+
309+
Using wildcard patterns to extract resources by naming convention:
310+
311+
```yaml
312+
# configuration.extractor.yaml
313+
apis:
314+
- 'team-payments-*' # All APIs owned by the payments team
315+
namedValues:
316+
- 'payments-*' # All named values for payments
317+
backends:
318+
- '*-payments-*' # All backends related to payments
319+
```
320+
271321
---
272322

273323
## Tips
@@ -276,6 +326,7 @@ There is no "exclude" syntax. To extract everything except certain resources, li
276326
- **One filter per team** — In multi-team setups, each team maintains its own `configuration.extractor.yaml`
277327
- **Commit the filter file** — Keep it in version control alongside your artifacts so CI/CD pipelines can use it
278328
- **Case-insensitive matching** — Filter values are matched case-insensitively against APIM resource names
329+
- **Use wildcard patterns** — `*` and `?` patterns let you match resources by naming convention instead of listing each name individually
279330
- **Validate early** — The config loader validates filter entries and will throw `Failed to load filter config` on invalid YAML. Unknown top-level keys produce a warning.
280331

281332
---

src/templates/configs/filter-config.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ export function generateFilterConfig(): string {
1111
# For full format details and examples, see:
1212
# https://github.com/Azure/apiops-cli/blob/main/docs/guides/filtering-resources.md
1313
14-
# Extract only specific APIs by name
14+
# Extract only specific APIs by name (or wildcard pattern)
1515
# apis:
1616
# - echo-api
1717
# - petstore-api
18+
# - prod-* # Wildcard: all APIs starting with prod-
19+
# - *-internal-* # Wildcard: all APIs containing -internal-
1820
1921
# Advanced: Filter API sub-resources (operations, diagnostics, schemas, releases)
2022
# apis:
@@ -23,6 +25,7 @@ export function generateFilterConfig(): string {
2325
# operations:
2426
# - get-pets
2527
# - create-pet
28+
# - list-* # Wildcard: all operations starting with list-
2629
# diagnostics:
2730
# - applicationinsights
2831
# schemas: [] # Exclude all schemas
@@ -116,5 +119,9 @@ export function generateFilterConfig(): string {
116119
# Example:
117120
# gateways: []
118121
# subscriptions: []
122+
# - Use * to match any characters: prod-* matches prod-api, prod-users
123+
# - Use ? to match a single character: api-v? matches api-v1, api-v2
124+
# - Exact names and wildcard patterns can be mixed in the same list
125+
# - All matching is case-insensitive
119126
`;
120127
}

0 commit comments

Comments
 (0)