# This is an automatically generated code sample.
# To make this code sample work in your Oracle Cloud tenancy,
# please replace the values for any parameters whose current values do not fit
# your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and
# boolean, number, and enum parameters with values not fitting your use case).
require 'date'
require 'oci'
# Create a default config using DEFAULT profile in default location
# Refer to https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File for more info
config = OCI::ConfigFileLoader.load_config
# Initialize service client with default config file
cloud_bridge_client = OCI::CloudBridge::InventoryClient.new(config: config)
# Send the request to service, some parameters are not required, see API doc for more info
create_asset_response =
cloud_bridge_client.create_asset(
OCI::CloudBridge::Models::CreateAwsEc2AssetDetails.new(
asset_type: 'AWS_EC2',
inventory_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-inventoryId-Value',
compartment_id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value',
source_key: 'EXAMPLE-sourceKey-Value',
external_asset_key: 'EXAMPLE-externalAssetKey-Value',
compute:
OCI::CloudBridge::Models::ComputeProperties.new(
primary_ip: 'EXAMPLE-primaryIp-Value',
dns_name: 'EXAMPLE-dnsName-Value',
description: 'EXAMPLE-description-Value',
cores_count: 253,
cpu_model: 'EXAMPLE-cpuModel-Value',
gpu_devices_count: 603,
gpu_devices: [
OCI::CloudBridge::Models::GpuDevice.new(
name: 'EXAMPLE-name-Value',
description: 'EXAMPLE-description-Value',
cores_count: 953,
memory_in_mbs: 140,
manufacturer: 'EXAMPLE-manufacturer-Value'
)
],
threads_per_core_count: 802,
memory_in_mbs: 158,
is_pmem_enabled: true,
pmem_in_mbs: 667,
operating_system: 'EXAMPLE-operatingSystem-Value',
operating_system_version: 'EXAMPLE-operatingSystemVersion-Value',
host_name: 'EXAMPLE-hostName-Value',
power_state: 'EXAMPLE-powerState-Value',
guest_state: 'EXAMPLE-guestState-Value',
is_tpm_enabled: false,
connected_networks: 256,
nics_count: 593,
nics: [
OCI::CloudBridge::Models::Nic.new(
label: 'EXAMPLE-label-Value',
switch_name: 'EXAMPLE-switchName-Value',
mac_address: 'EXAMPLE-macAddress-Value',
mac_address_type: 'EXAMPLE-macAddressType-Value',
network_name: 'EXAMPLE-networkName-Value',
ip_addresses: %w[EXAMPLE--Value]
)
],
storage_provisioned_in_mbs: 13,
disks_count: 459,
disks: [
OCI::CloudBridge::Models::Disk.new(
name: 'EXAMPLE-name-Value',
boot_order: 254,
uuid: 'EXAMPLE-uuid-Value',
uuid_lun: 'EXAMPLE-uuidLun-Value',
size_in_mbs: 691,
location: 'EXAMPLE-location-Value',
persistent_mode: 'EXAMPLE-persistentMode-Value',
is_cbt_enabled: true
)
],
firmware: 'EXAMPLE-firmware-Value',
latency_sensitivity: 'EXAMPLE-latencySensitivity-Value',
nvdimms: [
OCI::CloudBridge::Models::Nvdimm.new(
label: 'EXAMPLE-label-Value',
unit_number: 357,
controller_key: 533
)
],
nvdimm_controller:
OCI::CloudBridge::Models::NvdimmController.new(
label: 'EXAMPLE-label-Value', bus_number: 576
),
scsi_controller:
OCI::CloudBridge::Models::ScsiController.new(
label: 'EXAMPLE-label-Value',
unit_number: 419,
shared_bus: 'EXAMPLE-sharedBus-Value'
),
hardware_version: 'EXAMPLE-hardwareVersion-Value'
),
vm:
OCI::CloudBridge::Models::VmProperties.new(
hypervisor_vendor: 'EXAMPLE-hypervisorVendor-Value',
hypervisor_version: 'EXAMPLE-hypervisorVersion-Value',
hypervisor_host: 'EXAMPLE-hypervisorHost-Value'
),
aws_ec2:
OCI::CloudBridge::Models::AwsEc2Properties.new(
architecture: 'EXAMPLE-architecture-Value',
instance_key: 'EXAMPLE-instanceKey-Value',
instance_type: 'EXAMPLE-instanceType-Value',
root_device_name: 'EXAMPLE-rootDeviceName-Value',
state:
OCI::CloudBridge::Models::InstanceState.new(
code: 541, name: 'EXAMPLE-name-Value'
),
boot_mode: 'EXAMPLE-bootMode-Value',
capacity_reservation_key: 'EXAMPLE-capacityReservationKey-Value',
are_elastic_inference_accelerators_present: false,
is_enclave_options: false,
is_hibernation_options: true,
image_key: 'EXAMPLE-imageKey-Value',
instance_lifecycle: 'EXAMPLE-instanceLifecycle-Value',
ip_address: 'EXAMPLE-ipAddress-Value',
ipv6_address: 'EXAMPLE-ipv6Address-Value',
kernel_key: 'EXAMPLE-kernelKey-Value',
time_launch: DateTime.parse('2011-01-25T19:14:25.802Z'),
licenses: %w[EXAMPLE--Value],
maintenance_options: 'EXAMPLE-maintenanceOptions-Value',
monitoring: 'EXAMPLE-monitoring-Value',
network_interfaces: [
OCI::CloudBridge::Models::InstanceNetworkInterface.new(
association:
OCI::CloudBridge::Models::InstanceNetworkInterfaceAssociation
.new(
carrier_ip: 'EXAMPLE-carrierIp-Value',
customer_owned_ip: 'EXAMPLE-customerOwnedIp-Value',
ip_owner_key: 'EXAMPLE-ipOwnerKey-Value',
public_dns_name: 'EXAMPLE-publicDnsName-Value',
public_ip: 'EXAMPLE-publicIp-Value'
),
attachment:
OCI::CloudBridge::Models::InstanceNetworkInterfaceAttachment
.new(
attachment_key: 'EXAMPLE-attachmentKey-Value',
time_attach: DateTime.parse('2040-08-21T21:49:13.881Z'),
is_delete_on_termination: false,
device_index: 940,
network_card_index: 473,
status: 'EXAMPLE-status-Value'
),
description: 'EXAMPLE-description-Value',
security_groups: [
OCI::CloudBridge::Models::GroupIdentifier.new(
group_key: 'EXAMPLE-groupKey-Value',
group_name: 'EXAMPLE-groupName-Value'
)
],
interface_type: 'EXAMPLE-interfaceType-Value',
ipv4_prefixes: %w[EXAMPLE--Value],
ipv6_addresses: %w[EXAMPLE--Value],
ipv6_prefixes: %w[EXAMPLE--Value],
mac_address: 'EXAMPLE-macAddress-Value',
network_interface_key: 'EXAMPLE-networkInterfaceKey-Value',
owner_key: 'EXAMPLE-ownerKey-Value',
private_ip_addresses: [
OCI::CloudBridge::Models::InstancePrivateIpAddress.new(
association:
OCI::CloudBridge::Models::InstanceNetworkInterfaceAssociation
.new(
carrier_ip: 'EXAMPLE-carrierIp-Value',
customer_owned_ip: 'EXAMPLE-customerOwnedIp-Value',
ip_owner_key: 'EXAMPLE-ipOwnerKey-Value',
public_dns_name: 'EXAMPLE-publicDnsName-Value',
public_ip: 'EXAMPLE-publicIp-Value'
),
is_primary: false,
private_dns_name: 'EXAMPLE-privateDnsName-Value',
private_ip_address: 'EXAMPLE-privateIpAddress-Value'
)
],
is_source_dest_check: false,
status: 'EXAMPLE-status-Value',
subnet_key: 'EXAMPLE-subnetKey-Value'
)
],
placement:
OCI::CloudBridge::Models::Placement.new(
affinity: 'EXAMPLE-affinity-Value',
availability_zone: 'EXAMPLE-availabilityZone-Value',
group_name: 'EXAMPLE-groupName-Value',
host_key: 'EXAMPLE-hostKey-Value',
host_resource_group_arn: 'EXAMPLE-hostResourceGroupArn-Value',
partition_number: 797,
spread_domain: 'EXAMPLE-spreadDomain-Value',
tenancy: 'EXAMPLE-tenancy-Value'
),
private_dns_name: 'EXAMPLE-privateDnsName-Value',
private_ip_address: 'EXAMPLE-privateIpAddress-Value',
root_device_type: 'EXAMPLE-rootDeviceType-Value',
security_groups: [
OCI::CloudBridge::Models::GroupIdentifier.new(
group_key: 'EXAMPLE-groupKey-Value',
group_name: 'EXAMPLE-groupName-Value'
)
],
is_source_dest_check: false,
is_spot_instance: false,
sriov_net_support: 'EXAMPLE-sriovNetSupport-Value',
subnet_key: 'EXAMPLE-subnetKey-Value',
tags: [
OCI::CloudBridge::Models::Tag.new(
key: 'EXAMPLE-key-Value', value: 'EXAMPLE-value-Value'
)
],
tpm_support: 'EXAMPLE-tpmSupport-Value',
virtualization_type: 'EXAMPLE-virtualizationType-Value',
vpc_key: 'EXAMPLE-vpcKey-Value'
),
display_name: 'EXAMPLE-displayName-Value',
asset_source_ids: %w[EXAMPLE--Value],
freeform_tags: {
'EXAMPLE_KEY_3bvm9' => 'EXAMPLE_VALUE_L6Lu7gccPZ0gUWmGV5NE'
},
defined_tags: {
'EXAMPLE_KEY_oKZUl' => { 'EXAMPLE_KEY_5rhTl' => 'EXAMPLE--Value' }
},
aws_ec2_cost:
OCI::CloudBridge::Models::MonthlyCostSummary.new(
amount: 8355.231, currency_code: 'EXAMPLE-currencyCode-Value'
),
attached_ebs_volumes_cost:
OCI::CloudBridge::Models::MonthlyCostSummary.new(
amount: 4176.9644, currency_code: 'EXAMPLE-currencyCode-Value'
)
)
)
# Get the data from response
puts "#{create_asset_response.data}"