Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 3.0.0 #9

Merged
merged 10 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions Autodesk.Forge.Oss.Tests/Autodesk.Forge.Oss.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Autodesk.Forge\Autodesk.Forge.csproj" />
<ProjectReference Include="..\Autodesk.Forge.Oss\Autodesk.Forge.Oss.csproj" />
</ItemGroup>

Expand Down
34 changes: 34 additions & 0 deletions Autodesk.Forge.Oss.Tests/BucketApiTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Autodesk.Forge.Client;
using NUnit.Framework;
using System;
using System.IO;
using System.Threading.Tasks;

namespace Autodesk.Forge.Oss.Tests
Expand Down Expand Up @@ -32,6 +34,38 @@ public async Task BucketApi_CreateAndDelete()
Assert.IsNull(await OssClient.TryGetBucketDetailsAsync(BucketKey));
}

[TestCase("US")]
[TestCase("EMEA")]
[TestCase("AUS")]
public async Task BucketApi_CreateAndDelete_Region(string region)
{
var bucketKey = $"{BucketKey}_{region}".ToLower();
var bucketCreated = await OssClient.CreateBucketAsync(bucketKey, region);
Assert.AreEqual(bucketKey, bucketCreated.BucketKey);
Assert.IsNotNull(await OssClient.GetBucketDetailsAsync(bucketKey));


// Test file in the region
{
var ObjectName = TestFactory.CreateObjectName();
var DataString = TestFactory.CreateDataString();
File.WriteAllText(ObjectName, DataString);
var fileDetail = await OssClient.UploadFileAsync(bucketKey, ObjectName, ObjectName);
Assert.AreEqual(DataString.Length, fileDetail.Size);

var objectDetails = await OssClient.GetObjectDetailsAsync(bucketKey, ObjectName);
Assert.AreEqual(DataString.Length, objectDetails.Size);

await OssClient.DeleteObjectAsync(bucketKey, ObjectName);
Assert.ThrowsAsync<ApiException>(() => OssClient.GetObjectDetailsAsync(bucketKey, ObjectName));

File.Delete(ObjectName);
}

await OssClient.DeleteBucketAsync(bucketKey);
Assert.IsNull(await OssClient.TryGetBucketDetailsAsync(bucketKey));
}

