github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/cf/api/securitygroups/defaults/running/running.go (about)

     1  package running
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/cf/configuration/coreconfig"
     5  	"code.cloudfoundry.org/cli/cf/models"
     6  	"code.cloudfoundry.org/cli/cf/net"
     7  
     8  	. "code.cloudfoundry.org/cli/cf/api/securitygroups/defaults"
     9  )
    10  
    11  const urlPath = "/v2/config/running_security_groups"
    12  
    13  //go:generate counterfeiter . SecurityGroupsRepo
    14  
    15  type SecurityGroupsRepo interface {
    16  	BindToRunningSet(string) error
    17  	List() ([]models.SecurityGroupFields, error)
    18  	UnbindFromRunningSet(string) error
    19  }
    20  
    21  type cloudControllerRunningSecurityGroupRepo struct {
    22  	repoBase DefaultSecurityGroupsRepoBase
    23  }
    24  
    25  func NewSecurityGroupsRepo(configRepo coreconfig.Reader, gateway net.Gateway) SecurityGroupsRepo {
    26  	return &cloudControllerRunningSecurityGroupRepo{
    27  		repoBase: DefaultSecurityGroupsRepoBase{
    28  			ConfigRepo: configRepo,
    29  			Gateway:    gateway,
    30  		},
    31  	}
    32  }
    33  
    34  func (repo *cloudControllerRunningSecurityGroupRepo) BindToRunningSet(groupGUID string) error {
    35  	return repo.repoBase.Bind(groupGUID, urlPath)
    36  }
    37  
    38  func (repo *cloudControllerRunningSecurityGroupRepo) List() ([]models.SecurityGroupFields, error) {
    39  	return repo.repoBase.List(urlPath)
    40  }
    41  
    42  func (repo *cloudControllerRunningSecurityGroupRepo) UnbindFromRunningSet(groupGUID string) error {
    43  	return repo.repoBase.Delete(groupGUID, urlPath)
    44  }