Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
7e964b0
update ApiClient doc
MansourNazifiAsl Feb 25, 2025
0eae8a6
add Olive.Audit.DatabaseLogger doc
MansourNazifiAsl Feb 25, 2025
ead1600
update Olive.Audit doc
MansourNazifiAsl Feb 25, 2025
b8e491d
add Olive.Aws.Comprehend doc
MansourNazifiAsl Feb 25, 2025
2fa2c31
add Olive.Aws.EventBus doc
MansourNazifiAsl Feb 26, 2025
44333cb
Olive.Aws.LambdaFunction doc
MansourNazifiAsl Feb 26, 2025
f21f8be
Olive.Aws.Mvc doc
MansourNazifiAsl Feb 26, 2025
d191701
Olive.Aws.Rekognition doc
MansourNazifiAsl Feb 26, 2025
4d30e93
Olive.Aws.Ses.AutoFetch.TestConsole doc
MansourNazifiAsl Feb 26, 2025
6ea14db
Olive.Aws.Ses.AutoFetch doc
MansourNazifiAsl Feb 27, 2025
c1feafe
Olive.Aws.Ses doc
MansourNazifiAsl Feb 27, 2025
6f8dd10
Olive.Aws.Textract doc
MansourNazifiAsl Feb 27, 2025
5c92716
Olive.Aws doc
MansourNazifiAsl Feb 28, 2025
1724c72
Olive.Azure.DocumentAnalyzer doc
MansourNazifiAsl Feb 28, 2025
779d979
Olive.Azure.DocumentClassification doc
MansourNazifiAsl Feb 28, 2025
631ed17
Olive.Azure.EventBus doc
MansourNazifiAsl Feb 28, 2025
865704e
Olive.Azure doc
MansourNazifiAsl Feb 28, 2025
411adfa
Olive.AzureSearch doc
MansourNazifiAsl Feb 28, 2025
722ef48
Olive.Blob.Aws doc
MansourNazifiAsl Feb 28, 2025
fb46967
Olive.Blob.Azure doc
MansourNazifiAsl Feb 28, 2025
2194d89
Olive.Cloud doc
MansourNazifiAsl Feb 28, 2025
2dd6761
Olive.Compression doc
MansourNazifiAsl Feb 28, 2025
134ff8f
Olive.Console doc
MansourNazifiAsl Mar 3, 2025
c09c729
Olive.Dashboards.PowerBI doc
MansourNazifiAsl Mar 3, 2025
d8e23b6
Olive.Drawing doc
MansourNazifiAsl Mar 3, 2025
74333fa
Olive.Email.Imap doc
MansourNazifiAsl Mar 3, 2025
1d09c04
Olive.Encryption doc
MansourNazifiAsl Mar 3, 2025
34f916a
Olive.Entities.Cache.Redis doc
MansourNazifiAsl Mar 3, 2025
6c325d7
Olive.Entities.Data.DynamoDB doc
MansourNazifiAsl Mar 3, 2025
eeece9e
Olive.Entities.Data.EF.Replication doc
MansourNazifiAsl Mar 3, 2025
729d7df
Olive.Entities.Data.MySql doc
MansourNazifiAsl Mar 3, 2025
b412e74
Olive.Entities.Data.PostgreSQL doc
MansourNazifiAsl Mar 3, 2025
4431737
Olive.Entities.Data.Replication.DataGenerator.UI doc
MansourNazifiAsl Mar 3, 2025
966c9d7
Olive.Entities.Data.Replication.Mvc.Extensions doc
MansourNazifiAsl Mar 3, 2025
0d279be
Olive.Entities.Data.Replication.QueueUrlProvider doc
MansourNazifiAsl Mar 3, 2025
0aec8d9
Olive.Entities.Data.Replication doc
MansourNazifiAsl Mar 4, 2025
49af9f8
Olive.Entities.Data.SQLite doc
MansourNazifiAsl Mar 4, 2025
d87e994
Olive.Entities.Data.SqlServer doc
MansourNazifiAsl Mar 4, 2025
946e118
Olive.Export doc
MansourNazifiAsl Mar 4, 2025
b1f5a4b
Olive.GeoLocation doc
MansourNazifiAsl Mar 4, 2025
317527f
Olive.Globalization doc
MansourNazifiAsl Mar 4, 2025
0e84261
Olive.Hangfire.Cron doc
MansourNazifiAsl Mar 4, 2025
e81d62a
Olive.Hangfire.MySql doc
MansourNazifiAsl Mar 4, 2025
ecfd348
Olive.Hangfire doc
MansourNazifiAsl Mar 4, 2025
5dd08c9
Olive.Log.EventBus doc
MansourNazifiAsl Mar 4, 2025
2bf49c1
Olive.Microservices doc
MansourNazifiAsl Mar 4, 2025
1b238d2
Olive.Mvc.CKEditorFileManager doc
MansourNazifiAsl Mar 4, 2025
a8d71c1
Olive.Mvc.lpFilter doc
MansourNazifiAsl Mar 4, 2025
39d643a
Olive.Mvc.Paging doc
MansourNazifiAsl Mar 4, 2025
b8639b1
Olive.Mvc.Recaptcha doc
MansourNazifiAsl Mar 4, 2025
9f26ec1
Olive.Mvc.Security doc
MansourNazifiAsl Mar 5, 2025
1758156
Olive.Net4x.Compatibility doc
MansourNazifiAsl Mar 5, 2025
194b6cc
Olive.OpenAl.Voice doc
MansourNazifiAsl Mar 5, 2025
2b6f52f
Olive.OpenAI doc
MansourNazifiAsl Mar 5, 2025
c7ce837
Olive.PDF doc
MansourNazifiAsl Mar 5, 2025
f234f41
Olive.PassiveBackgroundTasks doc
MansourNazifiAsl Mar 5, 2025
4d58d29
Olive.PushNotification doc
MansourNazifiAsl Mar 5, 2025
b936a1c
Olive.RabbitMQ doc
MansourNazifiAsl Mar 5, 2025
62cc3ad
Olive.SMS.TextMagic doc
MansourNazifiAsl Mar 5, 2025
b68c6dc
Olive.Security.Auth0 doc
MansourNazifiAsl Mar 6, 2025
7d0f51a
Olive.Security.Aws doc
MansourNazifiAsl Mar 6, 2025
74dad6c
Olive.Security.Azure doc
MansourNazifiAsl Mar 6, 2025
ec9d296
Olive.Security.Cloud.CustomEncryption doc
MansourNazifiAsl Mar 6, 2025
2d32be7
Olive.Security.Cloud doc
MansourNazifiAsl Mar 6, 2025
0102b7c
Olive.Security.Impersonation doc
MansourNazifiAsl Mar 6, 2025
9d7dd9c
Olive.Sms.Aws doc
MansourNazifiAsl Mar 6, 2025
5e010a6
Olive.Web doc
MansourNazifiAsl Mar 6, 2025
5d52ea4
Olive.Gpt doc
MansourNazifiAsl Mar 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions docs/AWS/Olive.Sms.Aws.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Olive.Sms.Aws

