-
Notifications
You must be signed in to change notification settings - Fork 10
/
graph_request_adapter_base.go
55 lines (47 loc) · 3.07 KB
/
graph_request_adapter_base.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package msgraphgocore
import (
"errors"
nethttp "net/http"
absauth "github.com/microsoft/kiota-abstractions-go/authentication"
absser "github.com/microsoft/kiota-abstractions-go/serialization"
khttp "github.com/microsoft/kiota-http-go"
)
// GraphRequestAdapterBase is the core service used by GraphServiceClient to make requests to Microsoft Graph.
type GraphRequestAdapterBase struct {
khttp.NetHttpRequestAdapter
}
// NewGraphRequestAdapterBase creates a new GraphRequestAdapterBase with the given parameters
func NewGraphRequestAdapterBase(authenticationProvider absauth.AuthenticationProvider, clientOptions GraphClientOptions) (*GraphRequestAdapterBase, error) {
return NewGraphRequestAdapterBaseWithParseNodeFactory(authenticationProvider, clientOptions, nil)
}
// NewGraphRequestAdapterBaseWithParseNodeFactory creates a new GraphRequestAdapterBase with the given parameters
func NewGraphRequestAdapterBaseWithParseNodeFactory(authenticationProvider absauth.AuthenticationProvider, clientOptions GraphClientOptions, parseNodeFactory absser.ParseNodeFactory) (*GraphRequestAdapterBase, error) {
return NewGraphRequestAdapterBaseWithParseNodeFactoryAndSerializationWriterFactory(authenticationProvider, clientOptions, parseNodeFactory, nil)
}
// NewGraphRequestAdapterBaseWithParseNodeFactoryAndSerializationWriterFactory creates a new GraphRequestAdapterBase with the given parameters
func NewGraphRequestAdapterBaseWithParseNodeFactoryAndSerializationWriterFactory(authenticationProvider absauth.AuthenticationProvider, clientOptions GraphClientOptions, parseNodeFactory absser.ParseNodeFactory, serializationWriterFactory absser.SerializationWriterFactory) (*GraphRequestAdapterBase, error) {
return NewGraphRequestAdapterBaseWithParseNodeFactoryAndSerializationWriterFactoryAndHttpClient(authenticationProvider, clientOptions, parseNodeFactory, serializationWriterFactory, nil)
}
// NewGraphRequestAdapterBaseWithParseNodeFactoryAndSerializationWriterFactoryAndHttpClient creates a new GraphRequestAdapterBase with the given parameters
func NewGraphRequestAdapterBaseWithParseNodeFactoryAndSerializationWriterFactoryAndHttpClient(authenticationProvider absauth.AuthenticationProvider, clientOptions GraphClientOptions, parseNodeFactory absser.ParseNodeFactory, serializationWriterFactory absser.SerializationWriterFactory, httpClient *nethttp.Client) (*GraphRequestAdapterBase, error) {
if authenticationProvider == nil {
return nil, errors.New("authenticationProvider cannot be nil")
}
if httpClient == nil {
httpClient = GetDefaultClient(&clientOptions)
}
if serializationWriterFactory == nil {
serializationWriterFactory = absser.DefaultSerializationWriterFactoryInstance
}
if parseNodeFactory == nil {
parseNodeFactory = absser.DefaultParseNodeFactoryInstance
}
baseAdapter, err := khttp.NewNetHttpRequestAdapterWithParseNodeFactoryAndSerializationWriterFactoryAndHttpClient(authenticationProvider, parseNodeFactory, serializationWriterFactory, httpClient)
if err != nil {
return nil, err
}
result := &GraphRequestAdapterBase{
NetHttpRequestAdapter: *baseAdapter,
}
return result, nil
}