Skip to content

Commit

Permalink
Merge pull request #166 from liangxin1300/0614c
Browse files Browse the repository at this point in the history
Api: Add 'belong' in resource return value(fate#323437)
  • Loading branch information
ayoub-belarbi authored Jun 15, 2018
2 parents 4de898e + 671dfb8 commit dcd4bc9
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion hawk/app/models/api/v1/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,23 @@ def location
@instances
end

def belong
type = @config.parent.name
if ["clone", "master", "group"].include?(type)
{ id: @config.parent.attributes['id'], type: type }
end
end

# Implicite conversion to hash
def to_hash
{ id: id, type: type, state: state, maintenance: maintenance, location: location }
{
id: id,
type: type,
state: state,
maintenance: maintenance,
location: location,
belong: belong
}
end

end
Expand Down

0 comments on commit dcd4bc9

Please sign in to comment.