_handleCreateServiceUser()

in gr-serviceuser/gr-serviceuser-create.js [138:168]


  _handleCreateServiceUser() {
    this._isAdding = true;
    this._computeButtonEnabled();
    const body = {
      ssh_key: this._newKey.trim(),
      email: this._newEmail ? this._newEmail.trim() : null,
    };
    return this.plugin.restApi('/a/config/server/serviceuser~serviceusers/')
        .post(this._newUsername, body)
        .then(response => {
          this._accountId = response._account_id;
          if (this._successMessage) {
            this.$.successDialogOverlay.open();
          } else {
            this._forwardToDetails();
          }
        }).catch(response => {
          this.dispatchEvent(
              new CustomEvent(
                  'show-error',
                  {
                    detail: {message: response},
                    bubbles: true,
                    composed: true,
                  }
              )
          );
          this._isAdding = false;
          this._computeButtonEnabled();
        });
  }