export async function _mongoClustersUpdateDeserialize()

in sdk/mongocluster/arm-mongocluster/src/api/mongoClusters/index.ts [422:554]


export async function _mongoClustersUpdateDeserialize(
  result: PathUncheckedResponse,
): Promise<MongoCluster> {
  const expectedStatuses = ["200", "202"];
  if (!expectedStatuses.includes(result.status)) {
    throw createRestError(result);
  }

  return {
    tags: result.body["tags"],
    location: result.body["location"],
    id: result.body["id"],
    name: result.body["name"],
    type: result.body["type"],
    systemData: !result.body.systemData
      ? undefined
      : {
          createdBy: result.body.systemData?.["createdBy"],
          createdByType: result.body.systemData?.["createdByType"],
          createdAt:
            result.body.systemData?.["createdAt"] !== undefined
              ? new Date(result.body.systemData?.["createdAt"])
              : undefined,
          lastModifiedBy: result.body.systemData?.["lastModifiedBy"],
          lastModifiedByType: result.body.systemData?.["lastModifiedByType"],
          lastModifiedAt:
            result.body.systemData?.["lastModifiedAt"] !== undefined
              ? new Date(result.body.systemData?.["lastModifiedAt"])
              : undefined,
        },
    properties: !result.body.properties
      ? undefined
      : {
          createMode: result.body.properties?.["createMode"],
          restoreParameters: !result.body.properties?.restoreParameters
            ? undefined
            : {
                pointInTimeUTC:
                  result.body.properties?.restoreParameters?.["pointInTimeUTC"] !== undefined
                    ? new Date(result.body.properties?.restoreParameters?.["pointInTimeUTC"])
                    : undefined,
                sourceResourceId: result.body.properties?.restoreParameters?.["sourceResourceId"],
              },
          replicaParameters: !result.body.properties?.replicaParameters
            ? undefined
            : {
                sourceResourceId: result.body.properties?.replicaParameters?.["sourceResourceId"],
                sourceLocation: result.body.properties?.replicaParameters?.["sourceLocation"],
              },
          administrator: !result.body.properties?.administrator
            ? undefined
            : {
                userName: result.body.properties?.administrator?.["userName"],
                password: result.body.properties?.administrator?.["password"],
              },
          serverVersion: result.body.properties?.["serverVersion"],
          connectionString: result.body.properties?.["connectionString"],
          provisioningState: result.body.properties?.["provisioningState"],
          clusterStatus: result.body.properties?.["clusterStatus"],
          publicNetworkAccess: result.body.properties?.["publicNetworkAccess"],
          highAvailability: !result.body.properties?.highAvailability
            ? undefined
            : {
                targetMode: result.body.properties?.highAvailability?.["targetMode"],
              },
          storage: !result.body.properties?.storage
            ? undefined
            : { sizeGb: result.body.properties?.storage?.["sizeGb"] },
          sharding: !result.body.properties?.sharding
            ? undefined
            : { shardCount: result.body.properties?.sharding?.["shardCount"] },
          compute: !result.body.properties?.compute
            ? undefined
            : { tier: result.body.properties?.compute?.["tier"] },
          backup: !result.body.properties?.backup
            ? undefined
            : {
                earliestRestoreTime: result.body.properties?.backup?.["earliestRestoreTime"],
              },
          privateEndpointConnections:
            result.body.properties?.["privateEndpointConnections"] === undefined
              ? result.body.properties?.["privateEndpointConnections"]
              : result.body.properties?.["privateEndpointConnections"].map((p: any) => {
                  return {
                    id: p["id"],
                    name: p["name"],
                    type: p["type"],
                    systemData: !p.systemData
                      ? undefined
                      : {
                          createdBy: p.systemData?.["createdBy"],
                          createdByType: p.systemData?.["createdByType"],
                          createdAt:
                            p.systemData?.["createdAt"] !== undefined
                              ? new Date(p.systemData?.["createdAt"])
                              : undefined,
                          lastModifiedBy: p.systemData?.["lastModifiedBy"],
                          lastModifiedByType: p.systemData?.["lastModifiedByType"],
                          lastModifiedAt:
                            p.systemData?.["lastModifiedAt"] !== undefined
                              ? new Date(p.systemData?.["lastModifiedAt"])
                              : undefined,
                        },
                    properties: !p.properties
                      ? undefined
                      : {
                          groupIds: p.properties?.["groupIds"],
                          privateEndpoint: !p.properties?.privateEndpoint
                            ? undefined
                            : { id: p.properties?.privateEndpoint?.["id"] },
                          privateLinkServiceConnectionState: {
                            status: p.properties?.privateLinkServiceConnectionState["status"],
                            description:
                              p.properties?.privateLinkServiceConnectionState["description"],
                            actionsRequired:
                              p.properties?.privateLinkServiceConnectionState["actionsRequired"],
                          },
                          provisioningState: p.properties?.["provisioningState"],
                        },
                  };
                }),
          previewFeatures: result.body.properties?.["previewFeatures"],
          replica: !result.body.properties?.replica
            ? undefined
            : {
                sourceResourceId: result.body.properties?.replica?.["sourceResourceId"],
                role: result.body.properties?.replica?.["role"],
                replicationState: result.body.properties?.replica?.["replicationState"],
              },
          infrastructureVersion: result.body.properties?.["infrastructureVersion"],
        },
  };
}