Class: AkamaiApi::CLI::ECCU::Base

Inherits:
Command
  • Object
show all
Defined in:
lib/akamai_api/cli/eccu/base.rb

Instance Method Summary collapse

Instance Method Details

#last_requestObject



20
21
22
23
24
25
26
# File 'lib/akamai_api/cli/eccu/base.rb', line 20

def last_request
  load_config
  request = AkamaiApi::ECCURequest.last verbose: options[:content]
  puts EntryRenderer.new(request).render
rescue ::AkamaiApi::Unauthorized
  puts "Your login credentials are invalid."
end

#publish_xml(source, property) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/akamai_api/cli/eccu/base.rb', line 40

def publish_xml(source, property)
  load_config
  args = {
    :notes => options[:notes],
    :property_exact_match => !options[:no_exact_match],
    :property_type => options[:property_type],
    :emails => options[:emails]
  }
  id = AkamaiApi::ECCURequest.publish_file property, source, args
  puts "Request correctly published:"
  puts EntryRenderer.new(AkamaiApi::ECCURequest.find(id, :verbose => true)).render
rescue ::AkamaiApi::Unauthorized
  puts "Your login credentials are invalid."
rescue ::AkamaiApi::ECCU::InvalidDomain
  puts "You are not authorized to specify this digital property."
rescue Savon::SOAPFault
  puts $!.message
end

#requestsObject



9
10
11
12
13
14
15
# File 'lib/akamai_api/cli/eccu/base.rb', line 9

def requests
  load_config
  requests = AkamaiApi::ECCURequest.all :verbose => options[:content]
  puts EntryRenderer.render requests
rescue ::AkamaiApi::Unauthorized
  puts "Your login credentials are invalid."
end

#revalidate(revalidate_on, property, querystring) ⇒ Object



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
# File 'lib/akamai_api/cli/eccu/base.rb', line 74

def revalidate(revalidate_on, property, querystring)
  load_config
  args = {
    :notes => options[:notes],
    :property_exact_match => !options[:no_exact_match],
    :property_type => options[:property_type],
    :emails => options[:emails]
  }
  parser = AkamaiApi::ECCUParser.new querystring, revalidate_on
  puts parser.xml
  if options[:force]
    str = "Y"
  else
    print "\nPublish this XML? (Y/n)"
    begin
      system("stty raw -echo")
      str = STDIN.getc
    ensure
      system("stty -raw echo")
    end
  end
  if str == "Y"
    id = AkamaiApi::ECCURequest.publish property, parser.xml, args
    puts "\n\nRequest correctly published:"
    puts EntryRenderer.new(AkamaiApi::ECCURequest.find(id, :verbose => true)).render
  else
    puts "\n\nExit without publish request"
  end
rescue Exception => e
  puts e.message
end