// 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).
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Oci.MarketplaceprivateofferService;
using Oci.Common;
using Oci.Common.Auth;
namespace Oci.Sdk.DotNet.Example.Marketplaceprivateoffer
{
public class CreateOfferExample
{
public static async Task Main()
{
// Create a request and dependent object(s).
var createOfferDetails = new Oci.MarketplaceprivateofferService.Models.CreateOfferDetails
{
DisplayName = "EXAMPLE-displayName-Value",
SellerCompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-sellerCompartmentId-Value",
BuyerCompartmentId = "ocid1.test.oc1..<unique_ID>EXAMPLE-buyerCompartmentId-Value",
Description = "EXAMPLE-description-Value",
InternalNotes = "EXAMPLE-internalNotes-Value",
TimeStartDate = DateTime.Parse("05/16/2023 23:28:59"),
Duration = "EXAMPLE-duration-Value",
TimeAcceptBy = DateTime.Parse("04/09/2023 00:07:24"),
Pricing = new Oci.MarketplaceprivateofferService.Models.Pricing
{
CurrencyType = "jUB",
TotalAmount = 907,
BillingCycle = Oci.MarketplaceprivateofferService.Models.Pricing.BillingCycleEnum.OneTime
},
BuyerInformation = new Oci.MarketplaceprivateofferService.Models.BuyerInformation
{
CompanyName = "EXAMPLE-companyName-Value",
NoteToBuyer = "EXAMPLE-noteToBuyer-Value",
PrimaryContact = new Oci.MarketplaceprivateofferService.Models.Contact
{
FirstName = "EXAMPLE-firstName-Value",
LastName = "EXAMPLE-lastName-Value",
Email = "EXAMPLE-email-Value"
},
AdditionalContacts = new List<Oci.MarketplaceprivateofferService.Models.Contact>
{
new Oci.MarketplaceprivateofferService.Models.Contact
{
FirstName = "EXAMPLE-firstName-Value",
LastName = "EXAMPLE-lastName-Value",
Email = "EXAMPLE-email-Value"
}
}
},
SellerInformation = new Oci.MarketplaceprivateofferService.Models.SellerInformation
{
PrimaryContact = new Oci.MarketplaceprivateofferService.Models.Contact
{
FirstName = "EXAMPLE-firstName-Value",
LastName = "EXAMPLE-lastName-Value",
Email = "EXAMPLE-email-Value"
},
AdditionalContacts = new List<Oci.MarketplaceprivateofferService.Models.Contact>
{
new Oci.MarketplaceprivateofferService.Models.Contact
{
FirstName = "EXAMPLE-firstName-Value",
LastName = "EXAMPLE-lastName-Value",
Email = "EXAMPLE-email-Value"
}
}
},
ResourceBundles = new List<Oci.MarketplaceprivateofferService.Models.ResourceBundle>
{
new Oci.MarketplaceprivateofferService.Models.ResourceBundle
{
Type = Oci.MarketplaceprivateofferService.Models.ResourceBundle.TypeEnum.Listing,
Quantity = 865,
UnitOfMeasurement = Oci.MarketplaceprivateofferService.Models.ResourceBundle.UnitOfMeasurementEnum.Credits,
ResourceIds = new List<string>
{
"EXAMPLE--Value"
}
}
},
CustomFields = new List<Oci.MarketplaceprivateofferService.Models.CustomField>
{
new Oci.MarketplaceprivateofferService.Models.CustomField
{
Key = "EXAMPLE-key-Value",
Value = "EXAMPLE-value-Value"
}
},
FreeformTags = new Dictionary<string, string>()
{
{
"EXAMPLE_KEY_VDA4v",
"EXAMPLE_VALUE_xUFVEXVI7a3HXXHSxFcQ"
}
},
DefinedTags = new Dictionary<string, Dictionary<string, Object>>()
{
{
"EXAMPLE_KEY_LRQMV",
new Dictionary<string, Object>()
{
{
"EXAMPLE_KEY_hBO5w",
"EXAMPLE--Value"
}
}
}
}
};
var createOfferRequest = new Oci.MarketplaceprivateofferService.Requests.CreateOfferRequest
{
CreateOfferDetails = createOfferDetails,
OpcRetryToken = "EXAMPLE-opcRetryToken-Value",
OpcRequestId = "JPU5FZEFTFD9HLNBQ7CH<unique_ID>"
};
// Create a default authentication provider that uses the DEFAULT
// profile in the configuration file.
// Refer to <see href="https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File>the public documentation</see> on how to prepare a configuration file.
var provider = new ConfigFileAuthenticationDetailsProvider("DEFAULT");
try
{
// Create a service client and send the request.
using (var client = new OfferClient(provider, new ClientConfiguration()))
{
var response = await client.CreateOffer(createOfferRequest);
// Retrieve value from the response.
var id = response.Offer.Id;
}
}
catch (Exception e)
{
Console.WriteLine($"CreateOffer Failed with {e.Message}");
throw e;
}
}
}
}