Module: PactBroker::Api::PactBrokerUrls
- Extended by:
- PactBrokerUrls
- Includes:
- Pacts::Metadata
- Included in:
- Decorators::BaseDecorator, Decorators::DashboardDecorator, Decorators::DashboardTextDecorator, Decorators::IntegrationDecorator, Decorators::MatrixDecorator, Decorators::PactCollectionDecorator, PactBrokerUrls, Resources::BaseResource, UI::ViewDomain::IndexItem, UI::ViewDomain::MatrixLine, UI::ViewDomain::MatrixTag
- Defined in:
- lib/pact_broker/api/pact_broker_urls.rb
Instance Method Summary collapse
- #badge_url_for_latest_pact(pact, base_url = '') ⇒ Object
- #build_webhook_metadata(pact) ⇒ Object
- #consumer_webhooks_url(consumer, base_url = '') ⇒ Object
- #dashboard_url_for_integration(consumer_name, provider_name, base_url = "") ⇒ Object
- #decode_webhook_metadata(metadata) ⇒ Object
- #encode_webhook_metadata(metadata) ⇒ Object
- #group_url(pacticipant_name, base_url = '') ⇒ Object
- #hal_browser_url(target_url) ⇒ Object
- #integration_url(consumer_name, provider_name, base_url = "") ⇒ Object
- #label_url(label, base_url) ⇒ Object
- #labels_url(pacticipant, base_url) ⇒ Object
- #latest_pact_url(base_url, pact) ⇒ Object
- #latest_pacts_url(base_url) ⇒ Object
- #latest_tagged_pact_url(pact, tag_name, base_url) ⇒ Object
- #latest_untagged_pact_url(pact, base_url) ⇒ Object
- #latest_verification_for_pact_url(pact, base_url, permalink = true) ⇒ Object
- #latest_verifications_for_consumer_version_url(version, base_url) ⇒ Object
- #latest_version_url(base_url, pacticipant) ⇒ Object
- #matrix_for_pact_url(pact, base_url = '') ⇒ Object
- #matrix_for_pacticipant_version_url(version, base_url = '') ⇒ Object
- #matrix_url(consumer_name, provider_name, base_url = '') ⇒ Object
- #matrix_url_from_params(params, base_url = '') ⇒ Object
- #new_verification_url(pact, number, base_url) ⇒ Object
- #pact_triggered_webhooks_url(pact, base_url = '') ⇒ Object
- #pact_url(base_url, pact) ⇒ Object
- #pact_url_from_params(base_url, params) ⇒ Object
- #pact_version_url(pact, base_url = '') ⇒ Object
- #pact_version_url_with_metadata(pact, base_url = '') ⇒ Object
- #pact_versions_url(consumer_name, provider_name, base_url = "") ⇒ Object
- #pacticipant_url(base_url, pacticipant) ⇒ Object
- #pacticipant_url_from_params(params, base_url = '') ⇒ Object
- #pacticipants_url(base_url) ⇒ Object
- #previous_distinct_diff_url(pact, base_url) ⇒ Object
- #previous_distinct_pact_version_url(pact, base_url) ⇒ Object
- #provider_webhooks_url(provider, base_url = '') ⇒ Object
- #tag_url(base_url, tag) ⇒ Object
- #tags_url(base_url, version) ⇒ Object
- #templated_diff_url(pact, base_url = '') ⇒ Object
- #templated_label_url_for_pacticipant(pacticipant_name, base_url = "") ⇒ Object
- #templated_tag_url_for_pacticipant(pacticipant_name, base_url = "") ⇒ Object
- #triggered_webhook_logs_url(triggered_webhook, base_url) ⇒ Object
- #url_encode(param) ⇒ Object
- #verification_publication_url(pact, base_url, metadata = "") ⇒ Object
- #verification_triggered_webhooks_url(verification, base_url = '') ⇒ Object
- #verification_url(verification, base_url = '') ⇒ Object
- #verification_url_from_params(params, base_url = '') ⇒ Object
- #version_url(base_url, version) ⇒ Object
- #version_url_from_params(params, base_url = '') ⇒ Object
- #versions_url(base_url, pacticipant) ⇒ Object
- #webhook_execution_url(webhook, base_url) ⇒ Object
- #webhook_url(uuid, base_url) ⇒ Object
- #webhooks_for_consumer_and_provider_url(consumer, provider, base_url = '') ⇒ Object
- #webhooks_for_pact_url(consumer, provider, base_url = '') ⇒ Object
- #webhooks_status_url(consumer, provider, base_url = '') ⇒ Object
- #webhooks_url(base_url) ⇒ Object
Methods included from Pacts::Metadata
#build_metadata_for_latest_pact, #build_metadata_for_webhook_triggered_by_pact_publication
Instance Method Details
#badge_url_for_latest_pact(pact, base_url = '') ⇒ Object
248 249 250 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 248 def badge_url_for_latest_pact pact, base_url = '' "#{latest_pact_url(base_url, pact)}/badge.svg" end |
#build_webhook_metadata(pact) ⇒ Object
63 64 65 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 63 def (pact) ((pact)) end |
#consumer_webhooks_url(consumer, base_url = '') ⇒ Object
224 225 226 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 224 def consumer_webhooks_url consumer, base_url = '' "#{base_url}/webhooks/consumer/#{url_encode(consumer.name)}" end |
#dashboard_url_for_integration(consumer_name, provider_name, base_url = "") ⇒ Object
112 113 114 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 112 def dashboard_url_for_integration consumer_name, provider_name, base_url = "" "#{base_url}/dashboard/provider/#{url_encode(provider_name)}/consumer/#{url_encode(consumer_name)}" end |
#decode_webhook_metadata(metadata) ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 71 def () if Rack::Utils.parse_nested_query(Base64.strict_decode64()).each_with_object({}) do | (k, v), new_hash | new_hash[k.to_sym] = v end else {} end end |
#encode_webhook_metadata(metadata) ⇒ Object
67 68 69 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 67 def () Base64.strict_encode64(Rack::Utils.build_nested_query()) end |
#group_url(pacticipant_name, base_url = '') ⇒ Object
279 280 281 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 279 def group_url(pacticipant_name, base_url = '') "#{base_url}/groups/#{pacticipant_name}" end |
#hal_browser_url(target_url) ⇒ Object
283 284 285 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 283 def hal_browser_url target_url "/hal-browser/browser.html#" + target_url end |
#integration_url(consumer_name, provider_name, base_url = "") ⇒ Object
108 109 110 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 108 def integration_url consumer_name, provider_name, base_url = "" "#{base_url}/integrations/provider/#{url_encode(provider_name)}/consumer/#{url_encode(consumer_name)}" end |
#label_url(label, base_url) ⇒ Object
200 201 202 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 200 def label_url label, base_url "#{labels_url(label.pacticipant, base_url)}/#{label.name}" end |
#labels_url(pacticipant, base_url) ⇒ Object
204 205 206 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 204 def labels_url pacticipant, base_url "#{pacticipant_url(base_url, pacticipant)}/labels" end |
#latest_pact_url(base_url, pact) ⇒ Object
88 89 90 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 88 def latest_pact_url base_url, pact "#{pactigration_base_url(base_url, pact)}/latest" end |
#latest_pacts_url(base_url) ⇒ Object
100 101 102 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 100 def latest_pacts_url base_url "#{base_url}/pacts/latest" end |
#latest_tagged_pact_url(pact, tag_name, base_url) ⇒ Object
96 97 98 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 96 def latest_tagged_pact_url pact, tag_name, base_url "#{latest_pact_url(base_url, pact)}/#{url_encode(tag_name)}" end |
#latest_untagged_pact_url(pact, base_url) ⇒ Object
92 93 94 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 92 def latest_untagged_pact_url pact, base_url "#{pactigration_base_url(base_url, pact)}/latest-untagged" end |
#latest_verification_for_pact_url(pact, base_url, permalink = true) ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 163 def latest_verification_for_pact_url pact, base_url, permalink = true if permalink verification_url_from_params( { provider_name: provider_name(pact), consumer_name: consumer_name(pact), pact_version_sha: pact.pact_version_sha, verification_number: 'latest' }, base_url ) else pact_url(base_url, pact) + "/verification-results/latest" end end |
#latest_verifications_for_consumer_version_url(version, base_url) ⇒ Object
159 160 161 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 159 def latest_verifications_for_consumer_version_url version, base_url "#{base_url}/verification-results/consumer/#{url_encode(version.pacticipant.name)}/version/#{version.number}/latest" end |
#latest_version_url(base_url, pacticipant) ⇒ Object
29 30 31 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 29 def latest_version_url base_url, pacticipant "#{pacticipant_url(base_url, pacticipant)}/versions/latest" end |
#matrix_for_pact_url(pact, base_url = '') ⇒ Object
264 265 266 267 268 269 270 271 272 273 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 264 def matrix_for_pact_url(pact, base_url = '') query = { q: [ { pacticipant: pact.consumer_name, version: pact.consumer_version_number }, { pacticipant: pact.provider_name, latest: true } ], latestby: 'cvpv' } "#{base_url}/matrix?#{Rack::Utils.build_nested_query(query)}" end |
#matrix_for_pacticipant_version_url(version, base_url = '') ⇒ Object
256 257 258 259 260 261 262 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 256 def matrix_for_pacticipant_version_url(version, base_url = '') query = { q: [{ pacticipant: version.pacticipant.name, version: version.number }], latestby: 'cvpv' } "#{base_url}/matrix?#{Rack::Utils.build_nested_query(query)}" end |
#matrix_url(consumer_name, provider_name, base_url = '') ⇒ Object
252 253 254 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 252 def matrix_url consumer_name, provider_name, base_url = '' "/matrix/provider/#{url_encode(provider_name)}/consumer/#{url_encode(consumer_name)}" end |
#matrix_url_from_params(params, base_url = '') ⇒ Object
275 276 277 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 275 def matrix_url_from_params params, base_url = '' matrix_url(params.fetch(:consumer_name), params.fetch(:provider_name), base_url) end |
#new_verification_url(pact, number, base_url) ⇒ Object
132 133 134 135 136 137 138 139 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 132 def new_verification_url pact, number, base_url [ base_url, 'pacts', 'provider', url_encode(pact.provider_name), 'consumer', url_encode(pact.consumer_name), 'pact-version', pact.pact_version_sha, 'verification-results', number ].join('/') end |
#pact_triggered_webhooks_url(pact, base_url = '') ⇒ Object
240 241 242 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 240 def pact_triggered_webhooks_url pact, base_url = '' "#{pact_url(base_url, pact)}/triggered-webhooks" end |
#pact_url(base_url, pact) ⇒ Object
51 52 53 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 51 def pact_url base_url, pact "#{pactigration_base_url(base_url, pact)}/version/#{url_encode(pact.consumer_version_number)}" end |
#pact_url_from_params(base_url, params) ⇒ Object
81 82 83 84 85 86 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 81 def pact_url_from_params base_url, params [ base_url, 'pacts', 'provider', url_encode(params[:provider_name]), 'consumer', url_encode(params[:consumer_name]), 'version', url_encode(params[:consumer_version_number]) ].join('/') end |
#pact_version_url(pact, base_url = '') ⇒ Object
55 56 57 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 55 def pact_version_url pact, base_url = '' "#{pactigration_base_url(base_url, pact)}/pact-version/#{pact.pact_version_sha}" end |
#pact_version_url_with_metadata(pact, base_url = '') ⇒ Object
59 60 61 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 59 def pact, base_url = '' "#{pactigration_base_url(base_url, pact)}/pact-version/#{pact.pact_version_sha}/metadata/#{build_webhook_metadata(pact)}" end |
#pact_versions_url(consumer_name, provider_name, base_url = "") ⇒ Object
104 105 106 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 104 def pact_versions_url consumer_name, provider_name, base_url = "" "#{base_url}/pacts/provider/#{url_encode(provider_name)}/consumer/#{url_encode(consumer_name)}/versions" end |
#pacticipant_url(base_url, pacticipant) ⇒ Object
17 18 19 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 17 def pacticipant_url base_url, pacticipant "#{pacticipants_url(base_url)}/#{url_encode(pacticipant.name)}" end |
#pacticipant_url_from_params(params, base_url = '') ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 21 def pacticipant_url_from_params params, base_url = '' [ base_url, 'pacticipants', url_encode(params.fetch(:pacticipant_name)) ].join("/") end |
#pacticipants_url(base_url) ⇒ Object
13 14 15 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 13 def pacticipants_url base_url "#{base_url}/pacticipants" end |
#previous_distinct_diff_url(pact, base_url) ⇒ Object
116 117 118 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 116 def previous_distinct_diff_url pact, base_url pact_url(base_url, pact) + "/diff/previous-distinct" end |
#previous_distinct_pact_version_url(pact, base_url) ⇒ Object
124 125 126 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 124 def previous_distinct_pact_version_url pact, base_url pact_url(base_url, pact) + "/previous-distinct" end |
#provider_webhooks_url(provider, base_url = '') ⇒ Object
228 229 230 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 228 def provider_webhooks_url provider, base_url = '' "#{base_url}/webhooks/provider/#{url_encode(provider.name)}" end |
#tag_url(base_url, tag) ⇒ Object
188 189 190 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 188 def tag_url base_url, tag "#{tags_url(base_url, tag.version)}/#{tag.name}" end |
#tags_url(base_url, version) ⇒ Object
128 129 130 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 128 def base_url, version "#{version_url(base_url, version)}/tags" end |
#templated_diff_url(pact, base_url = '') ⇒ Object
120 121 122 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 120 def templated_diff_url pact, base_url = '' pact_version_url(pact, base_url) + "/diff/pact-version/{pactVersion}" end |
#templated_label_url_for_pacticipant(pacticipant_name, base_url = "") ⇒ Object
196 197 198 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 196 def templated_label_url_for_pacticipant pacticipant_name, base_url = "" pacticipant_url_from_params({pacticipant_name: pacticipant_name}, base_url) + "/labels/{label}" end |
#templated_tag_url_for_pacticipant(pacticipant_name, base_url = "") ⇒ Object
192 193 194 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 192 def templated_tag_url_for_pacticipant pacticipant_name, base_url = "" pacticipant_url_from_params({pacticipant_name: pacticipant_name}, base_url) + "/versions/{version}/tags/{tag}" end |
#triggered_webhook_logs_url(triggered_webhook, base_url) ⇒ Object
244 245 246 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 244 def triggered_webhook_logs_url triggered_webhook, base_url "#{base_url}/webhooks/#{triggered_webhook.webhook_uuid}/trigger/#{triggered_webhook.trigger_uuid}/logs" end |
#url_encode(param) ⇒ Object
287 288 289 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 287 def url_encode param ERB::Util.url_encode param end |
#verification_publication_url(pact, base_url, metadata = "") ⇒ Object
183 184 185 186 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 183 def verification_publication_url pact, base_url, = "" = ? "/metadata/#{metadata}" : "" "#{pactigration_base_url(base_url, pact)}/pact-version/#{pact.pact_version_sha}#{metadata_part}/verification-results" end |
#verification_triggered_webhooks_url(verification, base_url = '') ⇒ Object
179 180 181 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 179 def verification_triggered_webhooks_url verification, base_url = '' "#{verification_url(verification, base_url)}/triggered-webhooks" end |
#verification_url(verification, base_url = '') ⇒ Object
141 142 143 144 145 146 147 148 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 141 def verification_url verification, base_url = '' [ base_url, 'pacts', 'provider', url_encode(verification.provider_name), 'consumer', url_encode(verification.consumer_name), 'pact-version', verification.pact_version_sha, 'verification-results', verification.number ].join('/') end |
#verification_url_from_params(params, base_url = '') ⇒ Object
150 151 152 153 154 155 156 157 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 150 def verification_url_from_params params, base_url = '' [ base_url, 'pacts', 'provider', url_encode(params.fetch(:provider_name)), 'consumer', url_encode(params.fetch(:consumer_name)), 'pact-version', params.fetch(:pact_version_sha), 'verification-results', params.fetch(:verification_number) ].join('/') end |
#version_url(base_url, version) ⇒ Object
37 38 39 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 37 def version_url base_url, version "#{pacticipant_url(base_url, version.pacticipant)}/versions/#{version.number}" end |
#version_url_from_params(params, base_url = '') ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 41 def version_url_from_params params, base_url = '' [ base_url, 'pacticipants', url_encode(params.fetch(:pacticipant_name)), 'versions', url_encode(params.fetch(:version_number)), ].join("/") end |
#versions_url(base_url, pacticipant) ⇒ Object
33 34 35 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 33 def versions_url base_url, pacticipant "#{pacticipant_url(base_url, pacticipant)}/versions" end |
#webhook_execution_url(webhook, base_url) ⇒ Object
216 217 218 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 216 def webhook_execution_url webhook, base_url "#{base_url}/webhooks/#{webhook.uuid}/execute" end |
#webhook_url(uuid, base_url) ⇒ Object
212 213 214 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 212 def webhook_url uuid, base_url "#{base_url}/webhooks/#{uuid}" end |
#webhooks_for_consumer_and_provider_url(consumer, provider, base_url = '') ⇒ Object
220 221 222 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 220 def webhooks_for_consumer_and_provider_url consumer, provider, base_url = '' "#{base_url}/webhooks/provider/#{url_encode(provider.name)}/consumer/#{url_encode(consumer.name)}" end |
#webhooks_for_pact_url(consumer, provider, base_url = '') ⇒ Object
232 233 234 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 232 def webhooks_for_pact_url consumer, provider, base_url = '' "#{base_url}/pacts/provider/#{url_encode(provider.name)}/consumer/#{url_encode(consumer.name)}/webhooks" end |
#webhooks_status_url(consumer, provider, base_url = '') ⇒ Object
236 237 238 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 236 def webhooks_status_url consumer, provider, base_url = '' "#{webhooks_for_pact_url(consumer, provider, base_url)}/status" end |
#webhooks_url(base_url) ⇒ Object
208 209 210 |
# File 'lib/pact_broker/api/pact_broker_urls.rb', line 208 def webhooks_url base_url "#{base_url}/webhooks" end |