protected override void ProcessRecord() { base.ProcessRecord(); var context = new CmdletContext { VaultName = this.VaultName }; if (this.ParameterSetName.Equals(ParamSet_Folder, StringComparison.Ordinal)) { if (!ConfirmShouldProceed(this.Force.IsPresent, this.FolderPath, "Write-GLCArchive")) { return; } context.FolderPath = PSHelpers.PSPathToAbsolute(this.SessionState.Path, this.FolderPath.Trim()); context.Recurse = this.Recurse.IsPresent; context.SearchPattern = this.SearchPattern; } else { if (!ConfirmShouldProceed(this.Force.IsPresent, this.FilePath, "Write-GLCArchive")) { return; } context.FilePath = PSHelpers.PSPathToAbsolute(this.SessionState.Path, this.FilePath.Trim()); } if (this.ParameterWasBound("AccountId")) { context.AccountId = this.AccountId; } else { WriteVerbose("AccountId parameter unset, using default value of '-'"); context.AccountId = "-"; } Execute(context); }
protected override void PostExecutionContextLoad(ExecutorContext context) { var cmdletContext = context as CmdletContext; #pragma warning disable CS0618, CS0612 //A class member was marked with the Obsolete attribute if (this.ZipFilename != null) { var fqZipFilename = PSHelpers.PSPathToAbsolute(this.SessionState.Path, this.ZipFilename); if (!File.Exists(fqZipFilename)) { this.ThrowArgumentError($"'{this.ZipFilename}' ('{fqZipFilename}') is not a valid file path for the ZipFilename parameter.", this); } cmdletContext.ZipFile = File.ReadAllBytes(fqZipFilename); } if (this.Publish.IsPresent) { cmdletContext.PublishVersion = true; } #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute }
protected override void ProcessRecord() { base.ProcessRecord(); var context = new CmdletContext { InstanceId = this.InstanceId, Decrypt = this.Decrypt.IsPresent }; // specifying a pem file implies the user wants the password decrypted if (!string.IsNullOrEmpty(this.PemFile)) { context.Decrypt = true; context.PemFile = PSHelpers.PSPathToAbsolute(this.SessionState.Path, this.PemFile.Trim()); } var output = Execute(context) as CmdletOutput; ProcessOutput(output); }
protected override void ProcessRecord() { base.ProcessRecord(); if (!ConfirmShouldProceed(this.Force.IsPresent, this.BucketName, "Write-S3Object (PutObject)")) { return; } var context = new CmdletContext { BucketName = this.BucketName }; if (this.Key != null) { context.Key = AmazonS3Helper.CleanKey(this.Key); } if (this.ParameterSetName == ParamSet_FromLocalFile) { context.File = PSHelpers.PSPathToAbsolute(this.SessionState.Path, this.File.Trim()); if (string.IsNullOrEmpty(context.Key)) { context.Key = Path.GetFileName(context.File); } } else if (this.ParameterSetName == ParamSet_FromStream) { context.Stream = this.Stream; } else if (this.ParameterSetName == ParamSet_FromContent) { context.Content = this.Content; } else { context.Folder = PSHelpers.PSPathToAbsolute(this.SessionState.Path, this.Folder.Trim()); context.Recurse = this.Recurse.IsPresent; context.OriginalKeyPrefix = this.KeyPrefix; if (!rootIndicators.Contains <string>(this.KeyPrefix, StringComparer.OrdinalIgnoreCase)) { context.KeyPrefix = AmazonS3Helper.CleanKey(this.KeyPrefix); } if (!string.IsNullOrEmpty(this.SearchPattern)) { context.SearchPattern = this.SearchPattern; } } if (!string.IsNullOrEmpty(this.CannedACLName)) { context.CannedACL = this.CannedACLName; } else if (this.PublicReadOnly.IsPresent) { context.CannedACL = S3CannedACL.PublicRead; } else if (this.PublicReadWrite.IsPresent) { context.CannedACL = S3CannedACL.PublicReadWrite; } context.ContentType = this.ContentType; if (ParameterWasBound("StorageClass")) { context.StorageClass = this.StorageClass; } else { if (this.StandardStorage.IsPresent) { context.StorageClass = S3StorageClass.Standard; } else if (this.ReducedRedundancyStorage.IsPresent) { context.StorageClass = S3StorageClass.ReducedRedundancy; } } if (!string.IsNullOrEmpty(this.ServerSideEncryption)) { context.ServerSideEncryptionMethod = AmazonS3Helper.Convert(this.ServerSideEncryption); } if (!string.IsNullOrEmpty(this.ServerSideEncryptionCustomerMethod)) { context.ServerSideEncryptionCustomerMethod = this.ServerSideEncryptionCustomerMethod; } context.ServerSideEncryptionCustomerProvidedKey = this.ServerSideEncryptionCustomerProvidedKey; context.ServerSideEncryptionCustomerProvidedKeyMD5 = this.ServerSideEncryptionCustomerProvidedKeyMD5; context.ServerSideEncryptionKeyManagementServiceKeyId = this.ServerSideEncryptionKeyManagementServiceKeyId; if (this.ConcurrentServiceRequest.HasValue) { if (this.ConcurrentServiceRequest.Value <= 0) { throw new ArgumentOutOfRangeException("ConcurrentServiceRequests", "ConcurrentServiceRequests should be set to a positive integer value."); } context.ConcurrentServiceRequests = this.ConcurrentServiceRequest.Value; } context.Metadata = this.Metadata; context.Headers = this.HeaderCollection; context.TagSet = this.TagSet; var output = Execute(context) as CmdletOutput; ProcessOutput(output); }
protected override void ProcessRecord() { base.ProcessRecord(); var context = new CmdletContext { BucketName = this.BucketName }; switch (this.ParameterSetName) { case ParamSet_ToLocalFile: { context.Key = AmazonS3Helper.CleanKey(this.Key); context.File = PSHelpers.PSPathToAbsolute(this.SessionState.Path, this.File); context.Version = this.Version; } break; case ParamSet_ToLocalFolder: { context.OriginalKeyPrefix = this.KeyPrefix; context.KeyPrefix = rootIndicators.Contains <string>(this.KeyPrefix, StringComparer.OrdinalIgnoreCase) ? "/" : AmazonS3Helper.CleanKey(this.KeyPrefix); context.Folder = PSHelpers.PSPathToAbsolute(this.SessionState.Path, this.Folder); } break; case ParamSet_FromS3Object: { context.BucketName = this.S3Object.BucketName; context.Key = this.S3Object.Key; var s3ObjectVersion = this.S3Object as S3ObjectVersion; context.Version = s3ObjectVersion == null ? null : s3ObjectVersion.VersionId; if (this.ParameterWasBound("File")) { context.File = PSHelpers.PSPathToAbsolute(this.SessionState.Path, this.File); } else { var path = PSHelpers.PSPathToAbsolute(this.SessionState.Path, this.Folder); context.File = Path.Combine(path, S3Object.Key); } } break; } if (ParameterWasBound("UtcModifiedSinceDate")) { context.UtcModifiedSinceDate = this.UtcModifiedSinceDate; } if (ParameterWasBound("UtcUnmodifiedSinceDate")) { context.UtcUnmodifiedSinceDate = this.UtcUnmodifiedSinceDate; } #pragma warning disable CS0618, CS0612 //A class member was marked with the Obsolete attribute if (ParameterWasBound("ModifiedSinceDate")) { context.ModifiedSinceDate = this.ModifiedSinceDate; } if (ParameterWasBound("UnmodifiedSinceDate")) { context.UnmodifiedSinceDate = this.UnmodifiedSinceDate; } #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute if (ParameterWasBound("ServerSideEncryptionCustomerMethod")) { context.ServerSideEncryptionCustomerMethod = this.ServerSideEncryptionCustomerMethod; } context.ServerSideEncryptionCustomerProvidedKey = this.ServerSideEncryptionCustomerProvidedKey; context.ServerSideEncryptionCustomerProvidedKeyMD5 = this.ServerSideEncryptionCustomerProvidedKeyMD5; var output = Execute(context) as CmdletOutput; ProcessOutput(output); }