class Fog::AWS::EFS::Real
Public Class Methods
# File lib/fog/aws/efs.rb, line 74 def initialize(options={}) @connection_options = options[:connection_options] || {} @instrumentor = options[:instrumentor] @instrumentor_name = options[:instrumentor_name] || 'fog.aws.efs' @region = options[:region] || 'us-east-1' @host = options[:host] || "elasticfilesystem.#{@region}.amazonaws.com" @port = options[:port] || 443 @scheme = options[:scheme] || "https" @persistent = options[:persistent] || false @connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options) @version = options[:version] || '2015-02-01' @path = options[:path] || "/#{@version}/" setup_credentials(options) end
Public Instance Methods
# File lib/fog/aws/efs.rb, line 141 def _request(body, headers, idempotent, parser, method, path, expects) response = @connection.request({ :body => body, :expects => expects, :idempotent => idempotent, :headers => headers, :method => method, :parser => parser, :path => path }) unless response.body.empty? response.body = Fog::JSON.decode(response.body) end response rescue Excon::Errors::HTTPStatusError => error match = Fog::AWS::Errors.match_error(error) raise if match.empty? if match[:code] == "IncorrectFileSystemLifeCycleState" raise Fog::AWS::EFS::IncorrectFileSystemLifeCycleState.slurp(error, match[:message]) elsif match[:code] == 'FileSystemInUse' raise Fog::AWS::EFS::FileSystemInUse.slurp(error, match[:message]) elsif match[:code].match(/(FileSystem|MountTarget)NotFound/) raise Fog::AWS::EFS::NotFound.slurp(error, match[:message]) end raise case match[:message] when /invalid ((file system)|(mount target)|(security group)) id/i Fog::AWS::EFS::NotFound.slurp(error, match[:message]) when /invalid subnet id/i Fog::AWS::EFS::InvalidSubnet.slurp(error, match[:message]) else Fog::AWS::EFS::Error.slurp(error, "#{match[:code]} => #{match[:message]}") end end
Create a new, empty file system docs.aws.amazon.com/efs/latest/ug/API_CreateFileSystem.html
Parameters¶ ↑
-
CreationToken <~String> - String of up to 64 ASCII characters. Amazon
EFS
uses this to ensure idempotent creation. -
PerformanceMode <~String> - (Optional) The PerformanceMode of the file system. We recommend generalPurpose performance mode for most file systems. File systems using the maxIO performance mode can scale to higher levels of aggregate throughput and operations per second with a tradeoff of slightly higher latencies for most file operations. This can't be changed after the file system has been created.
-
Encrypted <~Boolean> - (Optional) A Boolean value that, if true, creates an encrypted file system. When creating an encrypted file system, you have the option of specifying a CreateFileSystem:KmsKeyId for an existing
AWS
Key Management Service (AWS
KMS
) customer master key (CMK). If you don't specify a CMK, then the default CMK for AmazonEFS
, /aws/elasticfilesystem, is used to protect the encrypted file system. -
KmsKeyId <~String> - (Optional) The ID of the
AWS
KMS
CMK to be used to protect the encrypted file system. This parameter is only required if you want to use a non-default CMK. If this parameter is not specified, the default CMK for AmazonEFS
is used. This ID can be in one of the following formats:-
Key ID - A unique identifier of the key, for example, 1234abcd-12ab-34cd-56ef-1234567890ab.
-
ARN - An Amazon Resource Name (ARN) for the key, for example, arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab.
-
Key alias - A previously created display name for a key. For example, alias/projectKey1.
-
Key alias ARN - An ARN for a key alias, for example, arn:aws:kms:us-west-2:444455556666:alias/projectKey1.
If KmsKeyId is specified, the CreateFileSystem:Encrypted parameter must be set to true.
-
Returns¶ ↑
-
response<~Excon::Response>
-
body<~Hash>
-
# File lib/fog/aws/requests/efs/create_file_system.rb, line 20 def create_file_system(creation_token, options={}) params = { :path => "file-systems", :method => 'POST', :expects => 201, 'CreationToken' => creation_token, 'PerformanceMode' => options[:peformance_mode] || 'generalPurpose', 'Encrypted' => options[:encrypted] || false } params[:kms_key_id] = options[:kms_key_id] if options.key?(:kms_key_id) request(params) end
Create a mount target for a specified file system docs.aws.amazon.com/efs/latest/ug/API_CreateMountTarget.html
Parameters¶ ↑
-
FileSystemId <~String> - ID of the file system for which to create the mount target.
-
IpAddress <~String> - Valid IPv4 address within the address range of the specified subnet.
-
SecurityGroups <~Array> - Up to five VPC security group IDs, of the form sg-xxxxxxxx. These must be for the same VPC as subnet specified.
-
SubnetId <~String> - ID of the subnet to add the mount target in.
Returns¶ ↑
-
response<~Excon::Response>
-
body<~Hash>
-
# File lib/fog/aws/requests/efs/create_mount_target.rb, line 15 def create_mount_target(file_system_id, subnet_id, options={}) request({ :path => "mount-targets", :method => "POST", 'FileSystemId' => file_system_id, 'SubnetId' => subnet_id }.merge(options)) end
Delete a file system docs.aws.amazon.com/efs/latest/ug/API_DeleteFileSystem.html
Parameters¶ ↑
-
FileSystemId <~String> - ID of the file system you want to delete.
Returns¶ ↑
-
response<~Excon::Response>
-
body - Empty
-
status - 204
-
# File lib/fog/aws/requests/efs/delete_file_system.rb, line 13 def delete_file_system(id) request({ :path => "file-systems/#{id}", :method => 'DELETE', :expects => 204, }) end
Delete a mount target docs.aws.amazon.com/efs/latest/ug/API_DeleteMountTarget.html
Parameters¶ ↑
-
MountTargetId <~String> - ID of the mount target you want to delete
Returns¶ ↑
-
response<~Excon::Response>
-
body - Empty
-
status - 204
-
# File lib/fog/aws/requests/efs/delete_mount_target.rb, line 13 def delete_mount_target(id) request( :path => "mount-targets/#{id}", :method => "DELETE", :expects => 204 ) end
Describe all or specified elastic file systems docs.aws.amazon.com/efs/latest/ug/API_DescribeFileSystems.html
Parameters¶ ↑
-
CreationToken <~String> - (Optional) Restricts the list to the file system with this creation token (String). You specify a creation token when you create an Amazon
EFS
file system. -
FileSystemId <~String> - (Optional) ID of the file system whose description you want to retrieve (String).
Returns¶ ↑
-
response<~Excon::Response>:
-
body<~Hash>
-
# File lib/fog/aws/requests/efs/describe_file_systems.rb, line 13 def describe_file_systems(options={}) params = {} if options[:marker] params['Marker'] = options[:marker] end if options[:max_records] params['MaxRecords'] = options[:max_records] end if options[:id] params['FileSystemId'] = options[:id] end if options[:creation_token] params['CreationToken'] = options[:creation_token] end request({ :path => "file-systems" }.merge(params)) end
Describe mount target security groups docs.aws.amazon.com/efs/latest/ug/API_DescribeMountTargetSecurityGroups.html
Parameters¶ ↑
-
MountTargetId - Id of the mount target for which you want to describe security groups
Returns¶ ↑
-
response<~Excon::Response>
-
body<~Hash>
# File lib/fog/aws/requests/efs/describe_mount_target_security_groups.rb, line 13 def describe_mount_target_security_groups(mount_target_id) request( :path => "mount-targets/#{mount_target_id}/security-groups" ) end
Describe all mount targets for a filesystem, or specified mount target docs.aws.amazon.com/efs/latest/ug/API_DescribeMountTargets.html
Parameters¶ ↑
-
FileSystemId<~String> - Id of file system to describe mount targets for. Required unless MountTargetId is specified
-
MountTargetId<~String> - Specific mount target to describe. Required if FileSystemId is not specified
Returns¶ ↑
-
response<~Excon::Response>
-
body<~Hash>
-
# File lib/fog/aws/requests/efs/describe_mount_targets.rb, line 13 def describe_mount_targets(options={}) params = {} if options[:marker] params['Marker'] = options[:marker] end if options[:max_records] params['MaxRecords'] = options[:max_records] end if options[:id] params['MountTargetId'] = options[:id] end if options[:file_system_id] params['FileSystemId'] = options[:file_system_id] end request({ :path => "mount-targets" }.merge(params)) end
# File lib/fog/aws/requests/efs/modify_mount_target_security_groups.rb, line 5 def modify_mount_target_security_groups(id, security_groups) request({ :path => "mount-targets/#{id}/security-groups", :method => "PUT", :expects => 204, 'SecurityGroups' => security_groups }) end
# File lib/fog/aws/efs.rb, line 91 def reload @connection.reset end
# File lib/fog/aws/efs.rb, line 106 def request(params) refresh_credentials_if_expired idempotent = params.delete(:idempotent) parser = params.delete(:parser) expects = params.delete(:expects) || 200 path = @path + params.delete(:path) method = params.delete(:method) || 'GET' request_body = Fog::JSON.encode(params) body, headers = Fog::AWS.signed_params_v4( params, { 'Content-Type' => "application/x-amz-json-1.0", }, { :host => @host, :path => path, :port => @port, :version => @version, :signer => @signer, :aws_session_token => @aws_session_token, :method => method, :body => request_body } ) if @instrumentor @instrumentor.instrument("#{@instrumentor_name}.request", params) do _request(body, headers, idempotent, parser, method, path, expects) end else _request(body, headers, idempotent, parser, method, path, expects) end end
# File lib/fog/aws/efs.rb, line 95 def setup_credentials(options) @aws_access_key_id = options[:aws_access_key_id] @aws_secret_access_key = options[:aws_secret_access_key] @aws_session_token = options[:aws_session_token] @aws_credentials_expire_at = options[:aws_credentials_expire_at] #global services that have no region are signed with the us-east-1 region #the only exception is GovCloud, which requires the region to be explicitly specified as us-gov-west-1 @signer = Fog::AWS::SignatureV4.new(@aws_access_key_id, @aws_secret_access_key, @region, 'elasticfilesystem') end