Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
045663d4
Commit
045663d4
authored
Jul 28, 2016
by
Angus Lees
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add gophercloud openstack/networking/v2/extensions
Aka github.com/rackspace/gophercloud/openstack/networking/v2/extensions
parent
313272a2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
257 additions
and
0 deletions
+257
-0
Godeps.json
Godeps/Godeps.json
+10
-0
LICENSES
Godeps/LICENSES
+0
-0
doc.go
.../rackspace/gophercloud/openstack/common/extensions/doc.go
+15
-0
errors.go
...ckspace/gophercloud/openstack/common/extensions/errors.go
+1
-0
fixtures.go
...space/gophercloud/openstack/common/extensions/fixtures.go
+91
-0
requests.go
...space/gophercloud/openstack/common/extensions/requests.go
+21
-0
results.go
...kspace/gophercloud/openstack/common/extensions/results.go
+65
-0
urls.go
...rackspace/gophercloud/openstack/common/extensions/urls.go
+13
-0
delegate.go
...ophercloud/openstack/networking/v2/extensions/delegate.go
+41
-0
No files found.
Godeps/Godeps.json
View file @
045663d4
...
...
@@ -1758,6 +1758,11 @@
"Rev"
:
"934dbf81977c67c521c75492dc1f55ca74dc5b04"
},
{
"ImportPath"
:
"github.com/rackspace/gophercloud/openstack/common/extensions"
,
"Comment"
:
"v1.0.0-920-g934dbf8"
,
"Rev"
:
"934dbf81977c67c521c75492dc1f55ca74dc5b04"
},
{
"ImportPath"
:
"github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume"
,
"Comment"
:
"v1.0.0-920-g934dbf8"
,
"Rev"
:
"934dbf81977c67c521c75492dc1f55ca74dc5b04"
...
...
@@ -1803,6 +1808,11 @@
"Rev"
:
"934dbf81977c67c521c75492dc1f55ca74dc5b04"
},
{
"ImportPath"
:
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions"
,
"Comment"
:
"v1.0.0-920-g934dbf8"
,
"Rev"
:
"934dbf81977c67c521c75492dc1f55ca74dc5b04"
},
{
"ImportPath"
:
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/layer3/floatingips"
,
"Comment"
:
"v1.0.0-920-g934dbf8"
,
"Rev"
:
"934dbf81977c67c521c75492dc1f55ca74dc5b04"
...
...
Godeps/LICENSES
View file @
045663d4
This diff is collapsed.
Click to expand it.
vendor/github.com/rackspace/gophercloud/openstack/common/extensions/doc.go
0 → 100644
View file @
045663d4
// Package extensions provides information and interaction with the different extensions available
// for an OpenStack service.
//
// The purpose of OpenStack API extensions is to:
//
// - Introduce new features in the API without requiring a version change.
// - Introduce vendor-specific niche functionality.
// - Act as a proving ground for experimental functionalities that might be included in a future
// version of the API.
//
// Extensions usually have tags that prevent conflicts with other extensions that define attributes
// or resources with the same names, and with core resources and attributes.
// Because an extension might not be supported by all plug-ins, its availability varies with deployments
// and the specific plug-in.
package
extensions
vendor/github.com/rackspace/gophercloud/openstack/common/extensions/errors.go
0 → 100755
View file @
045663d4
package
extensions
vendor/github.com/rackspace/gophercloud/openstack/common/extensions/fixtures.go
0 → 100644
View file @
045663d4
// +build fixtures
package
extensions
import
(
"fmt"
"net/http"
"testing"
th
"github.com/rackspace/gophercloud/testhelper"
"github.com/rackspace/gophercloud/testhelper/client"
)
// ListOutput provides a single page of Extension results.
const
ListOutput
=
`
{
"extensions": [
{
"updated": "2013-01-20T00:00:00-00:00",
"name": "Neutron Service Type Management",
"links": [],
"namespace": "http://docs.openstack.org/ext/neutron/service-type/api/v1.0",
"alias": "service-type",
"description": "API for retrieving service providers for Neutron advanced services"
}
]
}`
// GetOutput provides a single Extension result.
const
GetOutput
=
`
{
"extension": {
"updated": "2013-02-03T10:00:00-00:00",
"name": "agent",
"links": [],
"namespace": "http://docs.openstack.org/ext/agent/api/v2.0",
"alias": "agent",
"description": "The agent management extension."
}
}
`
// ListedExtension is the Extension that should be parsed from ListOutput.
var
ListedExtension
=
Extension
{
Updated
:
"2013-01-20T00:00:00-00:00"
,
Name
:
"Neutron Service Type Management"
,
Links
:
[]
interface
{}{},
Namespace
:
"http://docs.openstack.org/ext/neutron/service-type/api/v1.0"
,
Alias
:
"service-type"
,
Description
:
"API for retrieving service providers for Neutron advanced services"
,
}
// ExpectedExtensions is a slice containing the Extension that should be parsed from ListOutput.
var
ExpectedExtensions
=
[]
Extension
{
ListedExtension
}
// SingleExtension is the Extension that should be parsed from GetOutput.
var
SingleExtension
=
&
Extension
{
Updated
:
"2013-02-03T10:00:00-00:00"
,
Name
:
"agent"
,
Links
:
[]
interface
{}{},
Namespace
:
"http://docs.openstack.org/ext/agent/api/v2.0"
,
Alias
:
"agent"
,
Description
:
"The agent management extension."
,
}
// HandleListExtensionsSuccessfully creates an HTTP handler at `/extensions` on the test handler
// mux that response with a list containing a single tenant.
func
HandleListExtensionsSuccessfully
(
t
*
testing
.
T
)
{
th
.
Mux
.
HandleFunc
(
"/extensions"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
th
.
TestMethod
(
t
,
r
,
"GET"
)
th
.
TestHeader
(
t
,
r
,
"X-Auth-Token"
,
client
.
TokenID
)
w
.
Header
()
.
Add
(
"Content-Type"
,
"application/json"
)
fmt
.
Fprintf
(
w
,
ListOutput
)
})
}
// HandleGetExtensionSuccessfully creates an HTTP handler at `/extensions/agent` that responds with
// a JSON payload corresponding to SingleExtension.
func
HandleGetExtensionSuccessfully
(
t
*
testing
.
T
)
{
th
.
Mux
.
HandleFunc
(
"/extensions/agent"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
th
.
TestMethod
(
t
,
r
,
"GET"
)
th
.
TestHeader
(
t
,
r
,
"X-Auth-Token"
,
client
.
TokenID
)
w
.
Header
()
.
Add
(
"Content-Type"
,
"application/json"
)
w
.
WriteHeader
(
http
.
StatusOK
)
fmt
.
Fprintf
(
w
,
GetOutput
)
})
}
vendor/github.com/rackspace/gophercloud/openstack/common/extensions/requests.go
0 → 100755
View file @
045663d4
package
extensions
import
(
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
)
// Get retrieves information for a specific extension using its alias.
func
Get
(
c
*
gophercloud
.
ServiceClient
,
alias
string
)
GetResult
{
var
res
GetResult
_
,
res
.
Err
=
c
.
Get
(
ExtensionURL
(
c
,
alias
),
&
res
.
Body
,
nil
)
return
res
}
// List returns a Pager which allows you to iterate over the full collection of extensions.
// It does not accept query parameters.
func
List
(
c
*
gophercloud
.
ServiceClient
)
pagination
.
Pager
{
return
pagination
.
NewPager
(
c
,
ListExtensionURL
(
c
),
func
(
r
pagination
.
PageResult
)
pagination
.
Page
{
return
ExtensionPage
{
pagination
.
SinglePageBase
(
r
)}
})
}
vendor/github.com/rackspace/gophercloud/openstack/common/extensions/results.go
0 → 100755
View file @
045663d4
package
extensions
import
(
"github.com/mitchellh/mapstructure"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/pagination"
)
// GetResult temporarily stores the result of a Get call.
// Use its Extract() method to interpret it as an Extension.
type
GetResult
struct
{
gophercloud
.
Result
}
// Extract interprets a GetResult as an Extension.
func
(
r
GetResult
)
Extract
()
(
*
Extension
,
error
)
{
if
r
.
Err
!=
nil
{
return
nil
,
r
.
Err
}
var
res
struct
{
Extension
*
Extension
`json:"extension"`
}
err
:=
mapstructure
.
Decode
(
r
.
Body
,
&
res
)
return
res
.
Extension
,
err
}
// Extension is a struct that represents an OpenStack extension.
type
Extension
struct
{
Updated
string
`json:"updated" mapstructure:"updated"`
Name
string
`json:"name" mapstructure:"name"`
Links
[]
interface
{}
`json:"links" mapstructure:"links"`
Namespace
string
`json:"namespace" mapstructure:"namespace"`
Alias
string
`json:"alias" mapstructure:"alias"`
Description
string
`json:"description" mapstructure:"description"`
}
// ExtensionPage is the page returned by a pager when traversing over a collection of extensions.
type
ExtensionPage
struct
{
pagination
.
SinglePageBase
}
// IsEmpty checks whether an ExtensionPage struct is empty.
func
(
r
ExtensionPage
)
IsEmpty
()
(
bool
,
error
)
{
is
,
err
:=
ExtractExtensions
(
r
)
if
err
!=
nil
{
return
true
,
err
}
return
len
(
is
)
==
0
,
nil
}
// ExtractExtensions accepts a Page struct, specifically an ExtensionPage struct, and extracts the
// elements into a slice of Extension structs.
// In other words, a generic collection is mapped into a relevant slice.
func
ExtractExtensions
(
page
pagination
.
Page
)
([]
Extension
,
error
)
{
var
resp
struct
{
Extensions
[]
Extension
`mapstructure:"extensions"`
}
err
:=
mapstructure
.
Decode
(
page
.
(
ExtensionPage
)
.
Body
,
&
resp
)
return
resp
.
Extensions
,
err
}
vendor/github.com/rackspace/gophercloud/openstack/common/extensions/urls.go
0 → 100644
View file @
045663d4
package
extensions
import
"github.com/rackspace/gophercloud"
// ExtensionURL generates the URL for an extension resource by name.
func
ExtensionURL
(
c
*
gophercloud
.
ServiceClient
,
name
string
)
string
{
return
c
.
ServiceURL
(
"extensions"
,
name
)
}
// ListExtensionURL generates the URL for the extensions resource collection.
func
ListExtensionURL
(
c
*
gophercloud
.
ServiceClient
)
string
{
return
c
.
ServiceURL
(
"extensions"
)
}
vendor/github.com/rackspace/gophercloud/openstack/networking/v2/extensions/delegate.go
0 → 100644
View file @
045663d4
package
extensions
import
(
"github.com/rackspace/gophercloud"
common
"github.com/rackspace/gophercloud/openstack/common/extensions"
"github.com/rackspace/gophercloud/pagination"
)
// Extension is a single OpenStack extension.
type
Extension
struct
{
common
.
Extension
}
// GetResult wraps a GetResult from common.
type
GetResult
struct
{
common
.
GetResult
}
// ExtractExtensions interprets a Page as a slice of Extensions.
func
ExtractExtensions
(
page
pagination
.
Page
)
([]
Extension
,
error
)
{
inner
,
err
:=
common
.
ExtractExtensions
(
page
)
if
err
!=
nil
{
return
nil
,
err
}
outer
:=
make
([]
Extension
,
len
(
inner
))
for
index
,
ext
:=
range
inner
{
outer
[
index
]
=
Extension
{
ext
}
}
return
outer
,
nil
}
// Get retrieves information for a specific extension using its alias.
func
Get
(
c
*
gophercloud
.
ServiceClient
,
alias
string
)
GetResult
{
return
GetResult
{
common
.
Get
(
c
,
alias
)}
}
// List returns a Pager which allows you to iterate over the full collection of extensions.
// It does not accept query parameters.
func
List
(
c
*
gophercloud
.
ServiceClient
)
pagination
.
Pager
{
return
common
.
List
(
c
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment