Giter Site home page Giter Site logo

Comments (6)

github-anurag avatar github-anurag commented on June 8, 2024

Hi @jbcintra
Thank you for reaching out.
An example for using ListKeys can be found at: https://docs.oracle.com/en-us/iaas/api/#/en/key/release/KeySummary/ListKeys
If you still see the issue can you provide the following:-

  1. The .NET SDK version you are using?
  2. A code snippet.

from oci-dotnet-sdk.

jbcintra avatar jbcintra commented on June 8, 2024

Hi @github-anurag

I'm using the latest SDK, updated this week. The issue is running code to query keys ... fails and asks for another parameter that is not defined in the Model, nor in the examples, so no means to pass it in.

Simple code passing only CompartmentId:
public IEnumerable ListKeys(string compartmentId, KmsManagementClient client)
{
var request = new ListKeysRequest() {CompartmentId = compartmentId };
var response = client.ListKeys(request);
return response.Result.Items;
}

Then using the CLI against the API, it raises an error unless the parameter --endpoint is included e.g.
oci kms management key list --compartment-id

with or without "--all" triggers the missing variable "--endpoint"

From the Vaults output, passing in the ManagementEndpoint as the parameter --endpoint runs properly. (CryptoEndpoint passed in returns 404)

from oci-dotnet-sdk.

github-anurag avatar github-anurag commented on June 8, 2024

Hi @jbcintra

You can set the endpoint following the example at: https://github.com/oracle/oci-dotnet-sdk/blob/master/Examples/KeymanagementExample.cs
Essentially what you have to do is to use the Endpoint provided by the VaultClient as mentioned below:-

 var provider = new ConfigFileAuthenticationDetailsProvider("DEFAULT");
 var vaultId = Environment.GetEnvironmentVariable("VAULT_ID");

 KmsVaultClient kmsVaultClient = new KmsVaultClient(provider);
 KmsManagementClient kmsManagementClient = new KmsManagementClient(provider);
 
 Vault vault = await GetVault(kmsVaultClient, vaultId);
 // The ManagementClient use Vault specific endpoints; Set them now.
 kmsManagementClient.SetEndpoint(vault.ManagementEndpoint);

Where GetVault is the following:-

 private static async Task<Vault> GetVault(KmsVaultClient kmsVaultClient, string vaultId)
        {
            logger.Info("Get Vault");

            GetVaultRequest getVaultRequest = new GetVaultRequest
            {
                VaultId = vaultId
            };
            GetVaultResponse getVaultResponse = await kmsVaultClient.GetVault(getVaultRequest);

            logger.Info($"Retrieved vault: {getVaultResponse.Vault.DisplayName}");
            return getVaultResponse.Vault;
        }

from oci-dotnet-sdk.

jbcintra avatar jbcintra commented on June 8, 2024

Hi @github-anurag
Thanks for the pointer. I've had to rejig the code to create the KmsManagementClient just in time with provider, clientConfig, and endpoint.

It makes the code more cumbersome having to create new clients constantly, unlike those I've created for the rest of the OCI stack (~50), this is the only one with that requirement. It's an issue as I'm auditing multiple tenancies and multiple vaults, so have to enumerate the tenancies and vaults, then create completely new KmsManagementClients on every pass. But ... it's working.

Is this element going to be moved into being a parameter to align with all the other OciClients?

Thanks,

Justin.

from oci-dotnet-sdk.

github-anurag avatar github-anurag commented on June 8, 2024

Hi @jbcintra,
The KMS client is a special client and does not align with the other OCI Clients.

from oci-dotnet-sdk.

jbcintra avatar jbcintra commented on June 8, 2024

Thanks @github-anurag ! Glad it's just the one.

from oci-dotnet-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.