-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from karimra/api-os
add os RPCs api
- Loading branch information
Showing
6 changed files
with
454 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package api | ||
|
||
import "errors" | ||
|
||
// ErrInvalidMsgType is returned by an Option in case the Option is supplied | ||
// an unexpected proto.Message | ||
var ErrInvalidMsgType = errors.New("invalid message type") | ||
|
||
// ErrInvalidValue is returned by a Option in case the Option is supplied | ||
// an unexpected value. | ||
var ErrInvalidValue = errors.New("invalid value") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package os | ||
|
||
import gnoios "github.com/openconfig/gnoi/os" | ||
|
||
func NewActivateRequest(opts ...OsOption) (*gnoios.ActivateRequest, error) { | ||
m := new(gnoios.ActivateRequest) | ||
err := apply(m, opts...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return m, nil | ||
} | ||
|
||
func NewActivateOKResponse() *gnoios.ActivateResponse { | ||
return &gnoios.ActivateResponse{ | ||
Response: &gnoios.ActivateResponse_ActivateOk{ | ||
ActivateOk: &gnoios.ActivateOK{}, | ||
}, | ||
} | ||
} | ||
|
||
func NewActivateErrorResponse(opts ...OsOption) (*gnoios.ActivateResponse, error) { | ||
m := new(gnoios.ActivateError) | ||
err := apply(m, opts...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &gnoios.ActivateResponse{ | ||
Response: &gnoios.ActivateResponse_ActivateError{ | ||
ActivateError: m, | ||
}, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
package os | ||
|
||
import ( | ||
gnoios "github.com/openconfig/gnoi/os" | ||
) | ||
|
||
func NewOSInstallTransferRequest(opts ...OsOption) (*gnoios.InstallRequest, error) { | ||
m, err := NewOSTransferRequest(opts...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &gnoios.InstallRequest{ | ||
Request: &gnoios.InstallRequest_TransferRequest{ | ||
TransferRequest: m, | ||
}, | ||
}, nil | ||
|
||
} | ||
|
||
func NewOSInstallTransferContent(opts ...OsOption) (*gnoios.InstallRequest, error) { | ||
m := new(gnoios.InstallRequest) | ||
err := apply(m, opts...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return m, nil | ||
} | ||
|
||
func NewOSInstallTransferEnd() *gnoios.InstallRequest { | ||
return &gnoios.InstallRequest{ | ||
Request: &gnoios.InstallRequest_TransferEnd{ | ||
TransferEnd: &gnoios.TransferEnd{}, | ||
}, | ||
} | ||
} | ||
|
||
func NewOSInstallTransferReadyResponse() *gnoios.InstallResponse { | ||
return &gnoios.InstallResponse{ | ||
Response: &gnoios.InstallResponse_TransferReady{ | ||
TransferReady: &gnoios.TransferReady{}, | ||
}, | ||
} | ||
} | ||
|
||
func NewOSInstallTransferProgressResponse(opts ...OsOption) (*gnoios.InstallResponse, error) { | ||
m, err := NewOSTransferProgress(opts...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &gnoios.InstallResponse{ | ||
Response: &gnoios.InstallResponse_TransferProgress{ | ||
TransferProgress: m, | ||
}, | ||
}, nil | ||
} | ||
|
||
func NewOSInstallSyncProgressResponse(opts ...OsOption) (*gnoios.InstallResponse, error) { | ||
m, err := NewOSSyncProgress(opts...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &gnoios.InstallResponse{ | ||
Response: &gnoios.InstallResponse_SyncProgress{ | ||
SyncProgress: m, | ||
}, | ||
}, nil | ||
} | ||
|
||
func NewOSInstallValidatedResponse(opts ...OsOption) (*gnoios.InstallResponse, error) { | ||
m, err := NewOSValidated(opts...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &gnoios.InstallResponse{ | ||
Response: &gnoios.InstallResponse_Validated{ | ||
Validated: m, | ||
}, | ||
}, nil | ||
} | ||
|
||
func NewOSInstallInstallErrorResponse(opts ...OsOption) (*gnoios.InstallResponse, error) { | ||
m, err := NewOSInstallError(opts...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &gnoios.InstallResponse{ | ||
Response: &gnoios.InstallResponse_InstallError{ | ||
InstallError: m, | ||
}, | ||
}, nil | ||
} | ||
|
||
func NewOSTransferRequest(opts ...OsOption) (*gnoios.TransferRequest, error) { | ||
m := new(gnoios.TransferRequest) | ||
err := apply(m, opts...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return m, nil | ||
} | ||
|
||
func NewOSTransferProgress(opts ...OsOption) (*gnoios.TransferProgress, error) { | ||
m := new(gnoios.TransferProgress) | ||
err := apply(m, opts...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return m, nil | ||
} | ||
|
||
func NewOSSyncProgress(opts ...OsOption) (*gnoios.SyncProgress, error) { | ||
m := new(gnoios.SyncProgress) | ||
err := apply(m, opts...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return m, nil | ||
} | ||
|
||
func NewOSValidated(opts ...OsOption) (*gnoios.Validated, error) { | ||
m := new(gnoios.Validated) | ||
err := apply(m, opts...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return m, nil | ||
} | ||
|
||
func NewOSInstallError(opts ...OsOption) (*gnoios.InstallError, error) { | ||
m := new(gnoios.InstallError) | ||
err := apply(m, opts...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return m, nil | ||
} |
Oops, something went wrong.