import type { AxiosInstance } from 'contentful-sdk-core' ; import copy from 'fast-copy' ; import { SetOptional } from 'type-fest' ; import { CollectionProp , GetSpaceParams , QueryParams } from '../../../common-types' ; import { ApiKeyProps , CreateApiKeyProps } from '../../../entities/api-key' ; import { RestEndpoint } from '../types' ; import * as raw from './raw' ; export const get = ( http , params ) => { return raw . get < ApiKeyProps > ( http , `/spaces/${ params . spaceId }/api_keys/${ params . apiKeyId }` ) ; } ; export const getMany = ( http , params ) => { return raw . get < CollectionProp < ApiKeyProps > > ( http , `/spaces/${ params . spaceId }/api_keys` , { params : params . query , } ) ; } ; export const create = ( http , params , data , headers ? ) => { return raw . post < ApiKeyProps > ( http , `/spaces/${ params . spaceId }/api_keys` , data , { headers } ) ; } ; export const createWithId = ( http , params , data , headers ? ) => { return raw . put < ApiKeyProps > ( http , `/spaces/${ params . spaceId }/api_keys/${ params . apiKeyId }` , data , { headers , } ) ; } ; export const update = ( http , params , rawData , headers ? ) => { const data = copy ( rawData ) ; if ( 'accessToken' in data ) { delete data . accessToken ; } if ( 'preview_api_key' in data ) { delete data . preview_api_key ; } if ( 'policies' in data ) { delete data . policies ; } delete data . sys ; return raw . put < ApiKeyProps > ( http , `/spaces/${ params . spaceId }/api_keys/${ params . apiKeyId }` , data , { headers : { 'X-Contentful-Version' : rawData . sys . version ?? 0 , ... headers , } , } ) ; } ; export const del = ( http , params ) => { return raw . del ( http , `/spaces/${ params . spaceId }/api_keys/${ params . apiKeyId }` ) ; } ;