private void instanceToRow()

in athena-aws-cmdb/src/main/java/com/amazonaws/athena/connectors/aws/cmdb/tables/RdsTableProvider.java [132:267]


    private void instanceToRow(DBInstance instance,
            BlockSpiller spiller)
    {
        spiller.writeRows((Block block, int row) -> {
            boolean matched = true;

            matched &= block.offerValue("instance_id", row, instance.getDBInstanceIdentifier());
            matched &= block.offerValue("primary_az", row, instance.getAvailabilityZone());
            matched &= block.offerValue("storage_gb", row, instance.getAllocatedStorage());
            matched &= block.offerValue("is_encrypted", row, instance.getStorageEncrypted());
            matched &= block.offerValue("storage_type", row, instance.getStorageType());
            matched &= block.offerValue("backup_retention_days", row, instance.getBackupRetentionPeriod());
            matched &= block.offerValue("auto_upgrade", row, instance.getAutoMinorVersionUpgrade());
            matched &= block.offerValue("instance_class", row, instance.getDBInstanceClass());
            matched &= block.offerValue("port", row, instance.getDbInstancePort());
            matched &= block.offerValue("status", row, instance.getDBInstanceStatus());
            matched &= block.offerValue("dbi_resource_id", row, instance.getDbiResourceId());
            matched &= block.offerValue("name", row, instance.getDBName());
            matched &= block.offerValue("engine", row, instance.getEngine());
            matched &= block.offerValue("engine_version", row, instance.getEngineVersion());
            matched &= block.offerValue("license_model", row, instance.getLicenseModel());
            matched &= block.offerValue("secondary_az", row, instance.getSecondaryAvailabilityZone());
            matched &= block.offerValue("backup_window", row, instance.getPreferredBackupWindow());
            matched &= block.offerValue("maint_window", row, instance.getPreferredMaintenanceWindow());
            matched &= block.offerValue("read_replica_source_id", row, instance.getReadReplicaSourceDBInstanceIdentifier());
            matched &= block.offerValue("create_time", row, instance.getInstanceCreateTime());
            matched &= block.offerValue("public_access", row, instance.getPubliclyAccessible());
            matched &= block.offerValue("iops", row, instance.getIops());
            matched &= block.offerValue("is_multi_az", row, instance.getMultiAZ());

            matched &= block.offerComplexValue("domains", row, (Field field, Object val) -> {
                        if (field.getName().equals("domain")) {
                            return ((DomainMembership) val).getDomain();
                        }
                        else if (field.getName().equals("fqdn")) {
                            return ((DomainMembership) val).getFQDN();
                        }
                        else if (field.getName().equals("iam_role")) {
                            return ((DomainMembership) val).getIAMRoleName();
                        }
                        else if (field.getName().equals("status")) {
                            return ((DomainMembership) val).getStatus();
                        }

                        throw new RuntimeException("Unexpected field " + field.getName());
                    },
                    instance.getDomainMemberships());

            matched &= block.offerComplexValue("param_groups", row, (Field field, Object val) -> {
                        if (field.getName().equals("name")) {
                            return ((DBParameterGroupStatus) val).getDBParameterGroupName();
                        }
                        else if (field.getName().equals("status")) {
                            return ((DBParameterGroupStatus) val).getParameterApplyStatus();
                        }
                        throw new RuntimeException("Unexpected field " + field.getName());
                    },
                    instance.getDBParameterGroups());

            matched &= block.offerComplexValue("db_security_groups",
                    row,
                    (Field field, Object val) -> {
                        if (field.getName().equals("name")) {
                            return ((DBSecurityGroupMembership) val).getDBSecurityGroupName();
                        }
                        else if (field.getName().equals("status")) {
                            return ((DBSecurityGroupMembership) val).getStatus();
                        }
                        throw new RuntimeException("Unexpected field " + field.getName());
                    },
                    instance.getDBSecurityGroups());

            matched &= block.offerComplexValue("subnet_group",
                    row,
                    (Field field, Object val) -> {
                        if (field.getName().equals("description")) {
                            return ((DBSubnetGroup) val).getDBSubnetGroupDescription();
                        }
                        else if (field.getName().equals("name")) {
                            return ((DBSubnetGroup) val).getDBSubnetGroupName();
                        }
                        else if (field.getName().equals("status")) {
                            return ((DBSubnetGroup) val).getSubnetGroupStatus();
                        }
                        else if (field.getName().equals("vpc")) {
                            return ((DBSubnetGroup) val).getVpcId();
                        }
                        else if (field.getName().equals("subnets")) {
                            return ((DBSubnetGroup) val).getSubnets().stream()
                                    .map(next -> next.getSubnetIdentifier()).collect(Collectors.toList());
                        }
                        else if (val instanceof Subnet) {
                            return ((Subnet) val).getSubnetIdentifier();
                        }
                        throw new RuntimeException("Unexpected field " + field.getName());
                    },
                    instance.getDBSubnetGroup());

            matched &= block.offerComplexValue("endpoint",
                    row,
                    (Field field, Object val) -> {
                        if (field.getName().equals("address")) {
                            return ((Endpoint) val).getAddress();
                        }
                        else if (field.getName().equals("port")) {
                            return ((Endpoint) val).getPort();
                        }
                        else if (field.getName().equals("zone")) {
                            return ((Endpoint) val).getHostedZoneId();
                        }
                        throw new RuntimeException("Unexpected field " + field.getName());
                    },
                    instance.getEndpoint());

            matched &= block.offerComplexValue("status_infos",
                    row,
                    (Field field, Object val) -> {
                        if (field.getName().equals("message")) {
                            return ((DBInstanceStatusInfo) val).getMessage();
                        }
                        else if (field.getName().equals("is_normal")) {
                            return ((DBInstanceStatusInfo) val).getNormal();
                        }
                        else if (field.getName().equals("status")) {
                            return ((DBInstanceStatusInfo) val).getStatus();
                        }
                        else if (field.getName().equals("type")) {
                            return ((DBInstanceStatusInfo) val).getStatusType();
                        }
                        throw new RuntimeException("Unexpected field " + field.getName());
                    },
                    instance.getStatusInfos());

            return matched ? 1 : 0;
        });
    }