{"size": 1267, "ext": "js", "max_stars_repo_path": "backend/lib/services/members/index.js", "max_stars_repo_name": "g-pavlov/dashboard", "max_stars_repo_stars_event_min_datetime": "2021-01-04T09:43:06.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-04T09:43:06.000Z", "max_issues_repo_path": "backend/lib/services/members/index.js", "max_issues_repo_name": "minchaow/dashboard", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "backend/lib/services/members/index.js", "max_forks_repo_name": "minchaow/dashboard", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 31.675, "max_line_length": 92, "alphanum_fraction": 0.7458563536}
//
// SPDX-FileCopyrightText: 2020 SAP SE or an SAP affiliate company and Gardener contributors
//
// SPDX-License-Identifier: Apache-2.0
//

'use strict'

const MemberManager = require('./MemberManager')

exports.list = async function ({ user, namespace }) {
  const memberManager = await MemberManager.create(user, namespace)
  return memberManager.list()
}

exports.get = async function ({ user, namespace, name }) {
  const memberManager = await MemberManager.create(user, namespace)
  return memberManager.get(name)
}

exports.create = async function ({ user, namespace, body: { name, ...data } }) {
  const memberManager = await MemberManager.create(user, namespace)
  return memberManager.create(name, data)
}

exports.update = async function ({ user, namespace, name, body: data }) {
  const memberManager = await MemberManager.create(user, namespace)
  return memberManager.update(name, data)
}

exports.remove = async function ({ user, namespace, name }) {
  const memberManager = await MemberManager.create(user, namespace)
  return memberManager.delete(name)
}

exports.rotateSecret = async function ({ user, namespace, name }) {
  const memberManager = await MemberManager.create(user, namespace)
  await memberManager.rotateServiceAccountSecret(name)
}
