# Discovery ## Retrieve discovered operations on a zone rendered as OpenAPI schemas `client.apiGateway.discovery.get(DiscoveryGetParamsparams, RequestOptionsoptions?): DiscoveryGetResponse` **get** `/zones/{zone_id}/api_gateway/discovery` Retrieve the most up to date view of discovered operations, rendered as OpenAPI schemas ### Parameters - `params: DiscoveryGetParams` - `zone_id: string` Identifier. ### Returns - `DiscoveryGetResponse` - `schemas: Array` - `timestamp: string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const discovery = await client.apiGateway.discovery.get({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', }); console.log(discovery.schemas); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "schemas": [ { "info": { "title": "OpenAPI JSON schema for www.example.com", "version": "1.0" }, "openapi": "3.0.0", "paths": { "... Further paths ...": {}, "/api/v1/users/{var1}": { "get": { "parameters": [ { "in": "path", "name": "var1", "required": true, "schema": { "type": "string" } } ] } } }, "servers": [ { "url": "www.example.com" } ] } ], "timestamp": "2014-01-01T05:20:00.12345Z" }, "success": true } ``` ## Domain Types ### Discovery Operation - `DiscoveryOperation` - `id: string` UUID. - `endpoint: string` The endpoint which can contain path parameter templates in curly braces, each will be replaced from left to right with {varN}, starting with {var1}, during insertion. This will further be Cloudflare-normalized upon insertion. See: https://developers.cloudflare.com/rules/normalization/how-it-works/. - `host: string` RFC3986-compliant host. - `last_updated: string` - `method: "GET" | "POST" | "HEAD" | 6 more` The HTTP method used to access the endpoint. - `"GET"` - `"POST"` - `"HEAD"` - `"OPTIONS"` - `"PUT"` - `"DELETE"` - `"CONNECT"` - `"PATCH"` - `"TRACE"` - `origin: Array<"ML" | "SessionIdentifier" | "LabelDiscovery">` API discovery engine(s) that discovered this operation - `"ML"` - `"SessionIdentifier"` - `"LabelDiscovery"` - `state: "review" | "saved" | "ignored"` State of operation in API Discovery * `review` - Operation is not saved into API Shield Endpoint Management * `saved` - Operation is saved into API Shield Endpoint Management * `ignored` - Operation is marked as ignored - `"review"` - `"saved"` - `"ignored"` - `features?: Features` - `traffic_stats?: TrafficStats` - `last_updated: string` - `period_seconds: number` The period in seconds these statistics were computed over - `requests: number` The average number of requests seen during this period ### Discovery Get Response - `DiscoveryGetResponse` - `schemas: Array` - `timestamp: string` # Operations ## Retrieve discovered operations on a zone `client.apiGateway.discovery.operations.list(OperationListParamsparams, RequestOptionsoptions?): V4PagePaginationArray` **get** `/zones/{zone_id}/api_gateway/discovery/operations` Retrieve the most up to date view of discovered operations ### Parameters - `params: OperationListParams` - `zone_id: string` Path param: Identifier. - `diff?: boolean` Query param: When `true`, only return API Discovery results that are not saved into API Shield Endpoint Management - `direction?: "asc" | "desc"` Query param: Direction to order results. - `"asc"` - `"desc"` - `endpoint?: string` Query param: Filter results to only include endpoints containing this pattern. - `host?: Array` Query param: Filter results to only include the specified hosts. - `method?: Array` Query param: Filter results to only include the specified HTTP methods. - `order?: "host" | "method" | "endpoint" | 2 more` Query param: Field to order by - `"host"` - `"method"` - `"endpoint"` - `"traffic_stats.requests"` - `"traffic_stats.last_updated"` - `origin?: "ML" | "SessionIdentifier" | "LabelDiscovery"` Query param: Filter results to only include discovery results sourced from a particular discovery engine * `ML` - Discovered operations that were sourced using ML API Discovery * `SessionIdentifier` - Discovered operations that were sourced using Session Identifier API Discovery - `"ML"` - `"SessionIdentifier"` - `"LabelDiscovery"` - `page?: number` Query param: Page number of paginated results. - `per_page?: number` Query param: Maximum number of results per page. - `state?: "review" | "saved" | "ignored"` Query param: Filter results to only include discovery results in a particular state. States are as follows * `review` - Discovered operations that are not saved into API Shield Endpoint Management * `saved` - Discovered operations that are already saved into API Shield Endpoint Management * `ignored` - Discovered operations that have been marked as ignored - `"review"` - `"saved"` - `"ignored"` ### Returns - `DiscoveryOperation` - `id: string` UUID. - `endpoint: string` The endpoint which can contain path parameter templates in curly braces, each will be replaced from left to right with {varN}, starting with {var1}, during insertion. This will further be Cloudflare-normalized upon insertion. See: https://developers.cloudflare.com/rules/normalization/how-it-works/. - `host: string` RFC3986-compliant host. - `last_updated: string` - `method: "GET" | "POST" | "HEAD" | 6 more` The HTTP method used to access the endpoint. - `"GET"` - `"POST"` - `"HEAD"` - `"OPTIONS"` - `"PUT"` - `"DELETE"` - `"CONNECT"` - `"PATCH"` - `"TRACE"` - `origin: Array<"ML" | "SessionIdentifier" | "LabelDiscovery">` API discovery engine(s) that discovered this operation - `"ML"` - `"SessionIdentifier"` - `"LabelDiscovery"` - `state: "review" | "saved" | "ignored"` State of operation in API Discovery * `review` - Operation is not saved into API Shield Endpoint Management * `saved` - Operation is saved into API Shield Endpoint Management * `ignored` - Operation is marked as ignored - `"review"` - `"saved"` - `"ignored"` - `features?: Features` - `traffic_stats?: TrafficStats` - `last_updated: string` - `period_seconds: number` The period in seconds these statistics were computed over - `requests: number` The average number of requests seen during this period ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const discoveryOperation of client.apiGateway.discovery.operations.list({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', })) { console.log(discoveryOperation.id); } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": [ { "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", "endpoint": "/api/v1/users/{var1}", "host": "www.example.com", "last_updated": "2014-01-01T05:20:00.12345Z", "method": "GET", "origin": [ "ML" ], "state": "review", "features": { "traffic_stats": { "last_updated": "2014-01-01T05:20:00.12345Z", "period_seconds": 3600, "requests": 1987.06 } } } ], "success": true, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000, "total_pages": 100 } } ``` ## Patch discovered operation `client.apiGateway.discovery.operations.edit(stringoperationId, OperationEditParamsparams, RequestOptionsoptions?): OperationEditResponse` **patch** `/zones/{zone_id}/api_gateway/discovery/operations/{operation_id}` Update the `state` on a discovered operation ### Parameters - `operationId: string` UUID. - `params: OperationEditParams` - `zone_id: string` Path param: Identifier. - `state?: "review" | "ignored"` Body param: Mark state of operation in API Discovery * `review` - Mark operation as for review * `ignored` - Mark operation as ignored - `"review"` - `"ignored"` ### Returns - `OperationEditResponse` - `state?: "review" | "saved" | "ignored"` State of operation in API Discovery * `review` - Operation is not saved into API Shield Endpoint Management * `saved` - Operation is saved into API Shield Endpoint Management * `ignored` - Operation is marked as ignored - `"review"` - `"saved"` - `"ignored"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.apiGateway.discovery.operations.edit( 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, ); console.log(response.state); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "state": "review" }, "success": true } ``` ## Patch discovered operations `client.apiGateway.discovery.operations.bulkEdit(OperationBulkEditParamsparams, RequestOptionsoptions?): OperationBulkEditResponse` **patch** `/zones/{zone_id}/api_gateway/discovery/operations` Update the `state` on one or more discovered operations ### Parameters - `params: OperationBulkEditParams` - `zone_id: string` Path param: Identifier. - `body: Record` Body param - `state?: "review" | "ignored"` Mark state of operation in API Discovery * `review` - Mark operation as for review * `ignored` - Mark operation as ignored - `"review"` - `"ignored"` ### Returns - `OperationBulkEditResponse = Record` - `state?: "review" | "ignored"` Mark state of operation in API Discovery * `review` - Mark operation as for review * `ignored` - Mark operation as ignored - `"review"` - `"ignored"` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.apiGateway.discovery.operations.bulkEdit({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353', body: { '3818d821-5901-4147-a474-f5f5aec1d54e': {}, 'b17c8043-99a0-4202-b7d9-8f7cdbee02cd': {}, }, }); console.log(response); ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "3818d821-5901-4147-a474-f5f5aec1d54e": { "state": "ignored" }, "b17c8043-99a0-4202-b7d9-8f7cdbee02cd": { "state": "review" } }, "success": true } ``` ## Domain Types ### Operation Edit Response - `OperationEditResponse` - `state?: "review" | "saved" | "ignored"` State of operation in API Discovery * `review` - Operation is not saved into API Shield Endpoint Management * `saved` - Operation is saved into API Shield Endpoint Management * `ignored` - Operation is marked as ignored - `"review"` - `"saved"` - `"ignored"` ### Operation Bulk Edit Response - `OperationBulkEditResponse = Record` - `state?: "review" | "ignored"` Mark state of operation in API Discovery * `review` - Mark operation as for review * `ignored` - Mark operation as ignored - `"review"` - `"ignored"`