Class: PactBroker::Api::Resources::Index

Inherits:
BaseResource
  • Object
show all
Defined in:
lib/pact_broker/api/resources/index.rb

Instance Method Summary collapse

Instance Method Details

#allowed_methodsObject



13
14
15
# File 'lib/pact_broker/api/resources/index.rb', line 13

def allowed_methods
  ["GET", "OPTIONS"]
end

#content_types_providedObject



9
10
11
# File 'lib/pact_broker/api/resources/index.rb', line 9

def content_types_provided
  [["application/hal+json", :to_json]]
end


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/pact_broker/api/resources/index.rb', line 21

def links
  links_hash = {
    'self' =>
    {
      href: base_url,
      title: 'Index',
      templated: false
    },
    'pb:publish-pact' => {
      href: base_url + '/pacts/provider/{provider}/consumer/{consumer}/version/{consumerApplicationVersion}',
      title: 'Publish a pact',
      templated: true
    },
    'pb:latest-pact-versions' =>
    {
      href: base_url + '/pacts/latest',
      title: 'Latest pact versions',
      templated: false
    },
    'pb:tagged-pact-versions' =>
    {
      href: base_url + '/pacts/provider/{provider}/consumer/{consumer}/tag/{tag}',
      title: 'All versions of a pact for a given consumer, provider and consumer version tag',
      templated: false
    },
    'pb:pacticipants' =>
    {
      href: base_url + '/pacticipants',
      title: 'Pacticipants',
      templated: false
    },
    'pb:pacticipant' =>
    {
      href: base_url + '/pacticipants/{pacticipant}',
      title: 'Fetch pacticipant by name',
      templated: true
    },
    'pb:latest-provider-pacts' =>
    {
      href: base_url + '/pacts/provider/{provider}/latest',
      title: 'Latest pacts by provider',
      templated: true
    },
    'pb:latest-provider-pacts-with-tag' =>
    {
      href: base_url + '/pacts/provider/{provider}/latest/{tag}',
      title: 'Latest pacts for provider with the specified tag',
      templated: true
    },
    'pb:provider-pacts-with-tag' =>
    {
      href: base_url + '/pacts/provider/{provider}/tag/{tag}',
      title: 'All pact versions for the provider with the specified consumer version tag',
      templated: true
    },
    'pb:provider-pacts' =>
    {
      href: base_url + '/pacts/provider/{provider}',
      title: 'All pact versions for the specified provider',
      templated: true
    },
    'pb:latest-version' => {
      href: base_url + '/pacticipants/{pacticipant}/latest-version',
      title: 'Latest pacticipant version',
      templated: true
    },
    'pb:latest-tagged-version' => {
      href: base_url + '/pacticipants/{pacticipant}/latest-version/{tag}',
      title: 'Latest pacticipant version with the specified tag',
      templated: true
    },
    'pb:webhooks' => {
      href: base_url + '/webhooks',
      title: 'Webhooks',
      templated: false
    },
    'pb:webhook' => {
      href: base_url + '/webhooks/{uuid}',
      title: 'Webhook',
      templated: true
    },
    'pb:integrations' => {
      href: base_url + '/integrations',
      title: 'Integrations',
      templated: false
    },
    'pb:pacticipant-version-tag' =>
    {
      href: base_url + '/pacticipants/{pacticipant}/versions/{version}/tags/{tag}',
      title: "Get, create or delete a tag for a pacticipant version",
      templated: true
    },
    'pb:metrics' =>
    {
      href: base_url + '/metrics',
      title: "Get Pact Broker metrics",
    },
    'pb:can-i-deploy-pacticipant-version-to-tag' =>
    {
      href: base_url + '/can-i-deploy?pacticipant={pacticipant}&version={version}&to={tag}',
      title: "Determine if an application can be safely deployed to an environment identified by the given tag",
      templated: true
    },
    'curies' =>
    [{
      name: 'pb',
      href: base_url + '/doc/{rel}?context=index',
      templated: true
    },{
      name: 'beta',
      href: base_url + '/doc/{rel}?context=index',
      templated: true
    }]
  }

  if PactBroker.feature_enabled?(:pacts_for_verification)
    links_hash['beta:provider-pacts-for-verification'] = {
        href: base_url + '/pacts/provider/{provider}/for-verification',
        title: 'Pact versions to be verified for the specified provider',
        templated: true
      }
  end

  links_hash
end

#policy_nameObject



147
148
149
# File 'lib/pact_broker/api/resources/index.rb', line 147

def policy_name
  :'index::index'
end

#to_jsonObject



17
18
19
# File 'lib/pact_broker/api/resources/index.rb', line 17

def to_json
  { _links: links }.to_json
end