|
| 1 | +// This file was automatically generated. DO NOT EDIT. |
| 2 | +// If you have any remark or suggestion do not hesitate to open an issue. |
| 3 | +import { |
| 4 | + isJSONObject, |
| 5 | + unmarshalArrayOfObject, |
| 6 | + unmarshalDate, |
| 7 | +} from '../../../bridge' |
| 8 | +import type { |
| 9 | + Event, |
| 10 | + EventPrincipal, |
| 11 | + KubernetesClusterInfo, |
| 12 | + KubernetesNodeInfo, |
| 13 | + KubernetesPoolInfo, |
| 14 | + ListEventsResponse, |
| 15 | + ListProductsResponse, |
| 16 | + Product, |
| 17 | + Resource, |
| 18 | + SecretManagerSecretInfo, |
| 19 | + SecretManagerSecretVersionInfo, |
| 20 | +} from './types.gen' |
| 21 | + |
| 22 | +const unmarshalKubernetesClusterInfo = ( |
| 23 | + data: unknown, |
| 24 | +): KubernetesClusterInfo => { |
| 25 | + if (!isJSONObject(data)) { |
| 26 | + throw new TypeError( |
| 27 | + `Unmarshalling the type 'KubernetesClusterInfo' failed as data isn't a dictionary.`, |
| 28 | + ) |
| 29 | + } |
| 30 | + |
| 31 | + return {} as KubernetesClusterInfo |
| 32 | +} |
| 33 | + |
| 34 | +const unmarshalKubernetesNodeInfo = (data: unknown): KubernetesNodeInfo => { |
| 35 | + if (!isJSONObject(data)) { |
| 36 | + throw new TypeError( |
| 37 | + `Unmarshalling the type 'KubernetesNodeInfo' failed as data isn't a dictionary.`, |
| 38 | + ) |
| 39 | + } |
| 40 | + |
| 41 | + return { |
| 42 | + id: data.id, |
| 43 | + name: data.name, |
| 44 | + } as KubernetesNodeInfo |
| 45 | +} |
| 46 | + |
| 47 | +const unmarshalKubernetesPoolInfo = (data: unknown): KubernetesPoolInfo => { |
| 48 | + if (!isJSONObject(data)) { |
| 49 | + throw new TypeError( |
| 50 | + `Unmarshalling the type 'KubernetesPoolInfo' failed as data isn't a dictionary.`, |
| 51 | + ) |
| 52 | + } |
| 53 | + |
| 54 | + return { |
| 55 | + id: data.id, |
| 56 | + name: data.name, |
| 57 | + } as KubernetesPoolInfo |
| 58 | +} |
| 59 | + |
| 60 | +const unmarshalSecretManagerSecretInfo = ( |
| 61 | + data: unknown, |
| 62 | +): SecretManagerSecretInfo => { |
| 63 | + if (!isJSONObject(data)) { |
| 64 | + throw new TypeError( |
| 65 | + `Unmarshalling the type 'SecretManagerSecretInfo' failed as data isn't a dictionary.`, |
| 66 | + ) |
| 67 | + } |
| 68 | + |
| 69 | + return { |
| 70 | + path: data.path, |
| 71 | + } as SecretManagerSecretInfo |
| 72 | +} |
| 73 | + |
| 74 | +const unmarshalSecretManagerSecretVersionInfo = ( |
| 75 | + data: unknown, |
| 76 | +): SecretManagerSecretVersionInfo => { |
| 77 | + if (!isJSONObject(data)) { |
| 78 | + throw new TypeError( |
| 79 | + `Unmarshalling the type 'SecretManagerSecretVersionInfo' failed as data isn't a dictionary.`, |
| 80 | + ) |
| 81 | + } |
| 82 | + |
| 83 | + return { |
| 84 | + revision: data.revision, |
| 85 | + } as SecretManagerSecretVersionInfo |
| 86 | +} |
| 87 | + |
| 88 | +const unmarshalEventPrincipal = (data: unknown): EventPrincipal => { |
| 89 | + if (!isJSONObject(data)) { |
| 90 | + throw new TypeError( |
| 91 | + `Unmarshalling the type 'EventPrincipal' failed as data isn't a dictionary.`, |
| 92 | + ) |
| 93 | + } |
| 94 | + |
| 95 | + return { |
| 96 | + id: data.id, |
| 97 | + } as EventPrincipal |
| 98 | +} |
| 99 | + |
| 100 | +export const unmarshalResource = (data: unknown): Resource => { |
| 101 | + if (!isJSONObject(data)) { |
| 102 | + throw new TypeError( |
| 103 | + `Unmarshalling the type 'Resource' failed as data isn't a dictionary.`, |
| 104 | + ) |
| 105 | + } |
| 106 | + |
| 107 | + return { |
| 108 | + createdAt: unmarshalDate(data.created_at), |
| 109 | + deletedAt: unmarshalDate(data.deleted_at), |
| 110 | + id: data.id, |
| 111 | + kubeClusterInfo: data.kube_cluster_info |
| 112 | + ? unmarshalKubernetesClusterInfo(data.kube_cluster_info) |
| 113 | + : undefined, |
| 114 | + kubeNodeInfo: data.kube_node_info |
| 115 | + ? unmarshalKubernetesNodeInfo(data.kube_node_info) |
| 116 | + : undefined, |
| 117 | + kubePoolInfo: data.kube_pool_info |
| 118 | + ? unmarshalKubernetesPoolInfo(data.kube_pool_info) |
| 119 | + : undefined, |
| 120 | + name: data.name, |
| 121 | + secmSecretInfo: data.secm_secret_info |
| 122 | + ? unmarshalSecretManagerSecretInfo(data.secm_secret_info) |
| 123 | + : undefined, |
| 124 | + secmSecretVersionInfo: data.secm_secret_version_info |
| 125 | + ? unmarshalSecretManagerSecretVersionInfo(data.secm_secret_version_info) |
| 126 | + : undefined, |
| 127 | + type: data.type, |
| 128 | + updatedAt: unmarshalDate(data.updated_at), |
| 129 | + } as Resource |
| 130 | +} |
| 131 | + |
| 132 | +export const unmarshalEvent = (data: unknown): Event => { |
| 133 | + if (!isJSONObject(data)) { |
| 134 | + throw new TypeError( |
| 135 | + `Unmarshalling the type 'Event' failed as data isn't a dictionary.`, |
| 136 | + ) |
| 137 | + } |
| 138 | + |
| 139 | + return { |
| 140 | + id: data.id, |
| 141 | + locality: data.locality, |
| 142 | + methodName: data.method_name, |
| 143 | + organizationId: data.organization_id, |
| 144 | + principal: data.principal |
| 145 | + ? unmarshalEventPrincipal(data.principal) |
| 146 | + : undefined, |
| 147 | + productName: data.product_name, |
| 148 | + projectId: data.project_id, |
| 149 | + recordedAt: unmarshalDate(data.recorded_at), |
| 150 | + requestBody: data.request_body, |
| 151 | + requestId: data.request_id, |
| 152 | + resource: data.resource ? unmarshalResource(data.resource) : undefined, |
| 153 | + serviceName: data.service_name, |
| 154 | + sourceIp: data.source_ip, |
| 155 | + statusCode: data.status_code, |
| 156 | + userAgent: data.user_agent, |
| 157 | + } as Event |
| 158 | +} |
| 159 | + |
| 160 | +export const unmarshalListEventsResponse = ( |
| 161 | + data: unknown, |
| 162 | +): ListEventsResponse => { |
| 163 | + if (!isJSONObject(data)) { |
| 164 | + throw new TypeError( |
| 165 | + `Unmarshalling the type 'ListEventsResponse' failed as data isn't a dictionary.`, |
| 166 | + ) |
| 167 | + } |
| 168 | + |
| 169 | + return { |
| 170 | + events: unmarshalArrayOfObject(data.events, unmarshalEvent), |
| 171 | + nextPageToken: data.next_page_token, |
| 172 | + } as ListEventsResponse |
| 173 | +} |
| 174 | + |
| 175 | +const unmarshalProduct = (data: unknown): Product => { |
| 176 | + if (!isJSONObject(data)) { |
| 177 | + throw new TypeError( |
| 178 | + `Unmarshalling the type 'Product' failed as data isn't a dictionary.`, |
| 179 | + ) |
| 180 | + } |
| 181 | + |
| 182 | + return { |
| 183 | + name: data.name, |
| 184 | + title: data.title, |
| 185 | + } as Product |
| 186 | +} |
| 187 | + |
| 188 | +export const unmarshalListProductsResponse = ( |
| 189 | + data: unknown, |
| 190 | +): ListProductsResponse => { |
| 191 | + if (!isJSONObject(data)) { |
| 192 | + throw new TypeError( |
| 193 | + `Unmarshalling the type 'ListProductsResponse' failed as data isn't a dictionary.`, |
| 194 | + ) |
| 195 | + } |
| 196 | + |
| 197 | + return { |
| 198 | + products: unmarshalArrayOfObject(data.products, unmarshalProduct), |
| 199 | + totalCount: data.total_count, |
| 200 | + } as ListProductsResponse |
| 201 | +} |
0 commit comments