service.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
  2. package sso
  3. import (
  4. "github.com/aws/aws-sdk-go/aws"
  5. "github.com/aws/aws-sdk-go/aws/client"
  6. "github.com/aws/aws-sdk-go/aws/client/metadata"
  7. "github.com/aws/aws-sdk-go/aws/request"
  8. "github.com/aws/aws-sdk-go/aws/signer/v4"
  9. "github.com/aws/aws-sdk-go/private/protocol"
  10. "github.com/aws/aws-sdk-go/private/protocol/restjson"
  11. )
  12. // SSO provides the API operation methods for making requests to
  13. // AWS Single Sign-On. See this package's package overview docs
  14. // for details on the service.
  15. //
  16. // SSO methods are safe to use concurrently. It is not safe to
  17. // modify mutate any of the struct's properties though.
  18. type SSO struct {
  19. *client.Client
  20. }
  21. // Used for custom client initialization logic
  22. var initClient func(*client.Client)
  23. // Used for custom request initialization logic
  24. var initRequest func(*request.Request)
  25. // Service information constants
  26. const (
  27. ServiceName = "SSO" // Name of service.
  28. EndpointsID = "portal.sso" // ID to lookup a service endpoint with.
  29. ServiceID = "SSO" // ServiceID is a unique identifier of a specific service.
  30. )
  31. // New creates a new instance of the SSO client with a session.
  32. // If additional configuration is needed for the client instance use the optional
  33. // aws.Config parameter to add your extra config.
  34. //
  35. // Example:
  36. //
  37. // mySession := session.Must(session.NewSession())
  38. //
  39. // // Create a SSO client from just a session.
  40. // svc := sso.New(mySession)
  41. //
  42. // // Create a SSO client with additional configuration
  43. // svc := sso.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  44. func New(p client.ConfigProvider, cfgs ...*aws.Config) *SSO {
  45. c := p.ClientConfig(EndpointsID, cfgs...)
  46. if c.SigningNameDerived || len(c.SigningName) == 0 {
  47. c.SigningName = "awsssoportal"
  48. }
  49. return newClient(*c.Config, c.Handlers, c.PartitionID, c.Endpoint, c.SigningRegion, c.SigningName, c.ResolvedRegion)
  50. }
  51. // newClient creates, initializes and returns a new service client instance.
  52. func newClient(cfg aws.Config, handlers request.Handlers, partitionID, endpoint, signingRegion, signingName, resolvedRegion string) *SSO {
  53. svc := &SSO{
  54. Client: client.New(
  55. cfg,
  56. metadata.ClientInfo{
  57. ServiceName: ServiceName,
  58. ServiceID: ServiceID,
  59. SigningName: signingName,
  60. SigningRegion: signingRegion,
  61. PartitionID: partitionID,
  62. Endpoint: endpoint,
  63. APIVersion: "2019-06-10",
  64. ResolvedRegion: resolvedRegion,
  65. },
  66. handlers,
  67. ),
  68. }
  69. // Handlers
  70. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  71. svc.Handlers.Build.PushBackNamed(restjson.BuildHandler)
  72. svc.Handlers.Unmarshal.PushBackNamed(restjson.UnmarshalHandler)
  73. svc.Handlers.UnmarshalMeta.PushBackNamed(restjson.UnmarshalMetaHandler)
  74. svc.Handlers.UnmarshalError.PushBackNamed(
  75. protocol.NewUnmarshalErrorHandler(restjson.NewUnmarshalTypedError(exceptionFromCode)).NamedHandler(),
  76. )
  77. // Run custom client initialization if present
  78. if initClient != nil {
  79. initClient(svc.Client)
  80. }
  81. return svc
  82. }
  83. // newRequest creates a new request for a SSO operation and runs any
  84. // custom request initialization.
  85. func (c *SSO) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  86. req := c.NewRequest(op, params, data)
  87. // Run custom request initialization if present
  88. if initRequest != nil {
  89. initRequest(req)
  90. }
  91. return req
  92. }