Download wp-calypso/client/data/domains/dnssec/use-enable-dnssec-mutation.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/data/domains/dnssec/use-enable-dnssec-mutation.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/data/domains/dnssec/use-enable-dnssec-mutation.ts
-
curl -L -o use-enable-dnssec-mutation.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/data/domains/dnssec/use-enable-dnssec-mutation.ts
1.01 kB
| import { useMutation } from '@tanstack/react-query'; | |
| import { DomainsApiError } from 'calypso/lib/domains/types'; | |
| import wp from 'calypso/lib/wp'; | |
| type Dnskey = { | |
| algorithm: number; | |
| flags: number; | |
| protocol: number; | |
| public_key: string; | |
| rdata: string; | |
| }; | |
| type DsData = { | |
| algorithm: number; | |
| digest: string; | |
| digest_type: number; | |
| key_tag: number; | |
| rdata: string; | |
| }; | |
| type EnableDnssecSuccessResponse = { | |
| data: { | |
| cryptokeys: Array< { | |
| dnskey?: Dnskey; | |
| ds_data?: Array< DsData >; | |
| } >; | |
| dnssec_data_set_at_registry: boolean; | |
| }; | |
| }; | |
| export default function useEnableDnssecMutation( | |
| domainName: string, | |
| queryOptions: { | |
| onSuccess?: ( success: EnableDnssecSuccessResponse ) => void; | |
| onError?: ( error: DomainsApiError ) => void; | |
| } | |
| ) { | |
| const mutation = useMutation( { | |
| mutationFn: () => { | |
| return wp.req.post( { | |
| path: `/domains/dnssec/${ domainName }`, | |
| apiNamespace: 'wpcom/v2', | |
| } ); | |
| }, | |
| ...queryOptions, | |
| } ); | |
| return { enableDnssec: mutation.mutate, ...mutation }; | |
| } | |