Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create getUserAccounts method in IbmCloudModule #406

Closed
sf2ne opened this issue Sep 16, 2020 · 3 comments
Closed

create getUserAccounts method in IbmCloudModule #406

sf2ne opened this issue Sep 16, 2020 · 3 comments
Assignees

Comments

@sf2ne
Copy link
Collaborator

sf2ne commented Sep 16, 2020

Here's the method I had written:

  def getUserAccounts(token: IamToken, userInfo: IamUserInfo) : Try[List[IamAccountInfo]] = {
    if (isIcp){
      /*
        curl -k -X GET \
        -H 'Accept: application/json' \
        -H "Authorization: Bearer $FIFTH_TOKEN" \
        -H 'Content-Type: application/json' \
        "https://$CLUSTER_ADDRESS/idmgmt/identity/api/v1/users/admin/accounts"
       */
      val accountsURL = getIcpMgmtIngressUrl + "/idmgmt/identity/api/v1/"+userInfo.user+"/admin/accounts"
      val response = Http(accountsURL).method("get").option(HttpOptions.sslSocketFactory(this.sslSocketFactory))
        .header("Content-Type", "application/json")
        .header("Accept", "application/json")
        .header("Authorization", "Bearer " + token.accessToken)
        .asString
      if (response.code == HttpCode.OK.intValue) {
        Success(parse(response.body).extract[List[IamAccountInfo]])
      } else Failure(new InvalidCredentialsException(ExchMsg.translate("invalid.iam.token")))
    } else Failure(new InvalidCredentialsException(ExchMsg.translate("api.access.denied")))
  }

I think token: IamToken, userInfo: IamUserInfo should be all the parameters you need, since this route just needs the OIDC access token and the user id.

Here's the common services docs for the API
https://www.ibm.com/support/knowledgecenter/en/SSHKN6/iam/3.4.0/apis/mt_apis.html#get8

@mikehyde
Copy link

mikehyde commented Jan 7, 2021

@sf2ne Please either close this issue (if completed or no longer relevant), or change the release to Winter or Future Release.

@mikehyde
Copy link

@sf2ne Please either close this issue (if completed or no longer relevant), or change the release to Winter or Future Release.

@bmpotter
Copy link
Member

This was verified by multi-tenancy QA testing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants