Class: Infrawrench::SlackNamespace

Inherits:
Object
  • Object
show all
Defined in:
lib/infrawrench/client.rb,
sig/infrawrench/sdk.rbs

Overview

client.slack

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ SlackNamespace

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of SlackNamespace.

Parameters:



5638
5639
5640
5641
5642
# File 'lib/infrawrench/client.rb', line 5638

def initialize(transport)
  @transport = transport
  @channels = SlackChannelsNamespace.new(@transport)
  @installations = SlackInstallationsNamespace.new(@transport)
end

Instance Attribute Details

#channelsSlackChannelsNamespace (readonly)

Returns client.slack.channels.

Returns:



5632
5633
5634
# File 'lib/infrawrench/client.rb', line 5632

def channels
  @channels
end

#installationsSlackInstallationsNamespace (readonly)

Returns client.slack.installations.

Returns:



5634
5635
5636
# File 'lib/infrawrench/client.rb', line 5634

def installations
  @installations
end

Instance Method Details

#install_url(org_id: nil, request_options: nil) ⇒ Hash

Get the Add to Slack URL

Returns a slack.com/oauth/v2/authorize URL carrying a signed state that binds the resulting install to this organization. Send the user's browser there; Slack redirects back to /api/slack/oauth/callback.

GET /api/org/orgId/slack/install-url

Raises on 400: Bad request

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • org_id: (String, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as Hash — see sig/infrawrench/sdk.rbs.

Raises:



5659
5660
5661
5662
5663
5664
5665
5666
# File 'lib/infrawrench/client.rb', line 5659

def install_url(org_id: nil, request_options: nil)
  @transport.request(
    http_method: "GET",
    path: "/api/org/{orgId}/slack/install-url",
    path_params: { "orgId" => org_id },
    request_options: request_options
  )
end

#status(org_id: nil, request_options: nil) ⇒ Hash

Get the organization's Slack connection

Reports whether the server has a Slack app registered, which workspaces this organization has connected, and which channels alerts are routed to.

GET /api/org/orgId/slack/status

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • org_id: (String, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as SlackStatus — see sig/infrawrench/sdk.rbs.

Raises:



5680
5681
5682
5683
5684
5685
5686
5687
# File 'lib/infrawrench/client.rb', line 5680

def status(org_id: nil, request_options: nil)
  @transport.request(
    http_method: "GET",
    path: "/api/org/{orgId}/slack/status",
    path_params: { "orgId" => org_id },
    request_options: request_options
  )
end

#test(org_id: nil, request_options: nil) ⇒ Hash

Post a test message to every configured channel

Ignores trigger opt-ins — every channel gets the test. Fails with the Slack error when nothing could be delivered (not_in_channel means the bot needs inviting to a private channel).

POST /api/org/orgId/slack/test

Raises on 400: Bad request

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • org_id: (String, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as Hash — see sig/infrawrench/sdk.rbs.

Raises:



5704
5705
5706
5707
5708
5709
5710
5711
# File 'lib/infrawrench/client.rb', line 5704

def test(org_id: nil, request_options: nil)
  @transport.request(
    http_method: "POST",
    path: "/api/org/{orgId}/slack/test",
    path_params: { "orgId" => org_id },
    request_options: request_options
  )
end