GithubHelp home page GithubHelp logo

isabella232 / oci-dotnet-sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from oracle/oci-dotnet-sdk

0.0 0.0 0.0 17.13 MB

Oracle Cloud Infrastructure SDK for .NET

Home Page: https://cloud.oracle.com/cloud-infrastructure

License: Other

C# 100.00% Makefile 0.01%

oci-dotnet-sdk's Introduction

Oracle Cloud Infrastructure SDK for .NET

About

The oci-dotnet-sdk provides an SDK for .NET that you can use to manage your Oracle Cloud Infrastructure resources.

The project is open source and maintained by Oracle Corp.

Dependencies

SDK Organization

The oci-dotnet-sdk contain the following 3 groups of packages:

  • Common package: Found in the Common and Commontests (unit tests for common package) directories. The common package provides supporting classes and methods used by service packages. It includes HTTP request/response (de)serialization, request signing, JSON parsing, and other helper functions. Most of the functions in this package are meant to be used by the service packages.
  • Examples package: Found in the Examples directory. It includes some working examples on how to use oci-dotnet-sdk to manage Oracle Cloud Infrastracture resources.
  • Service packages: All packages except Common, Commontests, and Examples. These packages represent the Oracle Cloud Infrastructure services supported by the .NET SDK. Each package represents a service. These packages include the service client(s) with methods to interact with the service, classes for the requests, responses, and input and output parameters.

Install Packages

The SDK is published as Nuget packages.

Use either dotnet CLI or Visual Studio to install and consume a package from nuget.org.

  • dotnet CLI:
dotnet add package <PACKAGE_ID> --version <VERSION> (If version not specified then it pulls the latest version)

Example:
dotnet add package OCI.DotNetSDK.Core (Installs the latest version of the Core Service package)
dotnet add package OCI.DotNetSDK.Identity -v 1.0.0 (Installs version 1.0.0 of the Identity Service package)

NOTE: To avoid dependency conflicts, you should use the same versions of all OCI .NET SDK Nuget packages within an application.
  • Visual Studio: Right-click a project and select "Manage Nuget Packages" and then search for the package name and version number to install.

Documentation

Public documentation and API Reference for the sdk can be found here.

Working with the .NET SDK

To start working with oci-dotnet-sdk, you need to create a .NET project, install packages, create a client, and then use that client to send requests to service endpoint.

Configuring

Before using the SDK, set up a config file with the required credentials. See SDK and Tool Configuration for instructions.

Creating Client

To create a service client, you need to set up the client to use the credentials. Check here on how to configure it.

Example that shows creating the Audit Service client using ConfigFileAuthenticationDetailsProvider Class for configuring credentials:

var provider = new ConfigFileAuthenticationDetailsProvider("DEFAULT");
var client = new AuditClient(provider, new ClientConfiguration());

Sending Request

To send a request to an Oracle Cloud Infrastructure service endpoint, build a request object and send it using the client created above.

var listEventsRequest = new ListEventsRequest
{
    // Assumption: the compartment id has been set in environment variable.
    CompartmentId = compartmentId,
    StartTime = DateTime.Now.AddDays(-1),
    EndTime = DateTime.Now
};

try
{
    var response = await client.ListEvents(listEventsRequest);
}
catch (Exception e)
{
    // Handle the exception.
}

Enable Logging

NLog package is used for logging in .NET projects. This package gets auto-installed as a dependency when you install OCI .NET SDK package. In order to view .NET SDK logs, you will need to:

  • Add NLog.config file at the project root directory. A sample NLog.config file can be found here.
  • Add ItemGroup section in the project file:
<ItemGroup>
     <Content Include="PATH TO NLog.config File" >
          <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
</ItemGroup>
  • To enable logging in user application, create a logger:
var logger = NLog.LogManager.GetCurrentClassLogger();
logger.Info("Hello World");

NOTE

Only SDK logging will be captured if logger is not created in user application.


Examples

Examples can be found here.

Examples for all supported services can be found at the API reference under their respective reference doc.

To use the example code: copy the sample, change the parameter values to values that make sense for your use case (ex: OCI instance ID with your OCI instance ID), and then you can run the code to have a working automation against OCI.

Building and Testing

Build

Building the SDK can be done at the root of the whole solution or at individual project level under it. At the root level, to build the whole solution, run with dotnet cli command:

dotnet build

or use the included Makefile:

make build

The Makefile also provides an option to build individal projects from the root level:

make build PROJECT_PATH=Common

Alternatively, individual project and be built using dotnet cli inside project directory.

Test

The common package has corresponding unit tests. These tests can be run using dotnet cli command or through Makefile. To run the unit tests from the root, a test filter needs to be provided:

dotnet test --filter Category=Unit

Alternatively, running tests inside common_tests project does not require the filter. To run tests using Makefile:

make unit-test

Help

Contributing

oci-dotnet-sdk is an open source project. See CONTRIBUTING for details.

Oracle gratefully acknowledges the contributions to oci-dotnet-sdk that have been made by the community.

License

Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.

This SDK is dual licensed under the Universal Permissive License 1.0 and the Apache License 2.0.

See LICENSE for more details.

Changes

See CHANGELOG

Known Issues

You can find information on any known issues with the SDK at Oracle Cloud Infrastructure Known Issues and under the Issues tab of this project's GitHub repository.

oci-dotnet-sdk's People

Contributors

bhagwatvyas avatar buzhidao77 avatar github-anurag avatar joshunter avatar oci-dex-release-bot avatar varunmankal avatar

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.