Module: Gitlab::Client::BroadcastMessages

Included in:
Gitlab::Client
Defined in:
lib/gitlab/client/broadcast_messages.rb

Overview

Defines methods related to broadcast messages (only accessible to administrators).

Instance Method Summary collapse

Instance Method Details

#broadcast_message(id) ⇒ Gitlab::ObjectifiedHash

Get a specific broadcast message

Examples:

Gitlab.broadcast_message(3)

Parameters:

  • id (Integer)

    The ID of broadcast message

Returns:



24
25
26
# File 'lib/gitlab/client/broadcast_messages.rb', line 24

def broadcast_message(id)
  get("/broadcast_messages/#{id}")
end

#broadcast_messagesArray<Gitlab::ObjectifiedHash>

Get all broadcast messages

Examples:

Gitlab.broadcast_messages

Returns:



13
14
15
# File 'lib/gitlab/client/broadcast_messages.rb', line 13

def broadcast_messages
  get('/broadcast_messages')
end

#create_broadcast_message(message, options = {}) ⇒ Gitlab::ObjectifiedHash

Create a broadcast message.

Examples:

Gitlab.create_broadcast_message('Mayday')
Gitlab.create_broadcast_message('Mayday', {starts_at: Time.zone.now, ends_at: Time.zone.now + 30.minutes, color: '#cecece', font: '#FFFFFF'})

Parameters:

  • message (String)

    Message to display

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :starts_at(optional) (DateTime)

    Starting time (defaults to current time)

  • :ends_at(optional) (DateTime)

    Ending time (defaults to one hour from current time)

  • :color(optional) (String)

    Background color hex code

  • :font(optional) (String)

    Foreground color hex code

Returns:



41
42
43
44
# File 'lib/gitlab/client/broadcast_messages.rb', line 41

def create_broadcast_message(message, options = {})
  body = { message: message }.merge(options)
  post('/broadcast_messages', body: body)
end

#delete_broadcast_message(id) ⇒ nil

Delete a broadcast message.

Examples:

Gitlab.delete_broadcast_message(3)

Parameters:

  • id (Integer)

    The ID of a broadcast message.

Returns:

  • (nil)

    This API call returns an empty response body.



71
72
73
# File 'lib/gitlab/client/broadcast_messages.rb', line 71

def delete_broadcast_message(id)
  delete("/broadcast_messages/#{id}")
end

#edit_broadcast_message(id, options = {}) ⇒ Gitlab::ObjectifiedHash

Update a broadcast message

Examples:

Gitlab.edit_broadcast_message(6, { message: 'No Mayday' })
Gitlab.edit_broadcast_message(6, { font: '#FEFEFE' })

Parameters:

  • id (Integer)

    The ID of a broadcast message

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :message(optional) (String)

    Message to display

  • :starts_at(optional) (DateTime)

    Starting time (defaults to current time)

  • :ends_at(optional) (DateTime)

    Ending time (defaults to one hour from current time)

  • :color(optional) (String)

    Background color hex code

  • :font(optional) (String)

    Foreground color hex code

Returns:



60
61
62
# File 'lib/gitlab/client/broadcast_messages.rb', line 60

def edit_broadcast_message(id, options = {})
  put("/broadcast_messages/#{id}", body: options)
end