Skip to content

Commit

Permalink
GetObject API with Args & Response objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
BigUstad committed Nov 6, 2020
2 parents 664eca5 + 87412ac commit efadd87
Show file tree
Hide file tree
Showing 22 changed files with 437 additions and 204 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/minio-dotnet-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Minio-dontet Linux Tests

on:
pull_request:
branches:
- master
push:
branches:
- master

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 2.1.810
- name: Install dependencies
run: dotnet restore
- name: Build & Unit Test
run: |
dotnet build -c Release
dotnet pack ./Minio/Minio.csproj --no-build -c Release -o ./artifacts
dotnet test ./Minio.Tests/Minio.Tests.csproj -f netcoreapp2.1
- name: Functional Tests
run: |
dotnet build Minio.Functional.Tests -c Release --framework netcoreapp2.1
dotnet Minio.Functional.Tests/bin/Release/netcoreapp2.1/Minio.Functional.Tests.dll
56 changes: 56 additions & 0 deletions .github/workflows/minio-dotnet-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Minio-dotnet Windows Tests

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:

build:

strategy:
matrix:
configuration: [ Release ]

runs-on: windows-latest
env:
Solution_Name: Minio.sln
Test_Project_Path: ./Minio.Tests/Minio.Tests.csproj -f netcoreapp2.1

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

# Install the .NET Core workload
- name: Install .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 2.1.810

# Add MSBuild to the PATH:
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@2008f912f56e61277eefaac6d1888b750582aa16

# Install dependencies
- name: Install dependencies
run: dotnet restore

# Build and Execute Build tests
- name: Build & Unit Test
run: |
dotnet build -c Release
dotnet pack ./Minio/Minio.csproj --no-build -c Release -o ./artifacts
dotnet test ./Minio.Tests/Minio.Tests.csproj -f netcoreapp2.1
# Execute all functional tests in the solution
- name: Execute Functional tests
run: |
dotnet build Minio.Functional.Tests -c Release --framework netcoreapp2.1
dotnet Minio.Functional.Tests/bin/Release/netcoreapp2.1/Minio.Functional.Tests.dll
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

51 changes: 29 additions & 22 deletions Docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -797,9 +797,9 @@ catch (MinioException e)


<a name="listenBucketNotifications"></a>
### ListenBucketNotificationsAsync(string bucketName, IList<EventType> events, string prefix = "", string suffix = "")
### ListenBucketNotificationsAsync(ListenBucketNotificationsArgs args)

`IObservable<MinioNotificationRaw> ListenBucketNotificationsAsync(string bucketName, IList<EventType> events, string prefix = "", string suffix = "", CancellationToken cancellationToken = default(CancellationToken))`
`IObservable<MinioNotificationRaw> ListenBucketNotificationsAsync(ListenBucketNotificationsArgs args, CancellationToken cancellationToken = default(CancellationToken))`

Subscribes to bucket change notifications (a Minio-only extension)

Expand All @@ -808,10 +808,7 @@ __Parameters__

|Param | Type | Description |
|:--- |:--- |:--- |
| ``bucketName`` | _string_ | Bucket to get notifications from |
| ``events`` | _IList< EventType >_ | Events to listen for |
| ``prefix`` | _string_ | Filter keys starting with this prefix |
| ``suffix`` | _string_ | Filter keys ending with this suffix |
| ``args`` | _ListenBucketNotificationsArgs_ | ListenBucketNotificationsArgs object - encapsulates bucket name, list of events, prefix, suffix. |
| ``cancellationToken``| _System.Threading.CancellationToken_ | Optional parameter. Defaults to default(CancellationToken) |


Expand All @@ -829,7 +826,12 @@ try
var events = new List<EventType> { EventType.ObjectCreatedAll };
var prefix = null;
var suffix = null;
IObservable<MinioNotificationRaw> observable = minioClient.ListenBucketNotificationsAsync(bucketName, events, prefix, suffix);
ListenBucketNotificationsArgs args = new ListenBucketNotificationsArgs()
.WithBucket(bucketName)
.WithEvents(events)
.WithPrefix(prefix)
.WithSuffix(suffix);
IObservable<MinioNotificationRaw> observable = minioClient.ListenBucketNotificationsAsync(args);

