Skip to content

Commit 8d3e73f

Browse files
Merge pull request #12 from sharefile-org/update-namespaces
Update namespaces
2 parents 6c62988 + ad3ee54 commit 8d3e73f

12 files changed

Lines changed: 97 additions & 102 deletions

Samples/AutoArchiveFiles.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ $fileParent = '{
4545

4646
#Once we have the files we move them
4747
foreach($file in $files){
48-
if ($file.GetType().ToString() -eq "ShareFile.Api.Models.File"){
48+
if ($file.GetType().ToString() -eq "ShareFile.Api.Client.Models.File"){
4949
Send-SfRequest -Client $sfClient -Entity Items -Method PATCH -Id $file.Id.ToString() -BodyText $fileParent
5050
}
5151
}

Samples/CreateUsers.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ foreach ($contact in $contacts)
1010
if ($contact.'E-mail Address' -and $contact.'First Name' -and $contact.'Last Name')
1111
{
1212
#create contact in ShareFile
13-
$user = New-Object ShareFile.Api.Models.User
13+
$user = New-Object ShareFile.Api.Client.Models.User
1414

1515
#required fields
1616
$user.FirstName = $contact.'First Name'

Samples/DeleteMostRecent.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Function CheckVersions($FolderRoot, $Dateofincident){
6868

6969
# Write-Host "date of upload " $item.creationdate
7070
# Check if Item is a file
71-
if ($item.__type -eq "ShareFile.Api.Models.File"){
71+
if ($item.__type -eq "ShareFile.Api.Client.Models.File"){
7272

7373
# If there are multiple versions and the date of upload was within the 1 day span of infection
7474
if (($item.HasMultipleVersions -eq "true") -and ($time.days -le 1)) {
@@ -83,7 +83,7 @@ Function CheckVersions($FolderRoot, $Dateofincident){
8383
}
8484

8585
# Item is a Folder; send back to CheckVersions
86-
if ($item.__type -eq "ShareFile.Api.Models.Folder"){
86+
if ($item.__type -eq "ShareFile.Api.Client.Models.Folder"){
8787
$newRoot = Send-SfRequest -client $client -Entity Items -Id $item.id -expand "Children"
8888
CheckVersions $newRoot $Dateofincident
8989
}

Samples/StorageReport.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function GetFileSize($ItemID, $ItemType)
3131
foreach ($item in $Items.Children)
3232
{
3333
#since folders return a 'file size' of all the children ignore unless it is a file
34-
if ($item.__type -eq "ShareFile.Api.Models.File")
34+
if ($item.__type -eq "ShareFile.Api.Client.Models.File")
3535
{
3636
#CREATE A HASTHATBLE WITH ID/NAME
3737
#LOOKUP WITH PATH AND ADD FROM GET IF NOT THERE SO WE ONLY GET ONCE
@@ -70,7 +70,7 @@ function GetFileSize($ItemID, $ItemType)
7070
}
7171

7272
#determine type of item and recurse if a folder
73-
if ($item.__type -eq "ShareFile.Api.Models.Folder") { GetFileSize $item.Id $ItemType}
73+
if ($item.__type -eq "ShareFile.Api.Client.Models.Folder") { GetFileSize $item.Id $ItemType}
7474
}
7575
}
7676

ShareFileModule/ShareFile.Format.ps1xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<View>
55
<Name>FolderTableView</Name>
66
<ViewSelectedBy>
7-
<TypeName>ShareFile.Api.Models.Item</TypeName>
7+
<TypeName>ShareFile.Api.Client.Models.Item</TypeName>
88
</ViewSelectedBy>
99
<TableControl>
1010
<TableHeaders>

ShareFileModule/ShareFileSnapIn.dll-Help.xml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ Retrieve a previously saved authentication state</maml:title>
391391
<command:parameter required="false" position="named">
392392
<maml:name>Body</maml:name>
393393
<maml:description/>
394-
<command:parameterValue>ShareFile.Api.Models.ODataObject</command:parameterValue>
394+
<command:parameterValue>ShareFile.Api.Client.Models.ODataObject</command:parameterValue>
395395
</command:parameter>
396396

397397
<command:parameter required="false" position="named">
@@ -447,7 +447,7 @@ Retrieve a previously saved authentication state</maml:title>
447447
<maml:description>
448448
<maml:para>The HTTP Verb used in the operation: GET, POST, PATCH, PUT or DELETE.</maml:para>
449449
<maml:para>GET retrieves elements, and do not perform changes in the API server.</maml:para>
450-
<maml:para>POST create new elements or relationships. Most POST operations require a Body, which are generally classes of ShareFile.Api.Models namespace (see examples)</maml:para>
450+
<maml:para>POST create new elements or relationships. Most POST operations require a Body, which are generally classes of ShareFile.Api.Client.Models namespace (see examples)</maml:para>
451451
<maml:para>PUT replaces the current element with a new set of values - most ShareFile Entities do not support this Verb - use PATCH by default instead</maml:para>
452452
<maml:para>PATCH replaces the attribute values provided in the request Body, but leave unspecified attributes unchanged.</maml:para>
453453
<maml:para>DELETE removes the Entity</maml:para>
@@ -543,7 +543,7 @@ Retrieve a previously saved authentication state</maml:title>
543543
<maml:description>
544544
<maml:para>Request Body for the operation. The request body is usually a single or a list of ShareFile.Api.Model objects. (see examples).</maml:para>
545545
</maml:description>
546-
<command:parametervalue required="true">ShareFile.Api.Models.ODataObject</command:parametervalue>
546+
<command:parametervalue required="true">ShareFile.Api.Client.Models.ODataObject</command:parametervalue>
547547
<dev:type>
548548
<maml:name></maml:name>
549549
<maml:uri/>
@@ -609,12 +609,12 @@ Retrieve a previously saved authentication state</maml:title>
609609
<command:returnValues>
610610
<command:returnValue>
611611
<dev:type>
612-
<maml:name>ShareFile.Api.Models.ODataObject</maml:name>
612+
<maml:name>ShareFile.Api.Client.Models.ODataObject</maml:name>
613613
<maml:uri />
614614
<maml:description>
615615
<maml:para>
616-
All API responses are deserialized into ShareFile.Api.Model classes, sub-types of ShareFile.Api.Models.ODataObject.
617-
</maml:para>
616+
All API responses are deserialized into ShareFile.Api.Client.Models classes, sub-types of ShareFile.Api.Client.Models.ODataObject.
617+
</maml:para>
618618
</maml:description>
619619
</dev:type>
620620
</command:returnValue>
@@ -646,7 +646,7 @@ $client = New-SfClient -Name acme
646646
Send-SfRequest -Client $c -Verb GET -Entity Users
647647
</dev:code>
648648
<dev:remarks>
649-
<maml:para>Return a ShareFile.Api.Models.User object containing attributes of the current user</maml:para>
649+
<maml:para>Return a ShareFile.Api.Client.Models.User object containing attributes of the current user</maml:para>
650650
</dev:remarks>
651651
</command:example>
652652

@@ -669,11 +669,11 @@ Create a new object
669669
</maml:title>
670670
<maml:introduction/>
671671
<dev:code>
672-
$folder = New-Object ShareFile.Api.Models.Folder
673-
$folder.Name = "Example Folder"
674-
$homeFolder = Send-SfRequest -Client $c -Verb GET -Entity Users -Navigation HomeFolder -Select "Id,url"
675-
Send-SfRequest -Client $c -Verb POST -Uri $homeFolder.url -Body $folder -Cast Folder -Parameters @{ "overwrite"="true" }
676-
</dev:code>
672+
$folder = New-Object ShareFile.Api.Client.Models.Folder
673+
$folder.Name = "Example Folder"
674+
$homeFolder = Send-SfRequest -Client $c -Verb GET -Entity Users -Navigation HomeFolder -Select "Id,url"
675+
Send-SfRequest -Client $c -Verb POST -Uri $homeFolder.url -Body $folder -Cast Folder -Parameters @{ "overwrite"="true" }
676+
</dev:code>
677677
<dev:remarks>
678678
<maml:para>Retrieves the current user home folder using the HomeFolder navigation property; then creates a new folder under that.</maml:para>
679679
</dev:remarks>
@@ -685,12 +685,12 @@ Updates an object
685685
</maml:title>
686686
<maml:introduction/>
687687
<dev:code>
688-
$folderUpdate = New-Object ShareFile.Api.Models.Folder
689-
$folder.Name = "Example Folder 2"
690-
$homeFolder = Send-SfRequest -Client $c -Verb GET -Entity Users -Navigation HomeFolder -Select "Id,url"
691-
$folderTarget = Send-SfRequest -Client $c -Verb GET -Uri $homeFolder.url -Action ByPath -Parameters @{ "path"="/Example Folder" }
692-
Send-SfRequest -Client $c -Verb PATCH -Uri $folderTarget.url -Body $folderUpdate
693-
</dev:code>
688+
$folderUpdate = New-Object ShareFile.Api.Client.Models.Folder
689+
$folder.Name = "Example Folder 2"
690+
$homeFolder = Send-SfRequest -Client $c -Verb GET -Entity Users -Navigation HomeFolder -Select "Id,url"
691+
$folderTarget = Send-SfRequest -Client $c -Verb GET -Uri $homeFolder.url -Action ByPath -Parameters @{ "path"="/Example Folder" }
692+
Send-SfRequest -Client $c -Verb PATCH -Uri $folderTarget.url -Body $folderUpdate
693+
</dev:code>
694694
<dev:remarks>
695695
<maml:para>Updates the element created in Example 3: retrieves the current user home folder; then finds a named folder under that element using the ByPath action. Then sends an update request to the retrieved folder.</maml:para>
696696
</dev:remarks>

Test-ShareFileModule/CopySFItemsTests.cs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
using System;
2-
using System.Collections;
3-
using System.Collections.ObjectModel;
4-
using System.IO;
1+
using System.Collections.ObjectModel;
52
using System.Management.Automation;
63
using System.Management.Automation.Runspaces;
74
using Microsoft.VisualStudio.TestTools.UnitTesting;
8-
using ShareFile.Api.Powershell;
95

106
namespace Test_ShareFileSnapIn
117
{
@@ -18,14 +14,7 @@ public class CopySFItemsTests
1814
[TestInitialize]
1915
public void InitializeTests()
2016
{
21-
RunspaceConfiguration config = RunspaceConfiguration.Create();
22-
23-
PSSnapInException warning;
24-
25-
config.AddPSSnapIn("ShareFile", out warning);
26-
27-
runspace = RunspaceFactory.CreateRunspace(config);
28-
runspace.Open();
17+
runspace = Utils.OpenRunspace();
2918

3019
// do login first to start tests
3120
using (Pipeline pipeline = runspace.CreatePipeline())
@@ -58,6 +47,13 @@ public void InitializeTests()
5847
}
5948
}
6049

50+
[TestCleanup]
51+
public void CleanupTests()
52+
{
53+
runspace?.Dispose();
54+
runspace = null;
55+
}
56+
6157
[TestMethod]
6258
public void TM1_CopyItemToLocalTest()
6359
{
@@ -128,7 +124,7 @@ public void TM3_CopyItemToShareFileServerTest()
128124
Collection<PSObject> psObjects = pipeline.Invoke();
129125

130126
Assert.AreEqual<int>(1, psObjects.Count);
131-
Assert.AreEqual("ShareFile.Api.Models.File", psObjects[0].BaseObject.ToString());
127+
Assert.AreEqual("ShareFile.Api.Client.Models.File", psObjects[0].BaseObject.ToString());
132128
}
133129
}
134130

@@ -160,7 +156,7 @@ public void TM4_CopyItemToShareFileServerForceTest()
160156
Collection<PSObject> psObjects = pipeline.Invoke();
161157

162158
Assert.AreEqual<int>(1, psObjects.Count);
163-
Assert.AreEqual("ShareFile.Api.Models.File", psObjects[0].BaseObject.ToString());
159+
Assert.AreEqual("ShareFile.Api.Client.Models.File", psObjects[0].BaseObject.ToString());
164160
}
165161
}
166162

Test-ShareFileModule/LoginTests.cs

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
using System;
2-
using System.Collections.ObjectModel;
3-
using System.IO;
1+
using System.Collections.ObjectModel;
42
using System.Management.Automation;
53
using System.Management.Automation.Runspaces;
64
using Microsoft.VisualStudio.TestTools.UnitTesting;
7-
using ShareFile.Api.Powershell;
85

96
namespace Test_ShareFileSnapIn
107
{
@@ -16,31 +13,27 @@ public class LoginTests
1613
[TestInitialize]
1714
public void InitializeTests()
1815
{
19-
RunspaceConfiguration config = RunspaceConfiguration.Create();
20-
21-
PSSnapInException warning;
22-
23-
config.AddPSSnapIn("ShareFile", out warning);
16+
runspace = Utils.OpenRunspace();
17+
}
2418

25-
runspace = RunspaceFactory.CreateRunspace(config);
26-
runspace.Open();
19+
[TestCleanup]
20+
public void CleanupTests()
21+
{
22+
runspace?.Dispose();
23+
runspace = null;
2724
}
2825

2926
[TestMethod]
3027
public void TM1_0_NewLoginTest()
3128
{
32-
PowerShell ps = PowerShell.Create();
33-
34-
ps.AddCommand("Add-PSSnapIn");
35-
ps.AddArgument("ShareFile");
36-
37-
Collection<PSObject> psObjects = ps.Invoke();
29+
using var ps = PowerShell.Create();
30+
ps.Runspace = runspace;
3831

3932
ps.Commands.Clear();
4033
ps.AddCommand("New-SFClient");
4134
ps.AddParameter("Name", Utils.LoginFilePath);
4235

43-
psObjects = ps.Invoke();
36+
var psObjects = ps.Invoke();
4437

4538
Assert.AreEqual<int>(1, psObjects.Count);
4639
}

Test-ShareFileModule/MapDriveTests.cs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
using System;
2-
using System.Collections;
3-
using System.Collections.ObjectModel;
1+
using System.Collections.ObjectModel;
42
using System.Management.Automation;
53
using System.Management.Automation.Runspaces;
64
using Microsoft.VisualStudio.TestTools.UnitTesting;
7-
using ShareFile.Api.Powershell;
85

96
namespace Test_ShareFileSnapIn
107
{
@@ -17,15 +14,7 @@ public class MapDriveTests
1714
[TestInitialize]
1815
public void InitializeTests()
1916
{
20-
21-
RunspaceConfiguration config = RunspaceConfiguration.Create();
22-
23-
PSSnapInException warning;
24-
25-
config.AddPSSnapIn("ShareFile", out warning);
26-
27-
runspace = RunspaceFactory.CreateRunspace(config);
28-
runspace.Open();
17+
runspace = Utils.OpenRunspace();
2918

3019
// do login first to start tests
3120
using (Pipeline pipeline = runspace.CreatePipeline())
@@ -41,7 +30,14 @@ public void InitializeTests()
4130
sfLogin = objs[0];
4231
}
4332
}
44-
33+
34+
[TestCleanup]
35+
public void CleanupTests()
36+
{
37+
runspace?.Dispose();
38+
runspace = null;
39+
}
40+
4541
[TestMethod]
4642
public void TM1_MapDriveTest()
4743
{
@@ -72,7 +68,7 @@ public void TM2_CheckHomeContentsTest()
7268
Command command = new Command("New-PSDrive");
7369
command.Parameters.Add("Name", Utils.ShareFileDriveLetter);
7470
command.Parameters.Add("PSProvider", "ShareFile");
75-
command.Parameters.Add("Root", "/My Files & Folders");
71+
command.Parameters.Add("Root", "/");
7672
command.Parameters.Add("Client", sfLogin);
7773

7874
pipeline.Commands.Add(command);

Test-ShareFileModule/SyncSFItemsTests.cs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
using System;
2-
using System.Collections;
3-
using System.Collections.ObjectModel;
1+
using System.Collections.ObjectModel;
42
using System.Management.Automation;
53
using System.Management.Automation.Runspaces;
64
using Microsoft.VisualStudio.TestTools.UnitTesting;
7-
using ShareFile.Api.Powershell;
85

96
namespace Test_ShareFileSnapIn
107
{
@@ -17,14 +14,7 @@ public class SyncSFItemsTests
1714
[TestInitialize]
1815
public void InitializeTests()
1916
{
20-
RunspaceConfiguration config = RunspaceConfiguration.Create();
21-
22-
PSSnapInException warning;
23-
24-
config.AddPSSnapIn("ShareFile", out warning);
25-
26-
runspace = RunspaceFactory.CreateRunspace(config);
27-
runspace.Open();
17+
runspace = Utils.OpenRunspace();
2818

2919
// do login first to start tests
3020
using (Pipeline pipeline = runspace.CreatePipeline())
@@ -57,6 +47,13 @@ public void InitializeTests()
5747
}
5848
}
5949

50+
[TestCleanup]
51+
public void CleanupTests()
52+
{
53+
runspace?.Dispose();
54+
runspace = null;
55+
}
56+
6057

6158
[TestMethod]
6259
public void TM1_SyncDownloadFileTest()
@@ -108,7 +105,7 @@ public void TM3_SyncDownloadRecursiveTest()
108105
Utils.DeleteLocalFolder(Utils.LocalFolderDownloaded);
109106

110107
Command command = new Command("Sync-SfItem");
111-
command.Parameters.Add("ShareFilePath", Utils.ShareFileFolder);
108+
command.Parameters.Add("ShareFilePath", Utils.ShareFileFolderFullPath);
112109
command.Parameters.Add("LocalPath", Utils.LocalBaseFolder);
113110
command.Parameters.Add("Download", true);
114111
command.Parameters.Add("Recursive", true);
@@ -129,7 +126,7 @@ public void TM4_SyncDownloadOverwriteTest()
129126
using (Pipeline pipeline = runspace.CreatePipeline())
130127
{
131128
Command command = new Command("Sync-SfItem");
132-
command.Parameters.Add("ShareFilePath", Utils.ShareFileFolder);
129+
command.Parameters.Add("ShareFilePath", Utils.ShareFileFolderFullPath);
133130
command.Parameters.Add("LocalPath", Utils.LocalBaseFolder);
134131
command.Parameters.Add("Download", true);
135132
command.Parameters.Add("OverWrite", true);
@@ -152,7 +149,7 @@ public void TM5_SyncDownloadMoveTest()
152149
Utils.DeleteLocalFolder(Utils.LocalFolderDownloaded);
153150

154151
Command command = new Command("Sync-SfItem");
155-
command.Parameters.Add("ShareFilePath", Utils.ShareFileFolder);
152+
command.Parameters.Add("ShareFilePath", Utils.ShareFileFolderFullPath);
156153
command.Parameters.Add("LocalPath", Utils.LocalBaseFolder);
157154
command.Parameters.Add("Download", true);
158155
command.Parameters.Add("Move", true);
@@ -195,7 +192,7 @@ public void TM11_SyncUploadFileTest()
195192
Collection<PSObject> psObjects = pipeline.Invoke();
196193

197194
Assert.AreEqual<int>(1, psObjects.Count);
198-
Assert.AreEqual("ShareFile.Api.Models.File", psObjects[0].BaseObject.ToString());
195+
Assert.AreEqual("ShareFile.Api.Client.Models.File", psObjects[0].BaseObject.ToString());
199196
}
200197
}
201198

0 commit comments

Comments
 (0)