_id
stringlengths 2
7
| title
stringlengths 1
118
| partition
stringclasses 3
values | text
stringlengths 52
85.5k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q1400
|
SetDetailsMap
|
train
|
func (s *JobExecutionStatusDetails) SetDetailsMap(v map[string]*string) *JobExecutionStatusDetails {
s.DetailsMap = v
return s
}
|
go
|
{
"resource": ""
}
|
q1401
|
SetExponentialRate
|
train
|
func (s *JobExecutionsRolloutConfig) SetExponentialRate(v *ExponentialRolloutRate) *JobExecutionsRolloutConfig {
s.ExponentialRate = v
return s
}
|
go
|
{
"resource": ""
}
|
q1402
|
SetNumberOfCanceledThings
|
train
|
func (s *JobProcessDetails) SetNumberOfCanceledThings(v int64) *JobProcessDetails {
s.NumberOfCanceledThings = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1403
|
SetNumberOfFailedThings
|
train
|
func (s *JobProcessDetails) SetNumberOfFailedThings(v int64) *JobProcessDetails {
s.NumberOfFailedThings = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1404
|
SetNumberOfInProgressThings
|
train
|
func (s *JobProcessDetails) SetNumberOfInProgressThings(v int64) *JobProcessDetails {
s.NumberOfInProgressThings = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1405
|
SetNumberOfQueuedThings
|
train
|
func (s *JobProcessDetails) SetNumberOfQueuedThings(v int64) *JobProcessDetails {
s.NumberOfQueuedThings = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1406
|
SetNumberOfRejectedThings
|
train
|
func (s *JobProcessDetails) SetNumberOfRejectedThings(v int64) *JobProcessDetails {
s.NumberOfRejectedThings = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1407
|
SetNumberOfRemovedThings
|
train
|
func (s *JobProcessDetails) SetNumberOfRemovedThings(v int64) *JobProcessDetails {
s.NumberOfRemovedThings = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1408
|
SetNumberOfTimedOutThings
|
train
|
func (s *JobProcessDetails) SetNumberOfTimedOutThings(v int64) *JobProcessDetails {
s.NumberOfTimedOutThings = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1409
|
SetProcessingTargets
|
train
|
func (s *JobProcessDetails) SetProcessingTargets(v []*string) *JobProcessDetails {
s.ProcessingTargets = v
return s
}
|
go
|
{
"resource": ""
}
|
q1410
|
SetActiveViolations
|
train
|
func (s *ListActiveViolationsOutput) SetActiveViolations(v []*ActiveViolation) *ListActiveViolationsOutput {
s.ActiveViolations = v
return s
}
|
go
|
{
"resource": ""
}
|
q1411
|
SetAuthorizers
|
train
|
func (s *ListAuthorizersOutput) SetAuthorizers(v []*AuthorizerSummary) *ListAuthorizersOutput {
s.Authorizers = v
return s
}
|
go
|
{
"resource": ""
}
|
q1412
|
SetBillingGroups
|
train
|
func (s *ListBillingGroupsOutput) SetBillingGroups(v []*GroupNameAndArn) *ListBillingGroupsOutput {
s.BillingGroups = v
return s
}
|
go
|
{
"resource": ""
}
|
q1413
|
SetIndexNames
|
train
|
func (s *ListIndicesOutput) SetIndexNames(v []*string) *ListIndicesOutput {
s.IndexNames = v
return s
}
|
go
|
{
"resource": ""
}
|
q1414
|
SetOtaUpdates
|
train
|
func (s *ListOTAUpdatesOutput) SetOtaUpdates(v []*OTAUpdateSummary) *ListOTAUpdatesOutput {
s.OtaUpdates = v
return s
}
|
go
|
{
"resource": ""
}
|
q1415
|
SetOutgoingCertificates
|
train
|
func (s *ListOutgoingCertificatesOutput) SetOutgoingCertificates(v []*OutgoingCertificate) *ListOutgoingCertificatesOutput {
s.OutgoingCertificates = v
return s
}
|
go
|
{
"resource": ""
}
|
q1416
|
SetPolicyVersions
|
train
|
func (s *ListPolicyVersionsOutput) SetPolicyVersions(v []*PolicyVersion) *ListPolicyVersionsOutput {
s.PolicyVersions = v
return s
}
|
go
|
{
"resource": ""
}
|
q1417
|
SetRoleAliases
|
train
|
func (s *ListRoleAliasesOutput) SetRoleAliases(v []*string) *ListRoleAliasesOutput {
s.RoleAliases = v
return s
}
|
go
|
{
"resource": ""
}
|
q1418
|
SetScheduledAudits
|
train
|
func (s *ListScheduledAuditsOutput) SetScheduledAudits(v []*ScheduledAuditMetadata) *ListScheduledAuditsOutput {
s.ScheduledAudits = v
return s
}
|
go
|
{
"resource": ""
}
|
q1419
|
SetSecurityProfileTargetMappings
|
train
|
func (s *ListSecurityProfilesForTargetOutput) SetSecurityProfileTargetMappings(v []*SecurityProfileTargetMapping) *ListSecurityProfilesForTargetOutput {
s.SecurityProfileTargetMappings = v
return s
}
|
go
|
{
"resource": ""
}
|
q1420
|
SetSecurityProfileIdentifiers
|
train
|
func (s *ListSecurityProfilesOutput) SetSecurityProfileIdentifiers(v []*SecurityProfileIdentifier) *ListSecurityProfilesOutput {
s.SecurityProfileIdentifiers = v
return s
}
|
go
|
{
"resource": ""
}
|
q1421
|
SetSecurityProfileTargets
|
train
|
func (s *ListTargetsForSecurityProfileOutput) SetSecurityProfileTargets(v []*SecurityProfileTarget) *ListTargetsForSecurityProfileOutput {
s.SecurityProfileTargets = v
return s
}
|
go
|
{
"resource": ""
}
|
q1422
|
SetParentGroup
|
train
|
func (s *ListThingGroupsInput) SetParentGroup(v string) *ListThingGroupsInput {
s.ParentGroup = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1423
|
SetResourceLinks
|
train
|
func (s *ListThingRegistrationTaskReportsOutput) SetResourceLinks(v []*string) *ListThingRegistrationTaskReportsOutput {
s.ResourceLinks = v
return s
}
|
go
|
{
"resource": ""
}
|
q1424
|
SetThingTypes
|
train
|
func (s *ListThingTypesOutput) SetThingTypes(v []*ThingTypeDefinition) *ListThingTypesOutput {
s.ThingTypes = v
return s
}
|
go
|
{
"resource": ""
}
|
q1425
|
SetLogTargetConfigurations
|
train
|
func (s *ListV2LoggingLevelsOutput) SetLogTargetConfigurations(v []*LogTargetConfiguration) *ListV2LoggingLevelsOutput {
s.LogTargetConfigurations = v
return s
}
|
go
|
{
"resource": ""
}
|
q1426
|
SetViolationEvents
|
train
|
func (s *ListViolationEventsOutput) SetViolationEvents(v []*ViolationEvent) *ListViolationEventsOutput {
s.ViolationEvents = v
return s
}
|
go
|
{
"resource": ""
}
|
q1427
|
SetCidrs
|
train
|
func (s *MetricValue) SetCidrs(v []*string) *MetricValue {
s.Cidrs = v
return s
}
|
go
|
{
"resource": ""
}
|
q1428
|
SetCodeSigning
|
train
|
func (s *OTAUpdateFile) SetCodeSigning(v *CodeSigning) *OTAUpdateFile {
s.CodeSigning = v
return s
}
|
go
|
{
"resource": ""
}
|
q1429
|
SetFileLocation
|
train
|
func (s *OTAUpdateFile) SetFileLocation(v *FileLocation) *OTAUpdateFile {
s.FileLocation = v
return s
}
|
go
|
{
"resource": ""
}
|
q1430
|
SetFileVersion
|
train
|
func (s *OTAUpdateFile) SetFileVersion(v string) *OTAUpdateFile {
s.FileVersion = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1431
|
SetErrorInfo
|
train
|
func (s *OTAUpdateInfo) SetErrorInfo(v *ErrorInfo) *OTAUpdateInfo {
s.ErrorInfo = v
return s
}
|
go
|
{
"resource": ""
}
|
q1432
|
SetOtaUpdateFiles
|
train
|
func (s *OTAUpdateInfo) SetOtaUpdateFiles(v []*OTAUpdateFile) *OTAUpdateInfo {
s.OtaUpdateFiles = v
return s
}
|
go
|
{
"resource": ""
}
|
q1433
|
SetTransferredTo
|
train
|
func (s *OutgoingCertificate) SetTransferredTo(v string) *OutgoingCertificate {
s.TransferredTo = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1434
|
SetExpiresInSec
|
train
|
func (s *PresignedUrlConfig) SetExpiresInSec(v int64) *PresignedUrlConfig {
s.ExpiresInSec = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1435
|
SetNumberOfNotifiedThings
|
train
|
func (s *RateIncreaseCriteria) SetNumberOfNotifiedThings(v int64) *RateIncreaseCriteria {
s.NumberOfNotifiedThings = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1436
|
SetAllowAutoRegistration
|
train
|
func (s *RegisterCACertificateInput) SetAllowAutoRegistration(v bool) *RegisterCACertificateInput {
s.AllowAutoRegistration = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1437
|
SetCaCertificate
|
train
|
func (s *RegisterCACertificateInput) SetCaCertificate(v string) *RegisterCACertificateInput {
s.CaCertificate = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1438
|
SetVerificationCertificate
|
train
|
func (s *RegisterCACertificateInput) SetVerificationCertificate(v string) *RegisterCACertificateInput {
s.VerificationCertificate = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1439
|
SetCaCertificatePem
|
train
|
func (s *RegisterCertificateInput) SetCaCertificatePem(v string) *RegisterCertificateInput {
s.CaCertificatePem = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1440
|
SetDeviceCertificateId
|
train
|
func (s *ResourceIdentifier) SetDeviceCertificateId(v string) *ResourceIdentifier {
s.DeviceCertificateId = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1441
|
SetPolicyVersionIdentifier
|
train
|
func (s *ResourceIdentifier) SetPolicyVersionIdentifier(v *PolicyVersionIdentifier) *ResourceIdentifier {
s.PolicyVersionIdentifier = v
return s
}
|
go
|
{
"resource": ""
}
|
q1442
|
SetCannedAcl
|
train
|
func (s *S3Action) SetCannedAcl(v string) *S3Action {
s.CannedAcl = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1443
|
SetSecurityProfileIdentifier
|
train
|
func (s *SecurityProfileTargetMapping) SetSecurityProfileIdentifier(v *SecurityProfileIdentifier) *SecurityProfileTargetMapping {
s.SecurityProfileIdentifier = v
return s
}
|
go
|
{
"resource": ""
}
|
q1444
|
SetLoggingOptionsPayload
|
train
|
func (s *SetLoggingOptionsInput) SetLoggingOptionsPayload(v *LoggingOptionsPayload) *SetLoggingOptionsInput {
s.LoggingOptionsPayload = v
return s
}
|
go
|
{
"resource": ""
}
|
q1445
|
SetCertificatePathOnDevice
|
train
|
func (s *SigningProfileParameter) SetCertificatePathOnDevice(v string) *SigningProfileParameter {
s.CertificatePathOnDevice = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1446
|
SetUseBase64
|
train
|
func (s *SqsAction) SetUseBase64(v bool) *SqsAction {
s.UseBase64 = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1447
|
SetSigningProfileName
|
train
|
func (s *StartSigningJobParameter) SetSigningProfileName(v string) *StartSigningJobParameter {
s.SigningProfileName = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1448
|
SetSigningProfileParameter
|
train
|
func (s *StartSigningJobParameter) SetSigningProfileParameter(v *SigningProfileParameter) *StartSigningJobParameter {
s.SigningProfileParameter = v
return s
}
|
go
|
{
"resource": ""
}
|
q1449
|
SetExecutionNamePrefix
|
train
|
func (s *StepFunctionsAction) SetExecutionNamePrefix(v string) *StepFunctionsAction {
s.ExecutionNamePrefix = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1450
|
SetStateMachineName
|
train
|
func (s *StepFunctionsAction) SetStateMachineName(v string) *StepFunctionsAction {
s.StateMachineName = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1451
|
SetCanceledChecks
|
train
|
func (s *TaskStatistics) SetCanceledChecks(v int64) *TaskStatistics {
s.CanceledChecks = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1452
|
SetCompliantChecks
|
train
|
func (s *TaskStatistics) SetCompliantChecks(v int64) *TaskStatistics {
s.CompliantChecks = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1453
|
SetFailedChecks
|
train
|
func (s *TaskStatistics) SetFailedChecks(v int64) *TaskStatistics {
s.FailedChecks = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1454
|
SetInProgressChecks
|
train
|
func (s *TaskStatistics) SetInProgressChecks(v int64) *TaskStatistics {
s.InProgressChecks = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1455
|
SetNonCompliantChecks
|
train
|
func (s *TaskStatistics) SetNonCompliantChecks(v int64) *TaskStatistics {
s.NonCompliantChecks = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1456
|
SetTotalChecks
|
train
|
func (s *TaskStatistics) SetTotalChecks(v int64) *TaskStatistics {
s.TotalChecks = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1457
|
SetWaitingForDataCollectionChecks
|
train
|
func (s *TaskStatistics) SetWaitingForDataCollectionChecks(v int64) *TaskStatistics {
s.WaitingForDataCollectionChecks = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1458
|
SetAuthInfos
|
train
|
func (s *TestAuthorizationInput) SetAuthInfos(v []*AuthInfo) *TestAuthorizationInput {
s.AuthInfos = v
return s
}
|
go
|
{
"resource": ""
}
|
q1459
|
SetPolicyNamesToAdd
|
train
|
func (s *TestAuthorizationInput) SetPolicyNamesToAdd(v []*string) *TestAuthorizationInput {
s.PolicyNamesToAdd = v
return s
}
|
go
|
{
"resource": ""
}
|
q1460
|
SetPolicyNamesToSkip
|
train
|
func (s *TestAuthorizationInput) SetPolicyNamesToSkip(v []*string) *TestAuthorizationInput {
s.PolicyNamesToSkip = v
return s
}
|
go
|
{
"resource": ""
}
|
q1461
|
SetAuthResults
|
train
|
func (s *TestAuthorizationOutput) SetAuthResults(v []*AuthResult) *TestAuthorizationOutput {
s.AuthResults = v
return s
}
|
go
|
{
"resource": ""
}
|
q1462
|
SetTokenSignature
|
train
|
func (s *TestInvokeAuthorizerInput) SetTokenSignature(v string) *TestInvokeAuthorizerInput {
s.TokenSignature = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1463
|
SetDisconnectAfterInSeconds
|
train
|
func (s *TestInvokeAuthorizerOutput) SetDisconnectAfterInSeconds(v int64) *TestInvokeAuthorizerOutput {
s.DisconnectAfterInSeconds = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1464
|
SetIsAuthenticated
|
train
|
func (s *TestInvokeAuthorizerOutput) SetIsAuthenticated(v bool) *TestInvokeAuthorizerOutput {
s.IsAuthenticated = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1465
|
SetPolicyDocuments
|
train
|
func (s *TestInvokeAuthorizerOutput) SetPolicyDocuments(v []*string) *TestInvokeAuthorizerOutput {
s.PolicyDocuments = v
return s
}
|
go
|
{
"resource": ""
}
|
q1466
|
SetRefreshAfterInSeconds
|
train
|
func (s *TestInvokeAuthorizerOutput) SetRefreshAfterInSeconds(v int64) *TestInvokeAuthorizerOutput {
s.RefreshAfterInSeconds = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1467
|
SetConnected
|
train
|
func (s *ThingConnectivity) SetConnected(v bool) *ThingConnectivity {
s.Connected = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1468
|
SetShadow
|
train
|
func (s *ThingDocument) SetShadow(v string) *ThingDocument {
s.Shadow = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1469
|
SetThingGroupNames
|
train
|
func (s *ThingDocument) SetThingGroupNames(v []*string) *ThingDocument {
s.ThingGroupNames = v
return s
}
|
go
|
{
"resource": ""
}
|
q1470
|
SetParentGroupNames
|
train
|
func (s *ThingGroupDocument) SetParentGroupNames(v []*string) *ThingGroupDocument {
s.ParentGroupNames = v
return s
}
|
go
|
{
"resource": ""
}
|
q1471
|
SetThingGroupIndexingMode
|
train
|
func (s *ThingGroupIndexingConfiguration) SetThingGroupIndexingMode(v string) *ThingGroupIndexingConfiguration {
s.ThingGroupIndexingMode = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1472
|
SetRootToParentThingGroups
|
train
|
func (s *ThingGroupMetadata) SetRootToParentThingGroups(v []*GroupNameAndArn) *ThingGroupMetadata {
s.RootToParentThingGroups = v
return s
}
|
go
|
{
"resource": ""
}
|
q1473
|
SetThingConnectivityIndexingMode
|
train
|
func (s *ThingIndexingConfiguration) SetThingConnectivityIndexingMode(v string) *ThingIndexingConfiguration {
s.ThingConnectivityIndexingMode = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1474
|
SetThingIndexingMode
|
train
|
func (s *ThingIndexingConfiguration) SetThingIndexingMode(v string) *ThingIndexingConfiguration {
s.ThingIndexingMode = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1475
|
SetDeprecated
|
train
|
func (s *ThingTypeMetadata) SetDeprecated(v bool) *ThingTypeMetadata {
s.Deprecated = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1476
|
SetSearchableAttributes
|
train
|
func (s *ThingTypeProperties) SetSearchableAttributes(v []*string) *ThingTypeProperties {
s.SearchableAttributes = v
return s
}
|
go
|
{
"resource": ""
}
|
q1477
|
SetThingTypeDescription
|
train
|
func (s *ThingTypeProperties) SetThingTypeDescription(v string) *ThingTypeProperties {
s.ThingTypeDescription = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1478
|
SetInProgressTimeoutInMinutes
|
train
|
func (s *TimeoutConfig) SetInProgressTimeoutInMinutes(v int64) *TimeoutConfig {
s.InProgressTimeoutInMinutes = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1479
|
SetTopicPattern
|
train
|
func (s *TopicRuleListItem) SetTopicPattern(v string) *TopicRuleListItem {
s.TopicPattern = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1480
|
SetTargetAwsAccount
|
train
|
func (s *TransferCertificateInput) SetTargetAwsAccount(v string) *TransferCertificateInput {
s.TargetAwsAccount = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1481
|
SetTransferredCertificateArn
|
train
|
func (s *TransferCertificateOutput) SetTransferredCertificateArn(v string) *TransferCertificateOutput {
s.TransferredCertificateArn = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1482
|
SetAcceptDate
|
train
|
func (s *TransferData) SetAcceptDate(v time.Time) *TransferData {
s.AcceptDate = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1483
|
SetRejectDate
|
train
|
func (s *TransferData) SetRejectDate(v time.Time) *TransferData {
s.RejectDate = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1484
|
SetNewAutoRegistrationStatus
|
train
|
func (s *UpdateCACertificateInput) SetNewAutoRegistrationStatus(v string) *UpdateCACertificateInput {
s.NewAutoRegistrationStatus = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1485
|
SetRemoveAutoRegistration
|
train
|
func (s *UpdateCACertificateInput) SetRemoveAutoRegistration(v bool) *UpdateCACertificateInput {
s.RemoveAutoRegistration = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1486
|
SetDeleteAdditionalMetricsToRetain
|
train
|
func (s *UpdateSecurityProfileInput) SetDeleteAdditionalMetricsToRetain(v bool) *UpdateSecurityProfileInput {
s.DeleteAdditionalMetricsToRetain = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1487
|
SetDeleteAlertTargets
|
train
|
func (s *UpdateSecurityProfileInput) SetDeleteAlertTargets(v bool) *UpdateSecurityProfileInput {
s.DeleteAlertTargets = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1488
|
SetDeleteBehaviors
|
train
|
func (s *UpdateSecurityProfileInput) SetDeleteBehaviors(v bool) *UpdateSecurityProfileInput {
s.DeleteBehaviors = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1489
|
SetThingGroupsToAdd
|
train
|
func (s *UpdateThingGroupsForThingInput) SetThingGroupsToAdd(v []*string) *UpdateThingGroupsForThingInput {
s.ThingGroupsToAdd = v
return s
}
|
go
|
{
"resource": ""
}
|
q1490
|
SetThingGroupsToRemove
|
train
|
func (s *UpdateThingGroupsForThingInput) SetThingGroupsToRemove(v []*string) *UpdateThingGroupsForThingInput {
s.ThingGroupsToRemove = v
return s
}
|
go
|
{
"resource": ""
}
|
q1491
|
SetRemoveThingType
|
train
|
func (s *UpdateThingInput) SetRemoveThingType(v bool) *UpdateThingInput {
s.RemoveThingType = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1492
|
SetViolationEventTime
|
train
|
func (s *ViolationEvent) SetViolationEventTime(v time.Time) *ViolationEvent {
s.ViolationEventTime = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1493
|
SetViolationEventType
|
train
|
func (s *ViolationEvent) SetViolationEventType(v string) *ViolationEvent {
s.ViolationEventType = &v
return s
}
|
go
|
{
"resource": ""
}
|
q1494
|
loadConfig
|
train
|
func loadConfig() (method Method, serverURL, key, filename string) {
var getKey, putKey string
flag.StringVar(&getKey, "get", "",
"Downloads the object from S3 by the `key`. Writes the object to a file the filename is provided, otherwise writes to stdout.")
flag.StringVar(&putKey, "put", "",
"Uploads data to S3 at the `key` provided. Uploads the file if filename is provided, otherwise reads from stdin.")
flag.StringVar(&serverURL, "s", "http://127.0.0.1:8080", "Required `URL` the client will request presigned S3 operation from.")
flag.StringVar(&filename, "f", "", "The `filename` of the file to upload and get from S3.")
flag.Parse()
var errs Errors
if len(serverURL) == 0 {
errs = append(errs, fmt.Errorf("server URL required"))
}
if !((len(getKey) != 0) != (len(putKey) != 0)) {
errs = append(errs, fmt.Errorf("either `get` or `put` can be provided, and one of the two is required."))
}
if len(getKey) > 0 {
method = GetMethod
key = getKey
} else {
method = PutMethod
key = putKey
}
if len(errs) > 0 {
fmt.Fprintf(os.Stderr, "Failed to load configuration:%v\n", errs)
flag.PrintDefaults()
os.Exit(1)
}
return method, filename, key, serverURL
}
|
go
|
{
"resource": ""
}
|
q1495
|
downloadFile
|
train
|
func downloadFile(serverURL, key, filename string) error {
var w *os.File
if len(filename) > 0 {
f, err := os.Create(filename)
if err != nil {
return fmt.Errorf("failed to create download file %s, %v", filename, err)
}
w = f
} else {
w = os.Stdout
}
defer w.Close()
// Get the presigned URL from the remote service.
req, err := getPresignedRequest(serverURL, "GET", key, 0)
if err != nil {
return fmt.Errorf("failed to get get presigned request, %v", err)
}
// Gets the file contents with the URL provided by the service.
resp, err := http.DefaultClient.Do(req)
if err != nil {
return fmt.Errorf("failed to do GET request, %v", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("failed to get S3 object, %d:%s",
resp.StatusCode, resp.Status)
}
if _, err = io.Copy(w, resp.Body); err != nil {
return fmt.Errorf("failed to write S3 object, %v", err)
}
return nil
}
|
go
|
{
"resource": ""
}
|
q1496
|
uploadFile
|
train
|
func uploadFile(serverURL, key, filename string) error {
var r io.ReadCloser
var size int64
if len(filename) > 0 {
f, err := os.Open(filename)
if err != nil {
return fmt.Errorf("failed to open upload file %s, %v", filename, err)
}
// Get the size of the file so that the constraint of Content-Length
// can be included with the presigned URL. This can be used by the
// server or client to ensure the content uploaded is of a certain size.
//
// These constraints can further be expanded to include things like
// Content-Type. Additionally constraints such as X-Amz-Content-Sha256
// header set restricting the content of the file to only the content
// the client initially made the request with. This prevents the object
// from being overwritten or used to upload other unintended content.
stat, err := f.Stat()
if err != nil {
return fmt.Errorf("failed to stat file, %s, %v", filename, err)
}
size = stat.Size()
r = f
} else {
buf := &bytes.Buffer{}
io.Copy(buf, os.Stdin)
size = int64(buf.Len())
r = ioutil.NopCloser(buf)
}
defer r.Close()
// Get the Presigned URL from the remote service. Pass in the file's
// size if it is known so that the presigned URL returned will be required
// to be used with the size of content requested.
req, err := getPresignedRequest(serverURL, "PUT", key, size)
if err != nil {
return fmt.Errorf("failed to get get presigned request, %v", err)
}
req.Body = r
// Upload the file contents to S3.
resp, err := http.DefaultClient.Do(req)
if err != nil {
return fmt.Errorf("failed to do GET request, %v", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("failed to put S3 object, %d:%s",
resp.StatusCode, resp.Status)
}
return nil
}
|
go
|
{
"resource": ""
}
|
q1497
|
getPresignedRequest
|
train
|
func getPresignedRequest(serverURL, method, key string, contentLen int64) (*http.Request, error) {
u := fmt.Sprintf("%s/presign/%s?method=%s&contentLength=%d",
serverURL, key, method, contentLen,
)
resp, err := http.Get(u)
if err != nil {
return nil, fmt.Errorf("failed to make request for presigned URL, %v", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("failed to get valid presign response, %s", resp.Status)
}
p := PresignResp{}
if err := json.NewDecoder(resp.Body).Decode(&p); err != nil {
return nil, fmt.Errorf("failed to decode response body, %v", err)
}
req, err := http.NewRequest(p.Method, p.URL, nil)
if err != nil {
return nil, fmt.Errorf("failed to build presigned request, %v", err)
}
for k, vs := range p.Header {
for _, v := range vs {
req.Header.Add(k, v)
}
}
// Need to ensure that the content length member is set of the HTTP Request
// or the request will not be transmitted correctly with a content length
// value across the wire.
if contLen := req.Header.Get("Content-Length"); len(contLen) > 0 {
req.ContentLength, _ = strconv.ParseInt(contLen, 10, 64)
}
return req, nil
}
|
go
|
{
"resource": ""
}
|
q1498
|
WaitUntilNodeAssociated
|
train
|
func (c *OpsWorksCM) WaitUntilNodeAssociated(input *DescribeNodeAssociationStatusInput) error {
return c.WaitUntilNodeAssociatedWithContext(aws.BackgroundContext(), input)
}
|
go
|
{
"resource": ""
}
|
q1499
|
SetConnectionRefusedCount
|
train
|
func (s *BackendConnectionErrors) SetConnectionRefusedCount(v int64) *BackendConnectionErrors {
s.ConnectionRefusedCount = &v
return s
}
|
go
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.