class MediaWiktory::Wikipedia::Actions::Protect

Change the protection level of a page.

Usage:

“`ruby api.protect.title(value).perform # returns string with raw output # or api.protect.title(value).response # returns output parsed and wrapped into Response object “`

See {Base} for generic explanation of working with MediaWiki actions and {MediaWiktory::Wikipedia::Response} for working with action responses.

All action's parameters are documented as its public methods, see below.

Public Instance Methods

_expiry(value) click to toggle source

@private

# File lib/mediawiktory/wikipedia/actions/protect.rb, line 60
def _expiry(value)
  merge(expiry: value.to_s, replace: false)
end
_protections(value) click to toggle source

@private

# File lib/mediawiktory/wikipedia/actions/protect.rb, line 47
def _protections(value)
  merge(protections: value.to_s, replace: false)
end
_tags(value) click to toggle source

@private

Calls superclass method
# File lib/mediawiktory/wikipedia/actions/protect.rb, line 81
def _tags(value)
  defined?(super) && super || ["ProveIt edit", "WPCleaner", "huggle", "large plot addition"].include?(value.to_s) && merge(tags: value.to_s, replace: false)
end
_watchlist(value) click to toggle source

@private

Calls superclass method
# File lib/mediawiktory/wikipedia/actions/protect.rb, line 108
def _watchlist(value)
  defined?(super) && super || ["watch", "unwatch", "preferences", "nochange"].include?(value.to_s) && merge(watchlist: value.to_s)
end
cascade() click to toggle source

Enable cascading protection (i.e. protect transcluded templates and images used in this page). Ignored if none of the given protection levels support cascading.

@return [self]

# File lib/mediawiktory/wikipedia/actions/protect.rb, line 88
def cascade()
  merge(cascade: 'true')
end
expiry(*values) click to toggle source

Expiry timestamps. If only one timestamp is set, it'll be used for all protections. Use infinite, indefinite, infinity, or never, for a never-expiring protection.

@param values [Array<String>] @return [self]

# File lib/mediawiktory/wikipedia/actions/protect.rb, line 55
def expiry(*values)
  values.inject(self) { |res, val| res._expiry(val) }
end
pageid(value) click to toggle source

ID of the page to (un)protect. Cannot be used together with title.

@param value [Integer] @return [self]

# File lib/mediawiktory/wikipedia/actions/protect.rb, line 34
def pageid(value)
  merge(pageid: value.to_s)
end
protections(*values) click to toggle source

List of protection levels, formatted action=level (e.g. edit=sysop). A level of all means everyone is allowed to take the action, i.e. no restriction.

@param values [Array<String>] @return [self]

# File lib/mediawiktory/wikipedia/actions/protect.rb, line 42
def protections(*values)
  values.inject(self) { |res, val| res._protections(val) }
end
reason(value) click to toggle source

Reason for (un)protecting.

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/protect.rb, line 68
def reason(value)
  merge(reason: value.to_s)
end
tags(*values) click to toggle source

Change tags to apply to the entry in the protection log.

@param values [Array<String>] Allowed values: “ProveIt edit”, “WPCleaner”, “huggle”, “large plot addition”. @return [self]

# File lib/mediawiktory/wikipedia/actions/protect.rb, line 76
def tags(*values)
  values.inject(self) { |res, val| res._tags(val) or fail ArgumentError, "Unknown value for tags: #{val}" }
end
title(value) click to toggle source

Title of the page to (un)protect. Cannot be used together with pageid.

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/protect.rb, line 26
def title(value)
  merge(title: value.to_s)
end
token(value) click to toggle source

A “csrf” token retrieved from action=query&meta=tokens

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/protect.rb, line 116
def token(value)
  merge(token: value.to_s)
end
watch() click to toggle source

If set, add the page being (un)protected to the current user's watchlist.

@return [self]

# File lib/mediawiktory/wikipedia/actions/protect.rb, line 95
def watch()
  merge(watch: 'true')
end
watchlist(value) click to toggle source

Unconditionally add or remove the page from the current user's watchlist, use preferences or do not change watch.

@param value [String] One of “watch”, “unwatch”, “preferences”, “nochange”. @return [self]

# File lib/mediawiktory/wikipedia/actions/protect.rb, line 103
def watchlist(value)
  _watchlist(value) or fail ArgumentError, "Unknown value for watchlist: #{value}"
end