diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index ce4ec4b953..56b889d467 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -24,13 +24,6 @@ updates:
open-pull-requests-limit: 10
labels:
- Ruby
-- package-ecosystem: gomod
- directory: "/abstractions/go"
- schedule:
- interval: daily
- open-pull-requests-limit: 10
- labels:
- - Go
- package-ecosystem: composer
directory: "/abstractions/php"
schedule:
diff --git a/.github/workflows/abstractions-go.yml b/.github/workflows/abstractions-go.yml
deleted file mode 100644
index 6f32237f10..0000000000
--- a/.github/workflows/abstractions-go.yml
+++ /dev/null
@@ -1,26 +0,0 @@
-name: Go abstractions
-
-on:
- workflow_dispatch:
- push:
- branches: [ main ]
- paths: ['abstractions/go/**', '.github/workflows/**']
- pull_request:
- paths: ['abstractions/go/**', '.github/workflows/**']
-
-jobs:
- build:
- runs-on: ubuntu-latest
- env:
- relativePath: ./abstractions/go
- steps:
- - uses: actions/checkout@v3
- - uses: actions/setup-go@v2
- with:
- go-version: '^1.17.3'
- - name: Install dependencies
- run: go install
- working-directory: ${{ env.relativePath }}
- - name: Build SDK project
- run: go build
- working-directory: ${{ env.relativePath }}
diff --git a/.github/workflows/authentication-go-azure.yml b/.github/workflows/authentication-go-azure.yml
deleted file mode 100644
index 36ebc4d66c..0000000000
--- a/.github/workflows/authentication-go-azure.yml
+++ /dev/null
@@ -1,26 +0,0 @@
-name: Go Authentication Azure
-
-on:
- workflow_dispatch:
- push:
- branches: [ main ]
- paths: ['authentication/go/azure/**', '.github/workflows/**']
- pull_request:
- paths: ['authentication/go/azure/**', '.github/workflows/**']
-
-jobs:
- build:
- runs-on: ubuntu-latest
- env:
- relativePath: ./authentication/go/azure
- steps:
- - uses: actions/checkout@v3
- - uses: actions/setup-go@v2
- with:
- go-version: '^1.17.3'
- - name: Install dependencies
- run: go install
- working-directory: ${{ env.relativePath }}
- - name: Build SDK project
- run: go build
- working-directory: ${{ env.relativePath }}
diff --git a/.github/workflows/http-go-nethttp.yml b/.github/workflows/http-go-nethttp.yml
deleted file mode 100644
index 7449e569d1..0000000000
--- a/.github/workflows/http-go-nethttp.yml
+++ /dev/null
@@ -1,26 +0,0 @@
-name: Go Http NetHttp
-
-on:
- workflow_dispatch:
- push:
- branches: [ main ]
- paths: ['http/go/nethttp/**', '.github/workflows/**']
- pull_request:
- paths: ['http/go/nethttp/**', '.github/workflows/**']
-
-jobs:
- build:
- runs-on: ubuntu-latest
- env:
- relativePath: ./http/go/nethttp
- steps:
- - uses: actions/checkout@v3
- - uses: actions/setup-go@v2
- with:
- go-version: '^1.17.3'
- - name: Install dependencies
- run: go install
- working-directory: ${{ env.relativePath }}
- - name: Build SDK project
- run: go build
- working-directory: ${{ env.relativePath }}
diff --git a/.github/workflows/serialization-go-json.yml b/.github/workflows/serialization-go-json.yml
deleted file mode 100644
index a9ffc0a4a3..0000000000
--- a/.github/workflows/serialization-go-json.yml
+++ /dev/null
@@ -1,29 +0,0 @@
-name: Go Serialization Json
-
-on:
- workflow_dispatch:
- push:
- branches: [ main ]
- paths: ['serialization/go/json/**', '.github/workflows/**']
- pull_request:
- paths: ['serialization/go/json/**', '.github/workflows/**']
-
-jobs:
- build:
- runs-on: ubuntu-latest
- env:
- relativePath: ./serialization/go/json
- steps:
- - uses: actions/checkout@v3
- - uses: actions/setup-go@v2
- with:
- go-version: '^1.17.3'
- - name: Install dependencies
- run: go install
- working-directory: ${{ env.relativePath }}
- - name: Build SDK project
- run: go build
- working-directory: ${{ env.relativePath }}
- - name: Run unit tests
- run: go test
- working-directory: ${{ env.relativePath }}
diff --git a/.github/workflows/serialization-go-text.yml b/.github/workflows/serialization-go-text.yml
deleted file mode 100644
index 057addb9d4..0000000000
--- a/.github/workflows/serialization-go-text.yml
+++ /dev/null
@@ -1,29 +0,0 @@
-name: Go Serialization Text
-
-on:
- workflow_dispatch:
- push:
- branches: [ main ]
- paths: ['serialization/go/text/**', '.github/workflows/**']
- pull_request:
- paths: ['serialization/go/text/**', '.github/workflows/**']
-
-jobs:
- build:
- runs-on: ubuntu-latest
- env:
- relativePath: ./serialization/go/text
- steps:
- - uses: actions/checkout@v3
- - uses: actions/setup-go@v2
- with:
- go-version: '^1.17.3'
- - name: Install dependencies
- run: go install
- working-directory: ${{ env.relativePath }}
- - name: Build SDK project
- run: go build
- working-directory: ${{ env.relativePath }}
- - name: Run unit tests
- run: go test
- working-directory: ${{ env.relativePath }}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4e61c1f57a..0144adc3ab 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,8 +18,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added support for unstructured response generation (stream). [#546](https://github.com/microsoft/kiota/issues/546)
### Changed
+
+- Moved go libraries to their own repository. [#370](https://github.com/microsoft/kiota/issues/370)
- Fixed a bug where the base url of the request adapter would be reset by the client(PHP). [#1469](https://github.com/microsoft/kiota/issues/1469)
-- Fix issue where custom date types are never corrected for method parameters(PHP). #1474
+- Fixed issue where custom date types are never corrected for method parameters(PHP). #1474
- Replace DateTimeOffset with DateTime for custom date types(PHP). #1474
- Fixed a bug where the base url of the request adapter would be reset by the client. [#1443](https://github.com/microsoft/kiota/issues/1443)
- Fixed a bug where request builder classes for collections endpoints would have a wrong name. #1052
diff --git a/README.md b/README.md
index 9f7ed52ab9..6db8001e63 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,7 @@ The following table provides an overview of the languages supported by Kiota and
| Language | Generation | Abstractions | Serialization | Authentication | HTTP | Required tools & dependencies |
| -------- | ---------- |--------------------------------|-----------------------------------------------------------------| -------------- | ---- | -------------- |
| CSharp | [✔](https://github.com/microsoft/kiota/projects/5) | [✔](https://github.com/microsoft/kiota-abstractions-dotnet) | [JSON](https://github.com/microsoft/kiota-serialization-json-dotnet), [TEXT](https://github.com/microsoft/kiota-serialization-text-dotnet) | [Anonymous](https://github.com/microsoft/kiota-abstractions-dotnet/blob/main/src/authentication/AnonymousAuthenticationProvider.cs), [Azure](https://github.com/microsoft/kiota-authentication-azure-dotnet) | [✔](https://github.com/microsoft/kiota-http-dotnet) | [link](https://microsoft.github.io/kiota/get-started/dotnet) |
-| Go | [✔](https://github.com/microsoft/kiota/projects/8) | [✔](./abstractions/go) | [JSON](./serialization/go/json), [TEXT](./serialization/go/text) | [Anonymous](./abstractions/go/authentication/anonymous_authentication_provider.go), [Azure](./authentication/go/azure) | [✔](./http/go/nethttp) | [link](https://microsoft.github.io/kiota/get-started/go) |
+| Go | [✔](https://github.com/microsoft/kiota/projects/8) | [✔](https://github.com/microsoft/kiota-abstractions-go) | [JSON](https://github.com/microsoft/kiota-serialization-json-go), [TEXT](https://github.com/microsoft/kiota-serialization-text-go) | [Anonymous](https://github.com/microsoft/kiota-abstractions-go/blob/main/authentication/anonymous_authentication_provider.go), [Azure](https://github.com/microsoft/kiota-authentication-azure-go/) | [✔](https://github.com/microsoft/kiota-http-go/) | [link](https://microsoft.github.io/kiota/get-started/go) |
| Java | [✔](https://github.com/microsoft/kiota/projects/7) | [✔](./abstractions/java) | [JSON](./serialization/java/json), [TEXT](./serialization/java/text) | [Anonymous](./abstractions/java/lib/src/main/java/com/microsoft/kiota/authentication/AnonymousAuthenticationProvider.java), [Azure](./authentication/java/azure) | [✔](./http/java/okhttp) | [link](https://microsoft.github.io/kiota/get-started/java) |
| PHP | [✔](https://github.com/microsoft/kiota/projects/4) | [✔](./abstractions/php) | [JSON](./serialization/php/json), [❌ TEXT](https://github.com/microsoft/kiota/issues/1405) | [Anonymous](./abstractions/php/src/Authentication/AnonymousAuthenticationProvider.php), [✔️ PHP League](./authentication/php/phpleague) | [✔](./http/php/guzzle) | |
| Python | [▶](https://github.com/microsoft/kiota/projects/3) | [✔](./abstractions/python) | [JSON](./serialization/python/json), [❌ TEXT](https://github.com/microsoft/kiota/issues/1406) | [Anonymous](./abstractions/python/kiota/abstractions/authentication/anonymous_authentication_provider.py), [Azure](./authentication/python/azure) | [✔](./http/python/requests) | |
diff --git a/abstractions/README.md b/abstractions/README.md
index 415867a7c9..1f60c8aacd 100644
--- a/abstractions/README.md
+++ b/abstractions/README.md
@@ -5,7 +5,7 @@ Your project will need a reference to the abstraction package to build and run,
- [Dotnet](https://github.com/microsoft/kiota-abstractions-dotnet)
- [Java](./java)
-- [Go](./go)
+- [Go](https://github.com/microsoft/kiota-abstractions-go)
- [Ruby](./ruby/microsoft_kiota_abstractions)
- [TypeScript](https://github.com/microsoft/kiota-typescript/tree/main/packages/abstractions)
- [PHP](./php)
diff --git a/abstractions/go/README.md b/abstractions/go/README.md
deleted file mode 100644
index 8f36e2f05e..0000000000
--- a/abstractions/go/README.md
+++ /dev/null
@@ -1,17 +0,0 @@
-# To-do
-
-![Go](https://github.com/microsoft/kiota/actions/workflows/abstractions-go.yml/badge.svg)
-
-- [ ] unit tests
-- [ ] move to its own repo and implement [the guidelines](https://golang.org/doc/#developing-modules) to make referencing the module easier
-- [ ] add doc.go
-- [ ] rename module name, update reference and remove the replace directive
-
-## Using the abstractions
-
-1. Navigate to the directory where `go.mod` is located for your project.
-1. Run the following command:
-
- ```Shell
- go get github.com/microsoft/kiota/abstractions/go
- ```
diff --git a/abstractions/go/api_client_builder.go b/abstractions/go/api_client_builder.go
deleted file mode 100644
index 8cbeaf3fe4..0000000000
--- a/abstractions/go/api_client_builder.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package abstractions
-
-import (
- sync "sync"
-
- s "github.com/microsoft/kiota/abstractions/go/serialization"
-)
-
-var serializerMutex sync.Mutex
-var deserializerMutex sync.Mutex
-
-// RegisterDefaultSerializer registers the default serializer to the registry singleton to be used by the request adapter.
-func RegisterDefaultSerializer(metaFactory func() s.SerializationWriterFactory) {
- factory := metaFactory()
- contentType, err := factory.GetValidContentType()
- if err == nil && contentType != "" {
- serializerMutex.Lock()
- s.DefaultSerializationWriterFactoryInstance.ContentTypeAssociatedFactories[contentType] = factory
- serializerMutex.Unlock()
- }
-}
-
-// RegisterDefaultDeserializer registers the default deserializer to the registry singleton to be used by the request adapter.
-func RegisterDefaultDeserializer(metaFactory func() s.ParseNodeFactory) {
- factory := metaFactory()
- contentType, err := factory.GetValidContentType()
- if err == nil && contentType != "" {
- deserializerMutex.Lock()
- s.DefaultParseNodeFactoryInstance.ContentTypeAssociatedFactories[contentType] = factory
- deserializerMutex.Unlock()
- }
-}
diff --git a/abstractions/go/api_client_builder_test.go b/abstractions/go/api_client_builder_test.go
deleted file mode 100644
index c0ff4b1a85..0000000000
--- a/abstractions/go/api_client_builder_test.go
+++ /dev/null
@@ -1,129 +0,0 @@
-package abstractions
-
-import (
- "github.com/google/uuid"
- serialization "github.com/microsoft/kiota/abstractions/go/serialization"
- assert "github.com/stretchr/testify/assert"
- "testing"
- "time"
-)
-
-type mockSerializer struct {
-}
-
-func (*mockSerializer) WriteStringValue(key string, value *string) error {
- return nil
-}
-func (*mockSerializer) WriteBoolValue(key string, value *bool) error {
- return nil
-}
-func (*mockSerializer) WriteByteValue(key string, value *byte) error {
- return nil
-}
-func (*mockSerializer) WriteInt8Value(key string, value *int8) error {
- return nil
-}
-func (*mockSerializer) WriteInt32Value(key string, value *int32) error {
- return nil
-}
-func (*mockSerializer) WriteInt64Value(key string, value *int64) error {
- return nil
-}
-func (*mockSerializer) WriteFloat32Value(key string, value *float32) error {
- return nil
-}
-func (*mockSerializer) WriteFloat64Value(key string, value *float64) error {
- return nil
-}
-func (*mockSerializer) WriteByteArrayValue(key string, value []byte) error {
- return nil
-}
-func (*mockSerializer) WriteTimeValue(key string, value *time.Time) error {
- return nil
-}
-func (*mockSerializer) WriteISODurationValue(key string, value *serialization.ISODuration) error {
- return nil
-}
-func (*mockSerializer) WriteDateOnlyValue(key string, value *serialization.DateOnly) error {
- return nil
-}
-func (*mockSerializer) WriteTimeOnlyValue(key string, value *serialization.TimeOnly) error {
- return nil
-}
-func (*mockSerializer) WriteUUIDValue(key string, value *uuid.UUID) error {
- return nil
-}
-func (*mockSerializer) WriteObjectValue(key string, item serialization.Parsable) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfObjectValues(key string, collection []serialization.Parsable) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfStringValues(key string, collection []string) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfBoolValues(key string, collection []bool) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfByteValues(key string, collection []byte) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfInt8Values(key string, collection []int8) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfInt32Values(key string, collection []int32) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfInt64Values(key string, collection []int64) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfFloat32Values(key string, collection []float32) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfFloat64Values(key string, collection []float64) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfTimeValues(key string, collection []time.Time) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfISODurationValues(key string, collection []serialization.ISODuration) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfDateOnlyValues(key string, collection []serialization.DateOnly) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfTimeOnlyValues(key string, collection []serialization.TimeOnly) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfUUIDValues(key string, collection []uuid.UUID) error {
- return nil
-}
-func (*mockSerializer) GetSerializedContent() ([]byte, error) {
- return nil, nil
-}
-func (*mockSerializer) WriteAdditionalData(value map[string]interface{}) error {
- return nil
-}
-func (*mockSerializer) Close() error {
- return nil
-}
-
-type mockSerializerFactory struct {
-}
-
-func (*mockSerializerFactory) GetValidContentType() (string, error) {
- return "application/json", nil
-}
-func (*mockSerializerFactory) GetSerializationWriter(contentType string) (serialization.SerializationWriter, error) {
- return &mockSerializer{}, nil
-}
-
-func TestItCreatesClientConcurrently(t *testing.T) {
- metaFactory := func() serialization.SerializationWriterFactory {
- return &mockSerializerFactory{}
- }
- for i := 0; i < 1000; i++ {
- go RegisterDefaultSerializer(metaFactory)
- }
- assert.Equal(t, 1, len(serialization.DefaultSerializationWriterFactoryInstance.ContentTypeAssociatedFactories))
-}
diff --git a/abstractions/go/api_error.go b/abstractions/go/api_error.go
deleted file mode 100644
index 90c3c0fb30..0000000000
--- a/abstractions/go/api_error.go
+++ /dev/null
@@ -1,21 +0,0 @@
-package abstractions
-
-import "fmt"
-
-// ApiError is the parent type for errors thrown by the client when receiving failed responses to its requests
-type ApiError struct {
- Message string
-}
-
-func (e *ApiError) Error() string {
- if len(e.Message) > 0 {
- return fmt.Sprint(e.Message)
- } else {
- return "error status code received from the API"
- }
-}
-
-// NewApiError creates a new ApiError instance
-func NewApiError() *ApiError {
- return &ApiError{}
-}
diff --git a/abstractions/go/authentication/access_token_provider.go b/abstractions/go/authentication/access_token_provider.go
deleted file mode 100644
index 22bf7e40af..0000000000
--- a/abstractions/go/authentication/access_token_provider.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package authentication
-
-import (
- u "net/url"
-)
-
-//AccessTokenProvider returns access tokens.
-type AccessTokenProvider interface {
- // GetAuthorizationToken returns the access token for the provided url.
- GetAuthorizationToken(url *u.URL) (string, error)
- // GetAllowedHostsValidator returns the hosts validator.
- GetAllowedHostsValidator() *AllowedHostsValidator
-}
diff --git a/abstractions/go/authentication/allowed_hosts_validator.go b/abstractions/go/authentication/allowed_hosts_validator.go
deleted file mode 100644
index 962e3f1acc..0000000000
--- a/abstractions/go/authentication/allowed_hosts_validator.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package authentication
-
-import (
- u "net/url"
- "strings"
-)
-
-// AllowedHostsValidator Maintains a list of valid hosts and allows authentication providers to check whether a host is valid before authenticating a request
-type AllowedHostsValidator struct {
- validHosts map[string]bool
-}
-
-// NewAllowedHostsValidator creates a new AllowedHostsValidator object with provided values.
-func NewAllowedHostsValidator(validHosts []string) AllowedHostsValidator {
- result := AllowedHostsValidator{}
- result.SetAllowedHosts(validHosts)
- return result
-}
-
-// GetAllowedHosts returns the list of valid hosts.
-func (v *AllowedHostsValidator) GetAllowedHosts() map[string]bool {
- hosts := make(map[string]bool, len(v.validHosts))
- for host := range v.validHosts {
- hosts[host] = true
- }
- return hosts
-}
-
-//SetAllowedHosts sets the list of valid hosts.
-func (v *AllowedHostsValidator) SetAllowedHosts(hosts []string) {
- v.validHosts = make(map[string]bool, len(hosts))
- if len(hosts) > 0 {
- for _, host := range hosts {
- v.validHosts[strings.ToLower(host)] = true
- }
- }
-}
-
-// IsValidHost returns true if the host is valid.
-func (v *AllowedHostsValidator) IsUrlHostValid(uri *u.URL) bool {
- if uri == nil {
- return false
- }
- host := uri.Hostname()
- if host == "" {
- return false
- }
- return v.validHosts[strings.ToLower(host)]
-}
diff --git a/abstractions/go/authentication/allowed_hosts_validator_test.go b/abstractions/go/authentication/allowed_hosts_validator_test.go
deleted file mode 100644
index ee1bfae6bf..0000000000
--- a/abstractions/go/authentication/allowed_hosts_validator_test.go
+++ /dev/null
@@ -1,14 +0,0 @@
-package authentication
-
-import (
- assert "github.com/stretchr/testify/assert"
- u "net/url"
- "testing"
-)
-
-func TestItValidatesHosts(t *testing.T) {
- validator := NewAllowedHostsValidator([]string{"graph.microsoft.com"})
- url, err := u.Parse("https://graph.microsoft.com/v1.0/me")
- assert.Nil(t, err)
- assert.True(t, validator.IsUrlHostValid(url))
-}
diff --git a/abstractions/go/authentication/anonymous_authentication_provider.go b/abstractions/go/authentication/anonymous_authentication_provider.go
deleted file mode 100644
index 06c00dcbdc..0000000000
--- a/abstractions/go/authentication/anonymous_authentication_provider.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package authentication
-
-import abs "github.com/microsoft/kiota/abstractions/go"
-
-// AnonymousAuthenticationProvider implements the AuthenticationProvider interface does not perform any authentication.
-type AnonymousAuthenticationProvider struct {
-}
-
-// AuthenticateRequest is a placeholder method that "authenticates" the RequestInformation instance: no-op.
-func (provider *AnonymousAuthenticationProvider) AuthenticateRequest(request *abs.RequestInformation) error {
- return nil
-}
diff --git a/abstractions/go/authentication/authentication_provider.go b/abstractions/go/authentication/authentication_provider.go
deleted file mode 100644
index ec3157aa22..0000000000
--- a/abstractions/go/authentication/authentication_provider.go
+++ /dev/null
@@ -1,11 +0,0 @@
-package authentication
-
-import (
- abs "github.com/microsoft/kiota/abstractions/go"
-)
-
-// AuthenticationProvider authenticates the RequestInformation request.
-type AuthenticationProvider interface {
- // AuthenticateRequest authenticates the provided RequestInformation.
- AuthenticateRequest(request *abs.RequestInformation) error
-}
diff --git a/abstractions/go/authentication/base_bearer_token_authentication_provider.go b/abstractions/go/authentication/base_bearer_token_authentication_provider.go
deleted file mode 100644
index a011d7db46..0000000000
--- a/abstractions/go/authentication/base_bearer_token_authentication_provider.go
+++ /dev/null
@@ -1,53 +0,0 @@
-package authentication
-
-import (
- "errors"
-
- abs "github.com/microsoft/kiota/abstractions/go"
-)
-
-const authorizationHeader = "Authorization"
-
-// BaseBearerTokenAuthenticationProvider provides a base class implementing AuthenticationProvider for Bearer token scheme.
-type BaseBearerTokenAuthenticationProvider struct {
- // accessTokenProvider is called by the BaseBearerTokenAuthenticationProvider class to authenticate the request via the returned access token.
- accessTokenProvider AccessTokenProvider
-}
-
-// NewBaseBearerTokenAuthenticationProvider creates a new instance of the BaseBearerTokenAuthenticationProvider class.
-func NewBaseBearerTokenAuthenticationProvider(accessTokenProvider AccessTokenProvider) *BaseBearerTokenAuthenticationProvider {
- return &BaseBearerTokenAuthenticationProvider{accessTokenProvider}
-}
-
-// AuthenticateRequest authenticates the provided RequestInformation instance using the provided authorization token callback.
-func (provider *BaseBearerTokenAuthenticationProvider) AuthenticateRequest(request *abs.RequestInformation) error {
- if request == nil {
- return errors.New("request is nil")
- }
- if request.Headers == nil {
- request.Headers = make(map[string]string)
- }
- if provider.accessTokenProvider == nil {
- return errors.New("this class needs to be initialized with an access token provider")
- }
- if request.Headers[authorizationHeader] == "" {
- uri, err := request.GetUri()
- if err != nil {
- return err
- }
- token, err := provider.accessTokenProvider.GetAuthorizationToken(uri)
- if err != nil {
- return err
- }
- if token != "" {
- request.Headers[authorizationHeader] = "Bearer " + token
- }
- }
-
- return nil
-}
-
-// GetAuthorizationTokenProvider returns the access token provider the BaseBearerTokenAuthenticationProvider class uses to authenticate the request.
-func (provider *BaseBearerTokenAuthenticationProvider) GetAuthorizationTokenProvider() AccessTokenProvider {
- return provider.accessTokenProvider
-}
diff --git a/abstractions/go/go.mod b/abstractions/go/go.mod
deleted file mode 100644
index 92bfe02902..0000000000
--- a/abstractions/go/go.mod
+++ /dev/null
@@ -1,16 +0,0 @@
-module github.com/microsoft/kiota/abstractions/go
-
-go 1.17
-
-require (
- github.com/cjlapao/common-go v0.0.19
- github.com/google/uuid v1.3.0
- github.com/stretchr/testify v1.7.1
- github.com/yosida95/uritemplate/v3 v3.0.1
-)
-
-require (
- github.com/davecgh/go-spew v1.1.1 // indirect
- github.com/pmezard/go-difflib v1.0.0 // indirect
- gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
-)
diff --git a/abstractions/go/go.sum b/abstractions/go/go.sum
deleted file mode 100644
index c3d7f222f2..0000000000
--- a/abstractions/go/go.sum
+++ /dev/null
@@ -1,67 +0,0 @@
-github.com/cjlapao/common-go v0.0.19 h1:dhPllblgZwHn92u8wNleLDCg6+T2rjV57H8eyz82tbQ=
-github.com/cjlapao/common-go v0.0.19/go.mod h1:EVLEXIxsBHblPMrhJYOvL4yBCcBj7IYDdW88VlfxpPM=
-github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
-github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
-github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
-github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
-github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
-github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
-github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
-github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
-github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q=
-github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
-github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
-github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
-github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
-github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
-github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
-github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
-github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
-github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
-github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
-github.com/pascaldekloe/jwt v1.10.0/go.mod h1:TKhllgThT7TOP5rGr2zMLKEDZRAgJfBbtKyVeRsNB9A=
-github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
-github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
-github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
-github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
-github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
-github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs=
-github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM=
-github.com/yosida95/uritemplate/v3 v3.0.1 h1:+Fs//CsT+x231WmUQhMHWMxZizMvpnkOVWop02mVCfs=
-github.com/yosida95/uritemplate/v3 v3.0.1/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
-github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
-go.mongodb.org/mongo-driver v1.8.0/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY=
-golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
-golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
-golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
-golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
-golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20211123173158-ef496fb156ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
-golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
-golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
-golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
-golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
-golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-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/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
-gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
-gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
-gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/abstractions/go/http_method.go b/abstractions/go/http_method.go
deleted file mode 100644
index 584d4e02a8..0000000000
--- a/abstractions/go/http_method.go
+++ /dev/null
@@ -1,30 +0,0 @@
-package abstractions
-
-// Represents the HTTP method used by a request.
-type HttpMethod int
-
-const (
- // The HTTP GET method.
- GET HttpMethod = iota
- // The HTTP POST method.
- POST
- // The HTTP PATCH method.
- PATCH
- // The HTTP DELETE method.
- DELETE
- // The HTTP OPTIONS method.
- OPTIONS
- // The HTTP CONNECT method.
- CONNECT
- // The HTTP PUT method.
- PUT
- // The HTTP TRACE method.
- TRACE
- // The HTTP HEAD method.
- HEAD
-)
-
-// String returns the string representation of the HTTP method.
-func (m HttpMethod) String() string {
- return []string{"GET", "POST", "PATCH", "DELETE", "OPTIONS", "CONNECT", "PUT", "TRACE", "HEAD"}[m]
-}
diff --git a/abstractions/go/request_adapter.go b/abstractions/go/request_adapter.go
deleted file mode 100644
index 1a4e630fa1..0000000000
--- a/abstractions/go/request_adapter.go
+++ /dev/null
@@ -1,38 +0,0 @@
-// Package abstractions provides the base infrastructure for the Kiota-generated SDKs to function.
-// It defines multiple concepts related to abstract HTTP requests, serialization, and authentication.
-// These concepts can then be implemented independently without tying the SDKs to any specific implementation.
-// Kiota also provides default implementations for these concepts.
-// Checkout:
-// - github.com/microsoft/kiota/authentication/go/azure
-// - github.com/microsoft/kiota/http/go/nethttp
-// - github.com/microsoft/kiota/serialization/go/json
-package abstractions
-
-import (
- s "github.com/microsoft/kiota/abstractions/go/serialization"
-)
-
-// ErrorMappings is a mapping of status codes to error types factories.
-type ErrorMappings map[string]s.ParsableFactory
-
-// RequestAdapter is the service responsible for translating abstract RequestInformation into native HTTP requests.
-type RequestAdapter interface {
- // SendAsync executes the HTTP request specified by the given RequestInformation and returns the deserialized response model.
- SendAsync(requestInfo *RequestInformation, constructor s.ParsableFactory, responseHandler ResponseHandler, errorMappings ErrorMappings) (s.Parsable, error)
- // SendCollectionAsync executes the HTTP request specified by the given RequestInformation and returns the deserialized response model collection.
- SendCollectionAsync(requestInfo *RequestInformation, constructor s.ParsableFactory, responseHandler ResponseHandler, errorMappings ErrorMappings) ([]s.Parsable, error)
- // SendPrimitiveAsync executes the HTTP request specified by the given RequestInformation and returns the deserialized primitive response model.
- SendPrimitiveAsync(requestInfo *RequestInformation, typeName string, responseHandler ResponseHandler, errorMappings ErrorMappings) (interface{}, error)
- // SendPrimitiveCollectionAsync executes the HTTP request specified by the given RequestInformation and returns the deserialized primitive response model collection.
- SendPrimitiveCollectionAsync(requestInfo *RequestInformation, typeName string, responseHandler ResponseHandler, errorMappings ErrorMappings) ([]interface{}, error)
- // SendNoContentAsync executes the HTTP request specified by the given RequestInformation with no return content.
- SendNoContentAsync(requestInfo *RequestInformation, responseHandler ResponseHandler, errorMappings ErrorMappings) error
- // GetSerializationWriterFactory returns the serialization writer factory currently in use for the request adapter service.
- GetSerializationWriterFactory() s.SerializationWriterFactory
- // EnableBackingStore enables the backing store proxies for the SerializationWriters and ParseNodes in use.
- EnableBackingStore()
- // SetBaseUrl sets the base url for every request.
- SetBaseUrl(baseUrl string)
- // GetBaseUrl gets the base url for every request.
- GetBaseUrl() string
-}
diff --git a/abstractions/go/request_information.go b/abstractions/go/request_information.go
deleted file mode 100644
index 2dd2173c2b..0000000000
--- a/abstractions/go/request_information.go
+++ /dev/null
@@ -1,216 +0,0 @@
-package abstractions
-
-import (
- "errors"
-
- "reflect"
- "strconv"
- "strings"
-
- u "net/url"
-
- s "github.com/microsoft/kiota/abstractions/go/serialization"
- t "github.com/yosida95/uritemplate/v3"
-)
-
-// RequestInformation represents an abstract HTTP request.
-type RequestInformation struct {
- // The HTTP method of the request.
- Method HttpMethod
- uri *u.URL
- // The Request Headers.
- Headers map[string]string
- // The Query Parameters of the request.
- QueryParameters map[string]string
- // The Request Body.
- Content []byte
- // The path parameters to use for the URL template when generating the URI.
- PathParameters map[string]string
- // The Url template for the current request.
- UrlTemplate string
- options map[string]RequestOption
-}
-
-const raw_url_key = "request-raw-url"
-
-// NewRequestInformation creates a new RequestInformation object with default values.
-func NewRequestInformation() *RequestInformation {
- return &RequestInformation{
- Headers: make(map[string]string),
- QueryParameters: make(map[string]string),
- options: make(map[string]RequestOption),
- PathParameters: make(map[string]string),
- }
-}
-
-// GetUri returns the URI of the request.
-func (request *RequestInformation) GetUri() (*u.URL, error) {
- if request.uri != nil {
- return request.uri, nil
- } else if request.UrlTemplate == "" {
- return nil, errors.New("uri cannot be empty")
- } else if request.PathParameters == nil {
- return nil, errors.New("uri template parameters cannot be nil")
- } else if request.QueryParameters == nil {
- return nil, errors.New("uri query parameters cannot be nil")
- } else if request.PathParameters[raw_url_key] != "" {
- uri, err := u.Parse(request.PathParameters[raw_url_key])
- if err != nil {
- return nil, err
- }
- request.SetUri(*uri)
- return request.uri, nil
- } else {
- uriTemplate, err := t.New(request.UrlTemplate)
- if err != nil {
- return nil, err
- }
- values := t.Values{}
- varNames := uriTemplate.Varnames()
- normalizedNames := make(map[string]string)
- for _, varName := range varNames {
- normalizedNames[strings.ToLower(varName)] = varName
- }
- for key, value := range request.PathParameters {
- addParameterWithOriginalName(key, value, normalizedNames, values)
- }
- for key, value := range request.QueryParameters {
- addParameterWithOriginalName(key, value, normalizedNames, values)
- }
- url, err := uriTemplate.Expand(values)
- if err != nil {
- return nil, err
- }
- uri, err := u.Parse(url)
- return uri, err
- }
-}
-
-// addParameterWithOriginalName adds the URI template parameter to the template using the right casing, because of go conventions, casing might have changed for the generated property
-func addParameterWithOriginalName(key string, value string, normalizedNames map[string]string, values t.Values) {
- lowercaseKey := strings.ToLower(key)
- if paramName, ok := normalizedNames[lowercaseKey]; ok {
- values.Set(paramName, t.String(value))
- } else {
- values.Set(key, t.String(value))
- }
-}
-
-// SetUri updates the URI for the request from a raw URL.
-func (request *RequestInformation) SetUri(url u.URL) {
- request.uri = &url
- for k := range request.PathParameters {
- delete(request.PathParameters, k)
- }
- for k := range request.QueryParameters {
- delete(request.QueryParameters, k)
- }
-}
-
-// AddRequestOptions adds an option to the request to be read by the middleware infrastructure.
-func (request *RequestInformation) AddRequestOptions(options ...RequestOption) error {
- if options == nil {
- return errors.New("RequestOptions cannot be nil")
- }
- if request.options == nil {
- request.options = make(map[string]RequestOption, len(options))
- }
- for _, option := range options {
- request.options[option.GetKey().Key] = option
- }
- return nil
-}
-
-// GetRequestOptions returns the options for this request. Options are unique by type. If an option of the same type is added twice, the last one wins.
-func (request *RequestInformation) GetRequestOptions() []RequestOption {
- if request.options == nil {
- return []RequestOption{}
- }
- result := make([]RequestOption, len(request.options))
- idx := 0
- for _, option := range request.options {
- result[idx] = option
- idx++
- }
- return result
-}
-
-const contentTypeHeader = "Content-Type"
-const binaryContentType = "application/octet-steam"
-
-// SetStreamContent sets the request body to a binary stream.
-func (request *RequestInformation) SetStreamContent(content []byte) {
- request.Content = content
- request.Headers[contentTypeHeader] = binaryContentType
-}
-
-// SetContentFromParsable sets the request body from a model with the specified content type.
-func (request *RequestInformation) SetContentFromParsable(requestAdapter RequestAdapter, contentType string, items ...s.Parsable) error {
- if contentType == "" {
- return errors.New("content type cannot be empty")
- } else if requestAdapter == nil {
- return errors.New("requestAdapter cannot be nil")
- } else if len(items) == 0 {
- return errors.New("items cannot be nil or empty")
- }
- factory := requestAdapter.GetSerializationWriterFactory()
- if factory == nil {
- return errors.New("factory cannot be nil")
- }
- writer, err := factory.GetSerializationWriter(contentType)
- if err != nil {
- return err
- } else if writer == nil {
- return errors.New("writer cannot be nil")
- }
- defer writer.Close()
- var writeErr error
- if len(items) == 1 {
- writeErr = writer.WriteObjectValue("", items[0])
- } else {
- writeErr = writer.WriteCollectionOfObjectValues("", items)
- }
- if writeErr != nil {
- return writeErr
- }
- content, err := writer.GetSerializedContent()
- if err != nil {
- return err
- } else if content == nil {
- return errors.New("content cannot be nil")
- }
- request.Content = content
- request.Headers[contentTypeHeader] = contentType
- return nil
-}
-
-// AddQueryParameters adds the query parameters to the request by reading the properties from the provided object.
-func (request *RequestInformation) AddQueryParameters(source interface{}) {
- if source == nil || request == nil {
- return
- }
- valOfP := reflect.ValueOf(source)
- fields := reflect.TypeOf(source)
- numOfFields := fields.NumField()
- for i := 0; i < numOfFields; i++ {
- field := fields.Field(i)
- fieldName := field.Name
- fieldValue := valOfP.Field(i)
- str, ok := fieldValue.Interface().(*string)
- if ok && str != nil {
- request.QueryParameters[fieldName] = *str
- }
- bl, ok := fieldValue.Interface().(*bool)
- if ok && bl != nil {
- request.QueryParameters[fieldName] = strconv.FormatBool(*bl)
- }
- it, ok := fieldValue.Interface().(*int32)
- if ok && it != nil {
- request.QueryParameters[fieldName] = strconv.FormatInt(int64(*it), 10)
- }
- arr, ok := fieldValue.Interface().([]string)
- if ok && len(arr) > 0 {
- request.QueryParameters[fieldName] = strings.Join(arr, ",")
- }
- }
-}
diff --git a/abstractions/go/request_information_test.go b/abstractions/go/request_information_test.go
deleted file mode 100644
index 83b3b58b3c..0000000000
--- a/abstractions/go/request_information_test.go
+++ /dev/null
@@ -1,71 +0,0 @@
-package abstractions
-
-import (
- assert "github.com/stretchr/testify/assert"
- "testing"
-)
-
-type QueryParameters struct {
- Count *bool
- Expand []string
- Filter *string
- Orderby []string
- Search *string
- Select_escaped []string
- Skip *int32
- Top *int32
-}
-
-func TestItAddsStringQueryParameters(t *testing.T) {
- requestInformation := NewRequestInformation()
- value := "somefilter"
- queryParameters := QueryParameters{
- Filter: &value,
- }
- requestInformation.AddQueryParameters(queryParameters)
-
- assert.Equal(t, value, requestInformation.QueryParameters["Filter"])
-}
-
-func TestItAddsBoolQueryParameters(t *testing.T) {
- requestInformation := NewRequestInformation()
- value := true
- queryParameters := QueryParameters{
- Count: &value,
- }
- requestInformation.AddQueryParameters(queryParameters)
- assert.Equal(t, "true", requestInformation.QueryParameters["Count"])
-}
-
-func TestItAddsIntQueryParameters(t *testing.T) {
- requestInformation := NewRequestInformation()
- value := int32(42)
- queryParameters := QueryParameters{
- Top: &value,
- }
- requestInformation.AddQueryParameters(queryParameters)
- assert.Equal(t, "42", requestInformation.QueryParameters["Top"])
-}
-
-func TestItAddsStringArrayQueryParameters(t *testing.T) {
- requestInformation := NewRequestInformation()
- value := []string{"somefilter", "someotherfilter"}
- queryParameters := QueryParameters{
- Expand: value,
- }
- requestInformation.AddQueryParameters(queryParameters)
- assert.Equal(t, "somefilter,someotherfilter", requestInformation.QueryParameters["Expand"])
-}
-
-func TestItSetsTheRawURL(t *testing.T) {
- requestInformation := NewRequestInformation()
- requestInformation.PathParameters[raw_url_key] = "https://someurl.com"
- requestInformation.UrlTemplate = "https://someotherurl.com{?select}"
- requestInformation.AddQueryParameters(QueryParameters{
- Select_escaped: []string{"somefield", "somefield2"},
- })
- uri, err := requestInformation.GetUri()
- assert.Nil(t, err)
- assert.Equal(t, "https://someurl.com", uri.String())
- assert.Equal(t, 0, len(requestInformation.QueryParameters))
-}
diff --git a/abstractions/go/request_option.go b/abstractions/go/request_option.go
deleted file mode 100644
index eb4b040d58..0000000000
--- a/abstractions/go/request_option.go
+++ /dev/null
@@ -1,13 +0,0 @@
-package abstractions
-
-// Represents a request option.
-type RequestOption interface {
- // GetKey returns the key to store the current option under.
- GetKey() RequestOptionKey
-}
-
-// RequestOptionKey represents a key to store a request option under.
-type RequestOptionKey struct {
- // The unique key for the option.
- Key string
-}
diff --git a/abstractions/go/response_handler.go b/abstractions/go/response_handler.go
deleted file mode 100644
index 7c729219ba..0000000000
--- a/abstractions/go/response_handler.go
+++ /dev/null
@@ -1,4 +0,0 @@
-package abstractions
-
-// ResponseHandler handler to implement when a request's response should be handled a specific way.
-type ResponseHandler func(response interface{}, errorMappings ErrorMappings) (interface{}, error)
diff --git a/abstractions/go/serialization/additional_data_holder.go b/abstractions/go/serialization/additional_data_holder.go
deleted file mode 100644
index 5ac010ac3a..0000000000
--- a/abstractions/go/serialization/additional_data_holder.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package serialization
-
-// AdditionalDataHolder defines a contract for models that can hold additional data besides the described properties.
-type AdditionalDataHolder interface {
- // GetAdditionalData returns additional data of the object that doesn't belong to a field.
- GetAdditionalData() map[string]interface{}
- // SetAdditionalData sets additional data of the object that doesn't belong to a field.
- SetAdditionalData(value map[string]interface{})
-}
diff --git a/abstractions/go/serialization/date_only.go b/abstractions/go/serialization/date_only.go
deleted file mode 100644
index e064008f54..0000000000
--- a/abstractions/go/serialization/date_only.go
+++ /dev/null
@@ -1,39 +0,0 @@
-package serialization
-
-import (
- "strings"
- "time"
-)
-
-// DateOnly is a struct that represents a date only from a date time (Time).
-type DateOnly struct {
- time time.Time
-}
-
-const dateOnlyFormat = "2006-01-02"
-
-// String returns the date only as a string following the RFC3339 standard.
-func (t DateOnly) String() string {
- return t.time.Format(dateOnlyFormat)
-}
-
-// ParseDateOnly parses a string into a DateOnly following the RFC3339 standard.
-func ParseDateOnly(s string) (*DateOnly, error) {
- if len(strings.TrimSpace(s)) <= 0 {
- return nil, nil
- }
- timeValue, err := time.Parse(dateOnlyFormat, s)
- if err != nil {
- return nil, err
- }
- return &DateOnly{
- time: timeValue,
- }, nil
-}
-
-// NewDateOnly creates a new DateOnly from a time.Time.
-func NewDateOnly(t time.Time) *DateOnly {
- return &DateOnly{
- time: t,
- }
-}
diff --git a/abstractions/go/serialization/date_only_test.go b/abstractions/go/serialization/date_only_test.go
deleted file mode 100644
index 521927aae0..0000000000
--- a/abstractions/go/serialization/date_only_test.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package serialization
-
-import (
- assert "github.com/stretchr/testify/assert"
- "testing"
- "time"
-)
-
-func TestItParsesADateOnly(t *testing.T) {
- dateOnly, err := ParseDateOnly("2020-01-04")
- assert.Nil(t, err)
- assert.Equal(t, "2020-01-04", dateOnly.String())
-}
-
-func TestItDoesntParseAFullDateADateOnly(t *testing.T) {
- _, err := ParseDateOnly("2020-01-04T15:04:05.00000")
- assert.NotNil(t, err)
-}
-
-func TestItCreateANewDateOnly(t *testing.T) {
- dateOnly := NewDateOnly(time.Date(2020, 1, 4, 0, 0, 0, 0, time.UTC))
- assert.Equal(t, "2020-01-04", dateOnly.String())
-}
diff --git a/abstractions/go/serialization/iso_duration.go b/abstractions/go/serialization/iso_duration.go
deleted file mode 100644
index 8f7eb5c70f..0000000000
--- a/abstractions/go/serialization/iso_duration.go
+++ /dev/null
@@ -1,123 +0,0 @@
-package serialization
-
-import (
- "time"
-
- cjl "github.com/cjlapao/common-go/duration"
-)
-
-// ISODuration represents an ISO 8601 duration
-type ISODuration struct {
- duration cjl.Duration
-}
-
-// GetYears returns the number of years.
-func (i ISODuration) GetYears() int {
- return i.duration.Years
-}
-
-// GetWeeks returns the number of weeks.
-func (i ISODuration) GetWeeks() int {
- return i.duration.Weeks
-}
-
-// GetDays returns the number of days.
-func (i ISODuration) GetDays() int {
- return i.duration.Days
-}
-
-// GetHours returns the number of hours.
-func (i ISODuration) GetHours() int {
- return i.duration.Hours
-}
-
-// GetMinutes returns the number of minutes.
-func (i ISODuration) GetMinutes() int {
- return i.duration.Minutes
-}
-
-// GetSeconds returns the number of seconds.
-func (i ISODuration) GetSeconds() int {
- return i.duration.Seconds
-}
-
-// GetMilliSeconds returns the number of milliseconds.
-func (i ISODuration) GetMilliSeconds() int {
- return i.duration.MilliSeconds
-}
-
-// SetYears sets the number of years.
-func (i ISODuration) SetYears(years int) {
- i.duration.Years = years
-}
-
-// SetWeeks sets the number of weeks.
-func (i ISODuration) SetWeeks(weeks int) {
- i.duration.Weeks = weeks
-}
-
-// SetDays sets the number of days.
-func (i ISODuration) SetDays(days int) {
- i.duration.Days = days
-}
-
-// SetHours sets the number of hours.
-func (i ISODuration) SetHours(hours int) {
- i.duration.Hours = hours
-}
-
-// SetMinutes sets the number of minutes.
-func (i ISODuration) SetMinutes(minutes int) {
- i.duration.Minutes = minutes
-}
-
-// SetSeconds sets the number of seconds.
-func (i ISODuration) SetSeconds(seconds int) {
- i.duration.Seconds = seconds
-}
-
-// SetMilliSeconds sets the number of milliseconds.
-func (i ISODuration) SetMilliSeconds(milliSeconds int) {
- i.duration.MilliSeconds = milliSeconds
-}
-
-// ParseISODuration parses a string into an ISODuration following the ISO 8601 standard.
-func ParseISODuration(s string) (*ISODuration, error) {
- d, err := cjl.FromString(s)
- if err != nil {
- return nil, err
- }
- return &ISODuration{
- duration: *d,
- }, nil
-}
-
-// NewISODuration creates a new ISODuration from primitive values.
-func NewDuration(years int, weeks int, days int, hours int, minutes int, seconds int, milliSeconds int) *ISODuration {
- return &ISODuration{
- duration: cjl.Duration{
- Years: years,
- Weeks: weeks,
- Days: days,
- Hours: hours,
- Minutes: minutes,
- Seconds: seconds,
- MilliSeconds: milliSeconds,
- },
- }
-}
-
-// String returns the ISO 8601 representation of the duration.
-func (i ISODuration) String() string {
- return i.duration.String()
-}
-
-// FromDuration returns an ISODuration from a time.Duration.
-func FromDuration(d time.Duration) *ISODuration {
- return NewDuration(0, 0, 0, 0, 0, 0, int(d.Truncate(time.Millisecond).Milliseconds()))
-}
-
-// ToDuration returns the time.Duration representation of the ISODuration.
-func (d ISODuration) ToDuration() (time.Duration, error) {
- return d.duration.ToDuration()
-}
diff --git a/abstractions/go/serialization/iso_duration_test.go b/abstractions/go/serialization/iso_duration_test.go
deleted file mode 100644
index 2220c5f04b..0000000000
--- a/abstractions/go/serialization/iso_duration_test.go
+++ /dev/null
@@ -1,45 +0,0 @@
-package serialization
-
-import (
- assert "github.com/stretchr/testify/assert"
- "testing"
- "time"
-)
-
-func TestItParsesADuration(t *testing.T) {
- duration, err := ParseISODuration("PT1H")
- assert.Nil(t, err)
- assert.Equal(t, "PT1H", duration.String())
-}
-
-func TestItMakesAnISODurationFromATimeDurationFor1h(t *testing.T) {
- duration := time.Duration(1) * time.Hour
- isoDuration := FromDuration(duration)
- assert.Equal(t, "PT1H", isoDuration.String())
-}
-
-func TestItMakesAnISODurationFromATimeDurationFor1d(t *testing.T) {
- duration := time.Duration(24) * time.Hour
- isoDuration := FromDuration(duration)
- assert.Equal(t, "P1D", isoDuration.String())
-}
-
-func TestItMakesAnNewISODurationFor1h(t *testing.T) {
- isoDuration := NewDuration(0, 0, 0, 1, 0, 0, 0)
- assert.Equal(t, "PT1H", isoDuration.String())
-}
-
-func TestItMakesAnNewISODurationFor1dAnd1h(t *testing.T) {
- isoDuration := NewDuration(0, 0, 1, 1, 0, 0, 0)
- assert.Equal(t, "P1DT1H", isoDuration.String())
-}
-
-func TestItMakesAnNewISODurationFor1wAnd1dAnd1h(t *testing.T) {
- isoDuration := NewDuration(0, 1, 1, 1, 0, 0, 0)
- assert.Equal(t, "P1W1DT1H", isoDuration.String())
-}
-
-func TestItMakesAnNewISODurationFor1yAnd1dAnd1h(t *testing.T) {
- isoDuration := NewDuration(1, 0, 1, 1, 0, 0, 0)
- assert.Equal(t, "P1Y1DT1H", isoDuration.String())
-}
diff --git a/abstractions/go/serialization/parsable.go b/abstractions/go/serialization/parsable.go
deleted file mode 100644
index cbc47cf633..0000000000
--- a/abstractions/go/serialization/parsable.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package serialization
-
-// Parsable defines a serializable model object.
-type Parsable interface {
- // Serialize writes the objects properties to the current writer.
- Serialize(writer SerializationWriter) error
- // GetFieldDeserializers returns the deserialization information for this object.
- GetFieldDeserializers() map[string]func(interface{}, ParseNode) error
-}
-
-// ParsableFactory is a factory for creating Parsable.
-type ParsableFactory func(parseNode ParseNode) (Parsable, error)
diff --git a/abstractions/go/serialization/parse_node.go b/abstractions/go/serialization/parse_node.go
deleted file mode 100644
index c47717b4a8..0000000000
--- a/abstractions/go/serialization/parse_node.go
+++ /dev/null
@@ -1,51 +0,0 @@
-package serialization
-
-import (
- "time"
-
- "github.com/google/uuid"
-)
-
-// ParseNode Interface for a deserialization node in a parse tree. This interace provides an abstraction layer over serialization formats, libraries and implementations.
-type ParseNode interface {
- // GetChildNode returns a new parse node for the given identifier.
- GetChildNode(index string) (ParseNode, error)
- // GetCollectionOfObjectValues returns the collection of Parsable values from the node.
- GetCollectionOfObjectValues(ctor ParsableFactory) ([]Parsable, error)
- // GetCollectionOfPrimitiveValues returns the collection of primitive values from the node.
- GetCollectionOfPrimitiveValues(targetType string) ([]interface{}, error)
- // GetCollectionOfEnumValues returns the collection of Enum values from the node.
- GetCollectionOfEnumValues(parser func(string) (interface{}, error)) ([]interface{}, error)
- // GetObjectValue returns the Parsable value from the node.
- GetObjectValue(ctor ParsableFactory) (Parsable, error)
- // GetStringValue returns a String value from the nodes.
- GetStringValue() (*string, error)
- // GetBoolValue returns a Bool value from the nodes.
- GetBoolValue() (*bool, error)
- // GetInt8Value returns a int8 value from the nodes.
- GetInt8Value() (*int8, error)
- // GetByteValue returns a Byte value from the nodes.
- GetByteValue() (*byte, error)
- // GetFloat32Value returns a Float32 value from the nodes.
- GetFloat32Value() (*float32, error)
- // GetFloat64Value returns a Float64 value from the nodes.
- GetFloat64Value() (*float64, error)
- // GetInt32Value returns a Int32 value from the nodes.
- GetInt32Value() (*int32, error)
- // GetInt64Value returns a Int64 value from the nodes.
- GetInt64Value() (*int64, error)
- // GetTimeValue returns a Time value from the nodes.
- GetTimeValue() (*time.Time, error)
- // GetISODurationValue returns a ISODuration value from the nodes.
- GetISODurationValue() (*ISODuration, error)
- // GetTimeOnlyValue returns a TimeOnly value from the nodes.
- GetTimeOnlyValue() (*TimeOnly, error)
- // GetDateOnlyValue returns a DateOnly value from the nodes.
- GetDateOnlyValue() (*DateOnly, error)
- // GetUUIDValue returns a UUID value from the nodes.
- GetUUIDValue() (*uuid.UUID, error)
- // GetEnumValue returns a Enum value from the nodes.
- GetEnumValue(parser func(string) (interface{}, error)) (interface{}, error)
- // GetByteArrayValue returns a ByteArray value from the nodes.
- GetByteArrayValue() ([]byte, error)
-}
diff --git a/abstractions/go/serialization/parse_node_factory.go b/abstractions/go/serialization/parse_node_factory.go
deleted file mode 100644
index 70feb92747..0000000000
--- a/abstractions/go/serialization/parse_node_factory.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package serialization
-
-// ParseNodeFactory defines the contract for a factory that creates new ParseNode.
-type ParseNodeFactory interface {
- // GetValidContentType returns the content type this factory's parse nodes can deserialize.
- GetValidContentType() (string, error)
- // GetRootParseNode return a new ParseNode instance that is the root of the content
- GetRootParseNode(contentType string, content []byte) (ParseNode, error)
-}
diff --git a/abstractions/go/serialization/parse_node_factory_registry.go b/abstractions/go/serialization/parse_node_factory_registry.go
deleted file mode 100644
index f1b56ae4c7..0000000000
--- a/abstractions/go/serialization/parse_node_factory_registry.go
+++ /dev/null
@@ -1,45 +0,0 @@
-package serialization
-
-import (
- "errors"
- re "regexp"
- "strings"
-)
-
-// ParseNodeFactoryRegistry holds a list of all the registered factories for the various types of nodes.
-type ParseNodeFactoryRegistry struct {
- ContentTypeAssociatedFactories map[string]ParseNodeFactory
-}
-
-// DefaultParseNodeFactoryInstance is the default singleton instance of the registry to be used when registering new factories that should be available by default.
-var DefaultParseNodeFactoryInstance = &ParseNodeFactoryRegistry{
- ContentTypeAssociatedFactories: make(map[string]ParseNodeFactory),
-}
-
-// GetValidContentType returns the valid content type for the ParseNodeFactoryRegistry
-func (m *ParseNodeFactoryRegistry) GetValidContentType() (string, error) {
- return "", errors.New("the registry supports multiple content types. Get the registered factory instead")
-}
-
-var contentTypeVendorCleanupPattern = re.MustCompile("[^/]+\\+")
-
-// GetRootParseNode returns a new ParseNode instance that is the root of the content
-func (m *ParseNodeFactoryRegistry) GetRootParseNode(contentType string, content []byte) (ParseNode, error) {
- if contentType == "" {
- return nil, errors.New("contentType is required")
- }
- if content == nil {
- return nil, errors.New("content is required")
- }
- vendorSpecificContentType := strings.Split(contentType, ";")[0]
- factory, ok := m.ContentTypeAssociatedFactories[vendorSpecificContentType]
- if ok {
- return factory.GetRootParseNode(vendorSpecificContentType, content)
- }
- cleanedContentType := contentTypeVendorCleanupPattern.ReplaceAllString(vendorSpecificContentType, "")
- factory, ok = m.ContentTypeAssociatedFactories[cleanedContentType]
- if ok {
- return factory.GetRootParseNode(cleanedContentType, content)
- }
- return nil, errors.New("content type " + cleanedContentType + " does not have a factory registered to be parsed")
-}
diff --git a/abstractions/go/serialization/serialization_writer.go b/abstractions/go/serialization/serialization_writer.go
deleted file mode 100644
index 754c5e9e1c..0000000000
--- a/abstractions/go/serialization/serialization_writer.go
+++ /dev/null
@@ -1,75 +0,0 @@
-package serialization
-
-import (
- i "io"
- "time"
-
- "github.com/google/uuid"
-)
-
-// SerializationWriter defines an interface for serialization of models to a byte array.
-type SerializationWriter interface {
- i.Closer
- // WriteStringValue writes a String value to underlying the byte array.
- WriteStringValue(key string, value *string) error
- // WriteBoolValue writes a Bool value to underlying the byte array.
- WriteBoolValue(key string, value *bool) error
- // WriteInt8Value writes a int8 value to underlying the byte array.
- WriteInt8Value(key string, value *int8) error
- // WriteByteValue writes a Byte value to underlying the byte array.
- WriteByteValue(key string, value *byte) error
- // WriteInt32Value writes a Int32 value to underlying the byte array.
- WriteInt32Value(key string, value *int32) error
- // WriteInt64Value writes a Int64 value to underlying the byte array.
- WriteInt64Value(key string, value *int64) error
- // WriteFloat32Value writes a Float32 value to underlying the byte array.
- WriteFloat32Value(key string, value *float32) error
- // WriteFloat64Value writes a Float64 value to underlying the byte array.
- WriteFloat64Value(key string, value *float64) error
- // WriteByteArrayValue writes a ByteArray value to underlying the byte array.
- WriteByteArrayValue(key string, value []byte) error
- // WriteTimeValue writes a Time value to underlying the byte array.
- WriteTimeValue(key string, value *time.Time) error
- // WriteTimeOnlyValue writes the time part of a Time value to underlying the byte array.
- WriteTimeOnlyValue(key string, value *TimeOnly) error
- // WriteDateOnlyValue writes the date part of a Time value to underlying the byte array.
- WriteDateOnlyValue(key string, value *DateOnly) error
- // WriteISODurationValue writes a ISODuration value to underlying the byte array.
- WriteISODurationValue(key string, value *ISODuration) error
- // WriteUUIDValue writes a UUID value to underlying the byte array.
- WriteUUIDValue(key string, value *uuid.UUID) error
- // WriteObjectValue writes a Parsable value to underlying the byte array.
- WriteObjectValue(key string, item Parsable) error
- // WriteCollectionOfObjectValues writes a collection of Parsable values to underlying the byte array.
- WriteCollectionOfObjectValues(key string, collection []Parsable) error
- // WriteCollectionOfStringValues writes a collection of String values to underlying the byte array.
- WriteCollectionOfStringValues(key string, collection []string) error
- // WriteCollectionOfBoolValues writes a collection of Bool values to underlying the byte array.
- WriteCollectionOfBoolValues(key string, collection []bool) error
- // WriteCollectionOfInt8Values writes a collection of Int8 values to underlying the byte array.
- WriteCollectionOfInt8Values(key string, collection []int8) error
- // WriteCollectionOfByteValues writes a collection of Byte values to underlying the byte array.
- WriteCollectionOfByteValues(key string, collection []byte) error
- // WriteCollectionOfInt32Values writes a collection of Int32 values to underlying the byte array.
- WriteCollectionOfInt32Values(key string, collection []int32) error
- // WriteCollectionOfInt64Values writes a collection of Int64 values to underlying the byte array.
- WriteCollectionOfInt64Values(key string, collection []int64) error
- // WriteCollectionOfFloat32Values writes a collection of Float32 values to underlying the byte array.
- WriteCollectionOfFloat32Values(key string, collection []float32) error
- // WriteCollectionOfFloat64Values writes a collection of Float64 values to underlying the byte array.
- WriteCollectionOfFloat64Values(key string, collection []float64) error
- // WriteCollectionOfTimeValues writes a collection of Time values to underlying the byte array.
- WriteCollectionOfTimeValues(key string, collection []time.Time) error
- // WriteCollectionOfISODurationValues writes a collection of ISODuration values to underlying the byte array.
- WriteCollectionOfISODurationValues(key string, collection []ISODuration) error
- // WriteCollectionOfDateOnlyValues writes a collection of DateOnly values to underlying the byte array.
- WriteCollectionOfDateOnlyValues(key string, collection []DateOnly) error
- // WriteCollectionOfTimeOnlyValues writes a collection of TimeOnly values to underlying the byte array.
- WriteCollectionOfTimeOnlyValues(key string, collection []TimeOnly) error
- // WriteCollectionOfUUIDValues writes a collection of UUID values to underlying the byte array.
- WriteCollectionOfUUIDValues(key string, collection []uuid.UUID) error
- // GetSerializedContent returns the resulting byte array from the serialization writer.
- GetSerializedContent() ([]byte, error)
- // WriteAdditionalData writes additional data to underlying the byte array.
- WriteAdditionalData(value map[string]interface{}) error
-}
diff --git a/abstractions/go/serialization/serialization_writer_factory.go b/abstractions/go/serialization/serialization_writer_factory.go
deleted file mode 100644
index ca501b85dd..0000000000
--- a/abstractions/go/serialization/serialization_writer_factory.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package serialization
-
-// SerializationWriterFactory defines the contract for a factory that creates SerializationWriter instances.
-type SerializationWriterFactory interface {
- // GetValidContentType returns the valid content type for the SerializationWriterFactoryRegistry
- GetValidContentType() (string, error)
- // GetSerializationWriter returns the relevant SerializationWriter instance for the given content type
- GetSerializationWriter(contentType string) (SerializationWriter, error)
-}
diff --git a/abstractions/go/serialization/serialization_writer_factory_registry.go b/abstractions/go/serialization/serialization_writer_factory_registry.go
deleted file mode 100644
index 13559adc63..0000000000
--- a/abstractions/go/serialization/serialization_writer_factory_registry.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package serialization
-
-import (
- "errors"
- "strings"
-)
-
-// SerializationWriterFactoryRegistry is a factory holds a list of all the registered factories for the various types of nodes.
-type SerializationWriterFactoryRegistry struct {
- // ContentTypeAssociatedFactories list of factories that are registered by content type.
- ContentTypeAssociatedFactories map[string]SerializationWriterFactory
-}
-
-// DefaultSerializationWriterFactoryInstance is the default singleton instance of the registry to be used when registering new factories that should be available by default.
-var DefaultSerializationWriterFactoryInstance = &SerializationWriterFactoryRegistry{
- ContentTypeAssociatedFactories: make(map[string]SerializationWriterFactory),
-}
-
-// GetValidContentType returns the valid content type for the SerializationWriterFactoryRegistry
-func (m *SerializationWriterFactoryRegistry) GetValidContentType() (string, error) {
- return "", errors.New("the registry supports multiple content types. Get the registered factory instead")
-}
-
-// GetSerializationWriter returns the relevant SerializationWriter instance for the given content type
-func (m *SerializationWriterFactoryRegistry) GetSerializationWriter(contentType string) (SerializationWriter, error) {
- if contentType == "" {
- return nil, errors.New("the content type is empty")
- }
- vendorSpecificContentType := strings.Split(contentType, ";")[0]
- factory, ok := m.ContentTypeAssociatedFactories[vendorSpecificContentType]
- if ok {
- return factory.GetSerializationWriter(contentType)
- }
- cleanedContentType := contentTypeVendorCleanupPattern.ReplaceAllString(vendorSpecificContentType, "")
- factory, ok = m.ContentTypeAssociatedFactories[cleanedContentType]
- if ok {
- return factory.GetSerializationWriter(cleanedContentType)
- }
- return nil, errors.New("Content type " + cleanedContentType + " does not have a factory registered to be parsed")
-}
diff --git a/abstractions/go/serialization/serialization_writer_factory_registry_test.go b/abstractions/go/serialization/serialization_writer_factory_registry_test.go
deleted file mode 100644
index e1a52c8c1c..0000000000
--- a/abstractions/go/serialization/serialization_writer_factory_registry_test.go
+++ /dev/null
@@ -1,123 +0,0 @@
-package serialization
-
-import (
- assert "github.com/stretchr/testify/assert"
- "testing"
- "github.com/stretchr/testify/mock"
-)
-type mockSerializer struct {
-}
-
-func (*mockSerializer) WriteStringValue(key string, value *string) error {
- return nil
-}
-func (*mockSerializer) WriteBoolValue(key string, value *bool) error {
- return nil
-}
-func (*mockSerializer) WriteByteValue(key string, value *byte) error {
- return nil
-}
-func (*mockSerializer) WriteInt8Value(key string, value *int8) error {
- return nil
-}
-func (*mockSerializer) WriteInt32Value(key string, value *int32) error {
- return nil
-}
-func (*mockSerializer) WriteInt64Value(key string, value *int64) error {
- return nil
-}
-func (*mockSerializer) WriteFloat32Value(key string, value *float32) error {
- return nil
-}
-func (*mockSerializer) WriteFloat64Value(key string, value *float64) error {
- return nil
-}
-func (*mockSerializer) WriteByteArrayValue(key string, value []byte) error {
- return nil
-}
-func (*mockSerializer) WriteTimeValue(key string, value *time.Time) error {
- return nil
-}
-func (*mockSerializer) WriteISODurationValue(key string, value *serialization.ISODuration) error {
- return nil
-}
-func (*mockSerializer) WriteDateOnlyValue(key string, value *serialization.DateOnly) error {
- return nil
-}
-func (*mockSerializer) WriteTimeOnlyValue(key string, value *serialization.TimeOnly) error {
- return nil
-}
-func (*mockSerializer) WriteUUIDValue(key string, value *uuid.UUID) error {
- return nil
-}
-func (*mockSerializer) WriteObjectValue(key string, item serialization.Parsable) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfObjectValues(key string, collection []serialization.Parsable) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfStringValues(key string, collection []string) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfBoolValues(key string, collection []bool) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfByteValues(key string, collection []byte) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfInt8Values(key string, collection []int8) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfInt32Values(key string, collection []int32) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfInt64Values(key string, collection []int64) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfFloat32Values(key string, collection []float32) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfFloat64Values(key string, collection []float64) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfTimeValues(key string, collection []time.Time) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfISODurationValues(key string, collection []serialization.ISODuration) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfDateOnlyValues(key string, collection []serialization.DateOnly) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfTimeOnlyValues(key string, collection []serialization.TimeOnly) error {
- return nil
-}
-func (*mockSerializer) WriteCollectionOfUUIDValues(key string, collection []uuid.UUID) error {
- return nil
-}
-func (*mockSerializer) GetSerializedContent() ([]byte, error) {
- return nil, nil
-}
-func (*mockSerializer) WriteAdditionalData(value map[string]interface{}) error {
- return nil
-}
-func (*mockSerializer) Close() error {
- return nil
-}
-
-type mockSerializerFactory struct {
-}
-
-func (*mockSerializerFactory) GetValidContentType() (string, error) {
- return "application/json", nil
-}
-func (*mockSerializerFactory) GetSerializationWriter(contentType string) (serialization.SerializationWriter, error) {
- return &mockSerializer{}, nil
-}
-
-func TestItGetsVendorSpecificSerializationWriter(t *testing.T) {
- registry := NewSerializationWriterFactoryRegistry()
- registry.ContentTypeAssociatedFactories["application/json"] = &mockSerializerFactory{}
- serializationWriter = registry.GetSerializationWriter("application/vnd+json")
- assert.NotNil(t, serializationWriter)
-}
diff --git a/abstractions/go/serialization/time_only.go b/abstractions/go/serialization/time_only.go
deleted file mode 100644
index 7c0955c1b5..0000000000
--- a/abstractions/go/serialization/time_only.go
+++ /dev/null
@@ -1,62 +0,0 @@
-package serialization
-
-import (
- "errors"
- "strings"
- "time"
-)
-
-// TimeOnly is represents the time part of a date time (time) value.
-type TimeOnly struct {
- time time.Time
-}
-
-const timeOnlyFormat = "15:04:05.000000000"
-
-var timeOnlyParsingFormats = map[int]string{
- 0: "15:04:05", //Go doesn't seem to support optional parameters in time.Parse, which is sad
- 1: "15:04:05.0",
- 2: "15:04:05.00",
- 3: "15:04:05.000",
- 4: "15:04:05.0000",
- 5: "15:04:05.00000",
- 6: "15:04:05.000000",
- 7: "15:04:05.0000000",
- 8: "15:04:05.00000000",
- 9: timeOnlyFormat,
-}
-
-// String returns the time only as a string following the RFC3339 standard.
-func (t TimeOnly) String() string {
- return t.time.Format(timeOnlyFormat)
-}
-
-// ParseTimeOnly parses a string into a TimeOnly following the RFC3339 standard.
-func ParseTimeOnly(s string) (*TimeOnly, error) {
- if len(strings.TrimSpace(s)) <= 0 {
- return nil, nil
- }
- splat := strings.Split(s, ".")
- parsingFormat := timeOnlyParsingFormats[0]
- if len(splat) > 1 {
- dotSectionLen := len(splat[1])
- if dotSectionLen >= len(timeOnlyParsingFormats) {
- return nil, errors.New("too many decimal places in time only string")
- }
- parsingFormat = timeOnlyParsingFormats[dotSectionLen]
- }
- timeValue, err := time.Parse(parsingFormat, s)
- if err != nil {
- return nil, err
- }
- return &TimeOnly{
- time: timeValue,
- }, nil
-}
-
-// NewTimeOnly creates a new TimeOnly from a time.Time.
-func NewTimeOnly(t time.Time) *TimeOnly {
- return &TimeOnly{
- time: t,
- }
-}
diff --git a/abstractions/go/serialization/time_only_test.go b/abstractions/go/serialization/time_only_test.go
deleted file mode 100644
index f4cecfda22..0000000000
--- a/abstractions/go/serialization/time_only_test.go
+++ /dev/null
@@ -1,34 +0,0 @@
-package serialization
-
-import (
- assert "github.com/stretchr/testify/assert"
- "testing"
- "time"
-)
-
-func TestItParsesATimeOnly(t *testing.T) {
- dateOnly, err := ParseTimeOnly("16:20:21.000")
- assert.Nil(t, err)
- assert.Equal(t, "16:20:21.000000000", dateOnly.String())
-}
-
-func TestItParsesATimeOnlyNoDecimals(t *testing.T) {
- dateOnly, err := ParseTimeOnly("16:20:21")
- assert.Nil(t, err)
- assert.Equal(t, "16:20:21.000000000", dateOnly.String())
-}
-
-func TestItDoesntParseATimeOnlyWithTooManyDecimals(t *testing.T) {
- _, err := ParseTimeOnly("2020-01-04T15:04:05.00000000000000000000")
- assert.NotNil(t, err)
-}
-
-func TestItDoesntParseAFullDateATimeOnly(t *testing.T) {
- _, err := ParseTimeOnly("2020-01-04T15:04:05.00000")
- assert.NotNil(t, err)
-}
-
-func TestItCreateANewTimeOnly(t *testing.T) {
- dateOnly := NewTimeOnly(time.Date(1, 1, 1, 16, 20, 21, 0, time.UTC))
- assert.Equal(t, "16:20:21.000000000", dateOnly.String())
-}
diff --git a/authentication/README.md b/authentication/README.md
index d5bd10fa21..a7f4555cbb 100644
--- a/authentication/README.md
+++ b/authentication/README.md
@@ -4,7 +4,7 @@ The Kiota Authentication libraries are language specific libraries implementing
Your project will need a reference to the abstraction package to build and run, the following languages are currently supported:
- [Dotnet](https://github.com/microsoft/kiota-authentication-azure-dotnet): relies on [Azure identity](https://www.nuget.org/packages/Azure.Identity).
-- [Go](./go/azure): relies on [Azure identity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity)
+- [Go](https://github.com/microsoft/kiota-authentication-azure-go/): relies on [Azure identity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity)
- [Java](./java/azure) : relies on [Azure identity](https://docs.microsoft.com/en-us/java/api/overview/azure/identity-readme?view=azure-java-stable).
- [TypeScript](https://github.com/microsoft/kiota-typescript/tree/main/packages/authentication/azure) : relies on [Azure identity](https://www.npmjs.com/package/@azure/identity).
- [Python](./python/azure) : relies on [Azure identity](https://pypi.org/project/azure-identity/).
diff --git a/authentication/go/azure/README.md b/authentication/go/azure/README.md
deleted file mode 100644
index a881f7a8fe..0000000000
--- a/authentication/go/azure/README.md
+++ /dev/null
@@ -1,24 +0,0 @@
-# To-do
-
-![Go](https://github.com/microsoft/kiota/actions/workflows/authentication-go-azure.yml/badge.svg)
-
-- [ ] unit tests
-- [ ] move to its own repo and implement [the guidelines](https://golang.org/doc/#developing-modules) to make referencing the module easier
-- [ ] add doc.go
-- [ ] rename module name, update reference and remove the replace directive
-
-## Using the Azure Authentication library
-
-1. Navigate to the directory where `go.mod` is located for your project.
-1. Run the following command:
-
- ```Shell
- go get github.com/microsoft/kiota/authentication/go/azure
- ```
-
-1. In the code
-
- ```Golang
- cred, err := azidentity.NewDeviceCodeCredential(nil)
- authProvider, err := kiotaazure.NewAzureIdentityAuthenticationProviderWithScopes(cred, []string{"User.Read"})
- ```
diff --git a/authentication/go/azure/azure_identity_access_token_provider.go b/authentication/go/azure/azure_identity_access_token_provider.go
deleted file mode 100644
index f3c8bc2c7e..0000000000
--- a/authentication/go/azure/azure_identity_access_token_provider.go
+++ /dev/null
@@ -1,78 +0,0 @@
-package microsoft_kiota_authentication_azure
-
-import (
- "context"
- "errors"
- "strings"
-
- u "net/url"
-
- azcore "github.com/Azure/azure-sdk-for-go/sdk/azcore"
- azpolicy "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
- absauth "github.com/microsoft/kiota/abstractions/go/authentication"
-)
-
-// AzureIdentityAccessTokenProvider implementation of AccessTokenProvider that supports implementations of TokenCredential from Azure.Identity.
-type AzureIdentityAccessTokenProvider struct {
- scopes []string
- credential azcore.TokenCredential
- allowedHostsValidator *absauth.AllowedHostsValidator
-}
-
-// NewAzureIdentityAccessTokenProvider creates a new instance of the AzureIdentityAccessTokenProvider using "https://graph.microsoft.com/.default" as the default scope.
-func NewAzureIdentityAccessTokenProvider(credential azcore.TokenCredential) (*AzureIdentityAccessTokenProvider, error) {
- return NewAzureIdentityAccessTokenProviderWithScopes(credential, nil)
-}
-
-// NewAzureIdentityAccessTokenProviderWithScopes creates a new instance of the AzureIdentityAccessTokenProvider.
-func NewAzureIdentityAccessTokenProviderWithScopes(credential azcore.TokenCredential, scopes []string) (*AzureIdentityAccessTokenProvider, error) {
- return NewAzureIdentityAccessTokenProviderWithScopesAndValidHosts(credential, scopes, nil)
-}
-
-// NewAzureIdentityAccessTokenProviderWithScopesAndValidhosts creates a new instance of the AzureIdentityAccessTokenProvider.
-func NewAzureIdentityAccessTokenProviderWithScopesAndValidHosts(credential azcore.TokenCredential, scopes []string, validhosts []string) (*AzureIdentityAccessTokenProvider, error) {
- if credential == nil {
- return nil, errors.New("credential cannot be nil")
- }
- scopesLen := len(scopes)
- finalScopes := make([]string, scopesLen)
- if scopesLen == 0 {
- finalScopes = append(finalScopes, "https://graph.microsoft.com/.default")
- } else {
- copy(finalScopes, scopes)
- }
- validator := absauth.NewAllowedHostsValidator(validhosts)
- if len(validhosts) == 0 {
- validator = absauth.NewAllowedHostsValidator([]string{"graph.microsoft.com", "graph.microsoft.us", "dod-graph.microsoft.us", "graph.microsoft.de", "microsoftgraph.chinacloudapi.cn", "canary.graph.microsoft.com"})
- }
- result := &AzureIdentityAccessTokenProvider{
- credential: credential,
- scopes: finalScopes,
- allowedHostsValidator: &validator,
- }
-
- return result, nil
-}
-
-// GetAuthorizationToken returns the access token for the provided url.
-func (p *AzureIdentityAccessTokenProvider) GetAuthorizationToken(url *u.URL) (string, error) {
- if !(*(p.allowedHostsValidator)).IsUrlHostValid(url) {
- return "", nil
- }
- if !strings.EqualFold(url.Scheme, "https") {
- return "", errors.New("url scheme must be https")
- }
- options := azpolicy.TokenRequestOptions{
- Scopes: p.scopes,
- }
- token, err := p.credential.GetToken(context.Background(), options)
- if err != nil {
- return "", err
- }
- return token.Token, nil
-}
-
-// GetAllowedHostsValidator returns the hosts validator.
-func (p *AzureIdentityAccessTokenProvider) GetAllowedHostsValidator() *absauth.AllowedHostsValidator {
- return p.allowedHostsValidator
-}
diff --git a/authentication/go/azure/azure_identity_access_token_provider_test.go b/authentication/go/azure/azure_identity_access_token_provider_test.go
deleted file mode 100644
index 4dce44b92d..0000000000
--- a/authentication/go/azure/azure_identity_access_token_provider_test.go
+++ /dev/null
@@ -1,63 +0,0 @@
-package microsoft_kiota_authentication_azure
-
-import (
- "context"
- azcore "github.com/Azure/azure-sdk-for-go/sdk/azcore"
- policy "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
- assert "github.com/stretchr/testify/assert"
- u "net/url"
- "testing"
-)
-
-type MockTokenCredential struct {
- TokenValue string
-}
-
-func (m *MockTokenCredential) GetToken(ctx context.Context, options policy.TokenRequestOptions) (*azcore.AccessToken, error) {
- return &azcore.AccessToken{
- Token: m.TokenValue,
- }, nil
-}
-
-func TestAddsTokenOnValidHost(t *testing.T) {
- provider, err := NewAzureIdentityAccessTokenProvider(&MockTokenCredential{TokenValue: "token"})
- assert.Nil(t, err)
- assert.NotNil(t, provider)
-
- token, err := provider.GetAuthorizationToken(&u.URL{Host: "graph.microsoft.com", Scheme: "https"})
- assert.Nil(t, err)
- assert.Equal(t, "token", token)
-}
-
-func TestAddsTokenOnValidHostFromParse(t *testing.T) {
- provider, err := NewAzureIdentityAccessTokenProvider(&MockTokenCredential{TokenValue: "token"})
- assert.Nil(t, err)
- assert.NotNil(t, provider)
-
- url, err := u.Parse("https://graph.microsoft.com")
- assert.Nil(t, err)
-
- token, err := provider.GetAuthorizationToken(url)
- assert.Nil(t, err)
- assert.Equal(t, "token", token)
-}
-
-func TestDoesntAddTokenOnDifferentHost(t *testing.T) {
- provider, err := NewAzureIdentityAccessTokenProvider(&MockTokenCredential{TokenValue: "token"})
- assert.Nil(t, err)
- assert.NotNil(t, provider)
-
- token, err := provider.GetAuthorizationToken(&u.URL{Host: "differenthost.com"})
- assert.Nil(t, err)
- assert.Empty(t, token)
-}
-
-func TestDoesntAddTokenOnHttp(t *testing.T) {
- provider, err := NewAzureIdentityAccessTokenProvider(&MockTokenCredential{TokenValue: "token"})
- assert.Nil(t, err)
- assert.NotNil(t, provider)
-
- token, err := provider.GetAuthorizationToken(&u.URL{Host: "differenthost.com", Scheme: "http"})
- assert.Nil(t, err)
- assert.Empty(t, token)
-}
diff --git a/authentication/go/azure/azure_identity_authentication_provider.go b/authentication/go/azure/azure_identity_authentication_provider.go
deleted file mode 100644
index dde4cd1274..0000000000
--- a/authentication/go/azure/azure_identity_authentication_provider.go
+++ /dev/null
@@ -1,36 +0,0 @@
-// Package microsoft_kiota_authentication_azure implements Kiota abstractions for authentication using the Azure Core library.
-// In order to use this package, you must also add the github.com/Azure/azure-sdk-for-go/sdk/azidentity.
-package microsoft_kiota_authentication_azure
-
-import (
- azcore "github.com/Azure/azure-sdk-for-go/sdk/azcore"
- auth "github.com/microsoft/kiota/abstractions/go/authentication"
-)
-
-// AzureIdentityAuthenticationProvider implementation of AuthenticationProvider that supports implementations of TokenCredential from Azure.Identity.
-type AzureIdentityAuthenticationProvider struct {
- auth.BaseBearerTokenAuthenticationProvider
-}
-
-// NewAzureIdentityAuthenticationProvider creates a new instance of the AzureIdentityAuthenticationProvider using "https://graph.microsoft.com/.default" as the default scope.
-func NewAzureIdentityAuthenticationProvider(credential azcore.TokenCredential) (*AzureIdentityAuthenticationProvider, error) {
- return NewAzureIdentityAuthenticationProviderWithScopes(credential, nil)
-}
-
-// NewAzureIdentityAuthenticationProviderWithScopes creates a new instance of the AzureIdentityAuthenticationProvider.
-func NewAzureIdentityAuthenticationProviderWithScopes(credential azcore.TokenCredential, scopes []string) (*AzureIdentityAuthenticationProvider, error) {
- return NewAzureIdentityAuthenticationProviderWithScopesAndValidHosts(credential, scopes, nil)
-}
-
-// NewAzureIdentityAuthenticationProviderWithScopesAndValidHosts creates a new instance of the AzureIdentityAuthenticationProvider.
-func NewAzureIdentityAuthenticationProviderWithScopesAndValidHosts(credential azcore.TokenCredential, scopes []string, validhosts []string) (*AzureIdentityAuthenticationProvider, error) {
- accessTokenProvider, err := NewAzureIdentityAccessTokenProviderWithScopesAndValidHosts(credential, scopes, validhosts)
- if err != nil {
- return nil, err
- }
- baseBearer := auth.NewBaseBearerTokenAuthenticationProvider(accessTokenProvider)
- result := &AzureIdentityAuthenticationProvider{
- BaseBearerTokenAuthenticationProvider: *baseBearer,
- }
- return result, nil
-}
diff --git a/authentication/go/azure/go.mod b/authentication/go/azure/go.mod
deleted file mode 100644
index 552ce83e50..0000000000
--- a/authentication/go/azure/go.mod
+++ /dev/null
@@ -1,21 +0,0 @@
-module github.com/microsoft/kiota/authentication/go/azure
-
-go 1.17
-
-require (
- github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0
- github.com/microsoft/kiota/abstractions/go v0.0.0-20220203083330-462603bf370f
- github.com/stretchr/testify v1.7.0
-)
-
-require (
- github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1 // indirect
- github.com/cjlapao/common-go v0.0.18 // indirect
- github.com/davecgh/go-spew v1.1.1 // indirect
- github.com/google/uuid v1.3.0 // indirect
- github.com/pmezard/go-difflib v1.0.0 // indirect
- github.com/yosida95/uritemplate/v3 v3.0.1 // indirect
- golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
- golang.org/x/text v0.3.7 // indirect
- gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
-)
diff --git a/authentication/go/azure/go.sum b/authentication/go/azure/go.sum
deleted file mode 100644
index e2261a7a31..0000000000
--- a/authentication/go/azure/go.sum
+++ /dev/null
@@ -1,51 +0,0 @@
-github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0 h1:8wVJL0HUP5yDFXvotdewORTw7Yu88JbreWN/mobSvsQ=
-github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM=
-github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I=
-github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1 h1:sLZ/Y+P/5RRtsXWylBjB5lkgixYfm0MQPiwrSX//JSo=
-github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I=
-github.com/cjlapao/common-go v0.0.18 h1:j6kT/0pmJ69HmUCs9LrCc7IWyxTOh2WYJyZMzUYTULs=
-github.com/cjlapao/common-go v0.0.18/go.mod h1:zGdh2KmXnH4HTRfT7vPpY41cws776KULk44f09OPJgs=
-github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
-github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko=
-github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
-github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220202140831-13ba7796cb22 h1:ZESe8hZcWwGo+Y4YrV6bS6/MQQ1lybP89bWf10CuEp0=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220202140831-13ba7796cb22/go.mod h1:BUv5PFNuBLFXQlDtarjdgqdqDjee3FgfjrNkfZlA5us=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220203083330-462603bf370f h1:uW+dBi9EsNsfbaV44vIm/fOnpTDkOTmoc1hCnsaeDWs=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220203083330-462603bf370f/go.mod h1:BUv5PFNuBLFXQlDtarjdgqdqDjee3FgfjrNkfZlA5us=
-github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8=
-github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
-github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
-github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/yosida95/uritemplate/v3 v3.0.1 h1:+Fs//CsT+x231WmUQhMHWMxZizMvpnkOVWop02mVCfs=
-github.com/yosida95/uritemplate/v3 v3.0.1/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
-golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
-golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
-golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
-golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
-golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk=
-golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
-golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
-golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
-golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
-golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
-golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
-golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
-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.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
-gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
-gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
-gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/docs/get-started/go.md b/docs/get-started/go.md
index ecd2fdd660..76b905464a 100644
--- a/docs/get-started/go.md
+++ b/docs/get-started/go.md
@@ -10,7 +10,7 @@ parent: Get started
## Target project requirements
-Before you can compile and run the target project, you will need to initialize it. After initializing the test project, you will need to add references to the [abstraction](https://github.com/microsoft/kiota/tree/main/abstractions/go/), [authentication](https://github.com/microsoft/kiota/tree/main/authentication/go/azure), [http](https://github.com/microsoft/kiota/tree/main/http/go/http/), and [serialization](https://github.com/microsoft/kiota/tree/main/serialization/go/json/) packages from the GitHub feed.
+Before you can compile and run the target project, you will need to initialize it. After initializing the test project, you will need to add references to the [abstraction](https://github.com/microsoft/kiota-abstractions-go), [authentication](https://github.com/microsoft/kiota-authentication-azure-go), [http](https://github.com/microsoft/kiota-http-go), [serialization JSON](https://github.com/microsoft/kiota-serialization-json-go), and [serialization Text](https://github.com/microsoft/kiota-serialization-text-go) packages.
## Creating target projects
@@ -27,15 +27,15 @@ go mod init getuser
Create a file named **getuser.go** and add the following code.
```bash
-go get github.com/microsoft/kiota/abstractions/go
-go get github.com/microsoft/kiota/http/go/nethttp
-go get github.com/microsoft/kiota/serialization/go/json
-go get github.com/microsoft/kiota/serialization/go/text
-go get github.com/microsoft/kiota/authentication/go/azure
+go get github.com/microsoft/kiota-abstractions-go
+go get github.com/microsoft/kiota-http-go
+go get github.com/microsoft/kiota-serialization-json-go
+go get github.com/microsoft/kiota-serialization-text-go
+go get github.com/microsoft/kiota-authentication-azure-go
go get github.com/Azure/azure-sdk-for-go/sdk/azidentity
```
-Only the first package, `github.com/microsoft/kiota/abstractions/go`, is required. The other packages provide default implementations that you can choose to replace with your own implementations if you wish.
+Only the first package, `github.com/microsoft/kiota-abstractions-go`, is required. The other packages provide default implementations that you can choose to replace with your own implementations if you wish.
## Generating the SDK
@@ -67,8 +67,8 @@ import (
"getuser/client"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
- azure "github.com/microsoft/kiota/authentication/go/azure"
- http "github.com/microsoft/kiota/http/go/nethttp"
+ azure "github.com/microsoft/kiota-authentication-azure-go"
+ http "github.com/microsoft/kiota-http-go"
)
func main() {
diff --git a/http/README.md b/http/README.md
index 36f2c44e65..04855c90bb 100644
--- a/http/README.md
+++ b/http/README.md
@@ -4,7 +4,7 @@ The Kiota HTTP libraries are language specific libraries implementing the interf
Your project will need a reference to the abstraction package to build and run, the following languages are currently supported:
- [Dotnet](https://github.com/microsoft/kiota-http-dotnet): relies on [HttpClient](https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient?view=net-6.0).
-- [Go](./do/nethttp): relies on [NetHttp](https://pkg.go.dev/net/http).
+- [Go](https://github.com/microsoft/kiota-http-go/): relies on [NetHttp](https://pkg.go.dev/net/http).
- [Java](./java/okhttp) : relies on [OkHttp](https://square.github.io/okhttp/).
- [TypeScript](https://github.com/microsoft/kiota-typescript/tree/main/packages/http/fetch : relies on [node-fetch](https://www.npmjs.com/package/cross-fetch) for node users and global browser fetch for browser applications.
- [PHP](./php/guzzle) : relies on [Guzzle](http://guzzlephp.org/)
diff --git a/http/go/nethttp/README.md b/http/go/nethttp/README.md
deleted file mode 100644
index 836c85839f..0000000000
--- a/http/go/nethttp/README.md
+++ /dev/null
@@ -1,23 +0,0 @@
-# To-do
-
-![Go](https://github.com/microsoft/kiota/actions/workflows/http-go-nethttp.yml/badge.svg)
-
-- [ ] unit tests
-- [ ] move to its own repo and implement [the guidelines](https://golang.org/doc/#developing-modules) to make referencing the module easier
-- [ ] add doc.go
-- [ ] rename module name, update reference and remove the replace directive
-
-## Using the net http implementation
-
-1. Navigate to the directory where `go.mod` is located for your project.
-1. Run the following command:
-
- ```Shell
- go get github.com/microsoft/kiota/http/go/nethttp
- ```
-
-1. Add the following code
-
- ```Golang
- httpAdapter, err := NewNetHttpRequestAdapter(authProvider)
- ```
diff --git a/http/go/nethttp/compression_handler.go b/http/go/nethttp/compression_handler.go
deleted file mode 100644
index 9e425252b4..0000000000
--- a/http/go/nethttp/compression_handler.go
+++ /dev/null
@@ -1,114 +0,0 @@
-package nethttplibrary
-
-import (
- "bytes"
- "compress/gzip"
- "io"
- "io/ioutil"
- "net/http"
-
- abstractions "github.com/microsoft/kiota/abstractions/go"
-)
-
-// CompressionHandler represents a compression middleware
-type CompressionHandler struct {
- options CompressionOptions
-}
-
-// CompressionOptions is a configuration object for the CompressionHandler middleware
-type CompressionOptions struct {
- enableCompression bool
-}
-
-type compression interface {
- abstractions.RequestOption
- ShouldCompress() bool
-}
-
-var compressKey = abstractions.RequestOptionKey{Key: "CompressionHandler"}
-
-// NewCompressionHandler creates an instance of a compression middleware
-func NewCompressionHandler() *CompressionHandler {
- options := NewCompressionOptions(true)
- return NewCompressionHandlerWithOptions(options)
-}
-
-// NewCompressionHandlerWithOptions creates an instance of the compression middlerware with
-// specified configurations.
-func NewCompressionHandlerWithOptions(option CompressionOptions) *CompressionHandler {
- return &CompressionHandler{options: option}
-}
-
-// NewCompressionOptions creates a configuration object for the CompressionHandler
-func NewCompressionOptions(enableCompression bool) CompressionOptions {
- return CompressionOptions{enableCompression: enableCompression}
-}
-
-// GetKey returns CompressionOptions unique name in context object
-func (o CompressionOptions) GetKey() abstractions.RequestOptionKey {
- return compressKey
-}
-
-// ShouldCompress reads compression setting form CompressionOptions
-func (o CompressionOptions) ShouldCompress() bool {
- return o.enableCompression
-}
-
-// Intercept is invoked by the middleware pipeline to either move the request/response
-// to the next middleware in the pipeline
-func (c *CompressionHandler) Intercept(pipeline Pipeline, middlewareIndex int, req *http.Request) (*http.Response, error) {
- reqOption, ok := req.Context().Value(compressKey).(compression)
- if !ok {
- reqOption = c.options
- }
-
- if !reqOption.ShouldCompress() || req.Body == nil {
- return pipeline.Next(req, middlewareIndex)
- }
-
- unCompressedBody, err := ioutil.ReadAll(req.Body)
- unCompressedContentLength := req.ContentLength
- if err != nil {
- return nil, err
- }
-
- compressedBody, size, err := compressReqBody(unCompressedBody)
- if err != nil {
- return nil, err
- }
-
- req.Header.Set("Content-Encoding", "gzip")
- req.Body = compressedBody
- req.ContentLength = int64(size)
-
- // Sending request with compressed body
- resp, err := pipeline.Next(req, middlewareIndex)
- if err != nil {
- return nil, err
- }
-
- // If response has status 415 retry request with uncompressed body
- if resp.StatusCode == 415 {
- delete(req.Header, "Content-Encoding")
- req.Body = ioutil.NopCloser(bytes.NewBuffer(unCompressedBody))
- req.ContentLength = unCompressedContentLength
-
- return pipeline.Next(req, middlewareIndex)
- }
-
- return resp, nil
-}
-
-func compressReqBody(reqBody []byte) (io.ReadCloser, int, error) {
- var buffer bytes.Buffer
- gzipWriter := gzip.NewWriter(&buffer)
- if _, err := gzipWriter.Write(reqBody); err != nil {
- return nil, 0, err
- }
-
- if err := gzipWriter.Close(); err != nil {
- return nil, 0, err
- }
-
- return ioutil.NopCloser(&buffer), buffer.Len(), nil
-}
diff --git a/http/go/nethttp/compression_handler_test.go b/http/go/nethttp/compression_handler_test.go
deleted file mode 100644
index 35e81fde87..0000000000
--- a/http/go/nethttp/compression_handler_test.go
+++ /dev/null
@@ -1,106 +0,0 @@
-package nethttplibrary
-
-import (
- "bytes"
- "encoding/json"
- "fmt"
- "io"
- nethttp "net/http"
- httptest "net/http/httptest"
- "testing"
-
- "github.com/stretchr/testify/assert"
-)
-
-func TestCompressionHandlerAddsAcceptEncodingHeader(t *testing.T) {
- postBody, _ := json.Marshal(map[string]string{"name": "Test", "email": "Test@Test.com"})
- var acceptEncodingHeader string
- testServer := httptest.NewServer(nethttp.HandlerFunc(func(res nethttp.ResponseWriter, req *nethttp.Request) {
- acceptEncodingHeader = req.Header.Get("Accept-Encoding")
- fmt.Fprint(res, `{}`)
- }))
- defer testServer.Close()
-
- client := GetDefaultClient(NewCompressionHandler())
- client.Post(testServer.URL, "application/json", bytes.NewBuffer(postBody))
-
- assert.Equal(t, acceptEncodingHeader, "gzip")
-}
-
-func TestCompressionHandlerAddsContentEncodingHeader(t *testing.T) {
- postBody, _ := json.Marshal(map[string]string{"name": "Test", "email": "Test@Test.com"})
- var contentTypeHeader string
- testServer := httptest.NewServer(nethttp.HandlerFunc(func(res nethttp.ResponseWriter, req *nethttp.Request) {
- contentTypeHeader = req.Header.Get("Content-Encoding")
- fmt.Fprint(res, `{}`)
- }))
- defer testServer.Close()
-
- client := GetDefaultClient(NewCompressionHandler())
- client.Post(testServer.URL, "application/json", bytes.NewBuffer(postBody))
-
- assert.Equal(t, contentTypeHeader, "gzip")
-}
-
-func TestCopmressionHandlerCopmressesRequestBody(t *testing.T) {
- postBody, _ := json.Marshal(map[string]string{"name": `Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.a line in section 1.10.32.
- `, "email": "Test@Test.com"})
- var compressedBody []byte
- testServer := httptest.NewServer(nethttp.HandlerFunc(func(res nethttp.ResponseWriter, req *nethttp.Request) {
- compressedBody, _ = io.ReadAll(req.Body)
- fmt.Fprint(res, `{}`)
- }))
- defer testServer.Close()
-
- client := GetDefaultClient(NewCompressionHandler())
- client.Post(testServer.URL, "application/json", bytes.NewBuffer(postBody))
-
- assert.Greater(t, len(postBody), len(compressedBody))
-
-}
-
-func TestCompressionHandlerRetriesRequest(t *testing.T) {
- postBody, _ := json.Marshal(map[string]string{"name": "Test", "email": "Test@Test.com"})
- status := 415
- reqCount := 0
-
- testServer := httptest.NewServer(nethttp.HandlerFunc(func(res nethttp.ResponseWriter, req *nethttp.Request) {
- defer req.Body.Close()
- res.Header().Set("Content-Type", "application/json")
- res.WriteHeader(status)
- status = 200
- reqCount += 1
- fmt.Fprint(res, `{}`)
- }))
- defer testServer.Close()
-
- client := getDefaultClientWithoutMiddleware()
- client.Transport = NewCustomTransport(NewCompressionHandler())
- client.Post(testServer.URL, "application/json", bytes.NewBuffer(postBody))
-
- assert.Equal(t, reqCount, 2)
-}
-
-func TestCompressionHandlerWorksWithEmptyBody(t *testing.T) {
- testServer := httptest.NewServer(nethttp.HandlerFunc(func(res nethttp.ResponseWriter, req *nethttp.Request) {
- result, _ := json.Marshal(map[string]string{"name": "Test", "email": "Test@Test.com"})
-
- res.Header().Set("Content-Type", "application/json")
- res.Header().Set("Content-Encoding", "gzip")
- fmt.Fprint(res, result)
- }))
- defer testServer.Close()
-
- client := getDefaultClientWithoutMiddleware()
- client.Transport = NewCustomTransport(NewCompressionHandler())
-
- fmt.Print(testServer.URL)
- resp, _ := client.Get(testServer.URL)
-
- assert.NotNil(t, resp)
-}
-
-func TestResetTransport(t *testing.T) {
- client := getDefaultClientWithoutMiddleware()
- client.Transport = &nethttp.Transport{}
-}
diff --git a/http/go/nethttp/decompression_handler_test.go b/http/go/nethttp/decompression_handler_test.go
deleted file mode 100644
index be31128f35..0000000000
--- a/http/go/nethttp/decompression_handler_test.go
+++ /dev/null
@@ -1,37 +0,0 @@
-package nethttplibrary
-
-import (
- "compress/gzip"
- "encoding/json"
- "io/ioutil"
- nethttp "net/http"
- httptest "net/http/httptest"
- "testing"
-
- "github.com/stretchr/testify/assert"
-)
-
-func TestTransportDecompressesResponse(t *testing.T) {
- result := map[string]string{"name": "Test", "email": "Test@Test.com"}
-
- testServer := httptest.NewServer(nethttp.HandlerFunc(func(res nethttp.ResponseWriter, req *nethttp.Request) {
- postBody, _ := json.Marshal(result)
- res.Header().Set("Content-Type", "application/json")
- res.Header().Set("Content-Encoding", "gzip")
-
- gz := gzip.NewWriter(res)
- defer gz.Close()
-
- gz.Write(postBody)
- }))
- defer testServer.Close()
-
- client := getDefaultClientWithoutMiddleware()
- client.Transport = NewCustomTransport(NewCompressionHandler())
-
- resp, _ := client.Get(testServer.URL)
- respBody, _ := ioutil.ReadAll(resp.Body)
-
- assert.True(t, resp.Uncompressed)
- assert.Equal(t, string(respBody), `{"email":"Test@Test.com","name":"Test"}`)
-}
diff --git a/http/go/nethttp/go.mod b/http/go/nethttp/go.mod
deleted file mode 100644
index 7493aeec9f..0000000000
--- a/http/go/nethttp/go.mod
+++ /dev/null
@@ -1,17 +0,0 @@
-module github.com/microsoft/kiota/http/go/nethttp
-
-go 1.17
-
-require (
- github.com/microsoft/kiota/abstractions/go v0.0.0-20220303111159-de55f78b58f1
- github.com/stretchr/testify v1.7.0
-)
-
-require (
- github.com/cjlapao/common-go v0.0.18 // indirect
- github.com/davecgh/go-spew v1.1.1 // indirect
- github.com/google/uuid v1.3.0 // indirect
- github.com/pmezard/go-difflib v1.0.0 // indirect
- github.com/yosida95/uritemplate/v3 v3.0.1 // indirect
- gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
-)
diff --git a/http/go/nethttp/go.sum b/http/go/nethttp/go.sum
deleted file mode 100644
index 8259e77835..0000000000
--- a/http/go/nethttp/go.sum
+++ /dev/null
@@ -1,33 +0,0 @@
-github.com/cjlapao/common-go v0.0.18 h1:j6kT/0pmJ69HmUCs9LrCc7IWyxTOh2WYJyZMzUYTULs=
-github.com/cjlapao/common-go v0.0.18/go.mod h1:zGdh2KmXnH4HTRfT7vPpY41cws776KULk44f09OPJgs=
-github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
-github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
-github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20211129093841-858bd540489b h1:K6kuW1GATRCuYinEFsAdjnTvpRM2FTyefRjkCj/sqIc=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20211129093841-858bd540489b/go.mod h1:pIT6aBVb0aHisY52bSbYvb0nyxe+TqdZ8lkpKB7pLIo=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220202150655-0505f19ca2d1 h1:X/Gl5CyFGfxeWluUsKDhw958XKOsx7wfPG82FVH9tH4=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220202150655-0505f19ca2d1/go.mod h1:BUv5PFNuBLFXQlDtarjdgqdqDjee3FgfjrNkfZlA5us=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220203083330-462603bf370f h1:uW+dBi9EsNsfbaV44vIm/fOnpTDkOTmoc1hCnsaeDWs=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220203083330-462603bf370f/go.mod h1:BUv5PFNuBLFXQlDtarjdgqdqDjee3FgfjrNkfZlA5us=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220210083802-7aca9e48205a h1:us4itqyqGAgnaY8+5/TFQysdXK7vM4UmHqAM/iC3GAI=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220210083802-7aca9e48205a/go.mod h1:BUv5PFNuBLFXQlDtarjdgqdqDjee3FgfjrNkfZlA5us=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220210185149-93a92d579e1e h1:oJHZ9gSwdyjxQrH4SXWyNpWu6uDXCNczAOUMqLxUZlQ=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220210185149-93a92d579e1e/go.mod h1:BUv5PFNuBLFXQlDtarjdgqdqDjee3FgfjrNkfZlA5us=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220302123028-4b9132ed532c h1:4Xj+OwZy68ZGBpANUBaRTyoVk+SthajQa/opc94HZ+M=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220302123028-4b9132ed532c/go.mod h1:BUv5PFNuBLFXQlDtarjdgqdqDjee3FgfjrNkfZlA5us=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220303111159-de55f78b58f1 h1:KdbImaH5KFucjwwD9B2C26JPq/8y6/D4K6u+TFAkaeA=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220303111159-de55f78b58f1/go.mod h1:BUv5PFNuBLFXQlDtarjdgqdqDjee3FgfjrNkfZlA5us=
-github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
-github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
-github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/yosida95/uritemplate/v3 v3.0.1 h1:+Fs//CsT+x231WmUQhMHWMxZizMvpnkOVWop02mVCfs=
-github.com/yosida95/uritemplate/v3 v3.0.1/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
-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.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
-gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/http/go/nethttp/kiota_client_factory.go b/http/go/nethttp/kiota_client_factory.go
deleted file mode 100644
index 8fb35fa398..0000000000
--- a/http/go/nethttp/kiota_client_factory.go
+++ /dev/null
@@ -1,36 +0,0 @@
-// Package nethttplibrary implements the Kiota abstractions with net/http to execute the requests.
-// It also provides a middleware infrastructure with some default middleware handlers like the retry handler and the redirect handler.
-package nethttplibrary
-
-import (
- nethttp "net/http"
- "time"
-)
-
-// GetDefaultClient creates a new default net/http client with the options configured for the Kiota request adapter
-func GetDefaultClient(middleware ...Middleware) *nethttp.Client {
- client := getDefaultClientWithoutMiddleware()
- client.Transport = NewCustomTransport(middleware...)
- return client
-}
-
-// used for internal unit testing
-func getDefaultClientWithoutMiddleware() *nethttp.Client {
- // the default client doesn't come with any other settings than making a new one does, and using the default client impacts behavior for non-kiota requests
- return &nethttp.Client{
- CheckRedirect: func(req *nethttp.Request, via []*nethttp.Request) error {
- return nethttp.ErrUseLastResponse
- },
- Timeout: time.Second * 30,
- }
-}
-
-// GetDefaultMiddlewares creates a new default set of middlewares for the Kiota request adapter
-func GetDefaultMiddlewares() []Middleware {
- return []Middleware{
- NewRetryHandler(),
- NewRedirectHandler(),
- NewCompressionHandler(),
- //TODO add additional middlewares
- }
-}
diff --git a/http/go/nethttp/middleware.go b/http/go/nethttp/middleware.go
deleted file mode 100644
index b114f865bd..0000000000
--- a/http/go/nethttp/middleware.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package nethttplibrary
-
-import nethttp "net/http"
-
-// Middleware interface for cross cutting concerns with HTTP requests and responses.
-type Middleware interface {
- // Intercept intercepts the request and returns the response. The implementer MUST call pipeline.Next()
- Intercept(Pipeline, int, *nethttp.Request) (*nethttp.Response, error)
-}
diff --git a/http/go/nethttp/nethttp_request_adapter.go b/http/go/nethttp/nethttp_request_adapter.go
deleted file mode 100644
index 3261b22a37..0000000000
--- a/http/go/nethttp/nethttp_request_adapter.go
+++ /dev/null
@@ -1,375 +0,0 @@
-package nethttplibrary
-
-import (
- "bytes"
- "errors"
- "io/ioutil"
- "strconv"
- "strings"
-
- ctx "context"
- nethttp "net/http"
-
- abs "github.com/microsoft/kiota/abstractions/go"
- absauth "github.com/microsoft/kiota/abstractions/go/authentication"
- absser "github.com/microsoft/kiota/abstractions/go/serialization"
-)
-
-// NetHttpRequestAdapter implements the RequestAdapter interface using net/http
-type NetHttpRequestAdapter struct {
- // serializationWriterFactory is the factory used to create serialization writers
- serializationWriterFactory absser.SerializationWriterFactory
- // parseNodeFactory is the factory used to create parse nodes
- parseNodeFactory absser.ParseNodeFactory
- // httpClient is the client used to send requests
- httpClient *nethttp.Client
- // authenticationProvider is the provider used to authenticate requests
- authenticationProvider absauth.AuthenticationProvider
- // The base url for every request.
- baseUrl string
-}
-
-// NewNetHttpRequestAdapter creates a new NetHttpRequestAdapter with the given parameters
-func NewNetHttpRequestAdapter(authenticationProvider absauth.AuthenticationProvider) (*NetHttpRequestAdapter, error) {
- return NewNetHttpRequestAdapterWithParseNodeFactory(authenticationProvider, nil)
-}
-
-// NewNetHttpRequestAdapterWithParseNodeFactory creates a new NetHttpRequestAdapter with the given parameters
-func NewNetHttpRequestAdapterWithParseNodeFactory(authenticationProvider absauth.AuthenticationProvider, parseNodeFactory absser.ParseNodeFactory) (*NetHttpRequestAdapter, error) {
- return NewNetHttpRequestAdapterWithParseNodeFactoryAndSerializationWriterFactory(authenticationProvider, parseNodeFactory, nil)
-}
-
-// NewNetHttpRequestAdapterWithParseNodeFactoryAndSerializationWriterFactory creates a new NetHttpRequestAdapter with the given parameters
-func NewNetHttpRequestAdapterWithParseNodeFactoryAndSerializationWriterFactory(authenticationProvider absauth.AuthenticationProvider, parseNodeFactory absser.ParseNodeFactory, serializationWriterFactory absser.SerializationWriterFactory) (*NetHttpRequestAdapter, error) {
- return NewNetHttpRequestAdapterWithParseNodeFactoryAndSerializationWriterFactoryAndHttpClient(authenticationProvider, parseNodeFactory, serializationWriterFactory, nil)
-}
-
-// NewNetHttpRequestAdapterWithParseNodeFactoryAndSerializationWriterFactoryAndHttpClient creates a new NetHttpRequestAdapter with the given parameters
-func NewNetHttpRequestAdapterWithParseNodeFactoryAndSerializationWriterFactoryAndHttpClient(authenticationProvider absauth.AuthenticationProvider, parseNodeFactory absser.ParseNodeFactory, serializationWriterFactory absser.SerializationWriterFactory, httpClient *nethttp.Client) (*NetHttpRequestAdapter, error) {
- if authenticationProvider == nil {
- return nil, errors.New("authenticationProvider cannot be nil")
- }
- result := &NetHttpRequestAdapter{
- serializationWriterFactory: serializationWriterFactory,
- parseNodeFactory: parseNodeFactory,
- httpClient: httpClient,
- authenticationProvider: authenticationProvider,
- baseUrl: "",
- }
- if result.httpClient == nil {
- defaultClient := GetDefaultClient()
- result.httpClient = defaultClient
- }
- if result.serializationWriterFactory == nil {
- result.serializationWriterFactory = absser.DefaultSerializationWriterFactoryInstance
- }
- if result.parseNodeFactory == nil {
- result.parseNodeFactory = absser.DefaultParseNodeFactoryInstance
- }
- return result, nil
-}
-
-// GetSerializationWriterFactory returns the serialization writer factory currently in use for the request adapter service.
-func (a *NetHttpRequestAdapter) GetSerializationWriterFactory() absser.SerializationWriterFactory {
- return a.serializationWriterFactory
-}
-
-// EnableBackingStore enables the backing store proxies for the SerializationWriters and ParseNodes in use.
-func (a *NetHttpRequestAdapter) EnableBackingStore() {
- //TODO implement when backing store is available for go
-}
-
-// SetBaseUrl sets the base url for every request.
-func (a *NetHttpRequestAdapter) SetBaseUrl(baseUrl string) {
- a.baseUrl = baseUrl
-}
-
-// GetBaseUrl gets the base url for every request.
-func (a *NetHttpRequestAdapter) GetBaseUrl() string {
- return a.baseUrl
-}
-func (a *NetHttpRequestAdapter) getHttpResponseMessage(requestInfo *abs.RequestInformation) (*nethttp.Response, error) {
- a.setBaseUrlForRequestInformation(requestInfo)
- err := a.authenticationProvider.AuthenticateRequest(requestInfo)
- if err != nil {
- return nil, err
- }
- request, err := a.getRequestFromRequestInformation(requestInfo)
- if err != nil {
- return nil, err
- }
- return (*a.httpClient).Do(request)
-}
-func (a *NetHttpRequestAdapter) getResponsePrimaryContentType(response *nethttp.Response) string {
- if response.Header == nil {
- return ""
- }
- rawType := response.Header.Get("Content-Type")
- splat := strings.Split(rawType, ";")
- return strings.ToLower(splat[0])
-}
-func (a *NetHttpRequestAdapter) setBaseUrlForRequestInformation(requestInfo *abs.RequestInformation) {
- requestInfo.PathParameters["baseurl"] = a.GetBaseUrl()
-}
-func (a *NetHttpRequestAdapter) getRequestFromRequestInformation(requestInfo *abs.RequestInformation) (*nethttp.Request, error) {
- uri, err := requestInfo.GetUri()
- if err != nil {
- return nil, err
- }
- request, err := nethttp.NewRequest(requestInfo.Method.String(), uri.String(), nil)
- if err != nil {
- return nil, err
- }
- if len(requestInfo.Content) > 0 {
- reader := bytes.NewReader(requestInfo.Content)
- request.Body = ioutil.NopCloser(reader)
- }
- if request.Header == nil {
- request.Header = make(nethttp.Header)
- }
- if requestInfo.Headers != nil {
- for key, value := range requestInfo.Headers {
- request.Header.Set(key, value)
- }
- }
- for _, value := range requestInfo.GetRequestOptions() {
- request = request.WithContext(ctx.WithValue(request.Context(), value.GetKey(), value))
- }
- return request, nil
-}
-
-// SendAsync executes the HTTP request specified by the given RequestInformation and returns the deserialized response model.
-func (a *NetHttpRequestAdapter) SendAsync(requestInfo *abs.RequestInformation, constructor absser.ParsableFactory, responseHandler abs.ResponseHandler, errorMappings abs.ErrorMappings) (absser.Parsable, error) {
- if requestInfo == nil {
- return nil, errors.New("requestInfo cannot be nil")
- }
- response, err := a.getHttpResponseMessage(requestInfo)
- if err != nil {
- return nil, err
- }
- if responseHandler != nil {
- result, err := responseHandler(response, errorMappings)
- if err != nil {
- return nil, err
- }
- return result.(absser.Parsable), nil
- } else if response != nil {
- defer a.purge(response)
- err = a.throwFailedResponses(response, errorMappings)
- if err != nil {
- return nil, err
- }
- if a.shouldReturnNil(response) {
- return nil, err
- }
- parseNode, err := a.getRootParseNode(response)
- if err != nil {
- return nil, err
- }
- result, err := parseNode.GetObjectValue(constructor)
- return result, err
- } else {
- return nil, errors.New("response is nil")
- }
-}
-
-// SendCollectionAsync executes the HTTP request specified by the given RequestInformation and returns the deserialized response model collection.
-func (a *NetHttpRequestAdapter) SendCollectionAsync(requestInfo *abs.RequestInformation, constructor absser.ParsableFactory, responseHandler abs.ResponseHandler, errorMappings abs.ErrorMappings) ([]absser.Parsable, error) {
- if requestInfo == nil {
- return nil, errors.New("requestInfo cannot be nil")
- }
- response, err := a.getHttpResponseMessage(requestInfo)
- if err != nil {
- return nil, err
- }
- if responseHandler != nil {
- result, err := responseHandler(response, errorMappings)
- if err != nil {
- return nil, err
- }
- return result.([]absser.Parsable), nil
- } else if response != nil {
- defer a.purge(response)
- err = a.throwFailedResponses(response, errorMappings)
- if err != nil {
- return nil, err
- }
- if a.shouldReturnNil(response) {
- return nil, err
- }
- parseNode, err := a.getRootParseNode(response)
- if err != nil {
- return nil, err
- }
- result, err := parseNode.GetCollectionOfObjectValues(constructor)
- return result, err
- } else {
- return nil, errors.New("response is nil")
- }
-}
-
-// SendPrimitiveAsync executes the HTTP request specified by the given RequestInformation and returns the deserialized primitive response model.
-func (a *NetHttpRequestAdapter) SendPrimitiveAsync(requestInfo *abs.RequestInformation, typeName string, responseHandler abs.ResponseHandler, errorMappings abs.ErrorMappings) (interface{}, error) {
- if requestInfo == nil {
- return nil, errors.New("requestInfo cannot be nil")
- }
- response, err := a.getHttpResponseMessage(requestInfo)
- if err != nil {
- return nil, err
- }
- if responseHandler != nil {
- result, err := responseHandler(response, errorMappings)
- if err != nil {
- return nil, err
- }
- return result.(absser.Parsable), nil
- } else if response != nil {
- defer a.purge(response)
- err = a.throwFailedResponses(response, errorMappings)
- if err != nil {
- return nil, err
- }
- if a.shouldReturnNil(response) {
- return nil, err
- }
- if typeName == "[]byte" {
- return ioutil.ReadAll(response.Body)
- }
- parseNode, err := a.getRootParseNode(response)
- if err != nil {
- return nil, err
- }
- switch typeName {
- case "string":
- return parseNode.GetStringValue()
- case "float32":
- return parseNode.GetFloat32Value()
- case "float64":
- return parseNode.GetFloat64Value()
- case "int32":
- return parseNode.GetInt32Value()
- case "int64":
- return parseNode.GetInt64Value()
- case "bool":
- return parseNode.GetBoolValue()
- case "Time":
- return parseNode.GetTimeValue()
- case "UUID":
- return parseNode.GetUUIDValue()
- default:
- return nil, errors.New("unsupported type")
- }
- } else {
- return nil, errors.New("response is nil")
- }
-}
-
-// SendPrimitiveCollectionAsync executes the HTTP request specified by the given RequestInformation and returns the deserialized primitive response model collection.
-func (a *NetHttpRequestAdapter) SendPrimitiveCollectionAsync(requestInfo *abs.RequestInformation, typeName string, responseHandler abs.ResponseHandler, errorMappings abs.ErrorMappings) ([]interface{}, error) {
- if requestInfo == nil {
- return nil, errors.New("requestInfo cannot be nil")
- }
- response, err := a.getHttpResponseMessage(requestInfo)
- if err != nil {
- return nil, err
- }
- if responseHandler != nil {
- result, err := responseHandler(response, errorMappings)
- if err != nil {
- return nil, err
- }
- return result.([]interface{}), nil
- } else if response != nil {
- defer a.purge(response)
- err = a.throwFailedResponses(response, errorMappings)
- if err != nil {
- return nil, err
- }
- if a.shouldReturnNil(response) {
- return nil, err
- }
- parseNode, err := a.getRootParseNode(response)
- if err != nil {
- return nil, err
- }
- return parseNode.GetCollectionOfPrimitiveValues(typeName)
- } else {
- return nil, errors.New("response is nil")
- }
-}
-
-// SendNoContentAsync executes the HTTP request specified by the given RequestInformation with no return content.
-func (a *NetHttpRequestAdapter) SendNoContentAsync(requestInfo *abs.RequestInformation, responseHandler abs.ResponseHandler, errorMappings abs.ErrorMappings) error {
- if requestInfo == nil {
- return errors.New("requestInfo cannot be nil")
- }
- response, err := a.getHttpResponseMessage(requestInfo)
- if err != nil {
- return err
- }
- if responseHandler != nil {
- _, err := responseHandler(response, errorMappings)
- return err
- } else if response != nil {
- defer a.purge(response)
- err = a.throwFailedResponses(response, errorMappings)
- return nil
- } else {
- return errors.New("response is nil")
- }
-}
-
-func (a *NetHttpRequestAdapter) getRootParseNode(response *nethttp.Response) (absser.ParseNode, error) {
- body, err := ioutil.ReadAll(response.Body)
- if err != nil {
- return nil, err
- }
- return a.parseNodeFactory.GetRootParseNode(a.getResponsePrimaryContentType(response), body)
-}
-func (a *NetHttpRequestAdapter) purge(response *nethttp.Response) error {
- _, _ = ioutil.ReadAll(response.Body) //we don't care about errors comming from reading the body, just trying to purge anything that maybe left
- err := response.Body.Close()
- if err != nil {
- return err
- }
- return nil
-}
-func (a *NetHttpRequestAdapter) shouldReturnNil(response *nethttp.Response) bool {
- return response.StatusCode == 204
-}
-
-func (a *NetHttpRequestAdapter) throwFailedResponses(response *nethttp.Response, errorMappings abs.ErrorMappings) error {
- if response.StatusCode < 400 {
- return nil
- }
-
- statusAsString := strconv.Itoa(response.StatusCode)
- var errorCtor absser.ParsableFactory = nil
- if len(errorMappings) != 0 {
- if errorMappings[statusAsString] != nil {
- errorCtor = errorMappings[statusAsString]
- } else if response.StatusCode >= 400 && response.StatusCode < 500 && errorMappings["4XX"] != nil {
- errorCtor = errorMappings["4XX"]
- } else if response.StatusCode >= 500 && response.StatusCode < 600 && errorMappings["5XX"] != nil {
- errorCtor = errorMappings["5XX"]
- }
- }
-
- if errorCtor == nil {
- return &abs.ApiError{
- Message: "The server returned an unexpected status code and no error factory is registered for this code: " + statusAsString,
- }
- }
-
- rootNode, err := a.getRootParseNode(response)
- if err != nil {
- return err
- }
-
- errValue, err := rootNode.GetObjectValue(errorCtor)
- if err != nil {
- return err
- }
-
- return errValue.(error)
-}
diff --git a/http/go/nethttp/pipeline.go b/http/go/nethttp/pipeline.go
deleted file mode 100644
index ad3e1b36f9..0000000000
--- a/http/go/nethttp/pipeline.go
+++ /dev/null
@@ -1,73 +0,0 @@
-package nethttplibrary
-
-import (
- nethttp "net/http"
-)
-
-// Pipeline contract for middleware infrastructure
-type Pipeline interface {
- // Next moves the request object through middlewares in the pipeline
- Next(req *nethttp.Request, middlewareIndex int) (*nethttp.Response, error)
-}
-
-// custom transport for net/http with a middleware pipeline
-type customTransport struct {
- // middleware pipeline in use for the client
- middlewarePipeline *middlewarePipeline
-}
-
-// middleware pipeline implementation using a roundtripper from net/http
-type middlewarePipeline struct {
- // the round tripper to use to execute the request
- transport nethttp.RoundTripper
- // the middlewares to execute
- middlewares []Middleware
-}
-
-func newMiddlewarePipeline(middlewares []Middleware, transport nethttp.RoundTripper) *middlewarePipeline {
- return &middlewarePipeline{
- transport: transport,
- middlewares: middlewares,
- }
-}
-
-// Next moves the request object through middlewares in the pipeline
-func (pipeline *middlewarePipeline) Next(req *nethttp.Request, middlewareIndex int) (*nethttp.Response, error) {
- if middlewareIndex < len(pipeline.middlewares) {
- middleware := pipeline.middlewares[middlewareIndex]
- return middleware.Intercept(pipeline, middlewareIndex+1, req)
- }
-
- return pipeline.transport.RoundTrip(req)
-}
-
-// RoundTrip executes the the next middleware and returns a response
-func (transport *customTransport) RoundTrip(req *nethttp.Request) (*nethttp.Response, error) {
- return transport.middlewarePipeline.Next(req, 0)
-}
-
-// GetDefaultTransport returns the default http transport used by the library
-func GetDefaultTransport() nethttp.RoundTripper {
- defaultTransport := nethttp.DefaultTransport.(*nethttp.Transport).Clone()
- defaultTransport.ForceAttemptHTTP2 = true
- defaultTransport.DisableCompression = false
- return defaultTransport
-}
-
-// NewCustomTransport creates a new custom transport for http client with the provided set of middleware
-func NewCustomTransport(middlewares ...Middleware) *customTransport {
- return NewCustomTransportWithParentTransport(nil, middlewares...)
-}
-
-// NewCustomTransportWithParentTransport creates a new custom transport which relies on the provided transport for http client with the provided set of middleware
-func NewCustomTransportWithParentTransport(parentTransport nethttp.RoundTripper, middlewares ...Middleware) *customTransport {
- if len(middlewares) == 0 {
- middlewares = GetDefaultMiddlewares()
- }
- if parentTransport == nil {
- parentTransport = GetDefaultTransport()
- }
- return &customTransport{
- middlewarePipeline: newMiddlewarePipeline(middlewares, parentTransport),
- }
-}
diff --git a/http/go/nethttp/pipeline_test.go b/http/go/nethttp/pipeline_test.go
deleted file mode 100644
index 620a2a4522..0000000000
--- a/http/go/nethttp/pipeline_test.go
+++ /dev/null
@@ -1,72 +0,0 @@
-package nethttplibrary
-
-import (
- assert "github.com/stretchr/testify/assert"
- "net/http"
- "testing"
-)
-
-type TestMiddleware struct{}
-
-func (middleware TestMiddleware) Intercept(pipeline Pipeline, middlewareIndex int, req *http.Request) (*http.Response, error) {
- req.Header.Add("test", "test-header")
-
- return pipeline.Next(req, middlewareIndex)
-}
-
-func TestCanInterceptRequests(t *testing.T) {
- transport := NewCustomTransport(&TestMiddleware{})
- client := &http.Client{Transport: transport}
- resp, _ := client.Get("https://example.com")
-
- expect := "test-header"
- got := resp.Request.Header.Get("test")
-
- if expect != got {
- t.Errorf("Expected: %v, but received: %v", expect, got)
- }
-}
-
-func TestCanInterceptMultipleRequests(t *testing.T) {
- transport := NewCustomTransport(&TestMiddleware{})
- client := &http.Client{Transport: transport}
- resp, _ := client.Get("https://example.com")
-
- expect := "test-header"
- got := resp.Request.Header.Get("test")
-
- if expect != got {
- t.Errorf("Expected: %v, but received: %v", expect, got)
- }
-
- resp2, _ := client.Get("https://example.com")
-
- got2 := resp2.Request.Header.Get("test")
-
- if expect != got2 {
- t.Errorf("Expected: %v, but received: %v", expect, got2)
- }
-}
-
-func TestItReturnsADefaultTransport(t *testing.T) {
- transport := GetDefaultTransport()
- assert.NotNil(t, transport)
- defaultTransport, ok := transport.(*http.Transport)
- assert.True(t, ok)
- assert.True(t, defaultTransport.ForceAttemptHTTP2)
-}
-
-func TestItAcceptsACustomizedTransport(t *testing.T) {
- transport := http.DefaultTransport.(*http.Transport).Clone()
- transport.ForceAttemptHTTP2 = false
- customTransport := NewCustomTransportWithParentTransport(transport)
- assert.NotNil(t, customTransport)
- result, ok := customTransport.middlewarePipeline.transport.(*http.Transport)
- assert.True(t, ok)
- assert.False(t, result.ForceAttemptHTTP2)
-}
-
-func TestItGetsADefaultTransportIfNoneIsProvided(t *testing.T) {
- customTransport := NewCustomTransport()
- assert.NotNil(t, customTransport.middlewarePipeline.transport)
-}
diff --git a/http/go/nethttp/redirect_handler.go b/http/go/nethttp/redirect_handler.go
deleted file mode 100644
index 101f3815a0..0000000000
--- a/http/go/nethttp/redirect_handler.go
+++ /dev/null
@@ -1,151 +0,0 @@
-package nethttplibrary
-
-import (
- "errors"
- nethttp "net/http"
- "net/url"
- "strings"
-
- abs "github.com/microsoft/kiota/abstractions/go"
-)
-
-// RedirectHandler handles redirect responses and follows them according to the options specified.
-type RedirectHandler struct {
- // options to use when evaluating whether to redirect or not
- options RedirectHandlerOptions
-}
-
-// NewRedirectHandler creates a new redirect handler with the default options.
-func NewRedirectHandler() *RedirectHandler {
- return NewRedirectHandlerWithOptions(RedirectHandlerOptions{
- MaxRedirects: defaultMaxRedirects,
- ShouldRedirect: func(req *nethttp.Request, res *nethttp.Response) bool {
- return true
- },
- })
-}
-
-// NewRedirectHandlerWithOptions creates a new redirect handler with the specified options.
-func NewRedirectHandlerWithOptions(options RedirectHandlerOptions) *RedirectHandler {
- return &RedirectHandler{options: options}
-}
-
-// RedirectHandlerOptions to use when evaluating whether to redirect or not.
-type RedirectHandlerOptions struct {
- // A callback that determines whether to redirect or not.
- ShouldRedirect func(req *nethttp.Request, res *nethttp.Response) bool
- // The maximum number of redirects to follow.
- MaxRedirects int
-}
-
-var redirectKeyValue = abs.RequestOptionKey{
- Key: "RedirectHandler",
-}
-
-type redirectHandlerOptionsInt interface {
- abs.RequestOption
- GetShouldRedirect() func(req *nethttp.Request, res *nethttp.Response) bool
- GetMaxRedirect() int
-}
-
-// GetKey returns the key value to be used when the option is added to the request context
-func (options *RedirectHandlerOptions) GetKey() abs.RequestOptionKey {
- return redirectKeyValue
-}
-
-// GetShouldRedirect returns the redirection evaluation function.
-func (options *RedirectHandlerOptions) GetShouldRedirect() func(req *nethttp.Request, res *nethttp.Response) bool {
- return options.ShouldRedirect
-}
-
-// GetMaxRedirect returns the maximum number of redirects to follow.
-func (options *RedirectHandlerOptions) GetMaxRedirect() int {
- if options == nil || options.MaxRedirects < 1 {
- return defaultMaxRedirects
- } else if options.MaxRedirects > absoluteMaxRedirects {
- return absoluteMaxRedirects
- } else {
- return options.MaxRedirects
- }
-}
-
-const defaultMaxRedirects = 5
-const absoluteMaxRedirects = 20
-const movedPermanently = 301
-const found = 302
-const seeOther = 303
-const temporaryRedirect = 307
-const permanentRedirect = 308
-const locationHeader = "Location"
-
-// Intercept implements the interface and evaluates whether to follow a redirect response.
-func (middleware RedirectHandler) Intercept(pipeline Pipeline, middlewareIndex int, req *nethttp.Request) (*nethttp.Response, error) {
- response, err := pipeline.Next(req, middlewareIndex)
- if err != nil {
- return response, err
- }
- reqOption, ok := req.Context().Value(redirectKeyValue).(redirectHandlerOptionsInt)
- if !ok {
- reqOption = &middleware.options
- }
- return middleware.redirectRequest(pipeline, middlewareIndex, reqOption, req, response, 0)
-}
-
-func (middleware RedirectHandler) redirectRequest(pipeline Pipeline, middlewareIndex int, reqOption redirectHandlerOptionsInt, req *nethttp.Request, response *nethttp.Response, redirectCount int) (*nethttp.Response, error) {
- shouldRedirect := reqOption.GetShouldRedirect() != nil && reqOption.GetShouldRedirect()(req, response) || reqOption.GetShouldRedirect() == nil
- if middleware.isRedirectResponse(response) &&
- redirectCount < reqOption.GetMaxRedirect() &&
- shouldRedirect {
- redirectCount++
- redirectRequest, err := middleware.getRedirectRequest(req, response)
- if err != nil {
- return response, err
- }
- result, err := pipeline.Next(redirectRequest, middlewareIndex)
- if err != nil {
- return result, err
- }
- return middleware.redirectRequest(pipeline, middlewareIndex, reqOption, redirectRequest, result, redirectCount)
- }
- return response, nil
-}
-
-func (middleware RedirectHandler) isRedirectResponse(response *nethttp.Response) bool {
- if response == nil {
- return false
- }
- locationHeader := response.Header.Get(locationHeader)
- if locationHeader == "" {
- return false
- }
- statusCode := response.StatusCode
- return statusCode == movedPermanently || statusCode == found || statusCode == seeOther || statusCode == temporaryRedirect || statusCode == permanentRedirect
-}
-
-func (middleware RedirectHandler) getRedirectRequest(request *nethttp.Request, response *nethttp.Response) (*nethttp.Request, error) {
- if request == nil || response == nil {
- return nil, errors.New("request or response is nil")
- }
- locationHeaderValue := response.Header.Get(locationHeader)
- if locationHeaderValue[0] == '/' {
- locationHeaderValue = request.URL.Scheme + "://" + request.URL.Host + locationHeaderValue
- }
- result := request.Clone(request.Context())
- targetUrl, err := url.Parse(locationHeaderValue)
- if err != nil {
- return nil, err
- }
- result.URL = targetUrl
- sameHost := strings.EqualFold(targetUrl.Host, request.URL.Host)
- sameScheme := strings.EqualFold(targetUrl.Scheme, request.URL.Scheme)
- if !sameHost || !sameScheme {
- result.Header.Del("Authorization")
- }
- if response.StatusCode == seeOther {
- result.Method = nethttp.MethodGet
- result.Header.Del("Content-Type")
- result.Header.Del("Content-Length")
- result.Body = nil
- }
- return result, nil
-}
diff --git a/http/go/nethttp/redirect_handler_test.go b/http/go/nethttp/redirect_handler_test.go
deleted file mode 100644
index be1524885c..0000000000
--- a/http/go/nethttp/redirect_handler_test.go
+++ /dev/null
@@ -1,114 +0,0 @@
-package nethttplibrary
-
-import (
- nethttp "net/http"
- httptest "net/http/httptest"
- testing "testing"
-
- "strconv"
-
- assert "github.com/stretchr/testify/assert"
-)
-
-func TestItCreatesANewRedirectHandler(t *testing.T) {
- handler := NewRedirectHandler()
- if handler == nil {
- t.Error("handler is nil")
- }
-}
-
-func TestItDoesntRedirectWithoutMiddleware(t *testing.T) {
- requestCount := int64(0)
- testServer := httptest.NewServer(nethttp.HandlerFunc(func(res nethttp.ResponseWriter, req *nethttp.Request) {
- requestCount++
- res.Header().Set("Location", "/"+strconv.FormatInt(requestCount, 10))
- res.WriteHeader(301)
- res.Write([]byte("body"))
- }))
- defer func() { testServer.Close() }()
- req, err := nethttp.NewRequest(nethttp.MethodGet, testServer.URL, nil)
- if err != nil {
- t.Error(err)
- }
- client := getDefaultClientWithoutMiddleware()
- resp, err := client.Do(req)
- if err != nil {
- t.Error(err)
- }
- assert.NotNil(t, resp)
- assert.Equal(t, int64(1), requestCount)
-}
-
-func TestItHonoursShouldRedirect(t *testing.T) {
- requestCount := int64(0)
- testServer := httptest.NewServer(nethttp.HandlerFunc(func(res nethttp.ResponseWriter, req *nethttp.Request) {
- requestCount++
- res.Header().Set("Location", "/"+strconv.FormatInt(requestCount, 10))
- res.WriteHeader(301)
- res.Write([]byte("body"))
- }))
- defer func() { testServer.Close() }()
- handler := NewRedirectHandlerWithOptions(RedirectHandlerOptions{
- ShouldRedirect: func(req *nethttp.Request, res *nethttp.Response) bool {
- return false
- },
- })
- req, err := nethttp.NewRequest(nethttp.MethodGet, testServer.URL, nil)
- if err != nil {
- t.Error(err)
- }
- resp, err := handler.Intercept(newNoopPipeline(), 0, req)
- if err != nil {
- t.Error(err)
- }
- assert.NotNil(t, resp)
- assert.Equal(t, int64(1), requestCount)
-}
-
-func TestItHonoursMaxRedirect(t *testing.T) {
- requestCount := int64(0)
- testServer := httptest.NewServer(nethttp.HandlerFunc(func(res nethttp.ResponseWriter, req *nethttp.Request) {
- requestCount++
- res.Header().Set("Location", "/"+strconv.FormatInt(requestCount, 10))
- res.WriteHeader(301)
- res.Write([]byte("body"))
- }))
- defer func() { testServer.Close() }()
- handler := NewRedirectHandler()
- req, err := nethttp.NewRequest(nethttp.MethodGet, testServer.URL, nil)
- if err != nil {
- t.Error(err)
- }
- resp, err := handler.Intercept(newNoopPipeline(), 0, req)
- if err != nil {
- t.Error(err)
- }
- assert.NotNil(t, resp)
- assert.Equal(t, int64(defaultMaxRedirects+1), requestCount)
-}
-
-func TestItStripsAuthorizationHeaderOnDifferentHost(t *testing.T) {
- testServer := httptest.NewServer(nethttp.HandlerFunc(func(res nethttp.ResponseWriter, req *nethttp.Request) {
- res.Header().Set("Location", "https://www.bing.com/")
- res.WriteHeader(301)
- res.Write([]byte("body"))
- }))
- defer func() { testServer.Close() }()
- handler := NewRedirectHandler()
- req, err := nethttp.NewRequest(nethttp.MethodGet, testServer.URL, nil)
- if err != nil {
- t.Error(err)
- }
- req.Header.Set("Authorization", "Bearer 12345")
- client := getDefaultClientWithoutMiddleware()
- resp, err := client.Do(req)
- if err != nil {
- t.Error(err)
- }
- result, err := handler.getRedirectRequest(req, resp)
- if err != nil {
- t.Error(err)
- }
- assert.NotNil(t, result)
- assert.Equal(t, "", result.Header.Get("Authorization"))
-}
diff --git a/http/go/nethttp/retry_handler.go b/http/go/nethttp/retry_handler.go
deleted file mode 100644
index 0d1cdb0c4f..0000000000
--- a/http/go/nethttp/retry_handler.go
+++ /dev/null
@@ -1,150 +0,0 @@
-package nethttplibrary
-
-import (
- "math"
- nethttp "net/http"
- "strconv"
- "time"
-
- abs "github.com/microsoft/kiota/abstractions/go"
-)
-
-// RetryHandler handles transient HTTP responses and retries the request given the retry options
-type RetryHandler struct {
- // default options to use when evaluating the response
- options RetryHandlerOptions
-}
-
-// NewRetryHandler creates a new RetryHandler with default options
-func NewRetryHandler() *RetryHandler {
- return NewRetryHandlerWithOptions(RetryHandlerOptions{
- ShouldRetry: func(delay time.Duration, executionCount int, request *nethttp.Request, response *nethttp.Response) bool {
- return true
- },
- })
-}
-
-// NewRetryHandlerWithOptions creates a new RetryHandler with the given options
-func NewRetryHandlerWithOptions(options RetryHandlerOptions) *RetryHandler {
- return &RetryHandler{options: options}
-}
-
-const defaultMaxRetries = 3
-const absoluteMaxRetries = 10
-const defaultDelaySeconds = 3
-const absoluteMaxDelaySeconds = 180
-
-// RetryHandlerOptions to apply when evaluating the response for retrial
-type RetryHandlerOptions struct {
- // Callback to determine if the request should be retried
- ShouldRetry func(delay time.Duration, executionCount int, request *nethttp.Request, response *nethttp.Response) bool
- // The maximum number of times a request can be retried
- MaxRetries int
- // The delay in seconds between retries
- DelaySeconds int
-}
-
-type retryHandlerOptionsInt interface {
- abs.RequestOption
- GetShouldRetry() func(delay time.Duration, executionCount int, request *nethttp.Request, response *nethttp.Response) bool
- GetDelaySeconds() int
- GetMaxRetries() int
-}
-
-var retryKeyValue = abs.RequestOptionKey{
- Key: "RetryHandler",
-}
-
-// GetKey returns the key value to be used when the option is added to the request context
-func (options *RetryHandlerOptions) GetKey() abs.RequestOptionKey {
- return retryKeyValue
-}
-
-// GetShouldRetry returns the should retry callback function which evaluates the response for retrial
-func (options *RetryHandlerOptions) GetShouldRetry() func(delay time.Duration, executionCount int, request *nethttp.Request, response *nethttp.Response) bool {
- return options.ShouldRetry
-}
-
-// GetDelaySeconds returns the delays in seconds between retries
-func (options *RetryHandlerOptions) GetDelaySeconds() int {
- if options.DelaySeconds < 1 {
- return defaultDelaySeconds
- } else if options.DelaySeconds > absoluteMaxDelaySeconds {
- return absoluteMaxDelaySeconds
- } else {
- return options.DelaySeconds
- }
-}
-
-// GetMaxRetries returns the maximum number of times a request can be retried
-func (options *RetryHandlerOptions) GetMaxRetries() int {
- if options.MaxRetries < 1 {
- return defaultMaxRetries
- } else if options.MaxRetries > absoluteMaxRetries {
- return absoluteMaxRetries
- } else {
- return options.MaxRetries
- }
-}
-
-const retryAttemptHeader = "Retry-Attempt"
-const retryAfterHeader = "Retry-After"
-
-const tooManyRequests = 429
-const serviceUnavailable = 503
-const gatewayTimeout = 504
-
-// Intercept implements the interface and evaluates whether to retry a failed request.
-func (middleware RetryHandler) Intercept(pipeline Pipeline, middlewareIndex int, req *nethttp.Request) (*nethttp.Response, error) {
- response, err := pipeline.Next(req, middlewareIndex)
- if err != nil {
- return response, err
- }
- reqOption, ok := req.Context().Value(retryKeyValue).(retryHandlerOptionsInt)
- if !ok {
- reqOption = &middleware.options
- }
- return middleware.retryRequest(pipeline, middlewareIndex, reqOption, req, response, 0, 0)
-}
-
-func (middleware RetryHandler) retryRequest(pipeline Pipeline, middlewareIndex int, options retryHandlerOptionsInt, req *nethttp.Request, resp *nethttp.Response, executionCount int, cummulativeDelay time.Duration) (*nethttp.Response, error) {
- if middleware.isRetriableErrorCode(resp.StatusCode) &&
- middleware.isRetriableRequest(req) &&
- executionCount < options.GetMaxRetries() &&
- cummulativeDelay < time.Duration(absoluteMaxDelaySeconds)*time.Second &&
- options.GetShouldRetry()(cummulativeDelay, executionCount, req, resp) {
- executionCount++
- delay := middleware.getRetryDelay(req, resp, options, executionCount)
- cummulativeDelay += delay
- req.Header.Set(retryAttemptHeader, strconv.Itoa(executionCount))
- time.Sleep(delay)
- response, err := pipeline.Next(req, middlewareIndex)
- if err != nil {
- return response, err
- }
- return middleware.retryRequest(pipeline, middlewareIndex, options, req, response, executionCount, cummulativeDelay)
- }
- return resp, nil
-}
-
-func (middleware RetryHandler) isRetriableErrorCode(code int) bool {
- return code == tooManyRequests || code == serviceUnavailable || code == gatewayTimeout
-}
-func (middleware RetryHandler) isRetriableRequest(req *nethttp.Request) bool {
- isBodiedMethod := req.Method == "POST" || req.Method == "PUT" || req.Method == "PATCH"
- if isBodiedMethod && req.Body != nil {
- return req.ContentLength != -1
- }
- return true
-}
-
-func (middleware RetryHandler) getRetryDelay(req *nethttp.Request, resp *nethttp.Response, options retryHandlerOptionsInt, executionCount int) time.Duration {
- retryAfter := resp.Header.Get(retryAfterHeader)
- if retryAfter != "" {
- retryAfterDelay, err := strconv.ParseFloat(retryAfter, 64)
- if err == nil {
- return time.Duration(retryAfterDelay) * time.Second
- }
- } //TODO parse the header if it's a date
- return time.Duration(math.Pow(float64(options.GetDelaySeconds()), float64(executionCount))) * time.Second
-}
diff --git a/http/go/nethttp/retry_handler_test.go b/http/go/nethttp/retry_handler_test.go
deleted file mode 100644
index d4cd223bf0..0000000000
--- a/http/go/nethttp/retry_handler_test.go
+++ /dev/null
@@ -1,127 +0,0 @@
-package nethttplibrary
-
-import (
- nethttp "net/http"
- httptest "net/http/httptest"
- testing "testing"
- "time"
-
- "strconv"
-
- assert "github.com/stretchr/testify/assert"
-)
-
-type NoopPipeline struct {
- client *nethttp.Client
-}
-
-func (pipeline *NoopPipeline) Next(req *nethttp.Request, middlewareIndex int) (*nethttp.Response, error) {
- return pipeline.client.Do(req)
-}
-func newNoopPipeline() *NoopPipeline {
- return &NoopPipeline{
- client: getDefaultClientWithoutMiddleware(),
- }
-}
-func TestItCreatesANewRetryHandler(t *testing.T) {
- handler := NewRetryHandler()
- if handler == nil {
- t.Error("handler is nil")
- }
-}
-func TestItAddsRetryAttemptHeaders(t *testing.T) {
- retryAttemptInt := 0
- testServer := httptest.NewServer(nethttp.HandlerFunc(func(res nethttp.ResponseWriter, req *nethttp.Request) {
- retryAttempt := req.Header.Get("Retry-Attempt")
- if retryAttempt == "" {
- res.WriteHeader(429)
- } else {
- res.WriteHeader(200)
- retryAttemptInt, _ = strconv.Atoi(retryAttempt)
- }
- res.Write([]byte("body"))
- }))
- defer func() { testServer.Close() }()
- handler := NewRetryHandler()
- req, err := nethttp.NewRequest(nethttp.MethodGet, testServer.URL, nil)
- if err != nil {
- t.Error(err)
- }
- resp, err := handler.Intercept(newNoopPipeline(), 0, req)
- if err != nil {
- t.Error(err)
- }
- assert.NotNil(t, resp)
- assert.Equal(t, 1, retryAttemptInt)
-}
-
-func TestItHonoursShouldRetry(t *testing.T) {
- testServer := httptest.NewServer(nethttp.HandlerFunc(func(res nethttp.ResponseWriter, req *nethttp.Request) {
- retryAttempt := req.Header.Get("Retry-Attempt")
- if retryAttempt == "" {
- res.WriteHeader(429)
- } else {
- res.WriteHeader(200)
- }
- res.Write([]byte("body"))
- }))
- defer func() { testServer.Close() }()
- handler := NewRetryHandlerWithOptions(RetryHandlerOptions{
- ShouldRetry: func(delay time.Duration, executionCount int, request *nethttp.Request, response *nethttp.Response) bool {
- return false
- },
- })
- req, err := nethttp.NewRequest(nethttp.MethodGet, testServer.URL, nil)
- if err != nil {
- t.Error(err)
- }
- resp, err := handler.Intercept(newNoopPipeline(), 0, req)
- if err != nil {
- t.Error(err)
- }
- assert.NotNil(t, resp)
- assert.Equal(t, 429, resp.StatusCode)
-}
-
-func TestItHonoursMaxRetries(t *testing.T) {
- retryAttemptInt := -1
- testServer := httptest.NewServer(nethttp.HandlerFunc(func(res nethttp.ResponseWriter, req *nethttp.Request) {
- res.WriteHeader(429)
- retryAttemptInt++
- res.Write([]byte("body"))
- }))
- defer func() { testServer.Close() }()
- handler := NewRetryHandler()
- req, err := nethttp.NewRequest(nethttp.MethodGet, testServer.URL, nil)
- if err != nil {
- t.Error(err)
- }
- resp, err := handler.Intercept(newNoopPipeline(), 0, req)
- if err != nil {
- t.Error(err)
- }
- assert.NotNil(t, resp)
- assert.Equal(t, 429, resp.StatusCode)
- assert.Equal(t, defaultMaxRetries, retryAttemptInt)
-}
-
-func TestItDoesntRetryOnSuccess(t *testing.T) {
- retryAttemptInt := -1
- testServer := httptest.NewServer(nethttp.HandlerFunc(func(res nethttp.ResponseWriter, req *nethttp.Request) {
- res.WriteHeader(200)
- retryAttemptInt++
- res.Write([]byte("body"))
- }))
- defer func() { testServer.Close() }()
- handler := NewRetryHandler()
- req, err := nethttp.NewRequest(nethttp.MethodGet, testServer.URL, nil)
- if err != nil {
- t.Error(err)
- }
- resp, err := handler.Intercept(newNoopPipeline(), 0, req)
- if err != nil {
- t.Error(err)
- }
- assert.NotNil(t, resp)
- assert.Equal(t, 0, retryAttemptInt)
-}
diff --git a/serialization/README.md b/serialization/README.md
index 4d319fe402..ea99e43ef3 100644
--- a/serialization/README.md
+++ b/serialization/README.md
@@ -6,7 +6,7 @@ Your project will need a reference to the abstraction package to build and run,
## Application/json
- [Dotnet](https://github.com/microsoft/kiota-serialization-json-dotnet): relies on [System.Text.Json](https://docs.microsoft.com/en-us/dotnet/api/system.text.json?view=net-6.0) for JSON serialization/deserialization.
-- [Go](./go/json): relies on [encoding/json](https://pkg.go.dev/encoding/json) for JSON serialization/deserialization.
+- [Go](https://github.com/microsoft/kiota-serialization-json-go): relies on [encoding/json](https://pkg.go.dev/encoding/json) for JSON serialization/deserialization.
- [Java](./java/json) : relies on [Gson](https://github.com/google/gson) for JSON serialization/deserialization.
- [TypeScript](https://github.com/microsoft/kiota-typescript/tree/main/packages/serialization/json) : relies on the native JSON capabilities for JSON serialization/deserialization.
- [PHP](./php/json) : relies on the native JSON capabilities for JSON deserialization
@@ -14,6 +14,6 @@ Your project will need a reference to the abstraction package to build and run,
## Text/plain
- [Dotnet](https://github.com/microsoft/kiota-serialization-text-dotnet)
-- [Go](./go/text)
+- [Go](https://github.com/microsoft/kiota-serialization-text-go)
- [Java](./java/text)
- [TypeScript](https://github.com/microsoft/kiota-typescript/tree/main/packages/serialization/text)
diff --git a/serialization/go/json/README.md b/serialization/go/json/README.md
deleted file mode 100644
index 38740a8414..0000000000
--- a/serialization/go/json/README.md
+++ /dev/null
@@ -1,17 +0,0 @@
-# To-do
-
-![Go Serialization Json](https://github.com/microsoft/kiota/actions/workflows/serialization-go-json.yml/badge.svg)
-
-- [ ] coverage code
-- [ ] analyzers
-- [ ] unit test project
-- [ ] docs comments
-
-## Using the JSON Serialization implementations
-
-1. Navigate to the directory where `go.mod` is located for your project.
-1. Run the following command:
-
- ```Shell
- go get github.com/microsoft/kiota/serialization/go/json
- ```
diff --git a/serialization/go/json/go.mod b/serialization/go/json/go.mod
deleted file mode 100644
index 614afcdb05..0000000000
--- a/serialization/go/json/go.mod
+++ /dev/null
@@ -1,17 +0,0 @@
-module github.com/microsoft/kiota/serialization/go/json
-
-go 1.17
-
-require (
- github.com/google/uuid v1.3.0
- github.com/microsoft/kiota/abstractions/go v0.0.0-20220314101957-d2823fe62079
- github.com/stretchr/testify v1.7.0
-)
-
-require (
- github.com/cjlapao/common-go v0.0.18 // indirect
- github.com/davecgh/go-spew v1.1.1 // indirect
- github.com/pmezard/go-difflib v1.0.0 // indirect
- github.com/yosida95/uritemplate/v3 v3.0.1 // indirect
- gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
-)
diff --git a/serialization/go/json/go.sum b/serialization/go/json/go.sum
deleted file mode 100644
index 30c571a708..0000000000
--- a/serialization/go/json/go.sum
+++ /dev/null
@@ -1,34 +0,0 @@
-github.com/cjlapao/common-go v0.0.16 h1:3CCMidbHuc+nvKHb1mX/rflMPrpeGQvoVk30b9CC/00=
-github.com/cjlapao/common-go v0.0.16/go.mod h1:zGdh2KmXnH4HTRfT7vPpY41cws776KULk44f09OPJgs=
-github.com/cjlapao/common-go v0.0.18 h1:j6kT/0pmJ69HmUCs9LrCc7IWyxTOh2WYJyZMzUYTULs=
-github.com/cjlapao/common-go v0.0.18/go.mod h1:zGdh2KmXnH4HTRfT7vPpY41cws776KULk44f09OPJgs=
-github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
-github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
-github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20211129093841-858bd540489b h1:K6kuW1GATRCuYinEFsAdjnTvpRM2FTyefRjkCj/sqIc=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20211129093841-858bd540489b/go.mod h1:pIT6aBVb0aHisY52bSbYvb0nyxe+TqdZ8lkpKB7pLIo=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220124135025-cd414c7de3e7 h1:jKAoSM2Hh64v9Gl1houx5RGtWOkZZwDlOUXqDk1iajI=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220124135025-cd414c7de3e7/go.mod h1:kY3tlHIUgSjgTfTIb1D1pfV5ytuRWWeBohRou/JNCSw=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220202150655-0505f19ca2d1 h1:X/Gl5CyFGfxeWluUsKDhw958XKOsx7wfPG82FVH9tH4=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220202150655-0505f19ca2d1/go.mod h1:BUv5PFNuBLFXQlDtarjdgqdqDjee3FgfjrNkfZlA5us=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220302123028-4b9132ed532c h1:4Xj+OwZy68ZGBpANUBaRTyoVk+SthajQa/opc94HZ+M=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220302123028-4b9132ed532c/go.mod h1:BUv5PFNuBLFXQlDtarjdgqdqDjee3FgfjrNkfZlA5us=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220304133504-2b8143da4e8a h1:nw6PxZdeuBjc2q97YJaX36tjpSJyPYpC/Ks/pn0dgFg=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220304133504-2b8143da4e8a/go.mod h1:BUv5PFNuBLFXQlDtarjdgqdqDjee3FgfjrNkfZlA5us=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220304190506-1b038c9cc6cb h1:qrWgSHID0v8AX2UnPATKdQwbG8p6r41I0g2+CVZaJ+E=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220304190506-1b038c9cc6cb/go.mod h1:BUv5PFNuBLFXQlDtarjdgqdqDjee3FgfjrNkfZlA5us=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220314101957-d2823fe62079 h1:M2GmF6QszBwSbAF5xvps1BJCLwRZOYKbPMeOMcFsqJM=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220314101957-d2823fe62079/go.mod h1:BUv5PFNuBLFXQlDtarjdgqdqDjee3FgfjrNkfZlA5us=
-github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
-github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
-github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/yosida95/uritemplate/v3 v3.0.1 h1:+Fs//CsT+x231WmUQhMHWMxZizMvpnkOVWop02mVCfs=
-github.com/yosida95/uritemplate/v3 v3.0.1/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
-gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
-gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/serialization/go/json/json_parse_node.go b/serialization/go/json/json_parse_node.go
deleted file mode 100644
index 48696ddeb3..0000000000
--- a/serialization/go/json/json_parse_node.go
+++ /dev/null
@@ -1,474 +0,0 @@
-// Package jsonserialization is the default Kiota serialization implementation for JSON.
-// It relies on the standard Go JSON library.
-package jsonserialization
-
-import (
- "bytes"
- "encoding/base64"
- "encoding/json"
- "errors"
- "io"
- "time"
-
- "github.com/google/uuid"
- absser "github.com/microsoft/kiota/abstractions/go/serialization"
-)
-
-// JsonParseNode is a ParseNode implementation for JSON.
-type JsonParseNode struct {
- value interface{}
-}
-
-// NewJsonParseNode creates a new JsonParseNode.
-func NewJsonParseNode(content []byte) (*JsonParseNode, error) {
- if len(content) == 0 {
- return nil, errors.New("content is empty")
- }
- decoder := json.NewDecoder(bytes.NewReader(content))
- value, err := loadJsonTree(decoder)
- return value, err
-}
-func loadJsonTree(decoder *json.Decoder) (*JsonParseNode, error) {
- for {
- token, err := decoder.Token()
- if err == io.EOF {
- break
- }
- if err != nil {
- return nil, err
- }
- switch token.(type) {
- case json.Delim:
- switch token.(json.Delim) {
- case '{':
- v := make(map[string]*JsonParseNode)
- for decoder.More() {
- key, err := decoder.Token()
- if err != nil {
- return nil, err
- }
- keyStr, ok := key.(string)
- if !ok {
- return nil, errors.New("key is not a string")
- }
- childNode, err := loadJsonTree(decoder)
- if err != nil {
- return nil, err
- }
- v[keyStr] = childNode
- }
- decoder.Token() // skip the closing curly
- result := &JsonParseNode{value: v}
- return result, nil
- case '[':
- v := make([]*JsonParseNode, 0)
- for decoder.More() {
- childNode, err := loadJsonTree(decoder)
- if err != nil {
- return nil, err
- }
- v = append(v, childNode)
- }
- decoder.Token() // skip the closing bracket
- result := &JsonParseNode{value: v}
- return result, nil
- case ']':
- case '}':
- }
- case json.Number:
- number := token.(json.Number)
- i, err := number.Int64()
- c := &JsonParseNode{}
- if err == nil {
- c.SetValue(&i)
- } else {
- f, err := number.Float64()
- if err == nil {
- c.SetValue(&f)
- } else {
- return nil, err
- }
- }
- return c, nil
- case string:
- v := token.(string)
- c := &JsonParseNode{}
- c.SetValue(&v)
- return c, nil
- case bool:
- c := &JsonParseNode{}
- v := token.(bool)
- c.SetValue(&v)
- return c, nil
- case int8:
- c := &JsonParseNode{}
- v := token.(int8)
- c.SetValue(&v)
- return c, nil
- case byte:
- c := &JsonParseNode{}
- v := token.(byte)
- c.SetValue(&v)
- return c, nil
- case float64:
- c := &JsonParseNode{}
- v := token.(float64)
- c.SetValue(&v)
- return c, nil
- case float32:
- c := &JsonParseNode{}
- v := token.(float32)
- c.SetValue(&v)
- return c, nil
- case int32:
- c := &JsonParseNode{}
- v := token.(int32)
- c.SetValue(&v)
- return c, nil
- case int64:
- c := &JsonParseNode{}
- v := token.(int64)
- c.SetValue(&v)
- return c, nil
- case nil:
- return nil, nil
- default:
- }
- }
- return nil, nil
-}
-
-// SetValue sets the value represented by the node
-func (n *JsonParseNode) SetValue(value interface{}) {
- n.value = value
-}
-
-// GetChildNode returns a new parse node for the given identifier.
-func (n *JsonParseNode) GetChildNode(index string) (absser.ParseNode, error) {
- if index == "" {
- return nil, errors.New("index is empty")
- }
- childNodes, ok := n.value.(map[string]*JsonParseNode)
- if !ok || len(childNodes) == 0 {
- return nil, errors.New("no child node available")
- }
- return childNodes[index], nil
-}
-
-// GetObjectValue returns the Parsable value from the node.
-func (n *JsonParseNode) GetObjectValue(ctor absser.ParsableFactory) (absser.Parsable, error) {
- if ctor == nil {
- return nil, errors.New("constructor is nil")
- }
- if n == nil || n.value == nil {
- return nil, nil
- }
- result, err := ctor(n)
- if err != nil {
- return nil, err
- }
- //TODO on before when implementing backing store
- properties, ok := n.value.(map[string]*JsonParseNode)
- if !ok {
- return nil, errors.New("value is not an object")
- }
- fields := result.GetFieldDeserializers()
- if len(properties) != 0 {
- itemAsHolder, isHolder := result.(absser.AdditionalDataHolder)
- var itemAdditionalData map[string]interface{}
- if isHolder {
- itemAdditionalData = itemAsHolder.GetAdditionalData()
- if itemAdditionalData == nil {
- itemAdditionalData = make(map[string]interface{})
- itemAsHolder.SetAdditionalData(itemAdditionalData)
- }
- }
-
- for key, value := range properties {
- field := fields[key]
- if field == nil {
- if value != nil && isHolder {
- itemAdditionalData[key] = value.value
- }
- } else {
- err := field(result, value)
- if err != nil {
- return nil, err
- }
- }
- }
- }
- //TODO on after when implementing backing store
- return result, nil
-}
-
-// GetCollectionOfObjectValues returns the collection of Parsable values from the node.
-func (n *JsonParseNode) GetCollectionOfObjectValues(ctor absser.ParsableFactory) ([]absser.Parsable, error) {
- if n == nil || n.value == nil {
- return nil, nil
- }
- if ctor == nil {
- return nil, errors.New("ctor is nil")
- }
- nodes, ok := n.value.([]*JsonParseNode)
- if !ok {
- return nil, errors.New("value is not a collection")
- }
- result := make([]absser.Parsable, len(nodes))
- for i, v := range nodes {
- val, err := (*v).GetObjectValue(ctor)
- if err != nil {
- return nil, err
- }
- result[i] = val
- }
- return result, nil
-}
-
-// GetCollectionOfPrimitiveValues returns the collection of primitive values from the node.
-func (n *JsonParseNode) GetCollectionOfPrimitiveValues(targetType string) ([]interface{}, error) {
- if n == nil || n.value == nil {
- return nil, nil
- }
- if targetType == "" {
- return nil, errors.New("targetType is empty")
- }
- nodes, ok := n.value.([]*JsonParseNode)
- if !ok {
- return nil, errors.New("value is not a collection")
- }
- result := make([]interface{}, len(nodes))
- for i, v := range nodes {
- val, err := v.getPrimitiveValue(targetType)
- if err != nil {
- return nil, err
- }
- result[i] = val
- }
- return result, nil
-}
-func (n *JsonParseNode) getPrimitiveValue(targetType string) (interface{}, error) {
- switch targetType {
- case "string":
- return n.GetStringValue()
- case "bool":
- return n.GetBoolValue()
- case "uint8":
- return n.GetInt8Value()
- case "byte":
- return n.GetByteValue()
- case "float32":
- return n.GetFloat32Value()
- case "float64":
- return n.GetFloat64Value()
- case "int32":
- return n.GetInt32Value()
- case "int64":
- return n.GetInt64Value()
- case "time":
- return n.GetTimeValue()
- case "timeonly":
- return n.GetTimeOnlyValue()
- case "dateonly":
- return n.GetDateOnlyValue()
- case "isoduration":
- return n.GetISODurationValue()
- case "uuid":
- return n.GetUUIDValue()
- case "base64":
- return n.GetByteArrayValue()
- default:
- return nil, errors.New("targetType is not supported")
- }
-}
-
-// GetCollectionOfEnumValues returns the collection of Enum values from the node.
-func (n *JsonParseNode) GetCollectionOfEnumValues(parser func(string) (interface{}, error)) ([]interface{}, error) {
- if n == nil || n.value == nil {
- return nil, nil
- }
- if parser == nil {
- return nil, errors.New("parser is nil")
- }
- nodes, ok := n.value.([]*JsonParseNode)
- if !ok {
- return nil, errors.New("value is not a collection")
- }
- result := make([]interface{}, len(nodes))
- for i, v := range nodes {
- val, err := v.GetEnumValue(parser)
- if err != nil {
- return nil, err
- }
- result[i] = val
- }
- return result, nil
-}
-
-// GetStringValue returns a String value from the nodes.
-func (n *JsonParseNode) GetStringValue() (*string, error) {
- if n == nil || n.value == nil {
- return nil, nil
- }
- return n.value.(*string), nil
-}
-
-// GetBoolValue returns a Bool value from the nodes.
-func (n *JsonParseNode) GetBoolValue() (*bool, error) {
- if n == nil || n.value == nil {
- return nil, nil
- }
- return n.value.(*bool), nil
-}
-
-// GetInt8Value returns a int8 value from the nodes.
-func (n *JsonParseNode) GetInt8Value() (*int8, error) {
- if n == nil || n.value == nil {
- return nil, nil
- }
- return n.value.(*int8), nil
-}
-
-// GetBoolValue returns a Bool value from the nodes.
-func (n *JsonParseNode) GetByteValue() (*byte, error) {
- if n == nil || n.value == nil {
- return nil, nil
- }
- return n.value.(*byte), nil
-}
-
-// GetFloat32Value returns a Float32 value from the nodes.
-func (n *JsonParseNode) GetFloat32Value() (*float32, error) {
- v, err := n.GetFloat64Value()
- if err != nil {
- return nil, err
- }
- if v == nil {
- return nil, nil
- }
- cast := float32(*v)
- return &cast, nil
-}
-
-// GetFloat64Value returns a Float64 value from the nodes.
-func (n *JsonParseNode) GetFloat64Value() (*float64, error) {
- if n == nil || n.value == nil {
- return nil, nil
- }
- return n.value.(*float64), nil
-}
-
-// GetInt32Value returns a Int32 value from the nodes.
-func (n *JsonParseNode) GetInt32Value() (*int32, error) {
- v, err := n.GetFloat64Value()
- if err != nil {
- return nil, err
- }
- if v == nil {
- return nil, nil
- }
- cast := int32(*v)
- return &cast, nil
-}
-
-// GetInt64Value returns a Int64 value from the nodes.
-func (n *JsonParseNode) GetInt64Value() (*int64, error) {
- v, err := n.GetFloat64Value()
- if err != nil {
- return nil, err
- }
- if v == nil {
- return nil, nil
- }
- cast := int64(*v)
- return &cast, nil
-}
-
-// GetTimeValue returns a Time value from the nodes.
-func (n *JsonParseNode) GetTimeValue() (*time.Time, error) {
- v, err := n.GetStringValue()
- if err != nil {
- return nil, err
- }
- if v == nil {
- return nil, nil
- }
- parsed, err := time.Parse(time.RFC3339, *v)
- return &parsed, err
-}
-
-// GetISODurationValue returns a ISODuration value from the nodes.
-func (n *JsonParseNode) GetISODurationValue() (*absser.ISODuration, error) {
- v, err := n.GetStringValue()
- if err != nil {
- return nil, err
- }
- if v == nil {
- return nil, nil
- }
- return absser.ParseISODuration(*v)
-}
-
-// GetTimeOnlyValue returns a TimeOnly value from the nodes.
-func (n *JsonParseNode) GetTimeOnlyValue() (*absser.TimeOnly, error) {
- v, err := n.GetStringValue()
- if err != nil {
- return nil, err
- }
- if v == nil {
- return nil, nil
- }
- return absser.ParseTimeOnly(*v)
-}
-
-// GetDateOnlyValue returns a DateOnly value from the nodes.
-func (n *JsonParseNode) GetDateOnlyValue() (*absser.DateOnly, error) {
- v, err := n.GetStringValue()
- if err != nil {
- return nil, err
- }
- if v == nil {
- return nil, nil
- }
- return absser.ParseDateOnly(*v)
-}
-
-// GetUUIDValue returns a UUID value from the nodes.
-func (n *JsonParseNode) GetUUIDValue() (*uuid.UUID, error) {
- v, err := n.GetStringValue()
- if err != nil {
- return nil, err
- }
- if v == nil {
- return nil, nil
- }
- parsed, err := uuid.Parse(*v)
- return &parsed, err
-}
-
-// GetEnumValue returns a Enum value from the nodes.
-func (n *JsonParseNode) GetEnumValue(parser func(string) (interface{}, error)) (interface{}, error) {
- if parser == nil {
- return nil, errors.New("parser is nil")
- }
- s, err := n.GetStringValue()
- if err != nil {
- return nil, err
- }
- if s == nil {
- return nil, nil
- }
- return parser(*s)
-}
-
-// GetByteArrayValue returns a ByteArray value from the nodes.
-func (n *JsonParseNode) GetByteArrayValue() ([]byte, error) {
- s, err := n.GetStringValue()
- if err != nil {
- return nil, err
- }
- if s == nil {
- return nil, nil
- }
- return base64.StdEncoding.DecodeString(*s)
-}
diff --git a/serialization/go/json/json_parse_node_factory.go b/serialization/go/json/json_parse_node_factory.go
deleted file mode 100644
index 9254fedf70..0000000000
--- a/serialization/go/json/json_parse_node_factory.go
+++ /dev/null
@@ -1,35 +0,0 @@
-package jsonserialization
-
-import (
- "errors"
-
- absser "github.com/microsoft/kiota/abstractions/go/serialization"
-)
-
-// JsonParseNodeFactory is a ParseNodeFactory implementation for JSON
-type JsonParseNodeFactory struct {
-}
-
-// Creates a new JsonParseNodeFactory
-func NewJsonParseNodeFactory() *JsonParseNodeFactory {
- return &JsonParseNodeFactory{}
-}
-
-// GetValidContentType returns the content type this factory's parse nodes can deserialize.
-func (f *JsonParseNodeFactory) GetValidContentType() (string, error) {
- return "application/json", nil
-}
-
-// GetRootParseNode return a new ParseNode instance that is the root of the content
-func (f *JsonParseNodeFactory) GetRootParseNode(contentType string, content []byte) (absser.ParseNode, error) {
- validType, err := f.GetValidContentType()
- if err != nil {
- return nil, err
- } else if contentType == "" {
- return nil, errors.New("contentType is empty")
- } else if contentType != validType {
- return nil, errors.New("contentType is not valid")
- } else {
- return NewJsonParseNode(content)
- }
-}
diff --git a/serialization/go/json/json_parse_node_test.go b/serialization/go/json/json_parse_node_test.go
deleted file mode 100644
index 6e7773139c..0000000000
--- a/serialization/go/json/json_parse_node_test.go
+++ /dev/null
@@ -1,126 +0,0 @@
-package jsonserialization
-
-import (
- testing "testing"
-)
-
-func TestTree(t *testing.T) {
- source := "{\"someProp\": \"stringValue\",\"otherProp\": [1,2,3],\"objectProp\": {\"boolProp\": true}}"
- sourceArray := []byte(source)
- parseNode, err := NewJsonParseNode(sourceArray)
- if err != nil {
- t.Errorf("Error creating parse node: %s", err.Error())
- }
- someProp, err := parseNode.GetChildNode("someProp")
- if err != nil {
- t.Errorf("Error getting child node: %s", err.Error())
- }
- stringValue, err := someProp.GetStringValue()
- if err != nil {
- t.Errorf("Error getting string value: %s", err.Error())
- }
- if *stringValue != "stringValue" {
- t.Errorf("Expected value to be 'stringValue', got '%s'", *stringValue)
- }
- otherProp, err := parseNode.GetChildNode("otherProp")
- if err != nil {
- t.Errorf("Error getting child node: %s", err.Error())
- }
- arrayValue, err := otherProp.GetCollectionOfPrimitiveValues("int32")
- if err != nil {
- t.Errorf("Error getting array value: %s", err.Error())
- }
- if len(arrayValue) != 3 {
- t.Errorf("Expected array to have 3 elements, got %d", len(arrayValue))
- }
- if *(arrayValue[0].(*int32)) != 1 {
- t.Errorf("Expected array element 0 to be 1, got %d", arrayValue[0])
- }
- objectProp, err := parseNode.GetChildNode("objectProp")
- if err != nil {
- t.Errorf("Error getting child node: %s", err.Error())
- }
- boolProp, err := objectProp.GetChildNode("boolProp")
- if err != nil {
- t.Errorf("Error getting child node: %s", err.Error())
- }
- boolValue, err := boolProp.GetBoolValue()
- if err != nil {
- t.Errorf("Error getting boolean value: %s", err.Error())
- }
- if !*boolValue {
- t.Errorf("Expected value to be true, got false")
- }
-}
-
-func TestFunctional(t *testing.T) {
- sourceArray := []byte(FunctionalTestSource)
- parseNode, err := NewJsonParseNode(sourceArray)
- if err != nil {
- t.Errorf("Error creating parse node: %s", err.Error())
- }
- if parseNode == nil {
- t.Errorf("Expected parse node to be non-nil")
- }
-}
-
-const FunctionalTestSource = "{" +
- "\"@odata.context\": \"https://graph.microsoft.com/v1.0/$metadata#users('vincent%40biret365.onmicrosoft.com')/messages\"," +
- "\"@odata.nextLink\": \"https://graph.microsoft.com/v1.0/users/vincent@biret365.onmicrosoft.com/messages?$skip=10\"," +
- "\"value\": [" +
- "{" +
- "\"@odata.etag\": \"W/\\\"CQAAABYAAAAs+XSiyjZdS4Rhtwk0v1pGAAA4Xv0v\\\"\"," +
- "\"id\": \"AAMkAGNmMGZiNjM5LTZmMDgtNGU2OS1iYmUwLWYwZDc4M2ZkOGY1ZQBGAAAAAAAK20ulGawAT7z-yx90ohp-BwAs_XSiyjZdS4Rhtwk0v1pGAAAAAAEMAAAs_XSiyjZdS4Rhtwk0v1pGAAA4dw6TAAA=\"," +
- "\"createdDateTime\": \"2021-10-14T09:19:01Z\"," +
- "\"lastModifiedDateTime\": \"2021-10-14T09:19:03Z\"," +
- "\"changeKey\": \"CQAAABYAAAAs+XSiyjZdS4Rhtwk0v1pGAAA4Xv0v\"," +
- "\"categories\": []," +
- "\"receivedDateTime\": \"2021-10-14T09:19:02Z\"," +
- "\"sentDateTime\": \"2021-10-14T09:18:59Z\"," +
- "\"hasAttachments\": false," +
- "\"internetMessageId\": \"<608fed24166f421aa1e27a6c822074ba-JFBVALKQOJXWILKNK4YVA7CPGM3DKTLFONZWCZ3FINSW45DFOJ6E2ZLTONQWOZKDMVXHIZLSL5GUGMRZGEYDQOD4KNWXI4A=@microsoft.com>\"," +
- "\"subject\": \"Major update from Message center\"," +
- "\"bodyPreview\": \"(Updated) Microsoft 365 Compliance Center Core eDiscovery - Search by ID list retirementMC291088 · BIRET365Updated October 13, 2021: We have updated this message with additional details for clarity.We will be retiring the option to Search by ID,\"," +
- "\"importance\": \"normal\"," +
- "\"parentFolderId\": \"AQMkAGNmMGZiNjM5LTZmMDgtNGU2OS1iYgBlMC1mMGQ3ODNmZDhmNWUALgAAAwrbS6UZrABPvP-LH3SiGn8BACz5dKLKNl1LhGG3CTS-WkYAAAIBDAAAAA==\"," +
- "\"conversationId\": \"AAQkAGNmMGZiNjM5LTZmMDgtNGU2OS1iYmUwLWYwZDc4M2ZkOGY1ZQAQANari86tqeZDsqpmA19AXLQ=\"," +
- "\"conversationIndex\": \"AQHXwNyG1quLzq2p5kOyqmYDX0BctA==\"," +
- "\"isDeliveryReceiptRequested\": null," +
- "\"isReadReceiptRequested\": false," +
- "\"isRead\": false," +
- "\"isDraft\": false," +
- "\"webLink\": \"https://outlook.office365.com/owa/?ItemID=AAMkAGNmMGZiNjM5LTZmMDgtNGU2OS1iYmUwLWYwZDc4M2ZkOGY1ZQBGAAAAAAAK20ulGawAT7z%2Fyx90ohp%2FBwAs%2BXSiyjZdS4Rhtwk0v1pGAAAAAAEMAAAs%2BXSiyjZdS4Rhtwk0v1pGAAA4dw6TAAA%3D&exvsurl=1&viewmodel=ReadMessageItem\"," +
- "\"inferenceClassification\": \"other\"," +
- "\"body\": {" +
- "\"contentType\": \"html\"," +
- "\"content\": \"
| | (Updated) Microsoft 365 Compliance Center Core eDiscovery - Search by ID list retirement | MC291088 · BIRET365 | Updated October 13, 2021: We have updated this message with additional details for clarity. We will be retiring the option to Search by ID list, as it is not functioning to an adequate level and creates significant challenges for organizations who depend on consistent and repeatable results for eDiscovery workflows.
When will this happen: We will begin making this change in mid-November and expect to complete by the end of November. How this will affect your organization:
You are receiving this message because our reporting indicates your organization may be using Search by ID list. Once this change is made, the option to Search by ID list will be removed. We suggest focusing on search by query, condition and/or locations rather that ID. What you need to do to prepare:
To fix this problem you need to review your eDiscovery search process, and update the workflow to focus on search by Subjects and dates rather than Search by ID list. Upon export from Core eDiscovery you can explore options to refine to only the messages of interest. Click Additional Information to find out more.
Additional Information | You're subscribed to this email using vincent@biret365.onmicrosoft.com. If you're an IT admin, you're subscribed by default, but you can unsubscribe at any time. If you're not an IT admin, ask your admin to remove your email address from Microsoft 365 message center preferences.
How to view translated messages
| Microsoft Corporation, One Microsoft Way, Redmond WA 98052 USA |
|
| |
\"" +
- "}," +
- "\"sender\": {" +
- "\"emailAddress\": {" +
- "\"name\": \"Microsoft 365 Message center\"," +
- "\"address\": \"o365mc@microsoft.com\"" +
- "}" +
- "}," +
- "\"from\": {" +
- "\"emailAddress\": {" +
- "\"name\": \"Microsoft 365 Message center\"," +
- "\"address\": \"o365mc@microsoft.com\"" +
- "}" +
- "}," +
- "\"toRecipients\": [" +
- "{" +
- "\"emailAddress\": {" +
- "\"name\": \"Vincent BIRET\"," +
- "\"address\": \"vincent@biret365.onmicrosoft.com\"" +
- "}" +
- "}" +
- "]," +
- "\"ccRecipients\": []," +
- "\"bccRecipients\": []," +
- "\"replyTo\": []," +
- "\"flag\": {" +
- "\"flagStatus\": \"notFlagged\"" +
- "}" +
- "}" +
- "]" +
- "}"
diff --git a/serialization/go/json/json_serialization_writer.go b/serialization/go/json/json_serialization_writer.go
deleted file mode 100644
index 3bfefc0729..0000000000
--- a/serialization/go/json/json_serialization_writer.go
+++ /dev/null
@@ -1,840 +0,0 @@
-package jsonserialization
-
-import (
- "encoding/base64"
- "strconv"
- "strings"
- "time"
-
- "github.com/google/uuid"
-
- absser "github.com/microsoft/kiota/abstractions/go/serialization"
-)
-
-// JsonSerializationWriter implements SerializationWriter for JSON.
-type JsonSerializationWriter struct {
- writer []string
-}
-
-// NewJsonSerializationWriter creates a new instance of the JsonSerializationWriter.
-func NewJsonSerializationWriter() *JsonSerializationWriter {
- return &JsonSerializationWriter{
- writer: make([]string, 0),
- }
-}
-func (w *JsonSerializationWriter) writeRawValue(value string) {
- w.writer = append(w.writer, value)
-}
-func (w *JsonSerializationWriter) writeStringValue(value string) {
- w.writeRawValue("\"" + value + "\"")
-}
-func (w *JsonSerializationWriter) writePropertyName(key string) {
- w.writeRawValue("\"" + key + "\":")
-}
-func (w *JsonSerializationWriter) writePropertySeparator() {
- w.writeRawValue(",")
-}
-func (w *JsonSerializationWriter) trimLastPropertySeparator() {
- writerLen := len(w.writer)
- if writerLen > 0 && w.writer[writerLen-1] == "," {
- w.writer = w.writer[:writerLen-1]
- }
-}
-func (w *JsonSerializationWriter) writeArrayStart() {
- w.writeRawValue("[")
-}
-func (w *JsonSerializationWriter) writeArrayEnd() {
- w.writeRawValue("]")
-}
-func (w *JsonSerializationWriter) writeObjectStart() {
- w.writeRawValue("{")
-}
-func (w *JsonSerializationWriter) writeObjectEnd() {
- w.writeRawValue("}")
-}
-
-// WriteStringValue writes a String value to underlying the byte array.
-func (w *JsonSerializationWriter) WriteStringValue(key string, value *string) error {
- if key != "" && value != nil {
- w.writePropertyName(key)
- }
- if value != nil {
- w.writeStringValue(*value)
- }
- if key != "" && value != nil {
- w.writePropertySeparator()
- }
- return nil
-}
-
-// WriteBoolValue writes a Bool value to underlying the byte array.
-func (w *JsonSerializationWriter) WriteBoolValue(key string, value *bool) error {
- if key != "" && value != nil {
- w.writePropertyName(key)
- }
- if value != nil {
- w.writeRawValue(strconv.FormatBool(*value))
- }
- if key != "" && value != nil {
- w.writePropertySeparator()
- }
- return nil
-}
-
-// WriteByteValue writes a Byte value to underlying the byte array.
-func (w *JsonSerializationWriter) WriteByteValue(key string, value *byte) error {
- if key != "" && value != nil {
- w.writePropertyName(key)
- }
- if value != nil {
- cast := int64(*value)
- return w.WriteInt64Value(key, &cast)
- }
- if key != "" && value != nil {
- w.writePropertySeparator()
- }
- return nil
-}
-
-// WriteInt8Value writes a int8 value to underlying the byte array.
-func (w *JsonSerializationWriter) WriteInt8Value(key string, value *int8) error {
- if key != "" && value != nil {
- w.writePropertyName(key)
- }
- if value != nil {
- cast := int64(*value)
- return w.WriteInt64Value(key, &cast)
- }
- if key != "" && value != nil {
- w.writePropertySeparator()
- }
- return nil
-}
-
-// WriteInt32Value writes a Int32 value to underlying the byte array.
-func (w *JsonSerializationWriter) WriteInt32Value(key string, value *int32) error {
- if value != nil {
- cast := int64(*value)
- return w.WriteInt64Value(key, &cast)
- }
- return nil
-}
-
-// WriteInt64Value writes a Int64 value to underlying the byte array.
-func (w *JsonSerializationWriter) WriteInt64Value(key string, value *int64) error {
- if key != "" && value != nil {
- w.writePropertyName(key)
- }
- if value != nil {
- w.writeRawValue(strconv.FormatInt(*value, 10))
- }
- if key != "" && value != nil {
- w.writePropertySeparator()
- }
- return nil
-}
-
-// WriteFloat32Value writes a Float32 value to underlying the byte array.
-func (w *JsonSerializationWriter) WriteFloat32Value(key string, value *float32) error {
- if value != nil {
- cast := float64(*value)
- return w.WriteFloat64Value(key, &cast)
- }
- return nil
-}
-
-// WriteFloat64Value writes a Float64 value to underlying the byte array.
-func (w *JsonSerializationWriter) WriteFloat64Value(key string, value *float64) error {
- if key != "" && value != nil {
- w.writePropertyName(key)
- }
- if value != nil {
- w.writeRawValue(strconv.FormatFloat(*value, 'f', -1, 64))
- }
- if key != "" && value != nil {
- w.writePropertySeparator()
- }
- return nil
-}
-
-// WriteTimeValue writes a Time value to underlying the byte array.
-func (w *JsonSerializationWriter) WriteTimeValue(key string, value *time.Time) error {
- if key != "" && value != nil {
- w.writePropertyName(key)
- }
- if value != nil {
- w.writeRawValue((*value).String())
- }
- if key != "" && value != nil {
- w.writePropertySeparator()
- }
- return nil
-}
-
-// WriteISODurationValue writes a ISODuration value to underlying the byte array.
-func (w *JsonSerializationWriter) WriteISODurationValue(key string, value *absser.ISODuration) error {
- if key != "" && value != nil {
- w.writePropertyName(key)
- }
- if value != nil {
- w.writeRawValue((*value).String())
- }
- if key != "" && value != nil {
- w.writePropertySeparator()
- }
- return nil
-}
-
-// WriteTimeOnlyValue writes a TimeOnly value to underlying the byte array.
-func (w *JsonSerializationWriter) WriteTimeOnlyValue(key string, value *absser.TimeOnly) error {
- if key != "" && value != nil {
- w.writePropertyName(key)
- }
- if value != nil {
- w.writeRawValue((*value).String())
- }
- if key != "" && value != nil {
- w.writePropertySeparator()
- }
- return nil
-}
-
-// WriteDateOnlyValue writes a DateOnly value to underlying the byte array.
-func (w *JsonSerializationWriter) WriteDateOnlyValue(key string, value *absser.DateOnly) error {
- if key != "" && value != nil {
- w.writePropertyName(key)
- }
- if value != nil {
- w.writeRawValue((*value).String())
- }
- if key != "" && value != nil {
- w.writePropertySeparator()
- }
- return nil
-}
-
-// WriteUUIDValue writes a UUID value to underlying the byte array.
-func (w *JsonSerializationWriter) WriteUUIDValue(key string, value *uuid.UUID) error {
- if key != "" && value != nil {
- w.writePropertyName(key)
- }
- if value != nil {
- w.writeStringValue((*value).String())
- }
- if key != "" && value != nil {
- w.writePropertySeparator()
- }
- return nil
-}
-
-// WriteByteArrayValue writes a ByteArray value to underlying the byte array.
-func (w *JsonSerializationWriter) WriteByteArrayValue(key string, value []byte) error {
- if key != "" && value != nil {
- w.writePropertyName(key)
- }
- if value != nil {
- w.writeStringValue(base64.StdEncoding.EncodeToString(value))
- }
- if key != "" && value != nil {
- w.writePropertySeparator()
- }
- return nil
-}
-
-// WriteObjectValue writes a Parsable value to underlying the byte array.
-func (w *JsonSerializationWriter) WriteObjectValue(key string, item absser.Parsable) error {
- if item != nil {
- if key != "" {
- w.writePropertyName(key)
- }
- //TODO onBefore for backing store
- w.writeObjectStart()
- //TODO onStart for backing store
- err := item.Serialize(w)
- //TODO onAfter for backing store
- if err != nil {
- return err
- }
- w.trimLastPropertySeparator()
- w.writeObjectEnd()
- if key != "" {
- w.writePropertySeparator()
- }
- }
- return nil
-}
-
-// WriteCollectionOfObjectValues writes a collection of Parsable values to underlying the byte array.
-func (w *JsonSerializationWriter) WriteCollectionOfObjectValues(key string, collection []absser.Parsable) error {
- if collection != nil { // empty collections are meaningful
- if key != "" {
- w.writePropertyName(key)
- }
- w.writeArrayStart()
- for _, item := range collection {
- err := w.WriteObjectValue("", item)
- if err != nil {
- return err
- }
- w.writePropertySeparator()
- }
- w.trimLastPropertySeparator()
- w.writeArrayEnd()
- if key != "" {
- w.writePropertySeparator()
- }
- }
- return nil
-}
-
-// WriteCollectionOfStringValues writes a collection of String values to underlying the byte array.
-func (w *JsonSerializationWriter) WriteCollectionOfStringValues(key string, collection []string) error {
- if collection != nil { // empty collections are meaningful
- if key != "" {
- w.writePropertyName(key)
- }
- w.writeArrayStart()
- for _, item := range collection {
- err := w.WriteStringValue("", &item)
- if err != nil {
- return err
- }
- w.writePropertySeparator()
- }
- w.trimLastPropertySeparator()
- w.writeArrayEnd()
- if key != "" {
- w.writePropertySeparator()
- }
- }
- return nil
-}
-
-// WriteCollectionOfInt32Values writes a collection of Int32 values to underlying the byte array.
-func (w *JsonSerializationWriter) WriteCollectionOfInt32Values(key string, collection []int32) error {
- if collection != nil { // empty collections are meaningful
- if key != "" {
- w.writePropertyName(key)
- }
- w.writeArrayStart()
- for _, item := range collection {
- err := w.WriteInt32Value("", &item)
- if err != nil {
- return err
- }
- w.writePropertySeparator()
- }
- w.trimLastPropertySeparator()
- w.writeArrayEnd()
- if key != "" {
- w.writePropertySeparator()
- }
- }
- return nil
-}
-
-// WriteCollectionOfInt64Values writes a collection of Int64 values to underlying the byte array.
-func (w *JsonSerializationWriter) WriteCollectionOfInt64Values(key string, collection []int64) error {
- if collection != nil { // empty collections are meaningful
- if key != "" {
- w.writePropertyName(key)
- }
- w.writeArrayStart()
- for _, item := range collection {
- err := w.WriteInt64Value("", &item)
- if err != nil {
- return err
- }
- w.writePropertySeparator()
- }
- w.trimLastPropertySeparator()
- w.writeArrayEnd()
- if key != "" {
- w.writePropertySeparator()
- }
- }
- return nil
-}
-
-// WriteCollectionOfFloat32Values writes a collection of Float32 values to underlying the byte array.
-func (w *JsonSerializationWriter) WriteCollectionOfFloat32Values(key string, collection []float32) error {
- if collection != nil { // empty collections are meaningful
- if key != "" {
- w.writePropertyName(key)
- }
- w.writeArrayStart()
- for _, item := range collection {
- err := w.WriteFloat32Value("", &item)
- if err != nil {
- return err
- }
- w.writePropertySeparator()
- }
- w.trimLastPropertySeparator()
- w.writeArrayEnd()
- if key != "" {
- w.writePropertySeparator()
- }
- }
- return nil
-}
-
-// WriteCollectionOfFloat64Values writes a collection of Float64 values to underlying the byte array.
-func (w *JsonSerializationWriter) WriteCollectionOfFloat64Values(key string, collection []float64) error {
- if collection != nil { // empty collections are meaningful
- if key != "" {
- w.writePropertyName(key)
- }
- w.writeArrayStart()
- for _, item := range collection {
- err := w.WriteFloat64Value("", &item)
- if err != nil {
- return err
- }
- w.writePropertySeparator()
- }
- w.trimLastPropertySeparator()
- w.writeArrayEnd()
- if key != "" {
- w.writePropertySeparator()
- }
- }
- return nil
-}
-
-// WriteCollectionOfTimeValues writes a collection of Time values to underlying the byte array.
-func (w *JsonSerializationWriter) WriteCollectionOfTimeValues(key string, collection []time.Time) error {
- if collection != nil { // empty collections are meaningful
- if key != "" {
- w.writePropertyName(key)
- }
- w.writeArrayStart()
- for _, item := range collection {
- err := w.WriteTimeValue("", &item)
- if err != nil {
- return err
- }
- w.writePropertySeparator()
- }
- w.trimLastPropertySeparator()
- w.writeArrayEnd()
- if key != "" {
- w.writePropertySeparator()
- }
- }
- return nil
-}
-
-// WriteCollectionOfISODurationValues writes a collection of ISODuration values to underlying the byte array.
-func (w *JsonSerializationWriter) WriteCollectionOfISODurationValues(key string, collection []absser.ISODuration) error {
- if collection != nil { // empty collections are meaningful
- if key != "" {
- w.writePropertyName(key)
- }
- w.writeArrayStart()
- for _, item := range collection {
- err := w.WriteISODurationValue("", &item)
- if err != nil {
- return err
- }
- w.writePropertySeparator()
- }
- w.trimLastPropertySeparator()
- w.writeArrayEnd()
- if key != "" {
- w.writePropertySeparator()
- }
- }
- return nil
-}
-
-// WriteCollectionOfTimeOnlyValues writes a collection of TimeOnly values to underlying the byte array.
-func (w *JsonSerializationWriter) WriteCollectionOfTimeOnlyValues(key string, collection []absser.TimeOnly) error {
- if collection != nil { // empty collections are meaningful
- if key != "" {
- w.writePropertyName(key)
- }
- w.writeArrayStart()
- for _, item := range collection {
- err := w.WriteTimeOnlyValue("", &item)
- if err != nil {
- return err
- }
- w.writePropertySeparator()
- }
- w.trimLastPropertySeparator()
- w.writeArrayEnd()
- if key != "" {
- w.writePropertySeparator()
- }
- }
- return nil
-}
-
-// WriteCollectionOfDateOnlyValues writes a collection of DateOnly values to underlying the byte array.
-func (w *JsonSerializationWriter) WriteCollectionOfDateOnlyValues(key string, collection []absser.DateOnly) error {
- if collection != nil { // empty collections are meaningful
- if key != "" {
- w.writePropertyName(key)
- }
- w.writeArrayStart()
- for _, item := range collection {
- err := w.WriteDateOnlyValue("", &item)
- if err != nil {
- return err
- }
- w.writePropertySeparator()
- }
- w.trimLastPropertySeparator()
- w.writeArrayEnd()
- if key != "" {
- w.writePropertySeparator()
- }
- }
- return nil
-}
-
-// WriteCollectionOfUUIDValues writes a collection of UUID values to underlying the byte array.
-func (w *JsonSerializationWriter) WriteCollectionOfUUIDValues(key string, collection []uuid.UUID) error {
- if collection != nil { // empty collections are meaningful
- if key != "" {
- w.writePropertyName(key)
- }
- w.writeArrayStart()
- for _, item := range collection {
- err := w.WriteUUIDValue("", &item)
- if err != nil {
- return err
- }
- w.writePropertySeparator()
- }
- w.trimLastPropertySeparator()
- w.writeArrayEnd()
- if key != "" {
- w.writePropertySeparator()
- }
- }
- return nil
-}
-
-// WriteCollectionOfBoolValues writes a collection of Bool values to underlying the byte array.
-func (w *JsonSerializationWriter) WriteCollectionOfBoolValues(key string, collection []bool) error {
- if collection != nil { // empty collections are meaningful
- if key != "" {
- w.writePropertyName(key)
- }
- w.writeArrayStart()
- for _, item := range collection {
- err := w.WriteBoolValue("", &item)
- if err != nil {
- return err
- }
- w.writePropertySeparator()
- }
- w.trimLastPropertySeparator()
- w.writeArrayEnd()
- if key != "" {
- w.writePropertySeparator()
- }
- }
- return nil
-}
-
-// WriteCollectionOfByteValues writes a collection of Byte values to underlying the byte array.
-func (w *JsonSerializationWriter) WriteCollectionOfByteValues(key string, collection []byte) error {
- if collection != nil { // empty collections are meaningful
- if key != "" {
- w.writePropertyName(key)
- }
- w.writeArrayStart()
- for _, item := range collection {
- err := w.WriteByteValue("", &item)
- if err != nil {
- return err
- }
- w.writePropertySeparator()
- }
- w.trimLastPropertySeparator()
- w.writeArrayEnd()
- if key != "" {
- w.writePropertySeparator()
- }
- }
- return nil
-}
-
-// WriteCollectionOfInt8Values writes a collection of int8 values to underlying the byte array.
-func (w *JsonSerializationWriter) WriteCollectionOfInt8Values(key string, collection []int8) error {
- if collection != nil { // empty collections are meaningful
- if key != "" {
- w.writePropertyName(key)
- }
- w.writeArrayStart()
- for _, item := range collection {
- err := w.WriteInt8Value("", &item)
- if err != nil {
- return err
- }
- w.writePropertySeparator()
- }
- w.trimLastPropertySeparator()
- w.writeArrayEnd()
- if key != "" {
- w.writePropertySeparator()
- }
- }
- return nil
-}
-
-// GetSerializedContent returns the resulting byte array from the serialization writer.
-func (w *JsonSerializationWriter) GetSerializedContent() ([]byte, error) {
- resultStr := strings.Join(w.writer, "")
- return []byte(resultStr), nil
-}
-
-// WriteAdditionalData writes additional data to underlying the byte array.
-func (w *JsonSerializationWriter) WriteAdditionalData(value map[string]interface{}) error {
- if len(value) != 0 {
- for key, value := range value {
- p, ok := value.(absser.Parsable)
- if ok {
- err := w.WriteObjectValue(key, p)
- if err != nil {
- return err
- }
- continue
- }
- c, ok := value.([]absser.Parsable)
- if ok {
- err := w.WriteCollectionOfObjectValues(key, c)
- if err != nil {
- return err
- }
- continue
- }
- sc, ok := value.([]string)
- if ok {
- err := w.WriteCollectionOfStringValues(key, sc)
- if err != nil {
- return err
- }
- continue
- }
- bc, ok := value.([]bool)
- if ok {
- err := w.WriteCollectionOfBoolValues(key, bc)
- if err != nil {
- return err
- }
- continue
- }
- byc, ok := value.([]byte)
- if ok {
- err := w.WriteCollectionOfByteValues(key, byc)
- if err != nil {
- return err
- }
- continue
- }
- i8c, ok := value.([]int8)
- if ok {
- err := w.WriteCollectionOfInt8Values(key, i8c)
- if err != nil {
- return err
- }
- continue
- }
- i32c, ok := value.([]int32)
- if ok {
- err := w.WriteCollectionOfInt32Values(key, i32c)
- if err != nil {
- return err
- }
- continue
- }
- i64c, ok := value.([]int64)
- if ok {
- err := w.WriteCollectionOfInt64Values(key, i64c)
- if err != nil {
- return err
- }
- continue
- }
- f32c, ok := value.([]float32)
- if ok {
- err := w.WriteCollectionOfFloat32Values(key, f32c)
- if err != nil {
- return err
- }
- continue
- }
- f64c, ok := value.([]float64)
- if ok {
- err := w.WriteCollectionOfFloat64Values(key, f64c)
- if err != nil {
- return err
- }
- continue
- }
- uc, ok := value.([]uuid.UUID)
- if ok {
- err := w.WriteCollectionOfUUIDValues(key, uc)
- if err != nil {
- return err
- }
- continue
- }
- tc, ok := value.([]time.Time)
- if ok {
- err := w.WriteCollectionOfTimeValues(key, tc)
- if err != nil {
- return err
- }
- continue
- }
- dc, ok := value.([]absser.ISODuration)
- if ok {
- err := w.WriteCollectionOfISODurationValues(key, dc)
- if err != nil {
- return err
- }
- continue
- }
- toc, ok := value.([]absser.TimeOnly)
- if ok {
- err := w.WriteCollectionOfTimeOnlyValues(key, toc)
- if err != nil {
- return err
- }
- continue
- }
- doc, ok := value.([]absser.DateOnly)
- if ok {
- err := w.WriteCollectionOfDateOnlyValues(key, doc)
- if err != nil {
- return err
- }
- continue
- }
- sv, ok := value.(*string)
- if ok {
- err := w.WriteStringValue(key, sv)
- if err != nil {
- return err
- }
- continue
- }
- bv, ok := value.(*bool)
- if ok {
- err := w.WriteBoolValue(key, bv)
- if err != nil {
- return err
- }
- continue
- }
- byv, ok := value.(*byte)
- if ok {
- err := w.WriteByteValue(key, byv)
- if err != nil {
- return err
- }
- continue
- }
- i8v, ok := value.(*int8)
- if ok {
- err := w.WriteInt8Value(key, i8v)
- if err != nil {
- return err
- }
- continue
- }
- i32v, ok := value.(*int32)
- if ok {
- err := w.WriteInt32Value(key, i32v)
- if err != nil {
- return err
- }
- continue
- }
- i64v, ok := value.(*int64)
- if ok {
- err := w.WriteInt64Value(key, i64v)
- if err != nil {
- return err
- }
- continue
- }
- f32v, ok := value.(*float32)
- if ok {
- err := w.WriteFloat32Value(key, f32v)
- if err != nil {
- return err
- }
- continue
- }
- f64v, ok := value.(*float64)
- if ok {
- err := w.WriteFloat64Value(key, f64v)
- if err != nil {
- return err
- }
- continue
- }
- uv, ok := value.(*uuid.UUID)
- if ok {
- err := w.WriteUUIDValue(key, uv)
- if err != nil {
- return err
- }
- continue
- }
- tv, ok := value.(*time.Time)
- if ok {
- err := w.WriteTimeValue(key, tv)
- if err != nil {
- return err
- }
- continue
- }
- dv, ok := value.(*absser.ISODuration)
- if ok {
- err := w.WriteISODurationValue(key, dv)
- if err != nil {
- return err
- }
- continue
- }
- tov, ok := value.(*absser.TimeOnly)
- if ok {
- err := w.WriteTimeOnlyValue(key, tov)
- if err != nil {
- return err
- }
- continue
- }
- dov, ok := value.(*absser.DateOnly)
- if ok {
- err := w.WriteDateOnlyValue(key, dov)
- if err != nil {
- return err
- }
- continue
- }
- ba, ok := value.([]byte)
- if ok {
- err := w.WriteByteArrayValue(key, ba)
- if err != nil {
- return err
- }
- continue
- }
- }
- w.trimLastPropertySeparator()
- }
- return nil
-}
-
-// Close clears the internal buffer.
-func (w *JsonSerializationWriter) Close() error {
- return nil
-}
diff --git a/serialization/go/json/json_serialization_writer_factory.go b/serialization/go/json/json_serialization_writer_factory.go
deleted file mode 100644
index 9f33524267..0000000000
--- a/serialization/go/json/json_serialization_writer_factory.go
+++ /dev/null
@@ -1,35 +0,0 @@
-package jsonserialization
-
-import (
- "errors"
-
- absser "github.com/microsoft/kiota/abstractions/go/serialization"
-)
-
-// JsonSerializationWriterFactory implements SerializationWriterFactory for JSON.
-type JsonSerializationWriterFactory struct {
-}
-
-// NewJsonSerializationWriterFactory creates a new instance of the JsonSerializationWriterFactory.
-func NewJsonSerializationWriterFactory() *JsonSerializationWriterFactory {
- return &JsonSerializationWriterFactory{}
-}
-
-// GetValidContentType returns the valid content type for the SerializationWriterFactoryRegistry
-func (f *JsonSerializationWriterFactory) GetValidContentType() (string, error) {
- return "application/json", nil
-}
-
-// GetSerializationWriter returns the relevant SerializationWriter instance for the given content type
-func (f *JsonSerializationWriterFactory) GetSerializationWriter(contentType string) (absser.SerializationWriter, error) {
- validType, err := f.GetValidContentType()
- if err != nil {
- return nil, err
- } else if contentType == "" {
- return nil, errors.New("contentType is empty")
- } else if contentType != validType {
- return nil, errors.New("contentType is not valid")
- } else {
- return NewJsonSerializationWriter(), nil
- }
-}
diff --git a/serialization/go/json/json_serialization_writer_test.go b/serialization/go/json/json_serialization_writer_test.go
deleted file mode 100644
index fdcd9fafab..0000000000
--- a/serialization/go/json/json_serialization_writer_test.go
+++ /dev/null
@@ -1,34 +0,0 @@
-package jsonserialization
-
-import (
- assert "github.com/stretchr/testify/assert"
- "testing"
-)
-
-func TestItDoesntWriteAnythingForNilAdditionalData(t *testing.T) {
- serializer := NewJsonSerializationWriter()
- serializer.WriteAdditionalData(nil)
- result, err := serializer.GetSerializedContent()
- assert.Nil(t, err)
- assert.Equal(t, 0, len(result))
-}
-
-func TestItDoesntWriteAnythingForEmptyAdditionalData(t *testing.T) {
- serializer := NewJsonSerializationWriter()
- serializer.WriteAdditionalData(make(map[string]interface{}))
- result, err := serializer.GetSerializedContent()
- assert.Nil(t, err)
- assert.Equal(t, 0, len(result))
-}
-
-func TestItDoesntTrimCommasOnEmptyAdditionalData(t *testing.T) {
- serializer := NewJsonSerializationWriter()
- value := "value"
- serializer.WriteStringValue("key", &value)
- serializer.WriteAdditionalData(make(map[string]interface{}))
- value2 := "value2"
- serializer.WriteStringValue("key2", &value2)
- result, err := serializer.GetSerializedContent()
- assert.Nil(t, err)
- assert.Equal(t, "\"key\":\"value\",\"key2\":\"value2\",", string(result[:]))
-}
diff --git a/serialization/go/text/README.md b/serialization/go/text/README.md
deleted file mode 100644
index df7fd948ac..0000000000
--- a/serialization/go/text/README.md
+++ /dev/null
@@ -1,17 +0,0 @@
-# To-do
-
-![Go Serialization Text](https://github.com/microsoft/kiota/actions/workflows/serialization-go-text.yml/badge.svg)
-
-- [ ] coverage code
-- [ ] analyzers
-- [ ] unit test project
-- [ ] docs comments
-
-## Using the Text Serialization implementations
-
-1. Navigate to the directory where `go.mod` is located for your project.
-1. Run the following command:
-
- ```Shell
- go get github.com/microsoft/kiota/serialization/go/text
- ```
diff --git a/serialization/go/text/go.mod b/serialization/go/text/go.mod
deleted file mode 100644
index 613cc462f8..0000000000
--- a/serialization/go/text/go.mod
+++ /dev/null
@@ -1,15 +0,0 @@
-module github.com/microsoft/kiota/serialization/go/text
-
-go 1.17
-
-require (
- github.com/cjlapao/common-go v0.0.18 // indirect
- github.com/davecgh/go-spew v1.1.1 // indirect
- github.com/google/uuid v1.3.0 // indirect
- github.com/microsoft/kiota/abstractions/go v0.0.0-20220316090511-468a319ac5ba // indirect
- github.com/pmezard/go-difflib v1.0.0 // indirect
- github.com/stretchr/objx v0.1.0 // indirect
- github.com/stretchr/testify v1.7.1 // indirect
- github.com/yosida95/uritemplate/v3 v3.0.1 // indirect
- gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
-)
diff --git a/serialization/go/text/go.sum b/serialization/go/text/go.sum
deleted file mode 100644
index 7271d6d739..0000000000
--- a/serialization/go/text/go.sum
+++ /dev/null
@@ -1,21 +0,0 @@
-github.com/cjlapao/common-go v0.0.18 h1:j6kT/0pmJ69HmUCs9LrCc7IWyxTOh2WYJyZMzUYTULs=
-github.com/cjlapao/common-go v0.0.18/go.mod h1:zGdh2KmXnH4HTRfT7vPpY41cws776KULk44f09OPJgs=
-github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
-github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
-github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220316090511-468a319ac5ba h1:woefjJxmzGYMrFFdPDVqwAbSJb21eNr72BmdaptZ90w=
-github.com/microsoft/kiota/abstractions/go v0.0.0-20220316090511-468a319ac5ba/go.mod h1:ByVU/M0XlWTE0uflKWPv9Xrfrait2pcpMZSNGYM2nRc=
-github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
-github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
-github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
-github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/yosida95/uritemplate/v3 v3.0.1 h1:+Fs//CsT+x231WmUQhMHWMxZizMvpnkOVWop02mVCfs=
-github.com/yosida95/uritemplate/v3 v3.0.1/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
-gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
-gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/serialization/go/text/text_parse_node.go b/serialization/go/text/text_parse_node.go
deleted file mode 100644
index f8e126ef0d..0000000000
--- a/serialization/go/text/text_parse_node.go
+++ /dev/null
@@ -1,245 +0,0 @@
-// Package textserialization is the default Kiota serialization implementation for text.
-package textserialization
-
-import (
- "encoding/base64"
- "errors"
- "strconv"
- "strings"
- "time"
-
- "github.com/google/uuid"
- absser "github.com/microsoft/kiota/abstractions/go/serialization"
-)
-
-// TextParseNode is a ParseNode implementation for JSON.
-type TextParseNode struct {
- value string
-}
-
-// NewTextParseNode creates a new TextParseNode.
-func NewTextParseNode(content []byte) (*TextParseNode, error) {
- if len(content) == 0 {
- return nil, errors.New("content is empty")
- }
- value, err := loadTextTree(content)
- return value, err
-}
-func loadTextTree(content []byte) (*TextParseNode, error) {
- return &TextParseNode{
- value: string(content),
- }, nil
-}
-
-// GetChildNode returns a new parse node for the given identifier.
-func (n *TextParseNode) GetChildNode(index string) (absser.ParseNode, error) {
- return nil, NoStructuredDataError
-}
-
-// GetObjectValue returns the Parsable value from the node.
-func (n *TextParseNode) GetObjectValue(ctor absser.ParsableFactory) (absser.Parsable, error) {
- return nil, NoStructuredDataError
-}
-
-// GetCollectionOfObjectValues returns the collection of Parsable values from the node.
-func (n *TextParseNode) GetCollectionOfObjectValues(ctor absser.ParsableFactory) ([]absser.Parsable, error) {
- return nil, NoStructuredDataError
-}
-
-// GetCollectionOfPrimitiveValues returns the collection of primitive values from the node.
-func (n *TextParseNode) GetCollectionOfPrimitiveValues(targetType string) ([]interface{}, error) {
- return nil, NoStructuredDataError
-}
-
-// GetCollectionOfEnumValues returns the collection of Enum values from the node.
-func (n *TextParseNode) GetCollectionOfEnumValues(parser func(string) (interface{}, error)) ([]interface{}, error) {
- return nil, NoStructuredDataError
-}
-
-// GetStringValue returns a String value from the nodes.
-func (n *TextParseNode) GetStringValue() (*string, error) {
- if n == nil {
- return nil, nil
- }
- val := strings.Trim(n.value, "\"")
- return &val, nil
-}
-
-// GetBoolValue returns a Bool value from the nodes.
-func (n *TextParseNode) GetBoolValue() (*bool, error) {
- if n == nil {
- return nil, nil
- }
- val, err := strconv.ParseBool(n.value)
- if err != nil {
- return nil, err
- }
- return &val, nil
-}
-
-// GetInt8Value returns a int8 value from the nodes.
-func (n *TextParseNode) GetInt8Value() (*int8, error) {
- if n == nil {
- return nil, nil
- }
- val, err := strconv.ParseInt(n.value, 0, 8)
- if err != nil {
- return nil, err
- }
- cast := int8(val)
- return &cast, nil
-}
-
-// GetBoolValue returns a Bool value from the nodes.
-func (n *TextParseNode) GetByteValue() (*byte, error) {
- if n == nil {
- return nil, nil
- }
- val, err := strconv.ParseInt(n.value, 0, 8)
- if err != nil {
- return nil, err
- }
- cast := uint8(val)
- return &cast, nil
-}
-
-// GetFloat32Value returns a Float32 value from the nodes.
-func (n *TextParseNode) GetFloat32Value() (*float32, error) {
- v, err := n.GetFloat64Value()
- if err != nil {
- return nil, err
- }
- if v == nil {
- return nil, nil
- }
- cast := float32(*v)
- return &cast, nil
-}
-
-// GetFloat64Value returns a Float64 value from the nodes.
-func (n *TextParseNode) GetFloat64Value() (*float64, error) {
- if n == nil {
- return nil, nil
- }
- val, err := strconv.ParseFloat(n.value, 0)
- if err != nil {
- return nil, err
- }
- cast := float64(val)
- return &cast, nil
-}
-
-// GetInt32Value returns a Int32 value from the nodes.
-func (n *TextParseNode) GetInt32Value() (*int32, error) {
- v, err := n.GetFloat64Value()
- if err != nil {
- return nil, err
- }
- if v == nil {
- return nil, nil
- }
- cast := int32(*v)
- return &cast, nil
-}
-
-// GetInt64Value returns a Int64 value from the nodes.
-func (n *TextParseNode) GetInt64Value() (*int64, error) {
- v, err := n.GetFloat64Value()
- if err != nil {
- return nil, err
- }
- if v == nil {
- return nil, nil
- }
- cast := int64(*v)
- return &cast, nil
-}
-
-// GetTimeValue returns a Time value from the nodes.
-func (n *TextParseNode) GetTimeValue() (*time.Time, error) {
- v, err := n.GetStringValue()
- if err != nil {
- return nil, err
- }
- if v == nil {
- return nil, nil
- }
- parsed, err := time.Parse(time.RFC3339, *v)
- return &parsed, err
-}
-
-// GetISODurationValue returns a ISODuration value from the nodes.
-func (n *TextParseNode) GetISODurationValue() (*absser.ISODuration, error) {
- v, err := n.GetStringValue()
- if err != nil {
- return nil, err
- }
- if v == nil {
- return nil, nil
- }
- return absser.ParseISODuration(*v)
-}
-
-// GetTimeOnlyValue returns a TimeOnly value from the nodes.
-func (n *TextParseNode) GetTimeOnlyValue() (*absser.TimeOnly, error) {
- v, err := n.GetStringValue()
- if err != nil {
- return nil, err
- }
- if v == nil {
- return nil, nil
- }
- return absser.ParseTimeOnly(*v)
-}
-
-// GetDateOnlyValue returns a DateOnly value from the nodes.
-func (n *TextParseNode) GetDateOnlyValue() (*absser.DateOnly, error) {
- v, err := n.GetStringValue()
- if err != nil {
- return nil, err
- }
- if v == nil {
- return nil, nil
- }
- return absser.ParseDateOnly(*v)
-}
-
-// GetUUIDValue returns a UUID value from the nodes.
-func (n *TextParseNode) GetUUIDValue() (*uuid.UUID, error) {
- v, err := n.GetStringValue()
- if err != nil {
- return nil, err
- }
- if v == nil {
- return nil, nil
- }
- parsed, err := uuid.Parse(*v)
- return &parsed, err
-}
-
-// GetEnumValue returns a Enum value from the nodes.
-func (n *TextParseNode) GetEnumValue(parser func(string) (interface{}, error)) (interface{}, error) {
- if parser == nil {
- return nil, errors.New("parser is nil")
- }
- s, err := n.GetStringValue()
- if err != nil {
- return nil, err
- }
- if s == nil {
- return nil, nil
- }
- return parser(*s)
-}
-
-// GetByteArrayValue returns a ByteArray value from the nodes.
-func (n *TextParseNode) GetByteArrayValue() ([]byte, error) {
- s, err := n.GetStringValue()
- if err != nil {
- return nil, err
- }
- if s == nil {
- return nil, nil
- }
- return base64.StdEncoding.DecodeString(*s)
-}
diff --git a/serialization/go/text/text_parse_node_factory.go b/serialization/go/text/text_parse_node_factory.go
deleted file mode 100644
index e19e715109..0000000000
--- a/serialization/go/text/text_parse_node_factory.go
+++ /dev/null
@@ -1,35 +0,0 @@
-package textserialization
-
-import (
- "errors"
-
- absser "github.com/microsoft/kiota/abstractions/go/serialization"
-)
-
-// TextParseNodeFactory is a ParseNodeFactory implementation for text
-type TextParseNodeFactory struct {
-}
-
-// Creates a new TextParseNodeFactory
-func NewTextParseNodeFactory() *TextParseNodeFactory {
- return &TextParseNodeFactory{}
-}
-
-// GetValidContentType returns the content type this factory's parse nodes can deserialize.
-func (f *TextParseNodeFactory) GetValidContentType() (string, error) {
- return "text/plain", nil
-}
-
-// GetRootParseNode return a new ParseNode instance that is the root of the content
-func (f *TextParseNodeFactory) GetRootParseNode(contentType string, content []byte) (absser.ParseNode, error) {
- validType, err := f.GetValidContentType()
- if err != nil {
- return nil, err
- } else if contentType == "" {
- return nil, errors.New("contentType is empty")
- } else if contentType != validType {
- return nil, errors.New("contentType is not valid")
- } else {
- return NewTextParseNode(content)
- }
-}
diff --git a/serialization/go/text/text_parse_node_test.go b/serialization/go/text/text_parse_node_test.go
deleted file mode 100644
index 04d620f74a..0000000000
--- a/serialization/go/text/text_parse_node_test.go
+++ /dev/null
@@ -1,23 +0,0 @@
-package textserialization
-
-import (
- assert "github.com/stretchr/testify/assert"
- testing "testing"
-)
-
-func TestTree(t *testing.T) {
- source := "\"stringValue\""
- sourceArray := []byte(source)
- parseNode, err := NewTextParseNode(sourceArray)
- if err != nil {
- t.Errorf("Error creating parse node: %s", err.Error())
- }
- someProp, err := parseNode.GetChildNode("someProp")
- assert.NotNil(t, err)
- assert.Nil(t, someProp)
-
- stringValue, err := parseNode.GetStringValue()
- assert.Nil(t, err)
- assert.NotNil(t, stringValue)
- assert.Equal(t, "stringValue", *stringValue)
-}
diff --git a/serialization/go/text/text_serialization_writer.go b/serialization/go/text/text_serialization_writer.go
deleted file mode 100644
index 3be399d4ec..0000000000
--- a/serialization/go/text/text_serialization_writer.go
+++ /dev/null
@@ -1,247 +0,0 @@
-package textserialization
-
-import (
- "encoding/base64"
- "errors"
- "strconv"
- "strings"
- "time"
-
- "github.com/google/uuid"
-
- absser "github.com/microsoft/kiota/abstractions/go/serialization"
-)
-
-var NoStructuredDataError = errors.New("text does not support structured data")
-var OnlyOneValue = errors.New("text serialization writer can only write one value")
-
-// TextSerializationWriter implements SerializationWriter for JSON.
-type TextSerializationWriter struct {
- writer []string
-}
-
-// NewTextSerializationWriter creates a new instance of the TextSerializationWriter.
-func NewTextSerializationWriter() *TextSerializationWriter {
- return &TextSerializationWriter{
- writer: make([]string, 0),
- }
-}
-func (w *TextSerializationWriter) writeStringValue(key string, value string) error {
- if key != "" {
- return NoStructuredDataError
- }
- if value != "" {
- if len(w.writer) > 0 {
- return OnlyOneValue
- }
- w.writer = append(w.writer, value)
- }
- return nil
-}
-
-// WriteStringValue writes a String value to underlying the byte array.
-func (w *TextSerializationWriter) WriteStringValue(key string, value *string) error {
- if value != nil {
- return w.writeStringValue(key, *value)
- }
- return nil
-}
-
-// WriteBoolValue writes a Bool value to underlying the byte array.
-func (w *TextSerializationWriter) WriteBoolValue(key string, value *bool) error {
- if value != nil {
- return w.writeStringValue(key, strconv.FormatBool(*value))
- }
- return nil
-}
-
-// WriteByteValue writes a Byte value to underlying the byte array.
-func (w *TextSerializationWriter) WriteByteValue(key string, value *byte) error {
- if value != nil {
- cast := int64(*value)
- return w.WriteInt64Value(key, &cast)
- }
- return nil
-}
-
-// WriteInt8Value writes a int8 value to underlying the byte array.
-func (w *TextSerializationWriter) WriteInt8Value(key string, value *int8) error {
- if value != nil {
- cast := int64(*value)
- return w.WriteInt64Value(key, &cast)
- }
- return nil
-}
-
-// WriteInt32Value writes a Int32 value to underlying the byte array.
-func (w *TextSerializationWriter) WriteInt32Value(key string, value *int32) error {
- if value != nil {
- cast := int64(*value)
- return w.WriteInt64Value(key, &cast)
- }
- return nil
-}
-
-// WriteInt64Value writes a Int64 value to underlying the byte array.
-func (w *TextSerializationWriter) WriteInt64Value(key string, value *int64) error {
- if value != nil {
- return w.writeStringValue(key, strconv.FormatInt(*value, 10))
- }
- return nil
-}
-
-// WriteFloat32Value writes a Float32 value to underlying the byte array.
-func (w *TextSerializationWriter) WriteFloat32Value(key string, value *float32) error {
- if value != nil {
- cast := float64(*value)
- return w.WriteFloat64Value(key, &cast)
- }
- return nil
-}
-
-// WriteFloat64Value writes a Float64 value to underlying the byte array.
-func (w *TextSerializationWriter) WriteFloat64Value(key string, value *float64) error {
- if value != nil {
- return w.writeStringValue(key, strconv.FormatFloat(*value, 'f', -1, 64))
- }
- return nil
-}
-
-// WriteTimeValue writes a Time value to underlying the byte array.
-func (w *TextSerializationWriter) WriteTimeValue(key string, value *time.Time) error {
- if value != nil {
- return w.writeStringValue(key, (*value).String())
- }
- return nil
-}
-
-// WriteISODurationValue writes a ISODuration value to underlying the byte array.
-func (w *TextSerializationWriter) WriteISODurationValue(key string, value *absser.ISODuration) error {
- if value != nil {
- return w.writeStringValue(key, (*value).String())
- }
- return nil
-}
-
-// WriteTimeOnlyValue writes a TimeOnly value to underlying the byte array.
-func (w *TextSerializationWriter) WriteTimeOnlyValue(key string, value *absser.TimeOnly) error {
- if value != nil {
- return w.writeStringValue(key, (*value).String())
- }
- return nil
-}
-
-// WriteDateOnlyValue writes a DateOnly value to underlying the byte array.
-func (w *TextSerializationWriter) WriteDateOnlyValue(key string, value *absser.DateOnly) error {
- if value != nil {
- return w.writeStringValue(key, (*value).String())
- }
- return nil
-}
-
-// WriteUUIDValue writes a UUID value to underlying the byte array.
-func (w *TextSerializationWriter) WriteUUIDValue(key string, value *uuid.UUID) error {
- if value != nil {
- return w.writeStringValue(key, (*value).String())
- }
- return nil
-}
-
-// WriteByteArrayValue writes a ByteArray value to underlying the byte array.
-func (w *TextSerializationWriter) WriteByteArrayValue(key string, value []byte) error {
- if value != nil {
- return w.writeStringValue(key, base64.StdEncoding.EncodeToString(value))
- }
- return nil
-}
-
-// WriteObjectValue writes a Parsable value to underlying the byte array.
-func (w *TextSerializationWriter) WriteObjectValue(key string, item absser.Parsable) error {
- return NoStructuredDataError
-}
-
-// WriteCollectionOfObjectValues writes a collection of Parsable values to underlying the byte array.
-func (w *TextSerializationWriter) WriteCollectionOfObjectValues(key string, collection []absser.Parsable) error {
- return NoStructuredDataError
-}
-
-// WriteCollectionOfStringValues writes a collection of String values to underlying the byte array.
-func (w *TextSerializationWriter) WriteCollectionOfStringValues(key string, collection []string) error {
- return NoStructuredDataError
-}
-
-// WriteCollectionOfInt32Values writes a collection of Int32 values to underlying the byte array.
-func (w *TextSerializationWriter) WriteCollectionOfInt32Values(key string, collection []int32) error {
- return NoStructuredDataError
-}
-
-// WriteCollectionOfInt64Values writes a collection of Int64 values to underlying the byte array.
-func (w *TextSerializationWriter) WriteCollectionOfInt64Values(key string, collection []int64) error {
- return NoStructuredDataError
-}
-
-// WriteCollectionOfFloat32Values writes a collection of Float32 values to underlying the byte array.
-func (w *TextSerializationWriter) WriteCollectionOfFloat32Values(key string, collection []float32) error {
- return NoStructuredDataError
-}
-
-// WriteCollectionOfFloat64Values writes a collection of Float64 values to underlying the byte array.
-func (w *TextSerializationWriter) WriteCollectionOfFloat64Values(key string, collection []float64) error {
- return NoStructuredDataError
-}
-
-// WriteCollectionOfTimeValues writes a collection of Time values to underlying the byte array.
-func (w *TextSerializationWriter) WriteCollectionOfTimeValues(key string, collection []time.Time) error {
- return NoStructuredDataError
-}
-
-// WriteCollectionOfISODurationValues writes a collection of ISODuration values to underlying the byte array.
-func (w *TextSerializationWriter) WriteCollectionOfISODurationValues(key string, collection []absser.ISODuration) error {
- return NoStructuredDataError
-}
-
-// WriteCollectionOfTimeOnlyValues writes a collection of TimeOnly values to underlying the byte array.
-func (w *TextSerializationWriter) WriteCollectionOfTimeOnlyValues(key string, collection []absser.TimeOnly) error {
- return NoStructuredDataError
-}
-
-// WriteCollectionOfDateOnlyValues writes a collection of DateOnly values to underlying the byte array.
-func (w *TextSerializationWriter) WriteCollectionOfDateOnlyValues(key string, collection []absser.DateOnly) error {
- return NoStructuredDataError
-}
-
-// WriteCollectionOfUUIDValues writes a collection of UUID values to underlying the byte array.
-func (w *TextSerializationWriter) WriteCollectionOfUUIDValues(key string, collection []uuid.UUID) error {
- return NoStructuredDataError
-}
-
-// WriteCollectionOfBoolValues writes a collection of Bool values to underlying the byte array.
-func (w *TextSerializationWriter) WriteCollectionOfBoolValues(key string, collection []bool) error {
- return NoStructuredDataError
-}
-
-// WriteCollectionOfByteValues writes a collection of Byte values to underlying the byte array.
-func (w *TextSerializationWriter) WriteCollectionOfByteValues(key string, collection []byte) error {
- return NoStructuredDataError
-}
-
-// WriteCollectionOfInt8Values writes a collection of int8 values to underlying the byte array.
-func (w *TextSerializationWriter) WriteCollectionOfInt8Values(key string, collection []int8) error {
- return NoStructuredDataError
-}
-
-// GetSerializedContent returns the resulting byte array from the serialization writer.
-func (w *TextSerializationWriter) GetSerializedContent() ([]byte, error) {
- resultStr := strings.Join(w.writer, "")
- return []byte(resultStr), nil
-}
-
-// WriteAdditionalData writes additional data to underlying the byte array.
-func (w *TextSerializationWriter) WriteAdditionalData(value map[string]interface{}) error {
- return NoStructuredDataError
-}
-
-// Close clears the internal buffer.
-func (w *TextSerializationWriter) Close() error {
- return nil
-}
diff --git a/serialization/go/text/text_serialization_writer_factory.go b/serialization/go/text/text_serialization_writer_factory.go
deleted file mode 100644
index 7261c54833..0000000000
--- a/serialization/go/text/text_serialization_writer_factory.go
+++ /dev/null
@@ -1,35 +0,0 @@
-package textserialization
-
-import (
- "errors"
-
- absser "github.com/microsoft/kiota/abstractions/go/serialization"
-)
-
-// TextSerializationWriterFactory implements SerializationWriterFactory for text.
-type TextSerializationWriterFactory struct {
-}
-
-// NewTextSerializationWriterFactory creates a new instance of the TextSerializationWriterFactory.
-func NewTextSerializationWriterFactory() *TextSerializationWriterFactory {
- return &TextSerializationWriterFactory{}
-}
-
-// GetValidContentType returns the valid content type for the SerializationWriterFactoryRegistry
-func (f *TextSerializationWriterFactory) GetValidContentType() (string, error) {
- return "text/plain", nil
-}
-
-// GetSerializationWriter returns the relevant SerializationWriter instance for the given content type
-func (f *TextSerializationWriterFactory) GetSerializationWriter(contentType string) (absser.SerializationWriter, error) {
- validType, err := f.GetValidContentType()
- if err != nil {
- return nil, err
- } else if contentType == "" {
- return nil, errors.New("contentType is empty")
- } else if contentType != validType {
- return nil, errors.New("contentType is not valid")
- } else {
- return NewTextSerializationWriter(), nil
- }
-}
diff --git a/serialization/go/text/text_serialization_writer_test.go b/serialization/go/text/text_serialization_writer_test.go
deleted file mode 100644
index a1ad565e75..0000000000
--- a/serialization/go/text/text_serialization_writer_test.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package textserialization
-
-import (
- assert "github.com/stretchr/testify/assert"
- "testing"
-)
-
-func TestItDoesntWriteAnythingForAdditionalData(t *testing.T) {
- serializer := NewTextSerializationWriter()
- err := serializer.WriteAdditionalData(nil)
- assert.NotNil(t, err)
-}
diff --git a/src/Kiota.Builder/Refiners/GoRefiner.cs b/src/Kiota.Builder/Refiners/GoRefiner.cs
index 4354b71303..f27fbf5299 100644
--- a/src/Kiota.Builder/Refiners/GoRefiner.cs
+++ b/src/Kiota.Builder/Refiners/GoRefiner.cs
@@ -79,22 +79,22 @@ public override void Refine(CodeNamespace generatedCode)
generatedCode);
ReplaceDefaultSerializationModules(
generatedCode,
- "github.com/microsoft/kiota/serialization/go/json.JsonSerializationWriterFactory",
- "github.com/microsoft/kiota/serialization/go/text.TextSerializationWriterFactory");
+ "github.com/microsoft/kiota-serialization-json-go.JsonSerializationWriterFactory",
+ "github.com/microsoft/kiota-serialization-text-go.TextSerializationWriterFactory");
ReplaceDefaultDeserializationModules(
generatedCode,
- "github.com/microsoft/kiota/serialization/go/json.JsonParseNodeFactory",
- "github.com/microsoft/kiota/serialization/go/text.TextParseNodeFactory");
+ "github.com/microsoft/kiota-serialization-json-go.JsonParseNodeFactory",
+ "github.com/microsoft/kiota-serialization-text-go.TextParseNodeFactory");
AddSerializationModulesImport(
generatedCode,
- new string[] {"github.com/microsoft/kiota/abstractions/go/serialization.SerializationWriterFactory", "github.com/microsoft/kiota/abstractions/go.RegisterDefaultSerializer"},
- new string[] {"github.com/microsoft/kiota/abstractions/go/serialization.ParseNodeFactory", "github.com/microsoft/kiota/abstractions/go.RegisterDefaultDeserializer"});
+ new string[] {"github.com/microsoft/kiota-abstractions-go/serialization.SerializationWriterFactory", "github.com/microsoft/kiota-abstractions-go.RegisterDefaultSerializer"},
+ new string[] {"github.com/microsoft/kiota-abstractions-go/serialization.ParseNodeFactory", "github.com/microsoft/kiota-abstractions-go.RegisterDefaultDeserializer"});
ReplaceExecutorAndGeneratorParametersByParameterSets(
generatedCode);
AddParentClassToErrorClasses(
generatedCode,
"ApiError",
- "github.com/microsoft/kiota/abstractions/go"
+ "github.com/microsoft/kiota-abstractions-go"
);
AddDiscriminatorMappingsUsingsToParentClasses(
generatedCode,
@@ -252,25 +252,25 @@ private static void AddErrorImportForEnums(CodeElement currentElement) {
};
private static readonly AdditionalUsingEvaluator[] defaultUsingEvaluators = new AdditionalUsingEvaluator[] {
new (x => x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.RequestAdapter),
- "github.com/microsoft/kiota/abstractions/go", "RequestAdapter"),
+ "github.com/microsoft/kiota-abstractions-go", "RequestAdapter"),
new (x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestGenerator),
- "github.com/microsoft/kiota/abstractions/go", "RequestInformation", "HttpMethod", "RequestOption"),
+ "github.com/microsoft/kiota-abstractions-go", "RequestInformation", "HttpMethod", "RequestOption"),
new (x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestExecutor),
- "github.com/microsoft/kiota/abstractions/go", "ResponseHandler"),
+ "github.com/microsoft/kiota-abstractions-go", "ResponseHandler"),
new (x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.Constructor) &&
method.Parameters.Any(x => x.IsOfKind(CodeParameterKind.Path) &&
!typeToSkipStrConv.Contains(x.Type.Name)),
"strconv", "FormatBool"),
new (x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.Serializer),
- "github.com/microsoft/kiota/abstractions/go/serialization", "SerializationWriter"),
+ "github.com/microsoft/kiota-abstractions-go/serialization", "SerializationWriter"),
new (x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.Deserializer, CodeMethodKind.Factory),
- "github.com/microsoft/kiota/abstractions/go/serialization", "ParseNode", "Parsable"),
+ "github.com/microsoft/kiota-abstractions-go/serialization", "ParseNode", "Parsable"),
new (x => x is CodeClass codeClass && codeClass.IsOfKind(CodeClassKind.Model),
- "github.com/microsoft/kiota/abstractions/go/serialization", "Parsable"),
+ "github.com/microsoft/kiota-abstractions-go/serialization", "Parsable"),
new (x => x is CodeClass @class && @class.IsOfKind(CodeClassKind.Model) &&
(@class.Properties.Any(x => x.IsOfKind(CodePropertyKind.AdditionalData)) ||
@class.StartBlock.Implements.Any(x => KiotaBuilder.AdditionalHolderInterface.Equals(x.Name, StringComparison.OrdinalIgnoreCase))),
- "github.com/microsoft/kiota/abstractions/go/serialization", "AdditionalDataHolder"),
+ "github.com/microsoft/kiota-abstractions-go/serialization", "AdditionalDataHolder"),
new (x => x is CodeEnum num, "ToUpper", "strings"),
};//TODO add backing store types once we have them defined
private static void CorrectImplements(ProprietableBlockDeclaration block) {
@@ -329,21 +329,21 @@ private static void CorrectMethodType(CodeMethod currentMethod) {
{"TimeSpan", ("ISODuration", new CodeUsing {
Name = "ISODuration",
Declaration = new CodeType {
- Name = "github.com/microsoft/kiota/abstractions/go/serialization",
+ Name = "github.com/microsoft/kiota-abstractions-go/serialization",
IsExternal = true,
},
})},
{"DateOnly", (null, new CodeUsing {
Name = "DateOnly",
Declaration = new CodeType {
- Name = "github.com/microsoft/kiota/abstractions/go/serialization",
+ Name = "github.com/microsoft/kiota-abstractions-go/serialization",
IsExternal = true,
},
})},
{"TimeOnly", (null, new CodeUsing {
Name = "TimeOnly",
Declaration = new CodeType {
- Name = "github.com/microsoft/kiota/abstractions/go/serialization",
+ Name = "github.com/microsoft/kiota-abstractions-go/serialization",
IsExternal = true,
},
})},
diff --git a/src/Kiota.Builder/Writers/Go/GoConventionService.cs b/src/Kiota.Builder/Writers/Go/GoConventionService.cs
index 40f5616a04..ed249a7542 100644
--- a/src/Kiota.Builder/Writers/Go/GoConventionService.cs
+++ b/src/Kiota.Builder/Writers/Go/GoConventionService.cs
@@ -13,8 +13,8 @@ public class GoConventionService : CommonLanguageConventionService
public override string DocCommentPrefix => "// ";
public override string ParseNodeInterfaceName => "ParseNode";
#pragma warning disable CA1822 // Method should be static
- public string AbstractionsHash => "ida96af0f171bb75f894a4013a6b3146a4397c58f11adb81a2b7cbea9314783a9";
- public string SerializationHash => "i04eb5309aeaafadd28374d79c8471df9b267510b4dc2e3144c378c50f6fd7b55";
+ public string AbstractionsHash => "i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f";
+ public string SerializationHash => "i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91";
#pragma warning restore CA1822 // Method should be static
public override string GetAccessModifier(AccessModifier access)
{
diff --git a/tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs b/tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs
index f02e7b2743..bc7f5ef0dd 100644
--- a/tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs
+++ b/tests/Kiota.Builder.Tests/Writers/Go/CodeMethodWriterTests.cs
@@ -397,7 +397,7 @@ public void DoesntWriteFactorySwitchOnEmptyMappings() {
Assert.Contains("return NewParentModel(), nil", result);
AssertExtensions.CurlyBracesAreClosed(result);
}
- private const string AbstractionsPackageHash = "ida96af0f171bb75f894a4013a6b3146a4397c58f11adb81a2b7cbea9314783a9";
+ private const string AbstractionsPackageHash = "i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f";
[Fact]
public void WritesRequestGeneratorBody() {
var configurationMock = new Mock();