All files / src/api credentials.api.ts

0% Statements 0/10
0% Branches 0/1
0% Functions 0/1
0% Lines 0/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29                                                         
import api from './axios'
import type {
  OpenStackCredentialFromYaml,
  OpenStackCredentialResponse,
  OpenStackCredentialUpsert,
} from '@/types/openstack-credential'
 
// ----------------------------------------------------------------
// OPENSTACK CREDENTIALS API
// ----------------------------------------------------------------
export const credentialsApi = {
  /** Read masked credential status for the current user. Always 200. */
  get: () => api.get<OpenStackCredentialResponse>('/me/openstack-credentials'),
 
  /** Replace credentials with a fully-formed payload. Auto-validates server-side. */
  put: (payload: OpenStackCredentialUpsert) =>
    api.put<OpenStackCredentialResponse>('/me/openstack-credentials', payload),
 
  /** Upload raw clouds.yaml; server picks the cloud apart and validates. */
  putFromYaml: (body: OpenStackCredentialFromYaml) =>
    api.put<OpenStackCredentialResponse>('/me/openstack-credentials/from-yaml', body),
 
  /** Re-authorize the stored credential and refresh `last_validated_at`. */
  test: () => api.post<OpenStackCredentialResponse>('/me/openstack-credentials/test'),
 
  /** Remove the stored credential. */
  remove: () => api.delete<void>('/me/openstack-credentials'),
}