github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/provider/oracle/common/interfaces.go (about)

     1  // Copyright 2017 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package common
     5  
     6  import (
     7  	"github.com/juju/go-oracle-cloud/api"
     8  	"github.com/juju/go-oracle-cloud/common"
     9  	"github.com/juju/go-oracle-cloud/response"
    10  
    11  	"github.com/juju/juju/core/instance"
    12  	"github.com/juju/juju/environs"
    13  )
    14  
    15  type OracleInstancer interface {
    16  	environs.Environ
    17  
    18  	Details(id instance.Id) (response.Instance, error)
    19  }
    20  
    21  // Instancer used to retrieve details from a given instance
    22  // in the oracle cloud infrastructure
    23  type Instancer interface {
    24  	// InstanceDetails retrieves information from the provider
    25  	// about one instance
    26  	InstanceDetails(string) (response.Instance, error)
    27  }
    28  
    29  // Composer has the simple task of composing an oracle compatible
    30  // resource name
    31  type Composer interface {
    32  	// ComposeName composes the name for a provider resource. The name
    33  	// for an oracle API resource typically has the following form:
    34  	//
    35  	// /Compute-<Identity Domain>/<username>/<resource name>
    36  	//
    37  	// The Identity Domain in this case equates to what some other providers
    38  	// like OpenStack refer to as tenants or projects.
    39  	// This information is supplied by the user in the cloud configuration
    40  	// information.
    41  	// This function is generally needed
    42  	ComposeName(string) string
    43  }
    44  
    45  // InstanceAPI uses to retrieve all instances, delete and create
    46  // in the oracle cloud infrastructure
    47  type InstanceAPI interface {
    48  	CreateInstance(api.InstanceParams) (response.LaunchPlan, error)
    49  	AllInstances([]api.Filter) (response.AllInstances, error)
    50  	DeleteInstance(string) error
    51  }
    52  
    53  // Authenticater authenticates the oracle client in the
    54  // oracle IAAS api
    55  type Authenticater interface {
    56  	Authenticate() error
    57  }
    58  
    59  // Shaper used to retrieve all shapes from the oracle cloud
    60  // environ
    61  type Shaper interface {
    62  	AllShapes([]api.Filter) (response.AllShapes, error)
    63  }
    64  
    65  // Imager used to retrieve all images iso meta data format from the
    66  // oracle cloud environment
    67  type Imager interface {
    68  	AllImageLists([]api.Filter) (response.AllImageLists, error)
    69  	CreateImageList(def int, description string, name string) (resp response.ImageList, err error)
    70  	CreateImageListEntry(name string, attributes map[string]interface{}, version int, machineImages []string) (resp response.ImageListEntryAdd, err error)
    71  	DeleteImageList(name string) (err error)
    72  }
    73  
    74  // IpReservationAPI provider methods for retrieving, updating, creating
    75  // and deleting ip reservations inside the oracle cloud infrastructure
    76  type IpReservationAPI interface {
    77  	AllIpReservations([]api.Filter) (response.AllIpReservations, error)
    78  	UpdateIpReservation(string, string,
    79  		common.IPPool, bool, []string) (response.IpReservation, error)
    80  	CreateIpReservation(string, common.IPPool,
    81  		bool, []string) (response.IpReservation, error)
    82  	DeleteIpReservation(string) error
    83  }
    84  
    85  // IpAssociationAPI provides methods for creating deleting and listing all
    86  // ip associations inside the oracle cloud environment
    87  type IpAssociationAPI interface {
    88  	CreateIpAssociation(common.IPPool, common.VcableID) (response.IpAssociation, error)
    89  	DeleteIpAssociation(string) error
    90  	AllIpAssociations([]api.Filter) (response.AllIpAssociations, error)
    91  }
    92  
    93  // IpNetworkExchanger provides a simple interface for retrieving all
    94  // ip network exchanges inside the oracle cloud environment
    95  type IpNetworkExchanger interface {
    96  	AllIpNetworkExchanges([]api.Filter) (response.AllIpNetworkExchanges, error)
    97  }
    98  
    99  // IpNetowrker provides a simple interface for retrieving all
   100  // ip networks inside the oracle cloud environment
   101  type IpNetworker interface {
   102  	AllIpNetworks([]api.Filter) (response.AllIpNetworks, error)
   103  }
   104  
   105  // VnicSetAPI provides methods for deleting, retrieving details and creating
   106  // virtual nics for providing access for instances to different subnets inside
   107  // the oracle cloud environment
   108  type VnicSetAPI interface {
   109  	DeleteVnicSet(string) error
   110  	VnicSetDetails(string) (response.VnicSet, error)
   111  	CreateVnicSet(api.VnicSetParams) (response.VnicSet, error)
   112  }
   113  
   114  // RulesAPI defines methods for retrieving, creating and deleting
   115  // Sec rules under the oracle cloud endpoint
   116  // For more information on sec rules, please see:
   117  // https://docs.oracle.com/cloud/latest/stcomputecs/STCSA/api-SecRules.html
   118  type RulesAPI interface {
   119  	// AllSecRules returns all sec rules matching a filter. A nil valued
   120  	// filter will return all entries in the API.
   121  	AllSecRules([]api.Filter) (response.AllSecRules, error)
   122  	// DeleteSecRule deletes the security rule with the given name
   123  	DeleteSecRule(string) error
   124  	// CreateSecRule creates the security rule inside oracle cloud
   125  	// given the sec rule parameters
   126  	CreateSecRule(api.SecRuleParams) (response.SecRule, error)
   127  }
   128  
   129  // AclAPI defines methods for retrieving, creating and deleting
   130  // access control lists under the oracle cloud endpoint
   131  type AclAPI interface {
   132  	// AclDetails retrieves the access control list details for one list
   133  	AclDetails(string) (response.Acl, error)
   134  	// CreateAcl creates the access control list
   135  	CreateAcl(string, string, bool, []string) (response.Acl, error)
   136  	// DeleteAcl deletes one access control list
   137  	DeleteAcl(string) error
   138  	// AllAcls fetches a list of all ACLs matching the given filter.
   139  	AllAcls([]api.Filter) (response.AllAcls, error)
   140  }
   141  
   142  // SecIpAPI defines methods for retrieving creating sec IP lists
   143  // in the oracle cloud
   144  // For more information about sec ip lists, please see:
   145  // https://docs.oracle.com/cloud/latest/stcomputecs/STCSA/api-SecIPLists.html
   146  type SecIpAPI interface {
   147  	// AllSecIpLists returns all sec IP lists that match a filter. A nil valued
   148  	// filter will return all entries in the API.
   149  	AllSecIpLists([]api.Filter) (response.AllSecIpLists, error)
   150  	// CreateSecIpList creates the sec IP list under the oracle cloud endpoint
   151  	CreateSecIpList(string, string, []string) (response.SecIpList, error)
   152  	// AllDefaultSecIpLists retrieves all default sec IP lists from the
   153  	// oracle cloud account. Default lists are defined by the cloud and cannot
   154  	// be changed in any way.
   155  	AllDefaultSecIpLists([]api.Filter) (response.AllSecIpLists, error)
   156  }
   157  
   158  // IpAddressPrefixSetAPI defines methods for creating and listing
   159  // IP address prefix sets under the oracle cloud endpoint
   160  // For information about IP address prefix sets, please see:
   161  // https://docs.oracle.com/cloud/latest/stcomputecs/STCSA/api-IPAddressPrefixSets.html
   162  type IpAddressPrefixSetAPI interface {
   163  	// CreateIpAddressPrefixSet creates a new IP address prefix set inside the oracle
   164  	// cloud, for the current user
   165  	CreateIpAddressPrefixSet(
   166  		api.IpAddressPrefixSetParams) (response.IpAddressPrefixSet, error)
   167  
   168  	// AllIpAddressPrefixSets returns all IP address prefix sets that match the given filter.
   169  	// A nil valued filter will return all entries in the API.
   170  	AllIpAddressPrefixSets([]api.Filter) (response.AllIpAddressPrefixSets, error)
   171  }
   172  
   173  // SecListAPI defines methods for retrieving, creating and deleting
   174  // sec lists under the oracle cloud endpoint
   175  // For more information about sec lists, please see:
   176  // https://docs.oracle.com/cloud/latest/stcomputecs/STCSA/api-SecLists.html
   177  type SecListAPI interface {
   178  	// SecListDetails retrieves sec list details for the given list
   179  	SecListDetails(string) (response.SecList, error)
   180  	// DeleteSecList deletes one sec list
   181  	DeleteSecList(string) error
   182  	// CreateSecList creates a sec list
   183  	CreateSecList(string, string,
   184  		common.SecRuleAction, common.SecRuleAction) (response.SecList, error)
   185  }
   186  
   187  // SecRulesAPI defines methods for retrieving, deleting and creating
   188  // security rules under the oracle cloud endpoint
   189  // For more details on sec rules, please see:
   190  // https://docs.oracle.com/cloud/latest/stcomputecs/STCSA/api-SecRules.html
   191  type SecRulesAPI interface {
   192  	// AllSecurityRules returns all security rules matching a filter. A nil valued
   193  	// filter will return all entries in the API.
   194  	AllSecurityRules([]api.Filter) (response.AllSecurityRules, error)
   195  	// DeleteSecurityRule deletes the security rule with the given name
   196  	DeleteSecurityRule(string) error
   197  	// CreateSecurityRule creates a security rule based on the security rule
   198  	// parameters under the oracle cloud endpoint
   199  	CreateSecurityRule(api.SecurityRuleParams) (response.SecurityRule, error)
   200  }
   201  
   202  // ApplicationsAPI also named protocols in the oracle cloud defines methods
   203  // for retriving and creating applications rules/protocol rules
   204  // under the oracle cloud endpoint
   205  // For more information about sec applications, please see:
   206  // https://docs.oracle.com/cloud/latest/stcomputecs/STCSA/api-SecApplications.html
   207  type ApplicationsAPI interface {
   208  	// AllSecApplications returns all sec applications matching a filter. A nil valued
   209  	// filter will return all entries in the API.
   210  	AllSecApplications([]api.Filter) (response.AllSecApplications, error)
   211  	// DefaultSecApplications returns all default security applications matching a filter.
   212  	// A nil valued filter will return all entries in the API.
   213  	DefaultSecApplications([]api.Filter) (response.AllSecApplications, error)
   214  	// CreateSecApplications creates a security applications
   215  	CreateSecApplication(api.SecApplicationParams) (response.SecApplication, error)
   216  }
   217  
   218  // AssociationAPI defines a rule for listing, retrieving all security
   219  // associations under the oracle cloud API
   220  // For more details about sec associations, please see:
   221  // https://docs.oracle.com/cloud/latest/stcomputecs/STCSA/api-SecAssociations.html
   222  type AssociationAPI interface {
   223  	// AllSecAssociations returns all security associations matching a filter. A nil valued
   224  	// filter will return all entries in the API.
   225  	AllSecAssociations([]api.Filter) (response.AllSecAssociations, error)
   226  }
   227  
   228  // StorageVolumeAPI defines methods for retrieving, creating, deleting and
   229  // updating storage volumes under the oracle cloud endpoint
   230  // For more details about storage volumes, please see:
   231  // https://docs.oracle.com/cloud/latest/stcomputecs/STCSA/api-StorageVolumes.html
   232  type StorageVolumeAPI interface {
   233  	// CreateStorageVolume creates a storage volume
   234  	CreateStorageVolume(p api.StorageVolumeParams) (resp response.StorageVolume, err error)
   235  	// DeleteStorageVolume deletes the storage volume
   236  	DeleteStorageVolume(name string) (err error)
   237  	// StorageVolumeDetails retrieves storage volume details
   238  	StorageVolumeDetails(name string) (resp response.StorageVolume, err error)
   239  	// AllStoragevolumes retrieves all storage volumes matching a filter. A nil valued
   240  	// filter will return all entries in the API.
   241  	AllStorageVolumes(filter []api.Filter) (resp response.AllStorageVolumes, err error)
   242  	// UpdateStorageVolume updates the state of the storage volume
   243  	UpdateStorageVolume(p api.StorageVolumeParams, currentName string) (resp response.StorageVolume, err error)
   244  }
   245  
   246  // StorageAttachmentAPI defines methods for attaching, detaching storages to
   247  // instances under the oracle cloud endpoint
   248  // For more information on storage attachments, please see:
   249  // https://docs.oracle.com/cloud/latest/stcomputecs/STCSA/api-StorageAttachments.html
   250  type StorageAttachmentAPI interface {
   251  	// CreateStorageAttachment creates a storage attachment
   252  	CreateStorageAttachment(p api.StorageAttachmentParams) (response.StorageAttachment, error)
   253  	// DeleteStorageAttachment deletes the storage attachment
   254  	DeleteStorageAttachment(name string) error
   255  	// StorageAttachmentDetails retrieves details of the storage attachment
   256  	StorageAttachmentDetails(name string) (response.StorageAttachment, error)
   257  	// AllStorageAttachments retrieves all storage attachments matching a filter. A nil valued
   258  	// filter will return all entries in the API.
   259  	AllStorageAttachments(filter []api.Filter) (response.AllStorageAttachments, error)
   260  }