Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
dont export types
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Aug 7, 2019
1 parent d3725df commit da1870a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
34 changes: 17 additions & 17 deletions cmd/apps/impapps/impapps.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@ import (
types "github.com/srinandan/apigeecli/cmd/types"
)

type App struct {
type application struct {
Name string `json:"name,omitempty"`
Status string `json:"status,omitempty"`
Credentials *[]Credential `json:"credentials,omitempty"`
Credentials *[]credential `json:"credentials,omitempty"`
DeveloperID *string `json:"developerId,omitempty"`
DisplayName string `json:"displayName,omitempty"`
Attributes []types.Attribute `json:"attributes,omitempty"`
CallbackURL string `json:"callbackUrl,omitempty"`
Scopes []string `json:"scopes,omitempty"`
}

type Credential struct {
APIProducts []APIProduct `json:"apiProducts,omitempty"`
type credential struct {
APIProducts []apiProduct `json:"apiProducts,omitempty"`
ConsumerKey string `json:"consumerKey,omitempty"`
ConsumerSecret string `json:"consumerSecret,omitempty"`
ExpiresAt int `json:"expiresAt,omitempty"`
Status string `json:"status,omitempty"`
Scopes []string `json:"scopes,omitempty"`
}

type APIProduct struct {
type apiProduct struct {
Name string `json:"apiproduct,omitempty"`
}

type ImportCredential struct {
type importCredential struct {
APIProducts []string `json:"apiProducts,omitempty"`
ConsumerKey string `json:"consumerKey,omitempty"`
ConsumerSecret string `json:"consumerSecret,omitempty"`
Expand Down Expand Up @@ -66,7 +66,7 @@ func init() {
_ = Cmd.MarkFlagRequired("file")
}

func createAsyncApp(app App, wg *sync.WaitGroup) {
func createAsyncApp(app application, wg *sync.WaitGroup) {
defer wg.Done()

//importing an app will be a two step process.
Expand Down Expand Up @@ -102,18 +102,18 @@ func createAsyncApp(app App, wg *sync.WaitGroup) {
products = append(products, apiProduct.Name)
}
//create a new credential
importCredential := ImportCredential{}
importCredential.APIProducts = products
importCredential.ConsumerKey = credential.ConsumerKey
importCredential.ConsumerSecret = credential.ConsumerSecret
importCredential.Scopes = credential.Scopes
importCred := importCredential{}
importCred.APIProducts = products
importCred.ConsumerKey = credential.ConsumerKey
importCred.ConsumerSecret = credential.ConsumerSecret
importCred.Scopes = credential.Scopes

impCred, err := json.Marshal(importCredential)
impCredJSON, err := json.Marshal(importCred)
if err != nil {
shared.Error.Fatalln(err)
return
}
_, err = shared.HttpClient(true, u.String(), string(impCred))
_, err = shared.HttpClient(true, u.String(), string(impCredJSON))
if err != nil {
shared.Error.Fatalln(err)
return
Expand All @@ -124,7 +124,7 @@ func createAsyncApp(app App, wg *sync.WaitGroup) {
}

//batch creates a batch of apps to create
func batch(entities []App, pwg *sync.WaitGroup) {
func batch(entities []application, pwg *sync.WaitGroup) {

defer pwg.Done()
//batch workgroup
Expand Down Expand Up @@ -180,9 +180,9 @@ func createApps() error {
return nil
}

func readAppsFile() ([]App, error) {
func readAppsFile() ([]application, error) {

apps := []App{}
apps := []application{}

jsonFile, err := os.Open(file)

Expand Down
24 changes: 12 additions & 12 deletions cmd/developers/impdev/impdev.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
types "github.com/srinandan/apigeecli/cmd/types"
)

type Developer struct {
type developer struct {
EMail string `json:"email,omitempty"`
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
Expand Down Expand Up @@ -45,9 +45,9 @@ func init() {
_ = Cmd.MarkFlagRequired("file")
}

func createAsyncDeveloper(url string, developer Developer, wg *sync.WaitGroup) {
func createAsyncDeveloper(url string, dev developer, wg *sync.WaitGroup) {
defer wg.Done()
out, err := json.Marshal(developer)
out, err := json.Marshal(dev)
if err != nil {
shared.Error.Fatalln(err)
return
Expand All @@ -58,11 +58,11 @@ func createAsyncDeveloper(url string, developer Developer, wg *sync.WaitGroup) {
return
}

shared.Info.Printf("Completed entity: %s", developer.EMail)
shared.Info.Printf("Completed entity: %s", dev.EMail)
}

//batch creates a batch of developers to create
func batch(url string, entities []Developer, pwg *sync.WaitGroup) {
func batch(url string, entities []developer, pwg *sync.WaitGroup) {

defer pwg.Done()
//batch workgroup
Expand Down Expand Up @@ -118,30 +118,30 @@ func createDevelopers(url string) error {
return nil
}

func readDevelopersFile() ([]Developer, error) {
func readDevelopersFile() ([]developer, error) {

developers := []Developer{}
devs := []developer{}

jsonFile, err := os.Open(file)

if err != nil {
return developers, err
return devs, err
}

defer jsonFile.Close()

byteValue, err := ioutil.ReadAll(jsonFile)

if err != nil {
return developers, err
return devs, err
}

err = json.Unmarshal(byteValue, &developers)
err = json.Unmarshal(byteValue, &devs)

if err != nil {
return developers, err
return devs, err
}

return developers, nil
return devs, nil

}
10 changes: 5 additions & 5 deletions cmd/products/impprod/impprod.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
types "github.com/srinandan/apigeecli/cmd/types"
)

type Product struct {
type product struct {
Name string `json:"name,omitempty"`
DisplayName string `json:"displayName,omitempty"`
ApprovalType string `json:"approvalType,omitempty"`
Expand Down Expand Up @@ -47,7 +47,7 @@ func init() {
_ = Cmd.MarkFlagRequired("file")
}

func createAsyncProduct(url string, entity Product, wg *sync.WaitGroup) {
func createAsyncProduct(url string, entity product, wg *sync.WaitGroup) {
defer wg.Done()
out, err := json.Marshal(entity)
if err != nil {
Expand All @@ -63,7 +63,7 @@ func createAsyncProduct(url string, entity Product, wg *sync.WaitGroup) {
}

//batch creates a batch of products to create
func batch(url string, entities []Product, pwg *sync.WaitGroup) {
func batch(url string, entities []product, pwg *sync.WaitGroup) {

defer pwg.Done()
//batch workgroup
Expand Down Expand Up @@ -119,9 +119,9 @@ func createProducts(url string) error {
return nil
}

func readProductsFile() ([]Product, error) {
func readProductsFile() ([]product, error) {

products := []Product{}
products := []product{}

jsonFile, err := os.Open(file)

Expand Down

0 comments on commit da1870a

Please sign in to comment.