Skip to content

Commit

Permalink
Merge pull request #9 from nyudlts/chore/minor-housekeeping
Browse files Browse the repository at this point in the history
Chore/minor housekeeping
  • Loading branch information
jgpawletko authored Dec 17, 2024
2 parents b8f6694 + 6f6aa64 commit d0644d8
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 52 deletions.
3 changes: 0 additions & 3 deletions ASClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"os"
"time"
Expand Down Expand Up @@ -49,8 +48,6 @@ func NewClientFromCreds(creds Creds, timeout int) (*ASClient, error) {

var client *ASClient

log.Printf("[DEBUG] url: %s, username: %s, password: %s", creds.URL, creds.Username, creds.Password)

tr := &http.Transport{
MaxIdleConns: 10,
IdleConnTimeout: time.Duration(timeout) * time.Second,
Expand Down
3 changes: 3 additions & 0 deletions Agents.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ func (a *ASClient) GetAgent(agentType string, agentID int) (Agent, error) {
}

err = json.Unmarshal(body, &agent)
if err != nil {
return agent, err
}
return agent, nil
}

Expand Down
42 changes: 20 additions & 22 deletions ArchivalObjects.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"encoding/json"
"fmt"
"io"
"regexp"
"strings"
)

func (a *ASClient) GetArchivalObjectIDs(repositoryID int) ([]int, error) {
Expand Down Expand Up @@ -91,14 +89,14 @@ func (a *ASClient) UpdateArchivalObject(repositoryId int, archivalObjectId int,
return responseMessage, nil
}

func getChildArchivalObjectURIs(children []ResourceTree, aos *[]string) {
for _, child := range children {
*aos = append(*aos, child.RecordURI)
if child.HasChildren {
getChildArchivalObjectURIs(child.Children, aos)
}
}
}
// func getChildArchivalObjectURIs(children []ResourceTree, aos *[]string) {
// for _, child := range children {
// *aos = append(*aos, child.RecordURI)
// if child.HasChildren {
// getChildArchivalObjectURIs(child.Children, aos)
// }
// }
// }

func (a ASClient) DeleteArchivalObject(repositoryID int, archivalObjectID int) (string, error) {
responseMessage := ""
Expand All @@ -119,18 +117,18 @@ func (a ASClient) DeleteArchivalObject(repositoryID int, archivalObjectID int) (
return responseMessage, nil
}

func getChildArchivalObjectURIsFiltered(children []ResourceTree, aos *[]string, filter string) {
matcher := regexp.MustCompile(filter)
for _, child := range children {
if matcher.MatchString(strings.Join(child.InstanceTypes, " ")) == true {
*aos = append(*aos, child.RecordURI)
}

if child.HasChildren {
getChildArchivalObjectURIs(child.Children, aos)
}
}
}
// func getChildArchivalObjectURIsFiltered(children []ResourceTree, aos *[]string, filter string) {
// matcher := regexp.MustCompile(filter)
// for _, child := range children {
// if matcher.MatchString(strings.Join(child.InstanceTypes, " ")) == true {
// *aos = append(*aos, child.RecordURI)
// }

// if child.HasChildren {
// getChildArchivalObjectURIs(child.Children, aos)
// }
// }
// }

func (a *ASClient) GetRandomArchivalObject(repositoryID int, resourceID int) (int, int, error) {

Expand Down
17 changes: 12 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
## CHANGELOG

#### v0.7.1
- remove debug print from `NewClientFromCreds()`
- tidy go mod files (removed unused libxml2 package)
- tweak range statement per linter recommendation
- add missing error check
- comment out unused code
- add error check to (a *ADClient)GetAgent()
- update CHANGELOG, bump to v0.7.1

#### v0.7.0
- add `func (a *ASClient) FindArchivalObjectsByID(...)([]string, error)`
- add `func (a *ASClient) FindArchivalObjectsByID(...)([]string, error)`
that allows you to look up archival objects by the `ref_id` or `component_id` fields

#### v0.6.1
- bug fix: rewrite `func (wor WorkOrderRow) String()` to use
`encoding/csv` to handle string escapes

#### v0.6.0
- add `...FromURI()` functions:
- add `GetArchivalObjectFromURI()`
Expand All @@ -24,5 +33,3 @@
- force `bool` key/value pairs to always be sent in marshaled JSON for selected types
- remove `omitempty` option from `DigitalObject` type `bool` JSON tags
- remove `omitempty` option from `FileVersion` type `bool` JSON tags


20 changes: 10 additions & 10 deletions Common.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"time"
)

var LibraryVersion = "v0.7.0"
var LibraryVersion = "v0.7.1"

var seed = rand.NewSource(time.Now().UnixNano())
var rGen = rand.New(seed)
Expand Down Expand Up @@ -105,15 +105,15 @@ func (a *ASClient) PostEndpoint(endpoint string, requestBody string, authenticat
return response, nil
}

// slice contains methods
func containsInt(list []int, id int) bool {
for _, i := range list {
if id == i {
return true
}
}
return false
}
// // slice contains methods
// func containsInt(list []int, id int) bool {
// for _, i := range list {
// if id == i {
// return true
// }
// }
// return false
// }

type CreateOrUpdateResponse struct {
Status string `json:"status"`
Expand Down
3 changes: 3 additions & 0 deletions Repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ func (a *ASClient) GetRepositories() ([]int, error) {

reps := make([]map[string]interface{}, 1, 1)
err = json.Unmarshal(body, &reps)
if err != nil {
return repIds, err
}

for i := range reps {
rep := fmt.Sprintf("%v", reps[i]["uri"])
Expand Down
5 changes: 3 additions & 2 deletions Schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package aspace

import (
"flag"
goaspacetest "github.com/nyudlts/go-aspace/goaspace_testing"
"testing"

goaspacetest "github.com/nyudlts/go-aspace/goaspace_testing"
)

func TestSchemas(t *testing.T) {
Expand All @@ -27,7 +28,7 @@ func TestSchemas(t *testing.T) {
t.Log("Successfully got a list of schemas")

keys := make([]string, 0, len(schemas))
for k, _ := range schemas {
for k := range schemas {
keys = append(keys, k)
}

Expand Down
7 changes: 1 addition & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,4 @@ module github.com/nyudlts/go-aspace

go 1.21

require (
github.com/lestrrat-go/libxml2 v0.0.0-20231124114421-99c71026c2f5
gopkg.in/yaml.v2 v2.3.0
)

require github.com/pkg/errors v0.9.1 // indirect
require gopkg.in/yaml.v2 v2.3.0
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
github.com/lestrrat-go/libxml2 v0.0.0-20231124114421-99c71026c2f5 h1:lR4DHv41vdkhNPNDlr56n8BuLINQeWNeQAaAzBEOcuw=
github.com/lestrrat-go/libxml2 v0.0.0-20231124114421-99c71026c2f5/go.mod h1:/0MMipmS+5SMXCSkulsvJwYmddKI4IL5tVy6AZMo9n0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
Expand Down

0 comments on commit d0644d8

Please sign in to comment.