Module: Legion::Extensions::Github::Runners::Comments
- Includes:
- Helpers::Cache, Helpers::Client, Helpers::Lex
- Included in:
- Client
- Defined in:
- lib/legion/extensions/github/runners/comments.rb
Constant Summary
Constants included from Helpers::Cache
Helpers::Cache::DEFAULT_TTL, Helpers::Cache::DEFAULT_TTLS
Constants included from Helpers::Client
Helpers::Client::CREDENTIAL_RESOLVERS
Constants included from Helpers::TokenCache
Helpers::TokenCache::TOKEN_BUFFER_SECONDS
Instance Method Summary collapse
- #create_comment(owner:, repo:, issue_number:, body:) ⇒ Object
- #delete_comment(owner:, repo:, comment_id:) ⇒ Object
- #get_comment(owner:, repo:, comment_id:) ⇒ Object
- #list_comments(owner:, repo:, issue_number:, per_page: 30, page: 1) ⇒ Object
- #update_comment(owner:, repo:, comment_id:, body:) ⇒ Object
Methods included from Helpers::Cache
#cache_connected?, #cache_invalidate, #cache_write, #cached_get, #github_ttl_for, #local_cache_connected?, #local_cache_delete, #local_cache_get, #local_cache_set
Methods included from Helpers::Client
#connection, #gh_cli_token_output, #max_fallback_retries, #on_rate_limit, #on_scope_authorized, #on_scope_denied, #resolve_broker_app, #resolve_credential, #resolve_env, #resolve_gh_cli, #resolve_next_credential, #resolve_settings_app, #resolve_settings_delegated, #resolve_settings_pat, #resolve_vault_app, #resolve_vault_delegated, #resolve_vault_pat
Methods included from Helpers::ScopeRegistry
#credential_fingerprint, #invalidate_scope, #mark_rate_limited, #rate_limited?, #register_scope, #scope_status
Methods included from Helpers::TokenCache
#fetch_token, #mark_rate_limited, #rate_limited?, #store_token
Instance Method Details
#create_comment(owner:, repo:, issue_number:, body:) ⇒ Object
27 28 29 30 |
# File 'lib/legion/extensions/github/runners/comments.rb', line 27 def create_comment(owner:, repo:, issue_number:, body:, **) response = connection(owner: owner, repo: repo, **).post("/repos/#{owner}/#{repo}/issues/#{issue_number}/comments", { body: body }) { result: response.body } end |
#delete_comment(owner:, repo:, comment_id:) ⇒ Object
38 39 40 41 42 |
# File 'lib/legion/extensions/github/runners/comments.rb', line 38 def delete_comment(owner:, repo:, comment_id:, **) response = connection(owner: owner, repo: repo, **).delete("/repos/#{owner}/#{repo}/issues/comments/#{comment_id}") cache_invalidate("github:repo:#{owner}/#{repo}:comments:#{comment_id}") if response.status == 204 { result: response.status == 204 } end |
#get_comment(owner:, repo:, comment_id:) ⇒ Object
21 22 23 24 25 |
# File 'lib/legion/extensions/github/runners/comments.rb', line 21 def get_comment(owner:, repo:, comment_id:, **) { result: cached_get("github:repo:#{owner}/#{repo}:comments:#{comment_id}") do connection(owner: owner, repo: repo, **).get("/repos/#{owner}/#{repo}/issues/comments/#{comment_id}").body end } end |
#list_comments(owner:, repo:, issue_number:, per_page: 30, page: 1) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/legion/extensions/github/runners/comments.rb', line 14 def list_comments(owner:, repo:, issue_number:, per_page: 30, page: 1, **) params = { per_page: per_page, page: page } { result: cached_get("github:repo:#{owner}/#{repo}:issues:#{issue_number}:comments:#{page}:#{per_page}") do connection(owner: owner, repo: repo, **).get("/repos/#{owner}/#{repo}/issues/#{issue_number}/comments", params).body end } end |
#update_comment(owner:, repo:, comment_id:, body:) ⇒ Object
32 33 34 35 36 |
# File 'lib/legion/extensions/github/runners/comments.rb', line 32 def update_comment(owner:, repo:, comment_id:, body:, **) response = connection(owner: owner, repo: repo, **).patch("/repos/#{owner}/#{repo}/issues/comments/#{comment_id}", { body: body }) cache_write("github:repo:#{owner}/#{repo}:comments:#{comment_id}", response.body) if response.body['id'] { result: response.body } end |