github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/api/client/credentialmanager/client.go (about)

     1  // Copyright 2018 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package credentialmanager
     5  
     6  import (
     7  	"github.com/juju/errors"
     8  
     9  	"github.com/juju/juju/api/base"
    10  	"github.com/juju/juju/rpc/params"
    11  )
    12  
    13  // Client allows access to the credential management API end point.
    14  type Client struct {
    15  	base.ClientFacade
    16  	facade base.FacadeCaller
    17  }
    18  
    19  // NewClient creates a new client for accessing the credential manager API.
    20  func NewClient(st base.APICallCloser) *Client {
    21  	frontend, backend := base.NewClientFacade(st, "CredentialManager")
    22  	return &Client{ClientFacade: frontend, facade: backend}
    23  }
    24  
    25  // InvalidateModelCredential invalidates cloud credential for the model that made a connection.
    26  func (c *Client) InvalidateModelCredential(reason string) error {
    27  	in := params.InvalidateCredentialArg{reason}
    28  	var result params.ErrorResult
    29  	err := c.facade.FacadeCall("InvalidateModelCredential", in, &result)
    30  	if err != nil {
    31  		return errors.Trace(err)
    32  	}
    33  	if result.Error != nil {
    34  		return errors.Trace(result.Error)
    35  	}
    36  	return nil
    37  }