
committed by
GitHub

No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 584 additions and 4 deletions
-
107Docs/API.md
-
48Minio.Examples/Cases/GetLegalHold.cs
-
52Minio.Examples/Cases/SetLegalHold.cs
-
54Minio.Functional.Tests/FunctionalTest.cs
-
20Minio/ApiEndpoints/IObjectOperations.cs
-
33Minio/ApiEndpoints/ObjectOperations.cs
-
45Minio/DataModel/ObjectLegalHoldConfiguration.cs
-
54Minio/DataModel/ObjectOperationsArgs.cs
-
30Minio/DataModel/ObjectOperationsResponse.cs
-
44Minio/Exceptions/AuthorizationException.cs
-
49Minio/Exceptions/MalFormedXMLException.cs
-
30Minio/Exceptions/MissingObjectLockConfiguration.cs
-
22Minio/MinioClient.cs
@ -0,0 +1,48 @@ |
|||
/* |
|||
* MinIO .NET Library for Amazon S3 Compatible Cloud Storage, (C) 2020 MinIO, Inc. |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
|
|||
using System; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Minio.Examples.Cases |
|||
{ |
|||
class GetLegalHold |
|||
{ |
|||
// Get Legal Hold status a object
|
|||
public async static Task Run(MinioClient minio, |
|||
string bucketName = "my-bucket-name", |
|||
string objectName = "my-object-name", |
|||
string versionId = null) |
|||
{ |
|||
try |
|||
{ |
|||
Console.WriteLine("Running example for API: GetLegalHold, "); |
|||
var args = new GetObjectLegalHoldArgs() |
|||
.WithBucket(bucketName) |
|||
.WithObject(objectName) |
|||
.WithVersionId(versionId); |
|||
bool enabled = await minio.GetObjectLegalHoldAsync(args); |
|||
Console.WriteLine("LegalHold Configuration STATUS for " + bucketName + "/" + objectName + |
|||
(!string.IsNullOrEmpty(versionId)?" with Version ID " + versionId: " ") + |
|||
" : " + (enabled?"ON":"OFF")); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
Console.WriteLine($"[Object] Exception: {e}"); |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,52 @@ |
|||
/* |
|||
* MinIO .NET Library for Amazon S3 Compatible Cloud Storage, (C) 2020 MinIO, Inc. |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
|
|||
using System; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Minio.Examples.Cases |
|||
{ |
|||
class SetLegalHold |
|||
{ |
|||
// Enable Legal Hold
|
|||
public async static Task Run(MinioClient minio, |
|||
string bucketName = "my-bucket-name", |
|||
string objectName = "my-object-name", |
|||
string versionId = null) |
|||
{ |
|||
try |
|||
{ |
|||
Console.WriteLine("Running example for API: SetLegalHold, enable legal hold"); |
|||
// Setting WithLegalHold true, sets Legal hold status to ON.
|
|||
// Setting WithLegalHold false will set Legal hold status to OFF.
|
|||
SetObjectLegalHoldArgs args = new SetObjectLegalHoldArgs() |
|||
.WithBucket(bucketName) |
|||
.WithObject(objectName) |
|||
.WithVersionId(versionId) |
|||
.WithLegalHold(true); |
|||
await minio.SetObjectLegalHoldAsync(args); |
|||
Console.WriteLine("Legal Hold status for " + bucketName + "/" + objectName + |
|||
(string.IsNullOrEmpty(versionId)?" " : " with version id " + versionId + " ") + |
|||
" set to ON." ); |
|||
Console.WriteLine(); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
Console.WriteLine($"[Object] Exception: {e}"); |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,45 @@ |
|||
/* |
|||
* MinIO .NET Library for Amazon S3 Compatible Cloud Storage, (C) 2020 MinIO, Inc. |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
|
|||
using System; |
|||
using System.Xml.Serialization; |
|||
|
|||
namespace Minio.DataModel |
|||
{ |
|||
[Serializable] |
|||
[XmlRoot(ElementName = "LegalHold", Namespace = "http://s3.amazonaws.com/doc/2006-03-01/")] |
|||
|
|||
// Legal Hold Configuration for the object. Status - {ON, OFF}.
|
|||
public class ObjectLegalHoldConfiguration |
|||
{ |
|||
public ObjectLegalHoldConfiguration() |
|||
{ |
|||
this.Status = "OFF"; |
|||
} |
|||
|
|||
public ObjectLegalHoldConfiguration(bool enable = true) |
|||
{ |
|||
if (enable) |
|||
{ |
|||
this.Status = "ON"; |
|||
return; |
|||
} |
|||
this.Status = "OFF"; |
|||
} |
|||
|
|||
public string Status { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,44 @@ |
|||
/* |
|||
* MinIO .NET Library for Amazon S3 Compatible Cloud Storage, |
|||
* (C) 2017, 2018, 2019, 2020 MinIO, Inc. |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
|
|||
using System; |
|||
|
|||
namespace Minio.Exceptions |
|||
{ |
|||
[Serializable] |
|||
public class AuthorizationException : Exception |
|||
{ |
|||
internal readonly string resource; |
|||
internal readonly string bucketName; |
|||
internal readonly string accessKey; |
|||
|
|||
public AuthorizationException() |
|||
{ |
|||
} |
|||
|
|||
public AuthorizationException(string message) : base(message) |
|||
{ |
|||
} |
|||
|
|||
public AuthorizationException(string resource, string bucketName, string message, string accesskey=null) : base(message) |
|||
{ |
|||
this.resource = resource; |
|||
this.bucketName = bucketName; |
|||
this.accessKey = accesskey; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,49 @@ |
|||
/* |
|||
* MinIO .NET Library for Amazon S3 Compatible Cloud Storage, |
|||
* (C) 2017, 2018, 2019, 2020 MinIO, Inc. |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
|
|||
using System; |
|||
using System.Runtime.Serialization; |
|||
|
|||
namespace Minio.Exceptions |
|||
{ |
|||
[Serializable] |
|||
internal class MalFormedXMLException : Exception |
|||
{ |
|||
internal string resource; |
|||
internal string bucketName; |
|||
internal string key; |
|||
|
|||
public MalFormedXMLException() |
|||
{ |
|||
} |
|||
|
|||
public MalFormedXMLException(string message) : base(message) |
|||
{ |
|||
} |
|||
|
|||
public MalFormedXMLException(string message, Exception innerException) : base(message, innerException) |
|||
{ |
|||
} |
|||
|
|||
public MalFormedXMLException(string resource, string bucketName, string message, string keyName=null) : base(message) |
|||
{ |
|||
this.resource = resource; |
|||
this.bucketName = bucketName; |
|||
this.key = keyName; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,30 @@ |
|||
/* |
|||
* MinIO .NET Library for Amazon S3 Compatible Cloud Storage, (C) 2017 MinIO, Inc. |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
|
|||
namespace Minio.Exceptions |
|||
{ |
|||
public class MissingObjectLockConfiguration : MinioException |
|||
{ |
|||
private readonly string bucketName; |
|||
|
|||
public MissingObjectLockConfiguration(string bucketName, string message) : base(message) |
|||
{ |
|||
this.bucketName = bucketName; |
|||
} |
|||
|
|||
public override string ToString() => $"{this.bucketName}: {base.ToString()}"; |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue