Class: ConnectorsSdk::ConfluenceCloud::CustomClient

Inherits:
ConnectorsSdk::Confluence::CustomClient show all
Defined in:
lib/connectors_sdk/confluence_cloud/custom_client.rb

Constant Summary

Constants inherited from ConnectorsSdk::Confluence::CustomClient

ConnectorsSdk::Confluence::CustomClient::CONTENT_EXPAND_FIELDS, ConnectorsSdk::Confluence::CustomClient::CONTENT_SEARCH_ENDPOINT, ConnectorsSdk::Confluence::CustomClient::SEARCH_ENDPOINT

Constants inherited from Atlassian::CustomClient

Atlassian::CustomClient::MEDIA_API_BASE_URL

Constants inherited from Base::CustomClient

Base::CustomClient::MAX_RETRIES

Instance Attribute Summary

Attributes inherited from Atlassian::CustomClient

#access_token, #base_url, #basic_auth_token

Attributes inherited from Base::CustomClient

#base_url, #ensure_fresh_auth, #middleware

Instance Method Summary collapse

Methods inherited from ConnectorsSdk::Confluence::CustomClient

#content, #content_by_id, #content_search, #me, #search, #spaces

Methods inherited from Atlassian::CustomClient

#additional_middleware, #default_middleware, #download, #initialize, #update_auth_data!

Methods inherited from Base::CustomClient

#additional_middleware, #default_middleware, #http_client, #http_client!, #initialize, #middleware!, #retry_config

Constructor Details

This class inherits a constructor from ConnectorsSdk::Atlassian::CustomClient

Instance Method Details

#user(account_id, expand: []) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/connectors_sdk/confluence_cloud/custom_client.rb', line 35

def user(, expand: [])
  params = {
    :accountId => 
  }
  if expand.present?
    params[:expand] = case expand
                      when Array
                        expand.join(',')
                      when String
                        expand
                      else
                        expand.to_s
                      end
  end
  response = get('rest/api/user', params)
  Hashie::Mash.new(parse_and_raise_if_necessary!(response))
rescue ConnectorsSdk::Atlassian::CustomClient::ClientError => e
  if e.status_code == 404
    ConnectorsShared::Logger.warn("Could not find a user with account id #{}")
    nil
  else
    raise
  end
end

#user_groups(account_id, limit: 200, start: 0) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/connectors_sdk/confluence_cloud/custom_client.rb', line 14

def user_groups(, limit: 200, start: 0)
  size = Float::INFINITY

  groups = []

  while start + limit < size
    params = {
      :start => start,
      :limit => limit,
      :accountId => 
    }
    response = get('rest/api/user/memberof', params)
    result = Hashie::Mash.new(parse_and_raise_if_necessary!(response))
    size = result.size
    start += limit
    groups.concat(result.results)
  end

  groups
end