This document provides an overview and usage examples for the public classes and methods in the `Olive.SMS` namespace related to sending SMS messages via Amazon Simple Notification Service (SNS). It integrates with AWS SNS to dispatch SMS messages, supporting optional sender ID and origination number configurations. A configuration section details the optional settings in an `appsettings.json` file.

---

## Table of Contents

1. [SmsDispatcher](#smsdispatcher)
- [Overview](#smsdispatcher-overview)
- [Methods](#smsdispatcher-methods)
2. [IServiceCollectionExtension](#iservicecollectionextension)
- [Overview](#iservicecollectionextension-overview)
- [Methods](#iservicecollectionextension-methods)
3. [Configuration](#configuration)

---

## SmsDispatcher

### SmsDispatcher Overview

The `SmsDispatcher` class implements `ISmsDispatcher` and `IDisposable` to send SMS messages using Amazon SNS. It uses the `AmazonSimpleNotificationServiceClient` to publish messages and supports optional attributes like sender ID and origination number.

### SmsDispatcher Methods

- **`Dispatch(ISmsMessage sms)`**
- Asynchronously sends an SMS message via AWS SNS with configurable attributes.
- **Usage Example:**
```csharp
var dispatcher = Context.Current.GetService<ISmsDispatcher>();
var sms = new SmsMessage { To = "+1234567890", Text = "Hello from AWS SNS!" }; // Assuming SmsMessage implements ISmsMessage
await dispatcher.Dispatch(sms);
Console.WriteLine("SMS sent successfully");
```

---

## IServiceCollectionExtension

### IServiceCollectionExtension Overview

The `IServiceCollectionExtension` static class provides an extension method to register the AWS SNS SMS dispatcher in an ASP.NET Core dependency injection container.

### IServiceCollectionExtension Methods

- **`AddAwsSms(this IServiceCollection @this)`**
- Registers `SmsDispatcher` as the `ISmsDispatcher` in the service collection.
- **Usage Example:**
```csharp
services.AddAwsSms();
```

---

## Configuration

The `SmsDispatcher` class supports optional configuration settings stored in an `appsettings.json` file with a JSON structure. These settings enhance the SMS sending process but are not strictly required. Below are the optional settings:

### Optional Settings
- **`Aws:Sns:SenderId`**
- The sender ID to display on the recipient's device (e.g., a brand name). Overrides `ISmsMessage.SenderName` if specified in the message.
- **`Aws:Sns:OriginationNumber`**
- The phone number to use as the origination number for the SMS (must be an AWS SNS-supported number).

### Full `appsettings.json` Example
```json
{
"Aws": {
"Sns": {
"SenderId": "MyApp",
"OriginationNumber": "+12025550123"
}
}
}
```

### Notes
- If `SenderId` or `OriginationNumber` are not provided in `appsettings.json`, the dispatcher will use the `SenderName` from the `ISmsMessage` (if available) or omit these attributes.
- The SMS type is hardcoded to `"Transactional"` for immediate delivery, suitable for critical notifications.
77 changes: 76 additions & 1 deletion docs/Api/ApiClient.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ When using HttpClient directly, you should manually take care of:
* Circuit breaking (to avoid server overloading)

## Olive.ApiClient
Olive provides a helper utility class named [ApiClient](https://github.com/Geeksltd/Olive/tree/master/Integration/Olive.ApiClient) which handles all of the above issues for you.
Olive provides a helper utility class named [ApiClient](https://github.com/Geeksltd/Olive/tree/master/Olive.ApiClient) which handles all of the above issues for you.
It's built on top of the standard HttpClient, and is ideal for invoking Web Apis.

The following simple line is enough to take care of all aspects of downloading a customer object from a remote Web Api.
Expand Down Expand Up @@ -216,3 +216,78 @@ If http exceptions are raised consecutively for the specified number of times, i
During the break period, any attempt to execute a new request will **immediately throw a BrokenCircuitException**.
Once the duration is over, if the first action throws http exception again,
the circuit will break again for the same duration. Otherwise the circuit will reset.

## HTTP Methods
### GET Request

- **Purpose**: Retrieves data from the API.
- **Usage**:
```csharp
var data = await new ApiClient($"{baseUrl}/customers").Get<Customer>(new { id = 123 });
```

### POST Request

- **Purpose**: Sends data to the server.
- **Usage**:
```csharp
var data = await new ApiClient($"{baseUrl}/customers").Post<Customer>(new { name = CustomerName });
```

### PUT Request

- **Purpose**: Updates a resource on the server.
- **Usage**:
```csharp
var data = await new ApiClient($"{baseUrl}/customers").Put<Customer>(new { name = CustomerName });
```

### DELETE Request

- **Purpose**: Deletes a resource.
- **Usage**:
```csharp
var data = await new ApiClient($"{baseUrl}/customers").Delete(new { id = 123 });
```

### PATCH Request

- **Purpose**: Partially updates a resource.
- **Usage**:
```csharp
var data = await new ApiClient($"{baseUrl}/customers").Patch<Customer>(new { id = 123 });
```

## Caching

- **Purpose**: Enables caching for GET requests.
- **Usage**:
```csharp
var data = await new ApiClient($"{baseUrl}/customers")
.Cache(CachePolicy.FreshOrCacheOrFail, TimeSpan.FromMinutes(10))
.Get<Customer>(new { id = 123 });
```

## Custom Headers

- **Purpose**: Adds custom headers to API requests.
- **Usage**:
```csharp
var client = new ApiClient($"{baseUrl}/customers").Header(headers => headers.Add("Authorization", "Bearer token"));
```

## Authentication

- **Purpose**: Authenticates the client using cookies.
- **Usage**:
```csharp
var client = new ApiClient($"{baseUrl}/customers").Authenticate(cookie1, cookie2);
```

## Deletes All Cache

- **Purpose**: Deletes all cached Get API results.
- **Usage**:
```csharp
await ApiClient.DisposeCache();
```
95 changes: 95 additions & 0 deletions docs/Api/Olive.Cloud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Olive.Cloud

## Overview
The `Olive.Cloud` is an abstract base class designed to manage and load secrets from a cloud-based provider. It stores secrets in a dictionary and updates the application configuration with the retrieved values.

## Namespace
```csharp
namespace Olive.Cloud;
```

## Class: `Secrets`
### Description
This abstract class facilitates the retrieval and storage of secrets within an application. The secrets are loaded from a cloud-based provider and stored in memory for use during runtime.

### Events
#### `Loaded`
- **Type:** `AwaitableEventHandler<Secrets>`
- **Description:** This event is triggered when the secrets are successfully loaded.

### Fields
#### `Config`
- **Type:** `IConfiguration`
- **Access Modifier:** `protected`
- **Description:** Holds the application configuration object.

#### `SecretString`
- **Type:** `string`
- **Access Modifier:** `protected`
- **Description:** Stores the downloaded secrets as a JSON string.

### Properties
#### `SecretId`
- **Type:** `string`
- **Access Modifier:** `protected abstract`
- **Description:** Specifies the unique identifier for the secret in the cloud provider.

### Methods
#### `DownloadSecrets()`
- **Access Modifier:** `protected abstract`
- **Return Type:** `string`
- **Description:** An abstract method that must be implemented in derived classes to download secrets from a cloud provider.

#### `Load()`
- **Access Modifier:** `public`
- **Return Type:** `void`
- **Description:** Downloads and loads secrets into the application configuration.
- **Implementation Steps:**
1. Calls `Download()` to retrieve the secret values.
2. Parses the retrieved secrets as JSON.
3. Updates the application configuration with the retrieved secret values.
4. Raises the `Loaded` event.

#### `Download()`
- **Access Modifier:** `private`
- **Return Type:** `void`
- **Description:** Downloads secrets and handles any errors that occur during retrieval.
- **Error Handling:**
- Logs errors when secrets cannot be retrieved.
- Throws exceptions when retrieval fails.
- **Implementation Steps:**
1. Calls `DownloadSecrets()` to retrieve the secrets.
2. Validates the retrieved data to ensure it is not empty.
3. Stores the retrieved secrets in `SecretString`.

### Logging
- Uses `ILogger` for logging errors and exceptions.
- Logs errors when secret retrieval fails.

## Usage Example
Since `Secrets` is an abstract class, it must be inherited by a concrete class that implements `DownloadSecrets()`. Below is an example implementation:

```csharp
public class MyCloudSecrets : Secrets
{
protected override string SecretId => "MySecretKey";

public MyCloudSecrets(IConfiguration config) : base(config) {}

protected override string DownloadSecrets()
{
// Replace this with actual cloud secret retrieval logic.
return "{ \"ApiKey\": \"12345\", \"DbPassword\": \"securepassword\" }";
}
}
```

To use this class in an application:

```csharp
IConfiguration configuration = new ConfigurationBuilder().Build();
MyCloudSecrets secrets = new MyCloudSecrets(configuration);
secrets.Load();
Console.WriteLine(configuration["ApiKey"]); // Output: 12345
```

56 changes: 56 additions & 0 deletions docs/Api/Olive.Compression.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
**Olive.Compression**

**Overview:**
The `Olive.Compression` provides methods for compressing and decompressing files and directories using different compression formats, such as ZIP, GZIP, and TAR.

**Methods:**

1. **Compress(IEnumerable<FileInfo>, CompressionFormat)**
- Compresses a list of files into a specified compression format.
- Throws an exception if duplicate filenames exist.
- Returns the compressed data as a byte array.

2. **Compress(DirectoryInfo, CompressionFormat)**
- Compresses an entire directory into a specified compression format.
- Returns the compressed data as a byte array.

3. **Compress(DirectoryInfo, FileInfo, CompressionFormat, bool)**
- Creates a compressed file from a directory and saves it to a specified destination.
- Supports ZIP, GZIP, and TAR formats.
- Throws an exception if the destination file already exists unless overwrite is set to `true`.

4. **Decompress(FileInfo, DirectoryInfo, bool, bool)**
- Decompresses a compressed file into a specified directory.
- Supports extracting full paths and overwriting existing files.

---

**SevenZip Documentation**

**Overview:**
The `SevenZip` class provides an interface to compress and decompress files using the 7-Zip utility.

**Properties:**

- `SEVEN_ZIP_EXE_FILE_PATH`: Specifies the path of the 7-Zip executable.

**Methods:**

1. **Compress(string, string[])**
- Compresses specified folders into a 7-Zip archive.

2. **Compress(string, int?, string[])**
- Supports splitting archives into parts of a specified size (in KB).

3. **Compress(string, int?, CompressionMode, string, string[], string[])**
- Compresses folders into a 7-Zip archive with custom parameters and optional exclusion filters.

4. **Compress(IEnumerable<FileInfo>, CompressionMode, string)**
- Compresses a list of files into a temporary 7-Zip file and returns the resulting file.

5. **CompressToBytes(IEnumerable<FileInfo>, CompressionMode, string)**
- Compresses a list of files into a 7-Zip archive and returns the compressed data as a byte array.

6. **Compress(FileInfo, IEnumerable<FileInfo>, CompressionMode, string)**
- Compresses specified files into a 7-Zip archive and saves it to a specified destination.

Loading