LCOV - code coverage report
Current view: top level - server/restapi/account - AccountRestApiModule.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 65 65 100.0 %
Date: 2022-11-19 15:00:39 Functions: 4 4 100.0 %

          Line data    Source code
       1             : // Copyright (C) 2012 The Android Open Source Project
       2             : //
       3             : // Licensed under the Apache License, Version 2.0 (the "License");
       4             : // you may not use this file except in compliance with the License.
       5             : // You may obtain a copy of the License at
       6             : //
       7             : // http://www.apache.org/licenses/LICENSE-2.0
       8             : //
       9             : // Unless required by applicable law or agreed to in writing, software
      10             : // distributed under the License is distributed on an "AS IS" BASIS,
      11             : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12             : // See the License for the specific language governing permissions and
      13             : // limitations under the License.
      14             : 
      15             : package com.google.gerrit.server.restapi.account;
      16             : 
      17             : import static com.google.gerrit.server.account.AccountResource.ACCOUNT_KIND;
      18             : import static com.google.gerrit.server.account.AccountResource.CAPABILITY_KIND;
      19             : import static com.google.gerrit.server.account.AccountResource.EMAIL_KIND;
      20             : import static com.google.gerrit.server.account.AccountResource.SSH_KEY_KIND;
      21             : import static com.google.gerrit.server.account.AccountResource.STARRED_CHANGE_KIND;
      22             : import static com.google.gerrit.server.account.AccountResource.Star.STAR_KIND;
      23             : 
      24             : import com.google.gerrit.extensions.registration.DynamicMap;
      25             : import com.google.gerrit.extensions.restapi.RestApiModule;
      26             : import com.google.gerrit.server.IdentifiedUser;
      27             : import com.google.gerrit.server.ServerInitiated;
      28             : import com.google.gerrit.server.UserInitiated;
      29             : import com.google.gerrit.server.account.AccountsUpdate;
      30             : import com.google.gerrit.server.account.externalids.ExternalIdNotes;
      31             : import com.google.inject.Provides;
      32             : 
      33         152 : public class AccountRestApiModule extends RestApiModule {
      34             :   @Override
      35             :   protected void configure() {
      36         152 :     bind(AccountsCollection.class);
      37         152 :     bind(Capabilities.class);
      38             : 
      39         152 :     DynamicMap.mapOf(binder(), ACCOUNT_KIND);
      40         152 :     DynamicMap.mapOf(binder(), CAPABILITY_KIND);
      41         152 :     DynamicMap.mapOf(binder(), EMAIL_KIND);
      42         152 :     DynamicMap.mapOf(binder(), SSH_KEY_KIND);
      43         152 :     DynamicMap.mapOf(binder(), STARRED_CHANGE_KIND);
      44         152 :     DynamicMap.mapOf(binder(), STAR_KIND);
      45             : 
      46         152 :     create(ACCOUNT_KIND).to(CreateAccount.class);
      47         152 :     put(ACCOUNT_KIND).to(PutAccount.class);
      48         152 :     get(ACCOUNT_KIND).to(GetAccount.class);
      49         152 :     get(ACCOUNT_KIND, "detail").to(GetDetail.class);
      50         152 :     post(ACCOUNT_KIND, "index").to(Index.class);
      51         152 :     get(ACCOUNT_KIND, "name").to(GetName.class);
      52         152 :     put(ACCOUNT_KIND, "name").to(PutName.class);
      53         152 :     delete(ACCOUNT_KIND, "name").to(PutName.class);
      54         152 :     get(ACCOUNT_KIND, "status").to(GetStatus.class);
      55         152 :     put(ACCOUNT_KIND, "status").to(PutStatus.class);
      56         152 :     put(ACCOUNT_KIND, "displayname").to(PutDisplayName.class);
      57         152 :     get(ACCOUNT_KIND, "username").to(GetUsername.class);
      58         152 :     put(ACCOUNT_KIND, "username").to(PutUsername.class);
      59         152 :     get(ACCOUNT_KIND, "active").to(GetActive.class);
      60         152 :     put(ACCOUNT_KIND, "active").to(PutActive.class);
      61         152 :     delete(ACCOUNT_KIND, "active").to(DeleteActive.class);
      62         152 :     child(ACCOUNT_KIND, "emails").to(EmailsCollection.class);
      63         152 :     create(EMAIL_KIND).to(CreateEmail.class);
      64         152 :     get(EMAIL_KIND).to(GetEmail.class);
      65         152 :     put(EMAIL_KIND).to(PutEmail.class);
      66         152 :     delete(EMAIL_KIND).to(DeleteEmail.class);
      67         152 :     put(EMAIL_KIND, "preferred").to(PutPreferred.class);
      68         152 :     put(ACCOUNT_KIND, "password.http").to(PutHttpPassword.class);
      69         152 :     delete(ACCOUNT_KIND, "password.http").to(PutHttpPassword.class);
      70         152 :     get(ACCOUNT_KIND, "watched.projects").to(GetWatchedProjects.class);
      71         152 :     post(ACCOUNT_KIND, "watched.projects").to(PostWatchedProjects.class);
      72         152 :     post(ACCOUNT_KIND, "watched.projects:delete").to(DeleteWatchedProjects.class);
      73             : 
      74         152 :     child(ACCOUNT_KIND, "sshkeys").to(SshKeys.class);
      75         152 :     postOnCollection(SSH_KEY_KIND).to(AddSshKey.class);
      76         152 :     get(SSH_KEY_KIND).to(GetSshKey.class);
      77         152 :     delete(SSH_KEY_KIND).to(DeleteSshKey.class);
      78             : 
      79         152 :     get(ACCOUNT_KIND, "avatar").to(GetAvatar.class);
      80         152 :     get(ACCOUNT_KIND, "avatar.change.url").to(GetAvatarChangeUrl.class);
      81             : 
      82         152 :     child(ACCOUNT_KIND, "capabilities").to(Capabilities.class);
      83             : 
      84         152 :     get(ACCOUNT_KIND, "groups").to(GetGroups.class);
      85         152 :     get(ACCOUNT_KIND, "preferences").to(GetPreferences.class);
      86         152 :     put(ACCOUNT_KIND, "preferences").to(SetPreferences.class);
      87         152 :     get(ACCOUNT_KIND, "preferences.diff").to(GetDiffPreferences.class);
      88         152 :     put(ACCOUNT_KIND, "preferences.diff").to(SetDiffPreferences.class);
      89         152 :     get(ACCOUNT_KIND, "preferences.edit").to(GetEditPreferences.class);
      90         152 :     put(ACCOUNT_KIND, "preferences.edit").to(SetEditPreferences.class);
      91         152 :     get(CAPABILITY_KIND).to(GetCapabilities.CheckOne.class);
      92             : 
      93         152 :     get(ACCOUNT_KIND, "agreements").to(GetAgreements.class);
      94         152 :     put(ACCOUNT_KIND, "agreements").to(PutAgreement.class);
      95             : 
      96         152 :     child(ACCOUNT_KIND, "starred.changes").to(StarredChanges.class);
      97         152 :     create(STARRED_CHANGE_KIND).to(StarredChanges.Create.class);
      98         152 :     put(STARRED_CHANGE_KIND).to(StarredChanges.Put.class);
      99         152 :     delete(STARRED_CHANGE_KIND).to(StarredChanges.Delete.class);
     100         152 :     bind(StarredChanges.Create.class);
     101             : 
     102         152 :     get(ACCOUNT_KIND, "external.ids").to(GetExternalIds.class);
     103         152 :     post(ACCOUNT_KIND, "external.ids:delete").to(DeleteExternalIds.class);
     104             : 
     105         152 :     post(ACCOUNT_KIND, "drafts:delete").to(DeleteDraftComments.class);
     106             : 
     107             :     // The gpgkeys REST endpoints are bound via GpgApiModule.
     108             : 
     109         152 :     factory(AccountsUpdate.Factory.class);
     110         152 :   }
     111             : 
     112             :   @Provides
     113             :   @ServerInitiated
     114             :   AccountsUpdate provideServerInitiatedAccountsUpdate(
     115             :       AccountsUpdate.Factory accountsUpdateFactory, ExternalIdNotes.Factory extIdNotesFactory) {
     116         151 :     return accountsUpdateFactory.createWithServerIdent(extIdNotesFactory);
     117             :   }
     118             : 
     119             :   @Provides
     120             :   @UserInitiated
     121             :   AccountsUpdate provideUserInitiatedAccountsUpdate(
     122             :       AccountsUpdate.Factory accountsUpdateFactory,
     123             :       IdentifiedUser currentUser,
     124             :       ExternalIdNotes.Factory extIdNotesFactory) {
     125          23 :     return accountsUpdateFactory.create(currentUser, extIdNotesFactory);
     126             :   }
     127             : }

Generated by: LCOV version 1.16+git.20220603.dfeb750