/
PoshStack-OpenStackObjectStorage.psm1
870 lines (661 loc) · 34.9 KB
/
PoshStack-OpenStackObjectStorage.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
<############################################################################################
PoshStack
Cloud Files
Description
-----------
**TODO**
############################################################################################>
function Script:Get-Provider {
Param(
[Parameter (Mandatory=$True)] [string] $Account = $(throw "Please specify required OpenStack Account with -Account parameter"),
[Parameter (Mandatory=$False)][string] $RegionOverride = $Null
)
$Provider = Get-OpenStackObjectStorageProvider -Account $Account
if ($RegionOverride){
$Global:RegionOverride = $RegionOverride
}
# Use Region code associated with Account, or was an override provided?
if ($RegionOverride) {
$Region = $Global:RegionOverride
} else {
$Region = $Credentials.Region
}
Add-Member -InputObject $Provider -MemberType NoteProperty -Name Region -Value $Region
Return $Provider
}
function Get-OpenStackObjectStorageProvider {
Param(
[Parameter (Mandatory=$True)] [string] $Account = $(throw "Please specify required OpenStack Account with -Account parameter")
)
# The Account comes from the file CloudAccounts.csv
# It has information regarding credentials and the type of provider (Generic or Rackspace)
Get-OpenStackAccount -Account $Account
# Is this Rackspace or Generic OpenStack?
switch ($Credentials.Type)
{
"Rackspace" {
# Get Identity Provider
$OpenStackId = New-Object net.openstack.Core.Domain.CloudIdentity
$OpenStackId.Username = $Credentials.CloudUsername
$OpenStackId.APIKey = $Credentials.CloudAPIKey
$Global:openstackId = New-Object net.openstack.Providers.Rackspace.CloudIdentityProvider($openstackId)
Return New-Object net.openstack.Providers.Rackspace.CloudFilesProvider($openstackId)
}
"OpenStack" {
$openstackIdentityWithProject = New-Object net.openstack.Core.Domain.CloudIdentityWithProject
$openstackIdentityWithProject.Password = $Credentials.CloudPassword
$openstackIdentityWithProject.Username = $Credentials.CloudUsername
$openstackIdentityWithProject.ProjectId = New-Object net.openstack.Core.Domain.ProjectId($Credentials.TenantId)
$openstackIdentityWithProject.ProjectName = $Credentials.TenantId
$Uri = New-Object System.Uri($Credentials.IdentityEndpointUri)
$openstackIdentityProvider = New-Object net.openstack.Core.Providers.OpenStackIdentityProvider($Uri, $openstackIdentityWithProject)
Return New-Object net.openstack.Providers.Rackspace.CloudFilesProvider($Null, $openstackIdentityProvider)
}
}
}
#CopyStream
#DeleteObject
function Remove-OpenStackObjectStorageObject {
Param(
[Parameter (Mandatory=$True)] [string] $Account = $(throw "Please specify required OpenStack Account with -Account parameter"),
[Parameter (Mandatory=$True)] [string] $ContainerName= $(throw "Please specify required Container Name with the -ContainerName paramter"),
[Parameter (Mandatory=$True)] [string] $ObjectName = $(throw "Please specify required object to be deleted with the -ObjectName parameter"),
[Parameter (Mandatory=$False)][array] $Headers = $null,
[Parameter (Mandatory=$False)][bool] $DeleteSegments = $True,
[Parameter (Mandatory=$False)][bool] $UseInternalUrl = $False,
[Parameter (Mandatory=$False)][string] $RegionOverride = $Null
)
$Provider = Get-Provider -Account $Account -RegionOverride $RegionOverride
try {
# DEBUGGING
Write-Debug -Message "Remove-OpenStackObjectStorageObject"
Write-Debug -Message "Account.......: $Account"
Write-Debug -Message "Container.....: $ContainerName"
Write-Debug -Message "RegionOverride: $RegionOverride"
Write-Debug -Message "Headers.......: $Headers"
Write-Debug -Message "ObjectName....: $ObjectName"
Write-Debug -Message "DeleteSegments: $DeleteSegments"
Write-Debug -Message "UseInternalUrl: $UseInternalUrl"
$Provider.DeleteObject($ContainerName, $ObjectName, $Headers, $DeleteSegments, $Provider.Region, $UseInternalUrl, $Null)
}
catch {
Invoke-Exception($_.Exception)
}
<#
.SYNOPSIS
Delete an object in containers.
.DESCRIPTION
The Remove-OpenStackObjectStorageObject cmdlet performs a DELETE operation on an object to permanently remove the object from the storage system (data and metadata).
Object deletion is processed immediately at the time of the request. Any subsequent GET, HEAD, POST, or DELETE operations return a 404 (Not Found) error unless object versioning is on and other versions exist.
.PARAMETER Account
Use this parameter to indicate which account you would like to execute this request against.
Valid choices are defined in PoshStack configuration file.
.PARAMETER ContainerName
The unique identifier of the container.
.PARAMETER ObjectName
The unique (within the container) identifier of the object.
.PARAMETER Headers
The metadata for the object.
.PARAMETER DeleteSegments
Indicates whether the file's segments should be deleted if any exist.
.PARAMETER UseInternalUrl
Use the endpoint internal URL instead of the endpoint Public URL.
.PARAMETER RegionOverride
This parameter will temporarily override the default region set in PoshStack configuration file.
.EXAMPLE
PS C:\Users\Administrator> Remove-OpenStackObjectStorageObject -Account demo -ContainerName "MyTestContainer" -ObjectName "Foo"
This example will delete the object "Foo" in container "MyTestContainer" in the default region for the account "demo".
.LINK
http://docs.rackspace.com/files/api/v1/cf-devguide/content/DELETE_deleteobject_v1__account___container___object__objectServicesOperations_d1e000.html
#>
}
#BulkDelete **TODO**
function Remove-OpenStackObjectStorageObjects {
Param(
[Parameter (Mandatory=$True)] [string] $Account = $(throw "Please specify required OpenStack Account with -Account parameter"),
[Parameter (Mandatory=$True)] [string] $ContainerName = $(throw "Please specify required Container Name with the -ContainerName paramter"),
[Parameter (Mandatory=$True)] [array] $ItemsToDelete = $(throw "Please specify required items to be deleted with the -ItemsToDelete parameter"),
[Parameter (Mandatory=$False)][hashtable] $Headers = @{},
[Parameter (Mandatory=$False)][bool] $UseInternalUrl = $False,
[Parameter (Mandatory=$False)][string] $RegionOverride = $Null
)
$Provider = Get-Provider -Account $Account -RegionOverride $RegionOverride
try {
# DEBUGGING
Write-Debug -Message "Remove-OpenStackObjectStorageObjects"
Write-Debug -Message "Account.......: $Account"
Write-Debug -Message "Container.....: $ContainerName"
Write-Debug -Message "RegionOverride: $RegionOverride"
Write-Debug -Message "Headers.......: $Headers"
Write-Debug -Message "ItemsToDelete.: $ItemsToDelete"
Write-Debug -Message "UseInternalUrl: $UseInternalUrl"
# ItemsToDelete is a hashtable, with the Key being the Container Name, and the Value being an array of Object Names
# e.g. @{"Container1" = @("Object1", "Object2", "Object4"); "Container2" = @("Object1", "ObjectX")}
# In this example, three objects are deleted from container "Container1", and two objects are deleted from container "Container2"
$ItemsArray = New-Object 'System.Collections.Generic.List[hashtable]'
$hdr = New-Object 'System.Collections.Generic.Dictionary[String,String]'
foreach($Item in $ItemsToDelete){
$ContainerName
$Item
$ThisItem = New-Object 'System.Collections.Generic.Dictionary[String,String]'
$ThisItem.Add($ContainerName, $Item)
$ItemsArray.Add($ThisItem)
}
$Provider.BulkDelete($ItemsArray, $Headers, $Provider.Region, $UseInternalUrl, $Null)
}
catch {
Invoke-Exception($_.Exception)
}
<#
.SYNOPSIS
Bulk delete of objects in containers.
.DESCRIPTION
The Remove-OpenStackObjectStorageObjects cmdlet allows you to bulk delete multiple objects in multiple containers.
.PARAMETER Account
Use this parameter to indicate which account you would like to execute this request against.
Valid choices are defined in PoshStack configuration file.
.PARAMETER ContainerName
The unique identifier of the container.
.PARAMETER Headers
The metadata for this container:
X-Container-Meta-name (Optional)
Custom container metadata. Replace name at the end of the header with the name for your metadata.
X-Container-Read (Optional)
Sets an access control list (ACL) that grants read access. This header can contain a comma-delimited list of users that can read the container (allows the GET method for all objects in the container).
X-Container-Write (Optional)
Sets an ACL that grants write access. This header can contain a comma-delimited list of users that can write to the container (allows PUT, POST, COPY, and DELETE methods for all objects in the container).
X-Versions-Location (Optional)
Enables versioning on this container. The value is the name of another container. You must UTF-8-encode and then URL-encode the name before you include it in the header. To disable versioning, set the header to an empty string.
.PARAMETER UseInternalUrl
Use the endpoint internal URL instead of the endpoint Public URL.
.PARAMETER RegionOverride
This parameter will temporarily override the default region set in PoshStack configuration file.
.EXAMPLE
PS C:\Users\Administrator> New-CloudFileContainer -Account demo -ContainerName "MyTestContainer"
This example will create the container "MyTestContainer" in the default region for the account "demo".
.LINK
http://docs.rackspace.com/files/api/v1/cf-devguide/content/PUT_createcontainer_v1__account___container__containerServicesOperations_d1e000.html
#>
}
#CopyObject **TODO**
function Copy-OpenStackObjectStorageObject {
}
#CreateContainer
function New-OpenStackObjectStorageContainer {
Param(
[Parameter (Mandatory=$True)] [string] $Account = $(throw "Please specify required Cloud Account with -Account parameter"),
[Parameter (Mandatory=$True)] [string] $ContainerName = $(throw "Please specify required Container Name with -ContainerName parameter"),
[Parameter (Mandatory=$False)][hashtable] $Headers,
[Parameter (Mandatory=$False)][bool] $UseInternalUrl,
[Parameter (Mandatory=$False)][string] $RegionOverride
)
$Provider = Get-Provider -Account $Account -RegionOverride $RegionOverride
try {
# DEBUGGING
Write-Debug -Message "New-OpenStackObjectStorageContainer"
Write-Debug -Message "Account.......: $Account"
Write-Debug -Message "RegionOverride: $RegionOverride"
Write-Debug -Message "ContainerName.: $ContainerName"
Write-Debug -Message "UseInternalUrl: $UseInternalUrl"
return $Provider.CreateContainer($ContainerName, $Headers, $Provider.Region, $UseInternalUrl, $Null)
}
catch {
Invoke-Exception($_.Exception)
}
<#
.SYNOPSIS
Create a Cloud Files Container.
.DESCRIPTION
The New-OpenStackObjectStorageContainer cmdlet creates a Cloud Files container. Containers are storage compartments for your data. The URL-encoded name must be no more than 256 bytes and cannot contain a forward slash character (/). You can create up to 500,000 containers in your Cloud Files account.
.PARAMETER Account
Use this parameter to indicate which account you would like to execute this request against.
Valid choices are defined in PoshStack configuration file.
.PARAMETER ContainerName
The unique identifier of the container.
.PARAMETER Headers
The metadata for this container:
X-Container-Meta-name (Optional)
Custom container metadata. Replace name at the end of the header with the name for your metadata.
X-Container-Read (Optional)
Sets an access control list (ACL) that grants read access. This header can contain a comma-delimited list of users that can read the container (allows the GET method for all objects in the container).
X-Container-Write (Optional)
Sets an ACL that grants write access. This header can contain a comma-delimited list of users that can write to the container (allows PUT, POST, COPY, and DELETE methods for all objects in the container).
X-Versions-Location (Optional)
Enables versioning on this container. The value is the name of another container. You must UTF-8-encode and then URL-encode the name before you include it in the header. To disable versioning, set the header to an empty string.
.PARAMETER UseInternalUrl
Use the endpoint internal URL instead of the endpoint Public URL.
.PARAMETER RegionOverride
This parameter will temporarily override the default region set in PoshStack configuration file.
.EXAMPLE
PS C:\Users\Administrator> New-CloudFileContainer -Account demo -ContainerName "MyTestContainer"
This example will create the container "MyTestContainer" in the default region for the account "demo".
.LINK
http://docs.rackspace.com/files/api/v1/cf-devguide/content/PUT_createcontainer_v1__account___container__containerServicesOperations_d1e000.html
#>
}
#CreateFormPostUri
#CreateObject **TODO**
function Add-OpenStackObjectStorageObject {
}
#CreateObjectFromFile **TODO**
function Add-OpenStackObjectStorageObjectFromFile {
Param(
[Parameter (Mandatory=$True)] [string] $Account = $(throw "Please specify required OpenStack Account with -Account parameter"),
[Parameter (Mandatory=$True)] [string] $ContainerName = $(throw "Please specify required Container Name with -ContainerName parameter"),
[Parameter (Mandatory=$True)] [string] $FilePath = $("Please specify required File Path with the -FilePath parameter"),
[Parameter (Mandatory=$False)][string] $ObjectName,
[Parameter (Mandatory=$False)][string] $ContentType,
[Parameter (Mandatory=$False)][int] $ChunkSize = 4096,
[Parameter (Mandatory=$False)][hashtable] $Headers = $Null,
[Parameter (Mandatory=$False)][bool] $UseInternalUrl = $False,
[Parameter (Mandatory=$False)][string] $RegionOverride
)
$Provider = Get-Provider -Account $Account -RegionOverride $RegionOverride
try {
# DEBUGGING
Write-Debug -Message "Add-OpenStackObjectStorageObjectFromFile"
Write-Debug -Message "Account.......: $Account"
Write-Debug -Message "cloudId.......: $OpenStackId"
Write-Debug -Message "RegionOverride: $RegionOverride"
Write-Debug -Message "ContainerName.: $ContainerName"
Write-Debug -Message "UseInternalUrl: $UseInternalUrl"
Write-Debug -Message "FilePath......: $FilePath"
Write-Debug -Message "ObjectName....: $ObjectName"
Write-Debug -Message "ContentType...: $ContentType"
Write-Debug -Message "ChunkSize.....: $ChunkSize"
Write-Debug -Message "Headers.......: $Headers"
$Provider.CreateObjectFromFile($ContainerName, $FilePath, $ObjectName, $ContentType, $ChunkSize, $Headers, $Provider.Region, $null, $UseInternalUrl, $Null)
}
catch {
Invoke-Exception($_.Exception)
}
<#
.SYNOPSIS
Creates or updates the content and metadata for a specified object.
.DESCRIPTION
The Add-OpenStackObjectStorageObjectFromFile cmdlet creates a Cloud Files object by reading and uploading the object from the given file path.
.PARAMETER Account
Use this parameter to indicate which account you would like to execute this request against.
Valid choices are defined in PoshStack configuration file.
.PARAMETER ContainerName
The unique identifier of the container.
.PARAMETER FilePath
The source file path, e.g. "C:\temp\foo.jpg".
.PARAMETER ObjectName
The name assigned to the object in the container. If omitted, the file name (from -FilePath) will be used.
.PARAMETER ContentType
The content type. If omitted, it will be automatically determined by the file name.
.PARAMETER ChunkSize
The buffer size to use for copying streaming data.
.PARAMETER Headers
The metadata information for the object.
.PARAMETER UseInternalUrl
Use the endpoint internal URL instead of the endpoint Public URL.
.PARAMETER RegionOverride
This parameter will temporarily override the default region set in PoshStack configuration file.
.EXAMPLE
PS C:\Users\Administrator> Add-OpenStackObjectStorageObjectFromFile -Account demo -ContainerName "MyTestContainer" -FilePath "C:\test\helloworld.jpg" -ObjectName "Hello_World.jpg"
This example will copy the local file "C:\test\helloworld.jpg" to the container "MyTestContainer", in the default region, and rename it to "Hello_World.jpg".
.LINK
http://docs.rackspace.com/files/api/v1/cf-devguide/content/PUT_createobject_v1__account___container___object__objectServicesOperations_d1e000.html
#>
}
#CreateTemporaryPublicUri
#DeleteContainer **TODO**
function Remove-OpenStackObjectStorageContainer {
Param(
[Parameter (Mandatory=$True)] [string] $Account = $(throw "Please specify required OpenStack Account with -Account parameter"),
[Parameter (Mandatory=$True)] [string] $ContainerName = $(throw "Please specify required Container Name with -ContainerName parameter"),
[Parameter (Mandatory=$False)][bool] $DeleteObjects = $False,
[Parameter (Mandatory=$False)][bool] $UseInternalUrl = $False,
[Parameter (Mandatory=$False)][string] $RegionOverride
)
$Provider = Get-Provider -Account $Account -RegionOverride $RegionOverride
try {
# DEBUGGING
Write-Debug -Message "Remove-OpenStackObjectStorageContainer"
Write-Debug -Message "Account.......: $Account"
Write-Debug -Message "cloudId.......: $OpenStackId"
Write-Debug -Message "RegionOverride: $RegionOverride"
Write-Debug -Message "ContainerName.: $ContainerName"
Write-Debug -Message "UseInternalUrl: $UseInternalUrl"
Write-Debug -Message "DeleteObjects.: $DeleteObjects"
$Provider.DeleteContainer($ContainerName, $DeleteObjects, $Provider.Region, $UseInternalUrl, $Null)
}
catch {
Invoke-Exception($_.Exception)
}
<#
.SYNOPSIS
Deletes a Container.
.DESCRIPTION
The Remove-OpenStackObjectStorageContainer cmdlet deletes a Cloud Files container. If a Container is not empty, you must use the -DeleteObjects parameter to delete the contents and the Container; otherwise, the Container will not be deleted if it contains objects.
.PARAMETER Account
Use this parameter to indicate which account you would like to execute this request against.
Valid choices are defined in PoshStack configuration file.
.PARAMETER ContainerName
The unique identifier of the container.
.PARAMETER DeleteObjects
This parameter allows you to delete a Container that contains objects. If this is not set to $TRUE, and if the Container contains objects, the Container will not be deleted.
.PARAMETER UseInternalUrl
Use the endpoint internal URL instead of the endpoint Public URL.
.PARAMETER RegionOverride
This parameter will temporarily override the default region set in PoshStack configuration file.
.EXAMPLE
PS C:\Users\Administrator> Remove-CloudFileContainer -Account demo -ContainerName "MyTestContainer"
This example will delete the container "MyTestContainer" in the default region for the account "demo" only if the container is empty.
PS C:\Users\Administrator> Remove-CloudFileContainer -Account demo -ContainerName "MyTestContainer" -DeleteObjects $True
This example will delete the container "MyTestContainer" in the default region for the account "demo"; all of the objects in the container will be deleted.
.LINK
http://docs.rackspace.com/files/api/v1/cf-devguide/content/DELETE_deletecontainer_v1__account___container__containerServicesOperations_d1e000.html
#>
}
#DeleteContainerMetadata **TODO**
function Remove-OpenStackObjectStorageContainerMetadata {
}
#DeleteObjectMetadata **TODO**
function Remove-OpenStackObjectStorageObjectMetadata {
}
#DisableCDNOnContainer **TODO**
function Disable-OpenStackObjectStorageContainerCDN {
}
#DisableStaticWebOnContainer **TODO**
function Disable-OpenStackObjectStorageStaticWebOnContainer {
}
#EnableCDNOnContainer **TODO**
function Enable-OpenStackObjectStorageContainerCDN {
Param(
[Parameter (Mandatory=$True)] [string] $Account = $(throw "Please specify required OpenStack Account with -Account parameter"),
[Parameter (Mandatory=$True)] [string] $ContainerName = $(throw "Please specify required Container Name with -ContainerName parameter"),
[Parameter (Mandatory=$True)] [bool] $LogRetention = $(throw "Please specify required Log Retention value with the -LogRetention parameter"),
[Parameter (Mandatory=$False)][string] $RegionOverride
)
$Provider = Get-Provider -Account $Account -RegionOverride $RegionOverride
try {
# DEBUGGING
Write-Debug -Message "Enable-OpenStackObjectStorageContainerCDN"
Write-Debug -Message "Account.......: $Account"
Write-Debug -Message "RegionOverride: $RegionOverride"
Write-Debug -Message "ContainerName.: $ContainerName"
Write-Debug -Message "LogRetention..: $LogRetention"
return $Provider.EnableCDNOnContainer($ContainerName, $LogRetention, $Provider.Region, $Null)
}
catch {
Invoke-Exception($_.Exception)
}
<#
.SYNOPSIS
Enables a container for use with the CDN.
.DESCRIPTION
The Enable-CloudFileContainerCDN cmdlet enables a Cloud Files container for use with the CDN. It returns four URIs:
X-Cdn-Ssl-Uri: The URI for downloading the object over HTTPS, using SSL.
X-Cdn-Ios-Uri: The URI for video streaming that uses HTTP Live Streaming from Apple.
X-Cdn-Uri: Indicates the URI that you can combine with object names to serve objects through the CDN.
X-Cdn-Streaming-Uri: The URI for video streaming that uses HTTP Dynamic Streaming from Adobe.
.PARAMETER Account
Use this parameter to indicate which account you would like to execute this request against.
Valid choices are defined in PoshStack configuration file.
.PARAMETER ContainerName
The unique identifier of the container.
.PARAMETER LogRetention
To enable log retention on the container.
.PARAMETER RegionOverride
This parameter will temporarily override the default region set in PoshStack configuration file.
.EXAMPLE
PS C:\Users\Administrator> Enable-OpenStackObjectStorageContainerCDN -Account demo -ContainerName "Container1" -RegionOverride "ORD" -LogRetention $false
This example will enable the container "Container1" in region "ORD" for the CDN. Logs will not be retained.
Key : X-Cdn-Ssl-Uri
Value : https://028bafb1829649a871c1-6a72eeb73f78514eb83f17de21d72eb7.ssl.cf2.rackcdn.com
Key : X-Cdn-Ios-Uri
Value : http://f0aafc8ff1453a3dda4f-6a72eeb73f78514eb83f17de21d72eb7.iosr.cf2.rackcdn.com
Key : X-Cdn-Uri
Value : http://f1e2a7f36b07f7d67f47-6a72eeb73f78514eb83f17de21d72eb7.r7.cf2.rackcdn.com
Key : X-Cdn-Streaming-Uri
Value : http://e593f92048ccc6711871-6a72eeb73f78514eb83f17de21d72eb7.r7.stream.cf2.rackcdn.com
Key : X-Trans-Id
Value : tx77dbefc6b52a4411a98d0-0054a6d053ord1
Key : Content-Length
Value : 0
Key : Content-Type
Value : text/html; charset=UTF-8
Key : Date
Value : Fri, 02 Jan 2015 17:07:31 GMT
.LINK
http://docs.rackspace.com/files/api/v1/cf-devguide/content/PUT_enableDisableCDNcontainer_v1__account___container__CDN_Container_Services-d1e2632.html
#>
}
#EnableStaticWebOnContainer **TODO**
function Enable-OpenStackObjectStorageStaticWebOnContainer {
}
#ExtractArchive
#ExtractArchiveFromFile
#GetAccountHeaders
#GetAccountMetaData
#GetContainerCDNHeader **TODO*
function Get-OpenStackObjectStorageContainerCDNHeader {
}
#GetContainerHeader **TODO**
function Get-OpenStackObjectStorageHeader {
}
#GetContainerMetaData **TODO**
function Get-OpenStackObjectStorageContainerMetadata {
}
#GetObjectHeaders **TODO**
function Get-OpenStackObjectStorageObjectHeader {
}
#GetObjectMetaData **TODO**
function Get-OpenStackObjectStorageObjectMetadata {
}
#GetObjectSaveToFile **TODO**
function Copy-OpenStackObjectStorageObjectToFile {
Param(
[Parameter (Mandatory=$True)] [string] $Account = $(throw "Please specify required OpenStack Account with -Account parameter"),
[Parameter (Mandatory=$True)] [string] $ContainerName = $(throw "Please specify required Container Name with the -ContainerName parameter"),
[Parameter (Mandatory=$True)] [string] $SaveDirectory = $(Throw "Please specify the target file path with the -SaveDirectory parameter"),
[Parameter (Mandatory=$True)] [string] $ObjectName = $(Throw "Please specify the object name with the -ObjectName parameter"),
[Parameter (Mandatory=$False)][string] $FileName = $Null,
[Parameter (Mandatory=$False)][int] $ChunkSize = 65536,
[Parameter (Mandatory=$False)][Array] $Headers = $Null,
[Parameter (Mandatory=$False)][string] $RegionOverride = $Null,
[Parameter (Mandatory=$False)][bool] $VerifyETag = $False,
[Parameter (Mandatory=$False)][long] $ProgressUpdated = $Null,
[Parameter (Mandatory=$False)][bool] $UseInternalUrl = $False
)
$Provider = Get-Provider -Account $Account -RegionOverride $RegionOverride
try {
# DEBUGGING
Write-Debug -Message "Copy-OpenStackObjectStorageObjectToFile"
Write-Debug -Message "Account........: $Account"
Write-Debug -Message "ContainerName..: $ContainerName"
Write-Debug -Message "RegionOverride.: $RegionOverride"
Write-Debug -Message "SaveDirectory..: $SaveDirectory"
Write-Debug -Message "ObjectName.....: $ObjectName"
Write-Debug -Message "FileName.......: $FileName"
Write-Debug -Message "ChunkSize......: $ChunkSize"
Write-Debug -Message "Headers........: $Headers"
Write-Debug -Message "VerifyETag.....: $VerifyETag"
Write-Debug -Message "ProgressUpdated: $ProgressUpdated"
Write-Debug -Message "UseInternalUrl.: $UseInternalUrl"
$Provider.GetObjectSaveToFile($ContainerName, $SaveDirectory, $ObjectName, $FileName, $ChunkSize, $Headers, $Provider.Region, $VerifyETag, $ProgressUpdated, $UseInternalUrl, $Null)
}
catch {
Invoke-Exception($_.Exception)
}
<#
.SYNOPSIS
Gets an object, saving the data to the specified file.
.DESCRIPTION
The Copy-OpenStackObjectStorageObjectToFile cmdlet will get an object from a container and save it to the local file system.
.PARAMETER Account
Use this parameter to indicate which account you would like to execute this request against.
Valid choices are defined in PoshStack configuration file.
.PARAMETER ContainerName
The unique identifier of the container.
.PARAMETER SaveDirectory
The local file system path to which to save the object.
.PARAMETER ObjectName
The name of the object to be retrieved.
.PARAMETER FileName
The name to give the object on the local file system. If omitted, the object name is used.
.PARAMETER ChunkSize
The buffer size to use for copying streaming data.
.PARAMETER Headers
A collection of custom HTTP headers to include with the request.
.PARAMETER RegionOverride
This parameter will temporarily override the default region set in PoshStack configuration file.
.PARAMETER VerifyETag
If the object includes an ETag, the retrieved data will be verified before returning.
.PARAMETER ProgressUpdated
A callback for progress updates. If the value is null, no updates are reported.
.PARAMETER UseInternalUrl
Use the endpoint internal URL instead of the endpoint Public URL.
.EXAMPLE
PS C:\Users\Administrator> Copy-OpenStackObjectStorageObjectToFile -Account demo -ContainerName "Container1" -SaveDirectory "C:\temp" -ObjectName "kittens.jpg"
This example will get the object "kittens.jpg" from the container "Container1" and save it as "C:\temp\kittens.jpg".
.EXAMPLE
PS C:\Users\Administrator> Copy-OpenStackObjectStorageObjectToFile -Account demo -ContainerName "Container1" -SaveDirectory "C:\temp" -ObjectName "kittens.jpg" -FileName "kittycat.jpg"
This example will get the object "kittens.jpg" from the container "Container1" and save it as "C:\temp\kittycat.jpg".
.LINK
http://docs.rackspace.com/files/api/v1/cf-devguide/content/PUT_createcontainer_v1__account___container__containerServicesOperations_d1e000.html
#>
}
#ListCDNContainers **TODO** (use -CDN switch)
#ListContainers **TODO**
function Get-OpenStackObjectStorageContainer {
Param(
[Parameter (Mandatory=$True)] [string] $Account = $(throw "Please specify required OpenStack Account with -Account parameter"),
[Parameter (Mandatory=$False)][int] $Limit = 100,
[Parameter (Mandatory=$False)][string] $Marker = $null,
[Parameter (Mandatory=$False)][string] $MarkerEnd = $Null,
[Parameter (Mandatory=$False)][bool] $UseInternalUrl = $False,
[Parameter (Mandatory=$False)][switch] $CDN,
[Parameter (Mandatory=$False)][string] $RegionOverride = $Null
)
$Provider = Get-Provider -Account $Account -RegionOverride $RegionOverride
try {
# DEBUGGING
Write-Debug -Message "Get-OpenStackObjectStorageContainer"
Write-Debug -Message "Limit.........: $Limit"
Write-Debug -Message "Marker........: $Marker"
Write-Debug -Message "MarkerEnd.....: $MarkerEnd"
Write-Debug -Message "RegionOverride: $RegionOverride"
Write-Debug -Message "UseInternalUrl: $UseInternalUrl"
If ($CDN) {
Return $Provider.ListCDNContainers($Limit, $Marker, $MarkerEnd, $True, $Provider.Region, $Null)
} else {
Return $Provider.ListContainers($Limit, $Marker, $MarkerEnd, $Provider.Region, $UseInternalUrl, $Null)
}
}
catch {
Invoke-Exception($_.Exception)
}
<#
.SYNOPSIS
Get the containers in a region.
.DESCRIPTION
The Get-OpenStackObjectStorageContainer cmdlet lists the storage containers in your account and sorts them by name. The list is limited to 10,000 containers at a time.
.PARAMETER Account
Use this parameter to indicate which account you would like to execute this request against.
Valid choices are defined in PoshStack configuration file.
.PARAMETER Limit
This parameter allows you to limit the number of results.
.PARAMETER Marker
This parameter allows you to begin the list at a specific container name.
.PARAMETER MarkerEnd
This parameter allows you to end the list at a specific container name.
.PARAMETER UseInternalUrl
Use the endpoint internal URL instead of the endpoint Public URL.
.PARAMETER CDN
This parameter will return CDN-related information for each container.
.PARAMETER RegionOverride
This parameter will temporarily override the default region set in PoshStack configuration file.
.EXAMPLE
PS C:\Users\Administrator> Get-OpenStackObjectStorageContainer -Account demo
This example will get the containers in the default region for the account "demo".
.LINK
http://docs.rackspace.com/files/api/v1/cf-devguide/content/GET_listcontainers_v1__account__accountServicesOperations_d1e000.html
#>
}
#ListObjects **TODO**
function Get-OpenStackObjectStorageObject {
Param(
[Parameter (Mandatory=$True)] [string] $Account = $(throw "Please specify required OpenStack Account with -Account parameter"),
[Parameter (Mandatory=$True)] [string] $ContainerName = $(throw "Please specify required Container with the -ContainerName parameter"),
[Parameter (Mandatory=$False)][string] $ObjectName = $null,
[Parameter (Mandatory=$False)][int] $Limit = 10000,
[Parameter (Mandatory=$False)][string] $Marker = $null,
[Parameter (Mandatory=$False)][string] $MarkerEnd = $Null,
[Parameter (Mandatory=$False)][string] $Prefix = $Null,
[Parameter (Mandatory=$False)][bool] $UseInternalUrl = $False,
[Parameter (Mandatory=$False)][string] $RegionOverride = $Null
)
$Provider = Get-Provider -Account $Account -RegionOverride $RegionOverride
try {
# DEBUGGING
Write-Debug -Message "Get-OpenStackObjectStorageObjects"
Write-Debug -Message "ContainerName.: $ContainerName"
Write-Debug -Message "Limit.........: $Limit"
Write-Debug -Message "Marker........: $Marker"
Write-Debug -Message "MarkerEnd.....: $MarkerEnd"
Write-Debug -Message "Prefix........: $Prefix"
Write-Debug -Message "RegionOverride: $RegionOverride"
Write-Debug -Message "UseInternalUrl: $UseInternalUrl"
$ListOfObjects = $Provider.ListObjects($ContainerName, $Limit, $Marker, $MarkerEnd, $Prefix, $Provider.Region, $UseInternalUrl, $Null)
foreach ($obj in $ListOfObjects) {
Add-Member -InputObject $obj -MemberType NoteProperty -Name Region -Value $Provider.Region
Add-Member -InputObject $obj -MemberType NoteProperty -Name Container -Value $ContainerName
}
Return $ListOfObjects
}
catch {
Invoke-Exception($_.Exception)
}
<#
.SYNOPSIS
Get the containers in a region.
.DESCRIPTION
The Get-OpenStackObjectStorageContainers cmdlet lists the storage containers in your account and sorts them by name. The list is limited to 10,000 containers at a time.
.PARAMETER Account
Use this parameter to indicate which account you would like to execute this request against.
Valid choices are defined in PoshStack configuration file.
.PARAMETER Limit
This parameter allows you to limit the number of results.
.PARAMETER Marker
This parameter allows you to begin the list at a specific container name.
.PARAMETER MarkerEnd
This parameter allows you to end the list at a specific container name.
.PARAMETER UseInternalUrl
Use the endpoint internal URL instead of the endpoint Public URL.
.PARAMETER CDN
This parameter will return CDN-related information for each container.
.PARAMETER RegionOverride
This parameter will temporarily override the default region set in PoshStack configuration file.
.EXAMPLE
PS C:\Users\Administrator> Get-OpenStackObjectStorageContainers -Account demo
This example will get the containers in the default region for the account "demo".
.LINK
http://docs.rackspace.com/files/api/v1/cf-devguide/content/GET_listcontainers_v1__account__accountServicesOperations_d1e000.html
#>
}
#MoveObject **TODO**
function Move-OpenStackObjectStorageObject {
}
#PurgeObjectFromCDN **TODO**
function Clear-OpenStackObjectStorageObjectFromCDN {
}
#UpdateAccountMetadata
#UpdateContainerCdnHeaders **TODO**
function Update-OpenStackObjectStorageContainerCDNHeader {
}
#UpdateContainerMetadata **TODO**
function Update-OpenStackObjectStorageContainerMetadata {
}
#UpdateObjectMetadata **TODO**
function Update-OpenStackObjectStorageObjectMetadata {
}
#GetServiceEndpointOpenStackObjectStorage
#GetServiceEndpointOpenStackObjectStorageCDN
#VerifyContainerIsCDNEnabled **TODO**
function Test-OpenStackObjectStorageContainerCDNEnabled {
}
Export-ModuleMember -Function *