[Ignore("Skip Delete Buckets")]
[Test]
public async Task BucketApi_DeleteAll()
Expand Down
9 changes: 8 additions & 1 deletion Autodesk.Forge.Oss.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution", "Solution", "{D62567F0-6FCF-4C5B-B139-B2B219D51FDF}"
ProjectSection(SolutionItems) = preProject
CHANGELOG.md = CHANGELOG.md
Directory.Build.props = Directory.Build.props
LICENSE = LICENSE
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Autodesk.Forge.Oss.Tests", "Autodesk.Forge.Oss.Tests\Autodesk.Forge.Oss.Tests.csproj", "{6CF07E6C-9623-4B4E-A549-59ABDC74537D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Autodesk.Forge.Oss.Tests", "Autodesk.Forge.Oss.Tests\Autodesk.Forge.Oss.Tests.csproj", "{6CF07E6C-9623-4B4E-A549-59ABDC74537D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Autodesk.Forge", "Autodesk.Forge\Autodesk.Forge.csproj", "{A30518D1-F6D0-4190-81A7-142088761FB2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -32,6 +35,10 @@ Global
{6CF07E6C-9623-4B4E-A549-59ABDC74537D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6CF07E6C-9623-4B4E-A549-59ABDC74537D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6CF07E6C-9623-4B4E-A549-59ABDC74537D}.Release|Any CPU.Build.0 = Release|Any CPU
{A30518D1-F6D0-4190-81A7-142088761FB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A30518D1-F6D0-4190-81A7-142088761FB2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A30518D1-F6D0-4190-81A7-142088761FB2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A30518D1-F6D0-4190-81A7-142088761FB2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
26 changes: 24 additions & 2 deletions Autodesk.Forge.Oss/Autodesk.Forge.Oss.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,28 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Autodesk.Forge" Version="*" />
<!--<PackageReference Include="Autodesk.Forge" Version="*" />-->
<ProjectReference Include="..\Autodesk.Forge\Autodesk.Forge.csproj" PrivateAssets="all" />
<PackageReference Include="Newtonsoft.Json" Version="*" />
<PackageReference Include="RestSharp" Version="*" />
</ItemGroup>

<PropertyGroup Condition="!$(Configuration.Contains('Debug'))">
<!-- https://learn.microsoft.com/en-us/nuget/reference/msbuild-targets#targetsfortfmspecificcontentinpackage -->
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);CustomContentTarget</TargetsForTfmSpecificContentInPackage>
</PropertyGroup>

<Target Name="CustomContentTarget">
<ItemGroup>
<TfmSpecificPackageFile Include="$(TargetDir)\ricaun.Autodesk.Forge.dll">
<PackagePath>lib/$(TargetFramework)</PackagePath>
</TfmSpecificPackageFile>
<TfmSpecificPackageFile Include="$(TargetDir)\ricaun.Autodesk.Forge.xml" Condition="Exists('$(TargetDir)\ricaun.Autodesk.Forge.xml')">
<PackagePath>lib/$(TargetFramework)</PackagePath>
</TfmSpecificPackageFile>
</ItemGroup>
</Target>

<!-- Release -->
<PropertyGroup Condition="!$(Configuration.Contains('Debug'))">
<Optimize>true</Optimize>
Expand All @@ -36,7 +55,6 @@

<PropertyGroup>
<PackageId>ricaun.Autodesk.Forge.Oss</PackageId>
<Version>2.1.0</Version>
<ProjectGuid>{54AC7247-0A9C-4A56-835B-D1790800647B}</ProjectGuid>
</PropertyGroup>

Expand Down Expand Up @@ -67,6 +85,10 @@

<PropertyGroup Condition="!$(Configuration.Contains('Debug'))">
<DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
</PropertyGroup>
<PropertyGroup Condition="$(Configuration.Contains('Debug'))">
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
Expand Down
50 changes: 25 additions & 25 deletions Autodesk.Forge.Oss/OssClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,30 +103,30 @@ public async Task DeleteBucketAsync(string bucketKey)
/// </summary>
/// <exception cref="Autodesk.Forge.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="bucketKey">Bucket key (required).</param>
/// <param name="allow">.</param>
/// <param name="region">The region where the bucket resides Acceptable values: &#x60;US&#x60;, &#x60;EMEA&#x60; Default is &#x60;US&#x60; (optional, default to US)</param>
/// <param name="policyKey">[Data retention policy](https://developer.autodesk.com/en/docs/data/v2/overview/retention-policy/) Acceptable values: &#x60;transient&#x60;, &#x60;temporary&#x60; or &#x60;persistent&#x60; (required).</param>
/// <param name="xAdsRegion">The region where the bucket resides Acceptable values: &#x60;US&#x60;, &#x60;EMEA&#x60; Default is &#x60;US&#x60; (optional, default to US)</param>
/// <param name="allow">.</param>
/// <returns></returns>
public async Task<Bucket> CreateBucketAsync(
string bucketKey,
List<PostBucketsPayloadAllow> allow = null,
string region = null,
PostBucketsPayload.PolicyKeyEnum policyKey = PostBucketsPayload.PolicyKeyEnum.Transient,
string xAdsRegion = null)
List<PostBucketsPayloadAllow> allow = null)
{
var postBuckets = new PostBucketsPayload(bucketKey, allow, policyKey);
return await this.CreateBucketAsync(postBuckets, xAdsRegion);
return await this.CreateBucketAsync(postBuckets, region);
}

/// <summary>
/// Use this endpoint to create a bucket. Buckets are arbitrary spaces created and owned by applications. Bucket keys are globally unique across all regions, regardless of where they were created, and they cannot be changed. The application creating the bucket is the owner of the bucket.
/// </summary>
/// <exception cref="Autodesk.Forge.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="postBuckets">Body Structure</param>
/// <param name="xAdsRegion">The region where the bucket resides Acceptable values: &#x60;US&#x60;, &#x60;EMEA&#x60; Default is &#x60;US&#x60; (optional, default to US)</param>
/// <param name="region">The region where the bucket resides Acceptable values: &#x60;US&#x60;, &#x60;EMEA&#x60; Default is &#x60;US&#x60; (optional, default to US)</param>
/// <returns>Task of Bucket</returns>
public async Task<Bucket> CreateBucketAsync(PostBucketsPayload postBuckets, string xAdsRegion = null)
public async Task<Bucket> CreateBucketAsync(PostBucketsPayload postBuckets, string region = null)
{
var value = await BucketsApi.CreateBucketAsync(postBuckets, xAdsRegion) as DynamicJsonResponse;
var value = await BucketsApi.CreateBucketAsync(postBuckets, region) as DynamicJsonResponse;
return value.ToObject<Bucket>();
}
#endregion
Expand All @@ -146,23 +146,23 @@ public async Task<BucketObjects> GetObjectsAsync(string bucketKey, int? limit =
var value = await this.ObjectsApi.GetObjectsAsync(bucketKey, limit, beginsWith, startAt) as DynamicJsonResponse;
return value.ToObject<BucketObjects>();
}
// /// <summary>
///// Download an object.
///// </summary>
///// <exception cref="Autodesk.Forge.Client.ApiException">Thrown when fails to make API call</exception>
///// <param name="bucketKey">URL-encoded bucket key</param>
///// <param name="objectName">URL-encoded object name</param>
///// <param name="range">A range of bytes to download from the specified object. (optional)</param>
///// <param name="ifNoneMatch">The value of this header is compared to the ETAG of the object. If they match, the body will not be included in the response. Only the object information will be included. (optional)</param>
///// <param name="ifModifiedSince">If the requested object has not been modified since the time specified in this field, an entity will not be returned from the server; instead, a 304 (not modified) response will be returned without any message body. (optional)</param>
///// <param name="acceptEncoding">When gzip is specified, a gzip compressed stream of the object’s bytes will be returned in the response. Cannot use “Accept-Encoding:gzip” with Range header containing an end byte range. End byte range will not be honored if “Accept-Encoding: gzip” header is used. (optional)</param>
///// <returns>Task of System.IO.Stream</returns>
//[Obsolete]
//public async Task<Stream> GetObjectAsync(string bucketKey, string objectName, string range = null, string ifNoneMatch = null, DateTime? ifModifiedSince = null, string acceptEncoding = null)
//{
// var value = await this.ObjectsApi.GetObjectAsync(bucketKey, objectName, range, ifNoneMatch, ifModifiedSince, acceptEncoding);
// return value as Stream;
//}
/// <summary>
/// Download an object.
/// </summary>
/// <exception cref="Autodesk.Forge.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="bucketKey">URL-encoded bucket key</param>
/// <param name="objectName">URL-encoded object name</param>
/// <param name="range">A range of bytes to download from the specified object. (optional)</param>
/// <param name="ifNoneMatch">The value of this header is compared to the ETAG of the object. If they match, the body will not be included in the response. Only the object information will be included. (optional)</param>
/// <param name="ifModifiedSince">If the requested object has not been modified since the time specified in this field, an entity will not be returned from the server; instead, a 304 (not modified) response will be returned without any message body. (optional)</param>
/// <param name="acceptEncoding">When gzip is specified, a gzip compressed stream of the object’s bytes will be returned in the response. Cannot use “Accept-Encoding:gzip” with Range header containing an end byte range. End byte range will not be honored if “Accept-Encoding: gzip” header is used. (optional)</param>
/// <returns>Task of System.IO.Stream</returns>
[Obsolete]
internal async Task<Stream> GetObjectAsyncObsolete(string bucketKey, string objectName, string range = null, string ifNoneMatch = null, DateTime? ifModifiedSince = null, string acceptEncoding = null)
{
var value = await this.ObjectsApi.GetObjectAsync(bucketKey, objectName, range, ifNoneMatch, ifModifiedSince, acceptEncoding);
return value as Stream;
}
/// <summary>
/// GetObjectAsync using CreateSignedFileAsync and GetStreamAsync
/// </summary>
Expand Down
Loading