IDisposable subscription = observable.Subscribe(
notification => Console.WriteLine($"Notification: {notification.json}"),
Expand Down Expand Up @@ -930,17 +932,16 @@ catch (MinioException e)


<a name="setBucketNotification"></a>
### SetBucketNotificationAsync(string bucketName, BucketNotification notification)
`Task SetBucketNotificationAsync(string bucketName, BucketNotification notification, CancellationToken cancellationToken = default(CancellationToken))`
### SetBucketNotificationAsync(SetBucketNotificationsArgs args)
`Task SetBucketNotificationAsync(SetBucketNotificationsArgs args, CancellationToken cancellationToken = default(CancellationToken))`

Sets notification configuration for a given bucket

__Parameters__

|Param | Type | Description |
|:--- |:--- |:--- |
| ``bucketName`` | _string_ | Name of the bucket |
| ``notification`` | _BucketNotification_ | Notifications to apply |
| ``args`` | _SetBucketNotificationsArgs_ | SetBucketNotificationsArgs object encapsulating bucket name, notification configuration object. |
| ``cancellationToken``| _System.Threading.CancellationToken_ | Optional parameter. Defaults to default(CancellationToken) |


Expand Down Expand Up @@ -972,9 +973,11 @@ try
queueConfiguration.AddEvents(new List<EventType>() { EventType.ObjectCreatedCompleteMultipartUpload });
notification.AddQueue(queueConfiguration);

await minio.SetBucketNotificationsAsync(bucketName,
notification);
Console.WriteLine("Notifications set for the bucket " + bucketName + " successfully");
SetBucketNotificationsArgs args = new SetBucketNotificationsArgs()
.WithBucket(bucketName)
.WithBucketNotificationConfiguration(notification);
await minio.SetBucketNotificationsAsync(args);
Console.WriteLine("Notifications set for the bucket " + args.BucketName + " successfully");
}
catch (MinioException e)
{
Expand All @@ -983,8 +986,8 @@ catch (MinioException e)
```

<a name="getBucketNotification"></a>
### GetBucketNotificationAsync(string bucketName)
`Task<BucketNotification> GetBucketNotificationAsync(string bucketName, CancellationToken cancellationToken = default(CancellationToken))`
### GetBucketNotificationAsync(GetBucketNotificationsArgs args)
`Task<BucketNotification> GetBucketNotificationAsync(GetBucketNotificationsArgs args, CancellationToken cancellationToken = default(CancellationToken))`

Get bucket notification configuration

Expand All @@ -993,7 +996,7 @@ __Parameters__

|Param | Type | Description |
|:--- |:--- |:--- |
| ``bucketName`` | _string_ | Name of the bucket. |
| ``args`` | _GetBucketNotificationsArgs_ | GetBucketNotificationsArgs object encapsulating bucket name. |
| ``cancellationToken``| _System.Threading.CancellationToken_ | Optional parameter. Defaults to default(CancellationToken) |


Expand All @@ -1014,7 +1017,9 @@ __Example__
```cs
try
{
BucketNotification notifications = await minioClient.GetBucketNotificationAsync(bucketName);
GetBucketNotificationsArgs args = new GetBucketNotificationsArgs()
.WithBucket(bucketName);
BucketNotification notifications = await minioClient.GetBucketNotificationAsync(args);
Console.WriteLine("Notifications is " + notifications.ToXML());
}
catch (MinioException e)
Expand All @@ -1024,8 +1029,8 @@ catch (MinioException e)
```

<a name="removeAllBucketNotification"></a>
### RemoveAllBucketNotificationsAsync(string bucketName)
`Task RemoveAllBucketNotificationsAsync(string bucketName, CancellationToken cancellationToken = default(CancellationToken))`
### RemoveAllBucketNotificationsAsync(RemoveAllBucketNotificationsArgs args)
`Task RemoveAllBucketNotificationsAsync(RemoveAllBucketNotificationsArgs args, CancellationToken cancellationToken = default(CancellationToken))`

Remove all notification configurations set on the bucket

Expand All @@ -1034,7 +1039,7 @@ __Parameters__

|Param | Type | Description |
|:--- |:--- |:--- |
| ``bucketName`` | _string_ | Name of the bucket. |
| ``args`` | _RemoveAllBucketNotificationsArgs_ | RemoveAllBucketNotificationsArgs args encapsulating the bucket name. |
| ``cancellationToken``| _System.Threading.CancellationToken_ | Optional parameter. Defaults to default(CancellationToken) |


Expand All @@ -1055,7 +1060,9 @@ __Example__
```cs
try
{
await minioClient.RemoveAllBucketNotificationsAsync(bucketName);
RemoveAllBucketNotificationsArgs args = new RemoveAllBucketNotificationsArgs()
.WithBucket(bucketName);
await minioClient.RemoveAllBucketNotificationsAsync(args);
Console.WriteLine("Notifications successfully removed from the bucket " + bucketName);
}
catch (MinioException e)
Expand Down
5 changes: 4 additions & 1 deletion Minio.Examples/Cases/GetBucketNotification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ public async static Task Run(MinioClient minio,
try
{
Console.WriteLine("Running example for API: GetBucketNotificationsAsync");
BucketNotification notifications = await minio.GetBucketNotificationsAsync(bucketName);
GetBucketNotificationsArgs args = new GetBucketNotificationsArgs()
.WithBucket(bucketName);
BucketNotification notifications = await minio.GetBucketNotificationsAsync(args);
Console.WriteLine($"Notifications is {notifications.ToXML()} for bucket {bucketName}");
Console.WriteLine();
}
catch (Exception e)
{
Console.WriteLine($"Error parsing bucket notifications - make sure that you are running this call against AWS end point: {e.Message}");
Console.WriteLine(e.StackTrace);
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion Minio.Examples/Cases/ListenBucketNotifications.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ListenBucketNotifications
// Listen for notifications from a specified bucket (a Minio-only extension)
public static void Run(MinioClient minio,
string bucketName = "my-bucket-name",
IList<EventType> events = null,
List<EventType> events = null,
string prefix = "",
string suffix = "",
bool recursive = true)
Expand All @@ -35,6 +35,11 @@ public static void Run(MinioClient minio,
Console.WriteLine("Running example for API: ListenBucketNotifications");
Console.WriteLine();
events = events ?? new List<EventType> { EventType.ObjectCreatedAll };
ListenBucketNotificationsArgs args = new ListenBucketNotificationsArgs()
.WithBucket(bucketName)
.WithPrefix(prefix)
.WithEvents(events)
.WithSuffix(suffix);
IObservable<MinioNotificationRaw> observable = minio.ListenBucketNotificationsAsync(bucketName, events, prefix, suffix);

IDisposable subscription = observable.Subscribe(
Expand Down
4 changes: 3 additions & 1 deletion Minio.Examples/Cases/RemoveAllBucketNotifications.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public async static Task Run(MinioClient minio,
{
Console.WriteLine("Running example for API: RemoveAllBucketNotificationAsync");

await minio.RemoveAllBucketNotificationsAsync(bucketName);
RemoveAllBucketNotificationsArgs args = new RemoveAllBucketNotificationsArgs()
.WithBucket(bucketName);
await minio.RemoveAllBucketNotificationsAsync(args);

Console.WriteLine($"Notifications successfully removed from the bucket {bucketName}");
Console.WriteLine();
Expand Down
5 changes: 4 additions & 1 deletion Minio.Examples/Cases/SetBucketNotification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public async static Task Run(MinioClient minio,
{
Console.WriteLine("Running example for API: SetBucketNotificationAsync");
var notification = new BucketNotification();
SetBucketNotificationsArgs args = new SetBucketNotificationsArgs()
.WithBucket(bucketName)
.WithBucketNotificationConfiguration(notification);

// Uncomment the code below and change Arn and event types to configure.
/*
Expand All @@ -52,7 +55,7 @@ public async static Task Run(MinioClient minio,
queueConfiguration.AddEvents(new List<EventType>() { EventType.ObjectCreatedCompleteMultipartUpload });
notification.AddQueue(queueConfiguration);
*/
await minio.SetBucketNotificationsAsync(bucketName, notification);
await minio.SetBucketNotificationsAsync(args);

Console.WriteLine("Notifications set for the bucket {bucketName} were set successfully");
Console.WriteLine();
Expand Down
Loading

0 comments on commit efadd87

Please sign in to comment.