Skip to content

Commit

Permalink
Convert name from self link to name
Browse files Browse the repository at this point in the history
Signed-off-by: jnahelou <[email protected]>
  • Loading branch information
jnahelou committed Jan 5, 2019
1 parent 0655ec1 commit 5b3b46b
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
4 changes: 4 additions & 0 deletions libraries/gcp_backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def create_resource_methods(object)
dm = GcpResourceDynamicMethods.new
dm.create_methods(self, object)
end

def name_from_self_link(property)
property.split('/').last if !property.nil?
end
end
# end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def initialize(args = nil)
@push_endpoint = args['pushEndpoint']
end
end

end
end
end
7 changes: 6 additions & 1 deletion libraries/google_pubsub_subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,17 @@ def initialize(params)
end

def parse
@name = @fetched['name']
@name = name_from_self_link(@fetched['name'])
@topic = @fetched['topic']
@push_config = GoogleInSpec::Pubsub::Property::SubscriptionPushconfig.new(@fetched['pushConfig'])
@ack_deadline_seconds = @fetched['ackDeadlineSeconds']
end

# Handles parsing RFC3339 time string
def parse_time_string(time_string)
time_string ? Time.parse(time_string) : nil
end

def exists?
!@fetched.nil?
end
Expand Down
1 change: 1 addition & 0 deletions libraries/google_pubsub_subscriptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def fetch_wrapped_resource(wrap_path)
response[wrap_path].each do |hash|
hash_with_symbols = {}
hash.each_pair { |k, v| hash_with_symbols[k.to_sym] = v }
hash_with_symbols[:name] = name_from_self_link(hash_with_symbols[:name])
converted.push(hash_with_symbols)
end
end
Expand Down
7 changes: 6 additions & 1 deletion libraries/google_pubsub_topic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ def initialize(params)
end

def parse
@name = @fetched['name']
@name = name_from_self_link(@fetched['name'])
end

# Handles parsing RFC3339 time string
def parse_time_string(time_string)
time_string ? Time.parse(time_string) : nil
end

def exists?
Expand Down
1 change: 1 addition & 0 deletions libraries/google_pubsub_topics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def fetch_wrapped_resource(wrap_path)
response[wrap_path].each do |hash|
hash_with_symbols = {}
hash.each_pair { |k, v| hash_with_symbols[k.to_sym] = v }
hash_with_symbols[:name] = name_from_self_link(hash_with_symbols[:name])
converted.push(hash_with_symbols)
end
end
Expand Down

0 comments on commit 5b3b46b

Please sign in to comment.